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
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-01-20 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:49 +0300
commitd9666cf046a8453b33b3e2fbf4d82295a9f87df3 (patch)
treec722ed19b844b53042aec0c1d7d2f8381140a5ed
parent804edc5756fede54dbb1aefda6d39d306111938d (diff)
4.44 beta
-rwxr-xr-x7zip/Archive/7z/7zEncode.h56
-rwxr-xr-x7zip/Archive/7z/7zHandlerOut.cpp1155
-rwxr-xr-x7zip/Archive/7z/7zUpdate.cpp1099
-rwxr-xr-x7zip/Archive/7z/DllExports.cpp115
-rwxr-xr-x7zip/Archive/7z_C/7zAlloc.h20
-rwxr-xr-x7zip/Archive/7z_C/7zBuffer.h19
-rwxr-xr-x7zip/Archive/7z_C/7zCrc.c76
-rwxr-xr-x7zip/Archive/7z_C/7zCrc.h24
-rwxr-xr-x7zip/Archive/7z_C/7zDecode.c150
-rwxr-xr-x7zip/Archive/7z_C/7zDecode.h21
-rwxr-xr-x7zip/Archive/7z_C/7zExtract.c118
-rwxr-xr-x7zip/Archive/7z_C/7zExtract.h40
-rwxr-xr-x7zip/Archive/7z_C/7zHeader.h55
-rwxr-xr-x7zip/Archive/7z_C/7zIn.c1282
-rwxr-xr-x7zip/Archive/7z_C/7zIn.h55
-rwxr-xr-x7zip/Archive/7z_C/7zItem.h90
-rwxr-xr-x7zip/Archive/7z_C/7zMain.c356
-rwxr-xr-x7zip/Archive/7z_C/7zMethodID.h18
-rwxr-xr-x7zip/Archive/7z_C/7zTypes.h67
-rwxr-xr-x7zip/Archive/7z_C/7z_C.dsp182
-rwxr-xr-x7zip/Archive/Arj/DllExports.cpp75
-rwxr-xr-x7zip/Archive/BZip2/BZip2Handler.cpp285
-rwxr-xr-x7zip/Archive/Cab/CabIn.cpp343
-rwxr-xr-x7zip/Archive/Cab/CabIn.h166
-rwxr-xr-x7zip/Archive/Cab/CabItem.h62
-rwxr-xr-x7zip/Archive/Common/CoderMixer2MT.cpp359
-rwxr-xr-x7zip/Archive/Lzh/LzhCRC.h27
-rwxr-xr-x7zip/Archive/Nsis/NsisIn.h166
-rwxr-xr-x7zip/Archive/Zip/ZipUpdate.cpp718
-rwxr-xr-x7zip/Bundles/Alone/Alone.dsp2201
-rwxr-xr-x7zip/Bundles/Alone/makefile357
-rwxr-xr-x7zip/Bundles/Alone7z/Alone.dsp1366
-rwxr-xr-x7zip/Bundles/Alone7z/makefile183
-rwxr-xr-x7zip/Bundles/Format7z/Format7z.dsp957
-rwxr-xr-x7zip/Bundles/Format7z/makefile190
-rwxr-xr-x7zip/Bundles/Format7zExtract/makefile175
-rwxr-xr-x7zip/Bundles/makefile13
-rwxr-xr-x7zip/Common/LSBFDecoder.cpp34
-rwxr-xr-x7zip/Compress/BWT/BlockSort.cpp288
-rwxr-xr-x7zip/Compress/BWT/BlockSort.h29
-rwxr-xr-x7zip/Compress/BWT/Mtf8.h140
-rwxr-xr-x7zip/Compress/BZip2/BZip2.dsp281
-rwxr-xr-x7zip/Compress/BZip2/BZip2CRC.h30
-rwxr-xr-x7zip/Compress/BZip2/BZip2Decoder.cpp648
-rwxr-xr-x7zip/Compress/BZip2/BZip2Decoder.h162
-rwxr-xr-x7zip/Compress/BZip2/BZip2Encoder.cpp876
-rwxr-xr-x7zip/Compress/BZip2/BZip2Encoder.h247
-rwxr-xr-x7zip/Compress/BZip2/DllExports.cpp93
-rwxr-xr-x7zip/Compress/BZip2/makefile50
-rwxr-xr-x7zip/Compress/BZip2Original/DllExports.cpp86
-rwxr-xr-x7zip/Compress/Branch/ARM.cpp16
-rwxr-xr-x7zip/Compress/Branch/ARMThumb.cpp16
-rwxr-xr-x7zip/Compress/Branch/IA64.cpp16
-rwxr-xr-x7zip/Compress/Branch/PPC.cpp17
-rwxr-xr-x7zip/Compress/Branch/SPARC.cpp17
-rwxr-xr-x7zip/Compress/Branch/x86.cpp18
-rwxr-xr-x7zip/Compress/Branch/x86.h19
-rwxr-xr-x7zip/Compress/Deflate/Deflate.dsp295
-rwxr-xr-x7zip/Compress/Deflate/DeflateEncoder.cpp885
-rwxr-xr-x7zip/Compress/Deflate/DeflateEncoder.h210
-rwxr-xr-x7zip/Compress/Deflate/DllExports.cpp145
-rwxr-xr-x7zip/Compress/Deflate/makefile51
-rwxr-xr-x7zip/Compress/Huffman/HuffmanEncoder.cpp325
-rwxr-xr-x7zip/Compress/Huffman/HuffmanEncoder.h82
-rwxr-xr-x7zip/Compress/Implode/DllExports.cpp65
-rwxr-xr-x7zip/Compress/LZ/BinTree/BinTree.h54
-rwxr-xr-x7zip/Compress/LZ/BinTree/BinTree2.h12
-rwxr-xr-x7zip/Compress/LZ/BinTree/BinTree3.h16
-rwxr-xr-x7zip/Compress/LZ/BinTree/BinTree3Z.h16
-rwxr-xr-x7zip/Compress/LZ/BinTree/BinTree4.h18
-rwxr-xr-x7zip/Compress/LZ/BinTree/BinTreeMain.h531
-rwxr-xr-x7zip/Compress/LZ/HashChain/HC2.h13
-rwxr-xr-x7zip/Compress/LZ/HashChain/HC3.h16
-rwxr-xr-x7zip/Compress/LZ/HashChain/HC4.h19
-rwxr-xr-x7zip/Compress/LZ/HashChain/HCMain.h6
-rwxr-xr-x7zip/Compress/LZ/IMatchFinder.h32
-rwxr-xr-x7zip/Compress/LZ/LZInWindow.cpp105
-rwxr-xr-x7zip/Compress/LZ/LZInWindow.h87
-rwxr-xr-x7zip/Compress/LZ/MT/MT.cpp295
-rwxr-xr-x7zip/Compress/LZ/MT/MT.h79
-rwxr-xr-x7zip/Compress/LZ/MT/StdAfx.h8
-rwxr-xr-x7zip/Compress/LZMA/DllExports.cpp101
-rwxr-xr-x7zip/Compress/LZMA/LZMA.dsp387
-rwxr-xr-x7zip/Compress/LZMA/LZMAEncoder.cpp1565
-rwxr-xr-x7zip/Compress/LZMA/LZMAEncoder.h411
-rwxr-xr-x7zip/Compress/LZMA/makefile59
-rwxr-xr-x7zip/Compress/LZMA_Alone/AloneLZMA.dsp475
-rwxr-xr-x7zip/Compress/LZMA_Alone/LzmaAlone.cpp526
-rwxr-xr-x7zip/Compress/LZMA_Alone/LzmaRam.cpp227
-rwxr-xr-x7zip/Compress/LZMA_Alone/LzmaRamDecode.c79
-rwxr-xr-x7zip/Compress/LZMA_Alone/makefile114
-rwxr-xr-x7zip/Compress/LZMA_Alone/makefile.gcc113
-rwxr-xr-x7zip/Compress/Lzh/LzhDecoder.cpp216
-rwxr-xr-x7zip/Compress/PPMD/DllExports.cpp93
-rwxr-xr-x7zip/Compress/PPMD/PPMDDecode.h137
-rwxr-xr-x7zip/Compress/PPMD/PPMDDecoder.cpp183
-rwxr-xr-x7zip/Compress/PPMD/PPMDDecoder.h89
-rwxr-xr-x7zip/Compress/PPMD/PPMDSubAlloc.h290
-rwxr-xr-x7zip/Compress/Rar20/DllExports.cpp66
-rwxr-xr-x7zip/Compress/Rar20/Rar20Const.h65
-rwxr-xr-x7zip/Compress/Rar20/Rar20Decoder.cpp322
-rwxr-xr-x7zip/Compress/Rar20/Rar20Decoder.h85
-rwxr-xr-x7zip/Compress/Rar20/Rar20ExtConst.h21
-rwxr-xr-x7zip/Compress/Rar20/Rar20Multimedia.cpp128
-rwxr-xr-x7zip/Compress/Rar20/Rar20Multimedia.h43
-rwxr-xr-x7zip/Compress/Rar29/DllExports.cpp105
-rwxr-xr-x7zip/Compress/Rar29/Original/archive.hpp128
-rwxr-xr-x7zip/Compress/Rar29/Original/array.hpp121
-rwxr-xr-x7zip/Compress/Rar29/Original/cmddata.hpp56
-rwxr-xr-x7zip/Compress/Rar29/Original/coder.cpp47
-rwxr-xr-x7zip/Compress/Rar29/Original/coder.hpp24
-rwxr-xr-x7zip/Compress/Rar29/Original/compress.hpp36
-rwxr-xr-x7zip/Compress/Rar29/Original/consio.hpp42
-rwxr-xr-x7zip/Compress/Rar29/Original/crc.cpp61
-rwxr-xr-x7zip/Compress/Rar29/Original/crc.hpp10
-rwxr-xr-x7zip/Compress/Rar29/Original/crypt.hpp60
-rwxr-xr-x7zip/Compress/Rar29/Original/encname.hpp20
-rwxr-xr-x7zip/Compress/Rar29/Original/errhnd.cpp356
-rwxr-xr-x7zip/Compress/Rar29/Original/errhnd.hpp61
-rwxr-xr-x7zip/Compress/Rar29/Original/extinfo.hpp8
-rwxr-xr-x7zip/Compress/Rar29/Original/extract.hpp40
-rwxr-xr-x7zip/Compress/Rar29/Original/filcreat.hpp12
-rwxr-xr-x7zip/Compress/Rar29/Original/file.hpp100
-rwxr-xr-x7zip/Compress/Rar29/Original/filefn.hpp39
-rwxr-xr-x7zip/Compress/Rar29/Original/filestr.hpp8
-rwxr-xr-x7zip/Compress/Rar29/Original/find.hpp48
-rwxr-xr-x7zip/Compress/Rar29/Original/getbits.cpp24
-rwxr-xr-x7zip/Compress/Rar29/Original/getbits.hpp37
-rwxr-xr-x7zip/Compress/Rar29/Original/global.hpp14
-rwxr-xr-x7zip/Compress/Rar29/Original/headers.hpp304
-rwxr-xr-x7zip/Compress/Rar29/Original/int64.cpp274
-rwxr-xr-x7zip/Compress/Rar29/Original/int64.hpp86
-rwxr-xr-x7zip/Compress/Rar29/Original/isnt.hpp6
-rwxr-xr-x7zip/Compress/Rar29/Original/list.hpp6
-rwxr-xr-x7zip/Compress/Rar29/Original/loclang.hpp340
-rwxr-xr-x7zip/Compress/Rar29/Original/log.hpp18
-rwxr-xr-x7zip/Compress/Rar29/Original/match.hpp16
-rwxr-xr-x7zip/Compress/Rar29/Original/model.cpp600
-rwxr-xr-x7zip/Compress/Rar29/Original/model.hpp126
-rwxr-xr-x7zip/Compress/Rar29/Original/options.hpp129
-rwxr-xr-x7zip/Compress/Rar29/Original/os.hpp235
-rwxr-xr-x7zip/Compress/Rar29/Original/pathfn.hpp44
-rwxr-xr-x7zip/Compress/Rar29/Original/rar.hpp80
-rwxr-xr-x7zip/Compress/Rar29/Original/rardefs.hpp21
-rwxr-xr-x7zip/Compress/Rar29/Original/rarfn.hpp7
-rwxr-xr-x7zip/Compress/Rar29/Original/rarlang.hpp10
-rwxr-xr-x7zip/Compress/Rar29/Original/raros.hpp41
-rwxr-xr-x7zip/Compress/Rar29/Original/rartypes.hpp21
-rwxr-xr-x7zip/Compress/Rar29/Original/rarvm.cpp1050
-rwxr-xr-x7zip/Compress/Rar29/Original/rarvm.hpp110
-rwxr-xr-x7zip/Compress/Rar29/Original/rarvmtbl.cpp53
-rwxr-xr-x7zip/Compress/Rar29/Original/rawread.hpp32
-rwxr-xr-x7zip/Compress/Rar29/Original/rdwrfn.cpp306
-rwxr-xr-x7zip/Compress/Rar29/Original/rdwrfn.hpp104
-rwxr-xr-x7zip/Compress/Rar29/Original/recvol.hpp16
-rwxr-xr-x7zip/Compress/Rar29/Original/resource.cpp12
-rwxr-xr-x7zip/Compress/Rar29/Original/resource.hpp14
-rwxr-xr-x7zip/Compress/Rar29/Original/rijndael.hpp37
-rwxr-xr-x7zip/Compress/Rar29/Original/rs.hpp32
-rwxr-xr-x7zip/Compress/Rar29/Original/savepos.hpp15
-rwxr-xr-x7zip/Compress/Rar29/Original/scantree.hpp52
-rwxr-xr-x7zip/Compress/Rar29/Original/sha1.hpp16
-rwxr-xr-x7zip/Compress/Rar29/Original/smallfn.cpp17
-rwxr-xr-x7zip/Compress/Rar29/Original/smallfn.hpp7
-rwxr-xr-x7zip/Compress/Rar29/Original/strfn.hpp24
-rwxr-xr-x7zip/Compress/Rar29/Original/strlist.hpp39
-rwxr-xr-x7zip/Compress/Rar29/Original/suballoc.cpp241
-rwxr-xr-x7zip/Compress/Rar29/Original/suballoc.hpp81
-rwxr-xr-x7zip/Compress/Rar29/Original/system.cpp79
-rwxr-xr-x7zip/Compress/Rar29/Original/system.hpp10
-rwxr-xr-x7zip/Compress/Rar29/Original/timefn.hpp57
-rwxr-xr-x7zip/Compress/Rar29/Original/ulinks.hpp9
-rwxr-xr-x7zip/Compress/Rar29/Original/unicode.hpp82
-rwxr-xr-x7zip/Compress/Rar29/Original/unpack.cpp939
-rwxr-xr-x7zip/Compress/Rar29/Original/unpack.hpp205
-rwxr-xr-x7zip/Compress/Rar29/Original/unpack15.cpp507
-rwxr-xr-x7zip/Compress/Rar29/Original/version.hpp6
-rwxr-xr-x7zip/Compress/Rar29/Original/volume.hpp11
-rwxr-xr-x7zip/Compress/Rar29/Rar29.dsp415
-rwxr-xr-x7zip/Compress/Rar29/Rar29.dsw29
-rwxr-xr-x7zip/Compress/Rar29/Rar29Decoder.cpp153
-rwxr-xr-x7zip/Compress/Rar29/Rar29Decoder.h97
-rwxr-xr-x7zip/Compress/Rar29/makefile62
-rwxr-xr-x7zip/Compress/Shrink/DllExports.cpp64
-rwxr-xr-x7zip/Compress/Z/ZDecoder.cpp172
-rwxr-xr-x7zip/Compress/Z/ZDecoder.h44
-rwxr-xr-x7zip/Compress/makefile14
-rwxr-xr-x7zip/Crypto/Zip/StdAfx.h8
-rwxr-xr-x7zip/FileManager/App.cpp751
-rwxr-xr-x7zip/FileManager/App.h332
-rwxr-xr-x7zip/FileManager/EnumFormatEtc.cpp108
-rwxr-xr-x7zip/FileManager/ExtractCallback.cpp377
-rwxr-xr-x7zip/FileManager/ExtractCallback.h124
-rwxr-xr-x7zip/FileManager/FM.cpp729
-rwxr-xr-x7zip/FileManager/FM.dsp1230
-rwxr-xr-x7zip/FileManager/FSFolder.cpp634
-rwxr-xr-x7zip/FileManager/FSFolder.h143
-rwxr-xr-x7zip/FileManager/FSFolderCopy.cpp472
-rwxr-xr-x7zip/FileManager/FileFolderPluginOpen.cpp108
-rwxr-xr-x7zip/FileManager/FileFolderPluginOpen.h9
-rwxr-xr-x7zip/FileManager/MyLoadMenu.cpp694
-rwxr-xr-x7zip/FileManager/OpenCallback.cpp112
-rwxr-xr-x7zip/FileManager/OpenCallback.h82
-rwxr-xr-x7zip/FileManager/Panel.cpp848
-rwxr-xr-x7zip/FileManager/Panel.h509
-rwxr-xr-x7zip/FileManager/PanelCopy.cpp210
-rwxr-xr-x7zip/FileManager/PanelDrag.cpp796
-rwxr-xr-x7zip/FileManager/PanelFolderChange.cpp406
-rwxr-xr-x7zip/FileManager/PanelItemOpen.cpp539
-rwxr-xr-x7zip/FileManager/PanelItems.cpp817
-rwxr-xr-x7zip/FileManager/PanelOperations.cpp382
-rwxr-xr-x7zip/FileManager/PanelSplitFile.cpp471
-rwxr-xr-x7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp976
-rwxr-xr-x7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h136
-rwxr-xr-x7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp80
-rwxr-xr-x7zip/FileManager/Resource/CopyDialog/resource.h5
-rwxr-xr-x7zip/FileManager/Resource/CopyDialog/resource.rc23
-rwxr-xr-x7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp100
-rwxr-xr-x7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h22
-rwxr-xr-x7zip/FileManager/Resource/MessagesDialog/resource.rc25
-rwxr-xr-x7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp124
-rwxr-xr-x7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h34
-rwxr-xr-x7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp175
-rwxr-xr-x7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h129
-rwxr-xr-x7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp432
-rwxr-xr-x7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h184
-rwxr-xr-x7zip/FileManager/Resource/ProgressDialog2/resource.rc57
-rwxr-xr-x7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp85
-rwxr-xr-x7zip/FileManager/Resource/SplitDialog/StdAfx.h18
-rwxr-xr-x7zip/FileManager/Resource/SplitDialog/resource.h6
-rwxr-xr-x7zip/FileManager/Resource/SplitDialog/resource.rc27
-rwxr-xr-x7zip/FileManager/SplitUtils.cpp66
-rwxr-xr-x7zip/FileManager/SplitUtils.h13
-rwxr-xr-x7zip/FileManager/StdAfx.cpp8
-rwxr-xr-x7zip/FileManager/StdAfx.h23
-rwxr-xr-x7zip/FileManager/makefile180
-rwxr-xr-x7zip/FileManager/resource.h150
-rwxr-xr-x7zip/FileManager/resource.rc226
-rwxr-xr-x7zip/MyVersion.h8
-rwxr-xr-x7zip/UI/Agent/Agent.cpp572
-rwxr-xr-x7zip/UI/Agent/AgentProxy.cpp198
-rwxr-xr-x7zip/UI/Common/ArchiveCommandLine.cpp984
-rwxr-xr-x7zip/UI/Common/ArchiveExtractCallback.cpp449
-rwxr-xr-x7zip/UI/Common/ArchiveOpenCallback.h87
-rwxr-xr-x7zip/UI/Common/ArchiverInfo.cpp359
-rwxr-xr-x7zip/UI/Common/DefaultName.cpp23
-rwxr-xr-x7zip/UI/Common/Extract.cpp142
-rwxr-xr-x7zip/UI/Common/IFileExtractCallback.h46
-rwxr-xr-x7zip/UI/Common/OpenArchive.cpp522
-rwxr-xr-x7zip/UI/Common/SortUtils.cpp33
-rwxr-xr-x7zip/UI/Console/ExtractCallbackConsole.cpp228
-rwxr-xr-x7zip/UI/Console/ExtractCallbackConsole.h65
-rwxr-xr-x7zip/UI/Console/Main.cpp369
-rwxr-xr-x7zip/UI/Console/MainAr.cpp159
-rwxr-xr-x7zip/UI/Console/OpenCallbackConsole.cpp47
-rwxr-xr-x7zip/UI/Console/OpenCallbackConsole.h24
-rwxr-xr-x7zip/UI/Console/PercentPrinter.cpp88
-rwxr-xr-x7zip/UI/Console/PercentPrinter.h40
-rwxr-xr-x7zip/UI/Console/UpdateCallbackConsole.cpp189
-rwxr-xr-x7zip/UI/Console/UpdateCallbackConsole.h75
-rwxr-xr-x7zip/UI/Console/makefile93
-rwxr-xr-x7zip/UI/Explorer/Explorer.dsp805
-rwxr-xr-x7zip/UI/Explorer/makefile130
-rwxr-xr-x7zip/UI/Far/makefile96
-rwxr-xr-x7zip/UI/GUI/CompressDialog.cpp1357
-rwxr-xr-x7zip/UI/GUI/CompressDialog.h172
-rwxr-xr-x7zip/UI/GUI/ExtractDialog.h77
-rwxr-xr-x7zip/UI/GUI/GUI.dsp904
-rwxr-xr-x7zip/UI/GUI/OpenCallbackGUI.cpp53
-rwxr-xr-x7zip/UI/GUI/OpenCallbackGUI.h30
-rwxr-xr-x7zip/UI/GUI/StdAfx.cpp8
-rwxr-xr-x7zip/UI/GUI/makefile135
-rwxr-xr-x7zip/UI/GUI/resource.h44
-rwxr-xr-x7zip/UI/GUI/resource.rc56
-rwxr-xr-x7zip/UI/Resource/Extract/resource.h12
-rwxr-xr-x7zip/UI/Resource/Extract/resource.rc17
-rwxr-xr-x7zip/UI/Resource/ExtractDialog/resource.rc80
-rwxr-xr-xC/7zCrc.c137
-rwxr-xr-xC/7zCrc.h31
-rwxr-xr-xC/Archive/7z/7zAlloc.c (renamed from 7zip/Archive/7z_C/7zAlloc.c)0
-rwxr-xr-xC/Archive/7z/7zBuffer.c (renamed from 7zip/Archive/7z_C/7zBuffer.c)0
-rwxr-xr-xC/Archive/7z/7zDecode.c150
-rwxr-xr-xC/Archive/7z/7zExtract.c118
-rwxr-xr-xC/Archive/7z/7zHeader.c (renamed from 7zip/Archive/7z_C/7zHeader.c)0
-rwxr-xr-xC/Archive/7z/7zIn.c1284
-rwxr-xr-xC/Archive/7z/7zItem.c (renamed from 7zip/Archive/7z_C/7zItem.c)0
-rwxr-xr-xC/Archive/7z/7zMain.c358
-rwxr-xr-xC/Archive/7z/7zMethodID.c (renamed from 7zip/Archive/7z_C/7zMethodID.c)0
-rwxr-xr-xC/Archive/7z/7z_C.dsp186
-rwxr-xr-xC/Archive/7z/7z_C.dsw (renamed from 7zip/Archive/7z_C/7z_C.dsw)0
-rwxr-xr-xC/Archive/7z/makefile (renamed from 7zip/Archive/7z_C/makefile)0
-rwxr-xr-xC/Archive/7z/makefile.gcc (renamed from 7zip/Archive/7z_C/makefile.gcc)0
-rwxr-xr-xC/Compress/Branch/BranchARM.c (renamed from 7zip/Compress/Branch/BranchARM.c)0
-rwxr-xr-xC/Compress/Branch/BranchARM.h (renamed from 7zip/Compress/Branch/BranchARM.h)0
-rwxr-xr-xC/Compress/Branch/BranchARMThumb.c (renamed from 7zip/Compress/Branch/BranchARMThumb.c)0
-rwxr-xr-xC/Compress/Branch/BranchARMThumb.h (renamed from 7zip/Compress/Branch/BranchARMThumb.h)0
-rwxr-xr-xC/Compress/Branch/BranchIA64.c (renamed from 7zip/Compress/Branch/BranchIA64.c)0
-rwxr-xr-xC/Compress/Branch/BranchIA64.h (renamed from 7zip/Compress/Branch/BranchIA64.h)0
-rwxr-xr-xC/Compress/Branch/BranchPPC.c (renamed from 7zip/Compress/Branch/BranchPPC.c)0
-rwxr-xr-xC/Compress/Branch/BranchPPC.h (renamed from 7zip/Compress/Branch/BranchPPC.h)0
-rwxr-xr-xC/Compress/Branch/BranchSPARC.c (renamed from 7zip/Compress/Branch/BranchSPARC.c)0
-rwxr-xr-xC/Compress/Branch/BranchSPARC.h (renamed from 7zip/Compress/Branch/BranchSPARC.h)0
-rwxr-xr-xC/Compress/Branch/BranchTypes.h (renamed from 7zip/Compress/Branch/BranchTypes.h)0
-rwxr-xr-xC/Compress/Branch/BranchX86.c (renamed from 7zip/Compress/Branch/BranchX86.c)0
-rwxr-xr-xC/Compress/Branch/BranchX86.h (renamed from 7zip/Compress/Branch/BranchX86.h)0
-rwxr-xr-xC/Compress/Huffman/HuffmanEncode.c146
-rwxr-xr-xC/Compress/Huffman/HuffmanEncode.h20
-rwxr-xr-xC/Compress/Lz/LzHash.h53
-rwxr-xr-xC/Compress/Lz/MatchFinder.c725
-rwxr-xr-xC/Compress/Lz/MatchFinder.h103
-rwxr-xr-xC/Compress/Lz/MatchFinderMt.c792
-rwxr-xr-xC/Compress/Lz/MatchFinderMt.h97
-rwxr-xr-xC/Compress/Lzma/LzmaDecode.c (renamed from 7zip/Compress/LZMA_C/LzmaDecode.c)0
-rwxr-xr-xC/Compress/Lzma/LzmaDecode.h (renamed from 7zip/Compress/LZMA_C/LzmaDecode.h)0
-rwxr-xr-xC/Compress/Lzma/LzmaDecodeSize.c (renamed from 7zip/Compress/LZMA_C/LzmaDecodeSize.c)0
-rwxr-xr-xC/Compress/Lzma/LzmaStateDecode.c (renamed from 7zip/Compress/LZMA_C/LzmaStateDecode.c)0
-rwxr-xr-xC/Compress/Lzma/LzmaStateDecode.h (renamed from 7zip/Compress/LZMA_C/LzmaStateDecode.h)0
-rwxr-xr-xC/Compress/Lzma/LzmaStateTest.c (renamed from 7zip/Compress/LZMA_C/LzmaStateTest.c)0
-rwxr-xr-xC/Compress/Lzma/LzmaTest.c (renamed from 7zip/Compress/LZMA_C/LzmaTest.c)0
-rwxr-xr-xC/Compress/Lzma/LzmaTypes.h (renamed from 7zip/Compress/LZMA_C/LzmaTypes.h)0
-rwxr-xr-xC/IStream.h19
-rwxr-xr-xC/Sort.c92
-rwxr-xr-xC/Sort.h11
-rwxr-xr-xC/Threads.c97
-rwxr-xr-xC/Threads.h60
-rwxr-xr-xC/Types.h92
-rwxr-xr-xCPP/7zip/Archive/7z/7z.dsp (renamed from 7zip/Archive/7z/7z.dsp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7z.dsw (renamed from 7zip/Archive/7z/7z.dsw)0
-rwxr-xr-xCPP/7zip/Archive/7z/7z.ico (renamed from 7zip/Archive/7z/7z.ico)bin4710 -> 4710 bytes
-rwxr-xr-xCPP/7zip/Archive/7z/7zCompressionMode.cpp (renamed from 7zip/Archive/7z/7zCompressionMode.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zCompressionMode.h (renamed from 7zip/Archive/7z/7zCompressionMode.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zDecode.cpp (renamed from 7zip/Archive/7z/7zDecode.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zDecode.h (renamed from 7zip/Archive/7z/7zDecode.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zEncode.cpp (renamed from 7zip/Archive/7z/7zEncode.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zEncode.h58
-rwxr-xr-xCPP/7zip/Archive/7z/7zExtract.cpp (renamed from 7zip/Archive/7z/7zExtract.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderInStream.cpp (renamed from 7zip/Archive/7z/7zFolderInStream.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderInStream.h (renamed from 7zip/Archive/7z/7zFolderInStream.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderOutStream.cpp (renamed from 7zip/Archive/7z/7zFolderOutStream.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderOutStream.h (renamed from 7zip/Archive/7z/7zFolderOutStream.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.cpp (renamed from 7zip/Archive/7z/7zHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.h (renamed from 7zip/Archive/7z/7zHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandlerOut.cpp1148
-rwxr-xr-xCPP/7zip/Archive/7z/7zHeader.cpp (renamed from 7zip/Archive/7z/7zHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zHeader.h (renamed from 7zip/Archive/7z/7zHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zIn.cpp (renamed from 7zip/Archive/7z/7zIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zIn.h (renamed from 7zip/Archive/7z/7zIn.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zItem.h (renamed from 7zip/Archive/7z/7zItem.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zMethodID.cpp (renamed from 7zip/Archive/7z/7zMethodID.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zMethodID.h (renamed from 7zip/Archive/7z/7zMethodID.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zMethods.cpp (renamed from 7zip/Archive/7z/7zMethods.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zMethods.h (renamed from 7zip/Archive/7z/7zMethods.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zOut.cpp (renamed from 7zip/Archive/7z/7zOut.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zOut.h (renamed from 7zip/Archive/7z/7zOut.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zProperties.cpp (renamed from 7zip/Archive/7z/7zProperties.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zProperties.h (renamed from 7zip/Archive/7z/7zProperties.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zSpecStream.cpp (renamed from 7zip/Archive/7z/7zSpecStream.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zSpecStream.h (renamed from 7zip/Archive/7z/7zSpecStream.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/7zUpdate.cpp1099
-rwxr-xr-xCPP/7zip/Archive/7z/7zUpdate.h (renamed from 7zip/Archive/7z/7zUpdate.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/DllExports.cpp113
-rwxr-xr-xCPP/7zip/Archive/7z/StdAfx.cpp (renamed from 7zip/Archive/7z/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/7z/StdAfx.h (renamed from 7zip/Archive/7z/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/7z/makefile (renamed from 7zip/Archive/7z/makefile)0
-rwxr-xr-xCPP/7zip/Archive/7z/resource.rc (renamed from 7zip/Archive/7z/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Archive.def (renamed from 7zip/Archive/Archive.def)0
-rwxr-xr-xCPP/7zip/Archive/Arj/Arj.dsp (renamed from 7zip/Archive/Arj/Arj.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Arj/Arj.dsw (renamed from 7zip/Archive/Arj/Arj.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjHandler.cpp (renamed from 7zip/Archive/Arj/ArjHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjHandler.h (renamed from 7zip/Archive/Arj/ArjHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjHeader.h (renamed from 7zip/Archive/Arj/ArjHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjIn.cpp (renamed from 7zip/Archive/Arj/ArjIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjIn.h (renamed from 7zip/Archive/Arj/ArjIn.h)0
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjItem.h (renamed from 7zip/Archive/Arj/ArjItem.h)0
-rwxr-xr-xCPP/7zip/Archive/Arj/DllExports.cpp72
-rwxr-xr-xCPP/7zip/Archive/Arj/StdAfx.cpp (renamed from 7zip/Archive/Arj/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Arj/StdAfx.h (renamed from 7zip/Archive/Arj/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Arj/arj.ico (renamed from 7zip/Archive/Arj/arj.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Arj/makefile (renamed from 7zip/Archive/Arj/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Arj/resource.rc (renamed from 7zip/Archive/Arj/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2.dsp (renamed from 7zip/Archive/BZip2/BZip2.dsp)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2.dsw (renamed from 7zip/Archive/BZip2/BZip2.dsw)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Handler.cpp287
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Handler.h (renamed from 7zip/Archive/BZip2/BZip2Handler.h)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp (renamed from 7zip/Archive/BZip2/BZip2HandlerOut.cpp)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Item.h (renamed from 7zip/Archive/BZip2/BZip2Item.h)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Update.cpp (renamed from 7zip/Archive/BZip2/BZip2Update.cpp)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Update.h (renamed from 7zip/Archive/BZip2/BZip2Update.h)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/DllExports.cpp (renamed from 7zip/Archive/BZip2/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/StdAfx.cpp (renamed from 7zip/Archive/BZip2/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/StdAfx.h (renamed from 7zip/Archive/BZip2/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/bz2.ico (renamed from 7zip/Archive/BZip2/bz2.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/BZip2/makefile (renamed from 7zip/Archive/BZip2/makefile)0
-rwxr-xr-xCPP/7zip/Archive/BZip2/resource.rc (renamed from 7zip/Archive/BZip2/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Cab/Cab.dsp (renamed from 7zip/Archive/Cab/Cab.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Cab/Cab.dsw (renamed from 7zip/Archive/Cab/Cab.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Cab/CabBlockInStream.cpp (renamed from 7zip/Archive/Cab/CabBlockInStream.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cab/CabBlockInStream.h (renamed from 7zip/Archive/Cab/CabBlockInStream.h)0
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHandler.cpp (renamed from 7zip/Archive/Cab/CabHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHandler.h (renamed from 7zip/Archive/Cab/CabHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHeader.cpp (renamed from 7zip/Archive/Cab/CabHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHeader.h (renamed from 7zip/Archive/Cab/CabHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Cab/CabIn.cpp343
-rwxr-xr-xCPP/7zip/Archive/Cab/CabIn.h166
-rwxr-xr-xCPP/7zip/Archive/Cab/CabItem.h62
-rwxr-xr-xCPP/7zip/Archive/Cab/DllExports.cpp (renamed from 7zip/Archive/Cab/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cab/StdAfx.cpp (renamed from 7zip/Archive/Cab/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cab/StdAfx.h (renamed from 7zip/Archive/Cab/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Cab/cab.ico (renamed from 7zip/Archive/Cab/cab.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Cab/makefile (renamed from 7zip/Archive/Cab/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Cab/resource.rc (renamed from 7zip/Archive/Cab/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Chm/Chm.dsp (renamed from 7zip/Archive/Chm/Chm.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Chm/Chm.dsw (renamed from 7zip/Archive/Chm/Chm.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHandler.cpp (renamed from 7zip/Archive/Chm/ChmHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHandler.h (renamed from 7zip/Archive/Chm/ChmHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHeader.cpp (renamed from 7zip/Archive/Chm/ChmHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHeader.h (renamed from 7zip/Archive/Chm/ChmHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmIn.cpp (renamed from 7zip/Archive/Chm/ChmIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmIn.h (renamed from 7zip/Archive/Chm/ChmIn.h)0
-rwxr-xr-xCPP/7zip/Archive/Chm/DllExports.cpp (renamed from 7zip/Archive/Chm/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Chm/StdAfx.cpp (renamed from 7zip/Archive/Chm/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Chm/StdAfx.h (renamed from 7zip/Archive/Chm/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Chm/makefile (renamed from 7zip/Archive/Chm/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Chm/resource.rc (renamed from 7zip/Archive/Chm/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Common/CodecsPath.cpp (renamed from 7zip/Archive/Common/CodecsPath.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/CodecsPath.h (renamed from 7zip/Archive/Common/CodecsPath.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/CoderLoader.cpp (renamed from 7zip/Archive/Common/CoderLoader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/CoderLoader.h (renamed from 7zip/Archive/Common/CoderLoader.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2.cpp (renamed from 7zip/Archive/Common/CoderMixer2.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2.h (renamed from 7zip/Archive/Common/CoderMixer2.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2MT.cpp359
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2MT.h (renamed from 7zip/Archive/Common/CoderMixer2MT.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2ST.cpp (renamed from 7zip/Archive/Common/CoderMixer2ST.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2ST.h (renamed from 7zip/Archive/Common/CoderMixer2ST.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/CrossThreadProgress.cpp (renamed from 7zip/Archive/Common/CrossThreadProgress.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/CrossThreadProgress.h (renamed from 7zip/Archive/Common/CrossThreadProgress.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/DummyOutStream.cpp (renamed from 7zip/Archive/Common/DummyOutStream.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/DummyOutStream.h (renamed from 7zip/Archive/Common/DummyOutStream.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/FilterCoder.cpp (renamed from 7zip/Archive/Common/FilterCoder.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/FilterCoder.h (renamed from 7zip/Archive/Common/FilterCoder.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/InStreamWithCRC.cpp (renamed from 7zip/Archive/Common/InStreamWithCRC.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/InStreamWithCRC.h (renamed from 7zip/Archive/Common/InStreamWithCRC.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/ItemNameUtils.cpp (renamed from 7zip/Archive/Common/ItemNameUtils.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/ItemNameUtils.h (renamed from 7zip/Archive/Common/ItemNameUtils.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/MultiStream.cpp (renamed from 7zip/Archive/Common/MultiStream.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/MultiStream.h (renamed from 7zip/Archive/Common/MultiStream.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/OutStreamWithCRC.cpp (renamed from 7zip/Archive/Common/OutStreamWithCRC.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/OutStreamWithCRC.h (renamed from 7zip/Archive/Common/OutStreamWithCRC.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/ParseProperties.cpp (renamed from 7zip/Archive/Common/ParseProperties.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Common/ParseProperties.h (renamed from 7zip/Archive/Common/ParseProperties.h)0
-rwxr-xr-xCPP/7zip/Archive/Common/StdAfx.h (renamed from 7zip/Archive/Common/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHandler.cpp (renamed from 7zip/Archive/cpio/CpioHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHandler.h (renamed from 7zip/Archive/cpio/CpioHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHeader.cpp (renamed from 7zip/Archive/cpio/CpioHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHeader.h (renamed from 7zip/Archive/cpio/CpioHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioIn.cpp (renamed from 7zip/Archive/cpio/CpioIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioIn.h (renamed from 7zip/Archive/cpio/CpioIn.h)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioItem.h (renamed from 7zip/Archive/cpio/CpioItem.h)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/DllExports.cpp (renamed from 7zip/Archive/cpio/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/StdAfx.cpp (renamed from 7zip/Archive/Deb/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/StdAfx.h (renamed from 7zip/Archive/Deb/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/cpio.dsp (renamed from 7zip/Archive/cpio/cpio.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/cpio.dsw (renamed from 7zip/Archive/cpio/cpio.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/cpio.ico (renamed from 7zip/Archive/cpio/cpio.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Cpio/makefile (renamed from 7zip/Archive/Cpio/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Cpio/resource.rc (renamed from 7zip/Archive/cpio/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Deb/Deb.dsp (renamed from 7zip/Archive/Deb/Deb.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Deb/Deb.dsw (renamed from 7zip/Archive/Deb/Deb.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Deb/DebHandler.cpp (renamed from 7zip/Archive/Deb/DebHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Deb/DebHandler.h (renamed from 7zip/Archive/Deb/DebHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Deb/DebHeader.cpp (renamed from 7zip/Archive/Deb/DebHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Deb/DebHeader.h (renamed from 7zip/Archive/Deb/DebHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Deb/DebIn.cpp (renamed from 7zip/Archive/Deb/DebIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Deb/DebIn.h (renamed from 7zip/Archive/Deb/DebIn.h)0
-rwxr-xr-xCPP/7zip/Archive/Deb/DebItem.h (renamed from 7zip/Archive/Deb/DebItem.h)0
-rwxr-xr-xCPP/7zip/Archive/Deb/DllExports.cpp (renamed from 7zip/Archive/Deb/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Deb/StdAfx.cpp (renamed from 7zip/Archive/GZip/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Deb/StdAfx.h (renamed from 7zip/Archive/GZip/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Deb/deb.ico (renamed from 7zip/Archive/Deb/deb.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Deb/makefile (renamed from 7zip/Archive/Deb/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Deb/resource.rc (renamed from 7zip/Archive/Deb/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/GZip/DllExports.cpp (renamed from 7zip/Archive/GZip/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZip.dsp (renamed from 7zip/Archive/GZip/GZip.dsp)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZip.dsw (renamed from 7zip/Archive/GZip/GZip.dsw)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHandler.cpp (renamed from 7zip/Archive/GZip/GZipHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHandler.h (renamed from 7zip/Archive/GZip/GZipHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHandlerOut.cpp (renamed from 7zip/Archive/GZip/GZipHandlerOut.cpp)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHeader.cpp (renamed from 7zip/Archive/GZip/GZipHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHeader.h (renamed from 7zip/Archive/GZip/GZipHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipIn.cpp (renamed from 7zip/Archive/GZip/GZipIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipIn.h (renamed from 7zip/Archive/GZip/GZipIn.h)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipItem.h (renamed from 7zip/Archive/GZip/GZipItem.h)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipOut.cpp (renamed from 7zip/Archive/GZip/GZipOut.cpp)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipOut.h (renamed from 7zip/Archive/GZip/GZipOut.h)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipUpdate.cpp (renamed from 7zip/Archive/GZip/GZipUpdate.cpp)0
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipUpdate.h (renamed from 7zip/Archive/GZip/GZipUpdate.h)0
-rwxr-xr-xCPP/7zip/Archive/GZip/StdAfx.cpp (renamed from 7zip/Archive/Iso/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/GZip/StdAfx.h (renamed from 7zip/Archive/Lzh/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/GZip/gz.ico (renamed from 7zip/Archive/GZip/gz.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/GZip/makefile (renamed from 7zip/Archive/GZip/makefile)0
-rwxr-xr-xCPP/7zip/Archive/GZip/resource.rc (renamed from 7zip/Archive/GZip/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/IArchive.h (renamed from 7zip/Archive/IArchive.h)0
-rwxr-xr-xCPP/7zip/Archive/Iso/DllExports.cpp (renamed from 7zip/Archive/Iso/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Iso/Iso.dsp (renamed from 7zip/Archive/Iso/Iso.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Iso/Iso.dsw (renamed from 7zip/Archive/Iso/Iso.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Iso/Iso.ico (renamed from 7zip/Archive/Iso/Iso.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoHandler.cpp (renamed from 7zip/Archive/Iso/IsoHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoHandler.h (renamed from 7zip/Archive/Iso/IsoHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoHeader.cpp (renamed from 7zip/Archive/Iso/IsoHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoHeader.h (renamed from 7zip/Archive/Iso/IsoHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoIn.cpp (renamed from 7zip/Archive/Iso/IsoIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoIn.h (renamed from 7zip/Archive/Iso/IsoIn.h)0
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoItem.h (renamed from 7zip/Archive/Iso/IsoItem.h)0
-rwxr-xr-xCPP/7zip/Archive/Iso/StdAfx.cpp (renamed from 7zip/Archive/Lzh/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Iso/StdAfx.h (renamed from 7zip/Archive/Iso/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Iso/makefile (renamed from 7zip/Archive/Iso/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Iso/resource.rc (renamed from 7zip/Archive/Iso/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/DllExports.cpp (renamed from 7zip/Archive/Lzh/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/Lzh.def (renamed from 7zip/Archive/Lzh/Lzh.def)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/Lzh.dsp (renamed from 7zip/Archive/Lzh/Lzh.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/Lzh.dsw (renamed from 7zip/Archive/Lzh/Lzh.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhCRC.cpp (renamed from 7zip/Archive/Lzh/LzhCRC.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhCRC.h27
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhHandler.cpp (renamed from 7zip/Archive/Lzh/LzhHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhHandler.h (renamed from 7zip/Archive/Lzh/LzhHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhHeader.h (renamed from 7zip/Archive/Lzh/LzhHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhIn.cpp (renamed from 7zip/Archive/Lzh/LzhIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhIn.h (renamed from 7zip/Archive/Lzh/LzhIn.h)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhItem.h (renamed from 7zip/Archive/Lzh/LzhItem.h)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp (renamed from 7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h (renamed from 7zip/Archive/Lzh/LzhOutStreamWithCRC.h)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/StdAfx.cpp (renamed from 7zip/Archive/Nsis/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/StdAfx.h (renamed from 7zip/Archive/RPM/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/lzh.ico (renamed from 7zip/Archive/Lzh/lzh.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Lzh/makefile (renamed from 7zip/Archive/Lzh/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Lzh/resource.rc (renamed from 7zip/Archive/Lzh/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/DllExports.cpp (renamed from 7zip/Archive/Nsis/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/Nsis.dsp (renamed from 7zip/Archive/Nsis/Nsis.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/Nsis.dsw (renamed from 7zip/Archive/Nsis/Nsis.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisDecode.cpp (renamed from 7zip/Archive/Nsis/NsisDecode.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisDecode.h (renamed from 7zip/Archive/Nsis/NsisDecode.h)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisHandler.cpp (renamed from 7zip/Archive/Nsis/NsisHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisHandler.h (renamed from 7zip/Archive/Nsis/NsisHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisIn.cpp (renamed from 7zip/Archive/Nsis/NsisIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisIn.h166
-rwxr-xr-xCPP/7zip/Archive/Nsis/StdAfx.cpp (renamed from 7zip/Archive/RPM/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/StdAfx.h (renamed from 7zip/Archive/Nsis/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/makefile (renamed from 7zip/Archive/Nsis/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Nsis/resource.rc (renamed from 7zip/Archive/Nsis/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/RPM/DllExports.cpp (renamed from 7zip/Archive/RPM/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/RPM/Rpm.dsp (renamed from 7zip/Archive/RPM/Rpm.dsp)0
-rwxr-xr-xCPP/7zip/Archive/RPM/Rpm.dsw (renamed from 7zip/Archive/RPM/Rpm.dsw)0
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmHandler.cpp (renamed from 7zip/Archive/RPM/RpmHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmHandler.h (renamed from 7zip/Archive/RPM/RpmHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmHeader.h (renamed from 7zip/Archive/RPM/RpmHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmIn.cpp (renamed from 7zip/Archive/RPM/RpmIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmIn.h (renamed from 7zip/Archive/RPM/RpmIn.h)0
-rwxr-xr-xCPP/7zip/Archive/RPM/StdAfx.cpp (renamed from 7zip/Archive/Rar/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/RPM/StdAfx.h (renamed from 7zip/Archive/Rar/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/RPM/makefile (renamed from 7zip/Archive/RPM/makefile)0
-rwxr-xr-xCPP/7zip/Archive/RPM/resource.rc (renamed from 7zip/Archive/RPM/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/RPM/rpm.ico (renamed from 7zip/Archive/RPM/rpm.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Rar/DllExports.cpp (renamed from 7zip/Archive/Rar/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Rar/Rar.dsp (renamed from 7zip/Archive/Rar/Rar.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Rar/Rar.dsw (renamed from 7zip/Archive/Rar/Rar.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.cpp (renamed from 7zip/Archive/Rar/RarHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.h (renamed from 7zip/Archive/Rar/RarHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHeader.cpp (renamed from 7zip/Archive/Rar/RarHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHeader.h (renamed from 7zip/Archive/Rar/RarHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.cpp (renamed from 7zip/Archive/Rar/RarIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.h (renamed from 7zip/Archive/Rar/RarIn.h)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarItem.cpp (renamed from 7zip/Archive/Rar/RarItem.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarItem.h (renamed from 7zip/Archive/Rar/RarItem.h)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarVolumeInStream.cpp (renamed from 7zip/Archive/Rar/RarVolumeInStream.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Rar/RarVolumeInStream.h (renamed from 7zip/Archive/Rar/RarVolumeInStream.h)0
-rwxr-xr-xCPP/7zip/Archive/Rar/StdAfx.cpp (renamed from 7zip/Archive/Split/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Rar/StdAfx.h (renamed from 7zip/Archive/Split/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Rar/makefile (renamed from 7zip/Archive/Rar/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Rar/rar.ico (renamed from 7zip/Archive/Rar/rar.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Rar/resource.rc (renamed from 7zip/Archive/Rar/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Split/DllExports.cpp (renamed from 7zip/Archive/Split/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Split/Split.dsp (renamed from 7zip/Archive/Split/Split.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Split/Split.dsw (renamed from 7zip/Archive/Split/Split.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Split/Split.ico (renamed from 7zip/Archive/Split/Split.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Split/SplitHandler.cpp (renamed from 7zip/Archive/Split/SplitHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Split/SplitHandler.h (renamed from 7zip/Archive/Split/SplitHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Split/SplitHandlerOut.cpp (renamed from 7zip/Archive/Split/SplitHandlerOut.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Split/StdAfx.cpp (renamed from 7zip/Archive/Tar/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Split/StdAfx.h (renamed from 7zip/Archive/Z/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Split/makefile (renamed from 7zip/Archive/Split/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Split/resource.rc (renamed from 7zip/Archive/Split/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Tar/DllExports.cpp (renamed from 7zip/Archive/Tar/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Tar/StdAfx.cpp (renamed from 7zip/Archive/Z/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Tar/StdAfx.h (renamed from 7zip/Archive/Tar/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Tar/Tar.dsp (renamed from 7zip/Archive/Tar/Tar.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Tar/Tar.dsw (renamed from 7zip/Archive/Tar/Tar.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHandler.cpp (renamed from 7zip/Archive/Tar/TarHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHandler.h (renamed from 7zip/Archive/Tar/TarHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHandlerOut.cpp (renamed from 7zip/Archive/Tar/TarHandlerOut.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHeader.cpp (renamed from 7zip/Archive/Tar/TarHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHeader.h (renamed from 7zip/Archive/Tar/TarHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarIn.cpp (renamed from 7zip/Archive/Tar/TarIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarIn.h (renamed from 7zip/Archive/Tar/TarIn.h)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarItem.h (renamed from 7zip/Archive/Tar/TarItem.h)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarOut.cpp (renamed from 7zip/Archive/Tar/TarOut.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarOut.h (renamed from 7zip/Archive/Tar/TarOut.h)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarUpdate.cpp (renamed from 7zip/Archive/Tar/TarUpdate.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Tar/TarUpdate.h (renamed from 7zip/Archive/Tar/TarUpdate.h)0
-rwxr-xr-xCPP/7zip/Archive/Tar/makefile (renamed from 7zip/Archive/Tar/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Tar/resource.rc (renamed from 7zip/Archive/Tar/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Tar/tar.ico (renamed from 7zip/Archive/Tar/tar.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Z/DllExports.cpp (renamed from 7zip/Archive/Z/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Z/StdAfx.cpp (renamed from 7zip/Archive/Zip/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Z/StdAfx.h (renamed from 7zip/Archive/Zip/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Z/Z.dsp (renamed from 7zip/Archive/Z/Z.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Z/Z.dsw (renamed from 7zip/Archive/Z/Z.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Z/Z.ico (renamed from 7zip/Archive/Z/Z.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Z/ZHandler.cpp (renamed from 7zip/Archive/Z/ZHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Z/ZHandler.h (renamed from 7zip/Archive/Z/ZHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Z/makefile (renamed from 7zip/Archive/Z/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Z/resource.rc (renamed from 7zip/Archive/Z/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Zip/DllExports.cpp (renamed from 7zip/Archive/Zip/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/StdAfx.cpp (renamed from 7zip/Archive/cpio/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/StdAfx.h (renamed from 7zip/Archive/cpio/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/Zip.dsp (renamed from 7zip/Archive/Zip/Zip.dsp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/Zip.dsw (renamed from 7zip/Archive/Zip/Zip.dsw)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.cpp (renamed from 7zip/Archive/Zip/ZipAddCommon.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.h (renamed from 7zip/Archive/Zip/ZipAddCommon.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipCompressionMode.h (renamed from 7zip/Archive/Zip/ZipCompressionMode.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.cpp (renamed from 7zip/Archive/Zip/ZipHandler.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.h (renamed from 7zip/Archive/Zip/ZipHandler.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandlerOut.cpp (renamed from 7zip/Archive/Zip/ZipHandlerOut.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHeader.cpp (renamed from 7zip/Archive/Zip/ZipHeader.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHeader.h (renamed from 7zip/Archive/Zip/ZipHeader.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipIn.cpp (renamed from 7zip/Archive/Zip/ZipIn.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipIn.h (renamed from 7zip/Archive/Zip/ZipIn.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipItem.cpp (renamed from 7zip/Archive/Zip/ZipItem.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipItem.h (renamed from 7zip/Archive/Zip/ZipItem.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipItemEx.h (renamed from 7zip/Archive/Zip/ZipItemEx.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipOut.cpp (renamed from 7zip/Archive/Zip/ZipOut.cpp)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipOut.h (renamed from 7zip/Archive/Zip/ZipOut.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipUpdate.cpp734
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipUpdate.h (renamed from 7zip/Archive/Zip/ZipUpdate.h)0
-rwxr-xr-xCPP/7zip/Archive/Zip/makefile (renamed from 7zip/Archive/Zip/makefile)0
-rwxr-xr-xCPP/7zip/Archive/Zip/resource.rc (renamed from 7zip/Archive/Zip/resource.rc)0
-rwxr-xr-xCPP/7zip/Archive/Zip/zip.ico (renamed from 7zip/Archive/Zip/zip.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/makefile (renamed from 7zip/Archive/makefile)0
-rwxr-xr-xCPP/7zip/Bundles/Alone/Alone.dsp2301
-rwxr-xr-xCPP/7zip/Bundles/Alone/Alone.dsw (renamed from 7zip/Bundles/Alone/Alone.dsw)0
-rwxr-xr-xCPP/7zip/Bundles/Alone/StdAfx.cpp (renamed from 7zip/Bundles/Alone/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/Alone/StdAfx.h (renamed from 7zip/Bundles/Alone/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Bundles/Alone/afxres.h (renamed from 7zip/Bundles/Alone/afxres.h)0
-rwxr-xr-xCPP/7zip/Bundles/Alone/makefile390
-rwxr-xr-xCPP/7zip/Bundles/Alone/resource.rc (renamed from 7zip/Bundles/Alone/resource.rc)0
-rwxr-xr-xCPP/7zip/Bundles/Alone7z/Alone.dsp1358
-rwxr-xr-xCPP/7zip/Bundles/Alone7z/Alone.dsw (renamed from 7zip/Bundles/Alone7z/Alone.dsw)0
-rwxr-xr-xCPP/7zip/Bundles/Alone7z/StdAfx.cpp (renamed from 7zip/Bundles/Alone7z/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/Alone7z/StdAfx.h (renamed from 7zip/Bundles/Alone7z/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Bundles/Alone7z/makefile196
-rwxr-xr-xCPP/7zip/Bundles/Alone7z/resource.rc (renamed from 7zip/Bundles/Alone7z/resource.rc)0
-rwxr-xr-xCPP/7zip/Bundles/Format7z/Format7z.dsp1006
-rwxr-xr-xCPP/7zip/Bundles/Format7z/Format7z.dsw (renamed from 7zip/Bundles/Format7z/Format7z.dsw)0
-rwxr-xr-xCPP/7zip/Bundles/Format7z/StdAfx.cpp (renamed from 7zip/Bundles/Format7z/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/Format7z/StdAfx.h (renamed from 7zip/Bundles/Format7z/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Bundles/Format7z/makefile201
-rwxr-xr-xCPP/7zip/Bundles/Format7z/resource.rc (renamed from 7zip/Bundles/Format7z/resource.rc)0
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtract/Format7z.dsp (renamed from 7zip/Bundles/Format7zExtract/Format7z.dsp)0
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtract/Format7z.dsw (renamed from 7zip/Bundles/Format7zExtract/Format7z.dsw)0
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtract/StdAfx.cpp (renamed from 7zip/Bundles/Format7zExtract/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtract/StdAfx.h (renamed from 7zip/Bundles/Format7zExtract/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtract/makefile174
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtract/resource.rc (renamed from 7zip/Bundles/Format7zExtract/resource.rc)0
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtractR/StdAfx.cpp (renamed from 7zip/Bundles/SFXCon/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtractR/StdAfx.h (renamed from 7zip/Bundles/SFXCon/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtractR/makefile117
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtractR/resource.rc5
-rwxr-xr-xCPP/7zip/Bundles/Format7zR/StdAfx.cpp (renamed from 7zip/Bundles/SFXSetup/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/Format7zR/StdAfx.h9
-rwxr-xr-xCPP/7zip/Bundles/Format7zR/makefile150
-rwxr-xr-xCPP/7zip/Bundles/Format7zR/resource.rc5
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/7z.ico (renamed from 7zip/Bundles/SFXCon/7z.ico)bin1078 -> 1078 bytes
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/Main.cpp (renamed from 7zip/Bundles/SFXCon/Main.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/SFXCon.dsp (renamed from 7zip/Bundles/SFXCon/SFXCon.dsp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/SFXCon.dsw (renamed from 7zip/Bundles/SFXCon/SFXCon.dsw)0
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/StdAfx.cpp (renamed from 7zip/Bundles/SFXWin/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/StdAfx.h9
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/makefile (renamed from 7zip/Bundles/SFXCon/makefile)0
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/resource.rc (renamed from 7zip/Bundles/SFXCon/resource.rc)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp (renamed from 7zip/Bundles/SFXSetup/ExtractCallback.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/ExtractCallback.h (renamed from 7zip/Bundles/SFXSetup/ExtractCallback.h)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp (renamed from 7zip/Bundles/SFXSetup/ExtractEngine.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/ExtractEngine.h (renamed from 7zip/Bundles/SFXSetup/ExtractEngine.h)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/Main.cpp (renamed from 7zip/Bundles/SFXSetup/Main.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/SFXSetup.dsp (renamed from 7zip/Bundles/SFXSetup/SFXSetup.dsp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/SFXSetup.dsw (renamed from 7zip/Bundles/SFXSetup/SFXSetup.dsw)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/StdAfx.cpp (renamed from 7zip/Compress/BZip2/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/StdAfx.h (renamed from 7zip/Bundles/SFXSetup/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/makefile (renamed from 7zip/Bundles/SFXSetup/makefile)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/resource.h (renamed from 7zip/Bundles/SFXSetup/resource.h)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/resource.rc (renamed from 7zip/Bundles/SFXSetup/resource.rc)0
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/setup.ico (renamed from 7zip/Bundles/SFXSetup/setup.ico)bin1078 -> 1078 bytes
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/7z.ico (renamed from 7zip/Bundles/SFXWin/7z.ico)bin1078 -> 1078 bytes
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/Main.cpp (renamed from 7zip/Bundles/SFXWin/Main.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/SFXWin.dsp (renamed from 7zip/Bundles/SFXWin/SFXWin.dsp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/SFXWin.dsw (renamed from 7zip/Bundles/SFXWin/SFXWin.dsw)0
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/StdAfx.cpp (renamed from 7zip/Compress/BZip2Original/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/StdAfx.h (renamed from 7zip/Bundles/SFXWin/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/makefile (renamed from 7zip/Bundles/SFXWin/makefile)0
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/resource.h (renamed from 7zip/Bundles/SFXWin/resource.h)0
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/resource.rc (renamed from 7zip/Bundles/SFXWin/resource.rc)0
-rwxr-xr-xCPP/7zip/Bundles/makefile15
-rwxr-xr-xCPP/7zip/Common/FilePathAutoRename.cpp (renamed from 7zip/Common/FilePathAutoRename.cpp)0
-rwxr-xr-xCPP/7zip/Common/FilePathAutoRename.h (renamed from 7zip/Common/FilePathAutoRename.h)0
-rwxr-xr-xCPP/7zip/Common/FileStreams.cpp (renamed from 7zip/Common/FileStreams.cpp)0
-rwxr-xr-xCPP/7zip/Common/FileStreams.h (renamed from 7zip/Common/FileStreams.h)0
-rwxr-xr-xCPP/7zip/Common/InBuffer.cpp (renamed from 7zip/Common/InBuffer.cpp)0
-rwxr-xr-xCPP/7zip/Common/InBuffer.h (renamed from 7zip/Common/InBuffer.h)0
-rwxr-xr-xCPP/7zip/Common/InMemStream.cpp (renamed from 7zip/Common/InMemStream.cpp)0
-rwxr-xr-xCPP/7zip/Common/InMemStream.h (renamed from 7zip/Common/InMemStream.h)0
-rwxr-xr-xCPP/7zip/Common/InOutTempBuffer.cpp (renamed from 7zip/Common/InOutTempBuffer.cpp)0
-rwxr-xr-xCPP/7zip/Common/InOutTempBuffer.h (renamed from 7zip/Common/InOutTempBuffer.h)0
-rwxr-xr-xCPP/7zip/Common/LSBFDecoder.cpp27
-rwxr-xr-xCPP/7zip/Common/LSBFDecoder.h (renamed from 7zip/Common/LSBFDecoder.h)0
-rwxr-xr-xCPP/7zip/Common/LSBFEncoder.cpp (renamed from 7zip/Common/LSBFEncoder.cpp)0
-rwxr-xr-xCPP/7zip/Common/LSBFEncoder.h (renamed from 7zip/Common/LSBFEncoder.h)0
-rwxr-xr-xCPP/7zip/Common/LimitedStreams.cpp (renamed from 7zip/Common/LimitedStreams.cpp)0
-rwxr-xr-xCPP/7zip/Common/LimitedStreams.h (renamed from 7zip/Common/LimitedStreams.h)0
-rwxr-xr-xCPP/7zip/Common/LockedStream.cpp (renamed from 7zip/Common/LockedStream.cpp)0
-rwxr-xr-xCPP/7zip/Common/LockedStream.h (renamed from 7zip/Common/LockedStream.h)0
-rwxr-xr-xCPP/7zip/Common/MSBFDecoder.h (renamed from 7zip/Common/MSBFDecoder.h)0
-rwxr-xr-xCPP/7zip/Common/MSBFEncoder.h (renamed from 7zip/Common/MSBFEncoder.h)0
-rwxr-xr-xCPP/7zip/Common/MemBlocks.cpp (renamed from 7zip/Common/MemBlocks.cpp)0
-rwxr-xr-xCPP/7zip/Common/MemBlocks.h (renamed from 7zip/Common/MemBlocks.h)0
-rwxr-xr-xCPP/7zip/Common/OffsetStream.cpp (renamed from 7zip/Common/OffsetStream.cpp)0
-rwxr-xr-xCPP/7zip/Common/OffsetStream.h (renamed from 7zip/Common/OffsetStream.h)0
-rwxr-xr-xCPP/7zip/Common/OutBuffer.cpp (renamed from 7zip/Common/OutBuffer.cpp)0
-rwxr-xr-xCPP/7zip/Common/OutBuffer.h (renamed from 7zip/Common/OutBuffer.h)0
-rwxr-xr-xCPP/7zip/Common/OutMemStream.cpp (renamed from 7zip/Common/OutMemStream.cpp)0
-rwxr-xr-xCPP/7zip/Common/OutMemStream.h (renamed from 7zip/Common/OutMemStream.h)0
-rwxr-xr-xCPP/7zip/Common/ProgressMt.cpp (renamed from 7zip/Common/ProgressMt.cpp)0
-rwxr-xr-xCPP/7zip/Common/ProgressMt.h (renamed from 7zip/Common/ProgressMt.h)0
-rwxr-xr-xCPP/7zip/Common/ProgressUtils.cpp (renamed from 7zip/Common/ProgressUtils.cpp)0
-rwxr-xr-xCPP/7zip/Common/ProgressUtils.h (renamed from 7zip/Common/ProgressUtils.h)0
-rwxr-xr-xCPP/7zip/Common/StdAfx.h (renamed from 7zip/Common/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Common/StreamBinder.cpp (renamed from 7zip/Common/StreamBinder.cpp)0
-rwxr-xr-xCPP/7zip/Common/StreamBinder.h (renamed from 7zip/Common/StreamBinder.h)0
-rwxr-xr-xCPP/7zip/Common/StreamObjects.cpp (renamed from 7zip/Common/StreamObjects.cpp)0
-rwxr-xr-xCPP/7zip/Common/StreamObjects.h (renamed from 7zip/Common/StreamObjects.h)0
-rwxr-xr-xCPP/7zip/Common/StreamUtils.cpp (renamed from 7zip/Common/StreamUtils.cpp)0
-rwxr-xr-xCPP/7zip/Common/StreamUtils.h (renamed from 7zip/Common/StreamUtils.h)0
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder1.cpp (renamed from 7zip/Compress/Arj/ArjDecoder1.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder1.h (renamed from 7zip/Compress/Arj/ArjDecoder1.h)0
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder2.cpp (renamed from 7zip/Compress/Arj/ArjDecoder2.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder2.h (renamed from 7zip/Compress/Arj/ArjDecoder2.h)0
-rwxr-xr-xCPP/7zip/Compress/Arj/StdAfx.h (renamed from 7zip/Compress/Arj/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/BWT/BlockSort.cpp487
-rwxr-xr-xCPP/7zip/Compress/BWT/BlockSort.h21
-rwxr-xr-xCPP/7zip/Compress/BWT/Mtf8.h195
-rwxr-xr-xCPP/7zip/Compress/BWT/StdAfx.h (renamed from 7zip/Compress/BWT/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2.dsp303
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2.dsw (renamed from 7zip/Compress/BZip2/BZip2.dsw)0
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2CRC.cpp (renamed from 7zip/Compress/BZip2/BZip2CRC.cpp)0
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2CRC.h31
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Const.h (renamed from 7zip/Compress/BZip2/BZip2Const.h)0
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Decoder.cpp770
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Decoder.h164
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Encoder.cpp883
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Encoder.h246
-rwxr-xr-xCPP/7zip/Compress/BZip2/DllExports.cpp93
-rwxr-xr-xCPP/7zip/Compress/BZip2/StdAfx.cpp (renamed from 7zip/Compress/Branch/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/BZip2/StdAfx.h (renamed from 7zip/Compress/BZip2/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/BZip2/makefile56
-rwxr-xr-xCPP/7zip/Compress/BZip2/resource.rc (renamed from 7zip/Compress/BZip2/resource.rc)0
-rwxr-xr-xCPP/7zip/Compress/BZip2Original/BZip2Decoder.cpp (renamed from 7zip/Compress/BZip2Original/BZip2Decoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/BZip2Original/BZip2Decoder.h (renamed from 7zip/Compress/BZip2Original/BZip2Decoder.h)0
-rwxr-xr-xCPP/7zip/Compress/BZip2Original/BZip2Encoder.cpp (renamed from 7zip/Compress/BZip2Original/BZip2Encoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/BZip2Original/BZip2Encoder.h (renamed from 7zip/Compress/BZip2Original/BZip2Encoder.h)0
-rwxr-xr-xCPP/7zip/Compress/BZip2Original/BZip2Error.cpp (renamed from 7zip/Compress/BZip2Original/BZip2Error.cpp)0
-rwxr-xr-xCPP/7zip/Compress/BZip2Original/DllExports.cpp86
-rwxr-xr-xCPP/7zip/Compress/BZip2Original/StdAfx.cpp (renamed from 7zip/Compress/ByteSwap/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/BZip2Original/StdAfx.h (renamed from 7zip/Compress/BZip2Original/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/Branch/ARM.cpp16
-rwxr-xr-xCPP/7zip/Compress/Branch/ARM.h (renamed from 7zip/Compress/Branch/ARM.h)0
-rwxr-xr-xCPP/7zip/Compress/Branch/ARMThumb.cpp16
-rwxr-xr-xCPP/7zip/Compress/Branch/ARMThumb.h (renamed from 7zip/Compress/Branch/ARMThumb.h)0
-rwxr-xr-xCPP/7zip/Compress/Branch/Branch.dsp (renamed from 7zip/Compress/Branch/Branch.dsp)0
-rwxr-xr-xCPP/7zip/Compress/Branch/Branch.dsw (renamed from 7zip/Compress/Branch/Branch.dsw)0
-rwxr-xr-xCPP/7zip/Compress/Branch/BranchCoder.cpp (renamed from 7zip/Compress/Branch/BranchCoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Branch/BranchCoder.h (renamed from 7zip/Compress/Branch/BranchCoder.h)0
-rwxr-xr-xCPP/7zip/Compress/Branch/DllExports.cpp (renamed from 7zip/Compress/Branch/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Branch/IA64.cpp16
-rwxr-xr-xCPP/7zip/Compress/Branch/IA64.h (renamed from 7zip/Compress/Branch/IA64.h)0
-rwxr-xr-xCPP/7zip/Compress/Branch/PPC.cpp17
-rwxr-xr-xCPP/7zip/Compress/Branch/PPC.h (renamed from 7zip/Compress/Branch/PPC.h)0
-rwxr-xr-xCPP/7zip/Compress/Branch/SPARC.cpp17
-rwxr-xr-xCPP/7zip/Compress/Branch/SPARC.h (renamed from 7zip/Compress/Branch/SPARC.h)0
-rwxr-xr-xCPP/7zip/Compress/Branch/StdAfx.cpp (renamed from 7zip/Compress/Copy/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Branch/StdAfx.h (renamed from 7zip/Compress/Branch/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/Branch/makefile (renamed from 7zip/Compress/Branch/makefile)0
-rwxr-xr-xCPP/7zip/Compress/Branch/resource.rc (renamed from 7zip/Compress/Branch/resource.rc)0
-rwxr-xr-xCPP/7zip/Compress/Branch/x86.cpp18
-rwxr-xr-xCPP/7zip/Compress/Branch/x86.h19
-rwxr-xr-xCPP/7zip/Compress/Branch/x86_2.cpp (renamed from 7zip/Compress/Branch/x86_2.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Branch/x86_2.h (renamed from 7zip/Compress/Branch/x86_2.h)0
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/ByteSwap.cpp (renamed from 7zip/Compress/ByteSwap/ByteSwap.cpp)0
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/ByteSwap.dsp (renamed from 7zip/Compress/ByteSwap/ByteSwap.dsp)0
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/ByteSwap.dsw (renamed from 7zip/Compress/ByteSwap/ByteSwap.dsw)0
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/ByteSwap.h (renamed from 7zip/Compress/ByteSwap/ByteSwap.h)0
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/DllExports.cpp (renamed from 7zip/Compress/ByteSwap/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/StdAfx.cpp (renamed from 7zip/Compress/Deflate/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/StdAfx.h (renamed from 7zip/Compress/ByteSwap/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/makefile (renamed from 7zip/Compress/ByteSwap/makefile)0
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/resource.rc (renamed from 7zip/Compress/ByteSwap/resource.rc)0
-rwxr-xr-xCPP/7zip/Compress/Codec.def (renamed from 7zip/Compress/Codec.def)0
-rwxr-xr-xCPP/7zip/Compress/Copy/Copy.dsp (renamed from 7zip/Compress/Copy/Copy.dsp)0
-rwxr-xr-xCPP/7zip/Compress/Copy/Copy.dsw (renamed from 7zip/Compress/Copy/Copy.dsw)0
-rwxr-xr-xCPP/7zip/Compress/Copy/CopyCoder.cpp (renamed from 7zip/Compress/Copy/CopyCoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Copy/CopyCoder.h (renamed from 7zip/Compress/Copy/CopyCoder.h)0
-rwxr-xr-xCPP/7zip/Compress/Copy/DllExports.cpp (renamed from 7zip/Compress/Copy/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Copy/StdAfx.cpp (renamed from 7zip/Compress/Implode/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Copy/StdAfx.h (renamed from 7zip/Compress/Copy/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/Copy/makefile (renamed from 7zip/Compress/Copy/makefile)0
-rwxr-xr-xCPP/7zip/Compress/Copy/resource.rc (renamed from 7zip/Compress/Copy/resource.rc)0
-rwxr-xr-xCPP/7zip/Compress/Deflate/Deflate.dsp341
-rwxr-xr-xCPP/7zip/Compress/Deflate/Deflate.dsw (renamed from 7zip/Compress/Deflate/Deflate.dsw)0
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateConst.h (renamed from 7zip/Compress/Deflate/DeflateConst.h)0
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateDecoder.cpp (renamed from 7zip/Compress/Deflate/DeflateDecoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateDecoder.h (renamed from 7zip/Compress/Deflate/DeflateDecoder.h)0
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateEncoder.cpp963
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateEncoder.h221
-rwxr-xr-xCPP/7zip/Compress/Deflate/DllExports.cpp157
-rwxr-xr-xCPP/7zip/Compress/Deflate/StdAfx.cpp (renamed from 7zip/Compress/LZMA/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Deflate/StdAfx.h (renamed from 7zip/Compress/Deflate/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/Deflate/makefile63
-rwxr-xr-xCPP/7zip/Compress/Deflate/resource.rc (renamed from 7zip/Compress/Deflate/resource.rc)0
-rwxr-xr-xCPP/7zip/Compress/Huffman/HuffmanDecoder.h (renamed from 7zip/Compress/Huffman/HuffmanDecoder.h)0
-rwxr-xr-xCPP/7zip/Compress/Huffman/StdAfx.h (renamed from 7zip/Compress/Huffman/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/Implode/DllExports.cpp65
-rwxr-xr-xCPP/7zip/Compress/Implode/ImplodeDecoder.cpp (renamed from 7zip/Compress/Implode/ImplodeDecoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Implode/ImplodeDecoder.h (renamed from 7zip/Compress/Implode/ImplodeDecoder.h)0
-rwxr-xr-xCPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp (renamed from 7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.h (renamed from 7zip/Compress/Implode/ImplodeHuffmanDecoder.h)0
-rwxr-xr-xCPP/7zip/Compress/Implode/StdAfx.cpp (renamed from 7zip/Compress/LZMA_Alone/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Implode/StdAfx.h (renamed from 7zip/Compress/Implode/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/LZ/LZOutWindow.cpp (renamed from 7zip/Compress/LZ/LZOutWindow.cpp)0
-rwxr-xr-xCPP/7zip/Compress/LZ/LZOutWindow.h (renamed from 7zip/Compress/LZ/LZOutWindow.h)0
-rwxr-xr-xCPP/7zip/Compress/LZ/StdAfx.h (renamed from 7zip/Compress/LZ/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/LZMA/DllExports.cpp109
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMA.dsp478
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMA.dsw (renamed from 7zip/Compress/LZMA/LZMA.dsw)0
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMA.h (renamed from 7zip/Compress/LZMA/LZMA.h)0
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMADecoder.cpp (renamed from 7zip/Compress/LZMA/LZMADecoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMADecoder.h (renamed from 7zip/Compress/LZMA/LZMADecoder.h)0
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMAEncoder.cpp1530
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMAEncoder.h435
-rwxr-xr-xCPP/7zip/Compress/LZMA/StdAfx.cpp (renamed from 7zip/Compress/PPMD/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/LZMA/StdAfx.h (renamed from 7zip/Compress/LZMA/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/LZMA/makefile69
-rwxr-xr-xCPP/7zip/Compress/LZMA/resource.rc (renamed from 7zip/Compress/LZMA/resource.rc)0
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp449
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsw (renamed from 7zip/Compress/LZMA_Alone/AloneLZMA.dsw)0
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp526
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp (renamed from 7zip/Compress/LZMA_Alone/LzmaBench.cpp)0
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaBench.h (renamed from 7zip/Compress/LZMA_Alone/LzmaBench.h)0
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaRam.cpp227
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaRam.h (renamed from 7zip/Compress/LZMA_Alone/LzmaRam.h)0
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.c79
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.h (renamed from 7zip/Compress/LZMA_Alone/LzmaRamDecode.h)0
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/StdAfx.cpp (renamed from 7zip/Compress/Rar20/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/StdAfx.h (renamed from 7zip/Compress/LZMA_Alone/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/makefile124
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/makefile.gcc117
-rwxr-xr-xCPP/7zip/Compress/Lzh/LzhDecoder.cpp216
-rwxr-xr-xCPP/7zip/Compress/Lzh/LzhDecoder.h (renamed from 7zip/Compress/Lzh/LzhDecoder.h)0
-rwxr-xr-xCPP/7zip/Compress/Lzx/Lzx.h (renamed from 7zip/Compress/Lzx/Lzx.h)0
-rwxr-xr-xCPP/7zip/Compress/Lzx/Lzx86Converter.cpp (renamed from 7zip/Compress/Lzx/Lzx86Converter.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Lzx/Lzx86Converter.h (renamed from 7zip/Compress/Lzx/Lzx86Converter.h)0
-rwxr-xr-xCPP/7zip/Compress/Lzx/LzxDecoder.cpp (renamed from 7zip/Compress/Lzx/LzxDecoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Lzx/LzxDecoder.h (renamed from 7zip/Compress/Lzx/LzxDecoder.h)0
-rwxr-xr-xCPP/7zip/Compress/Lzx/StdAfx.h (renamed from 7zip/Compress/Lzx/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/DllExports.cpp93
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMD.dsp (renamed from 7zip/Compress/PPMD/PPMD.dsp)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMD.dsw (renamed from 7zip/Compress/PPMD/PPMD.dsw)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDContext.h (renamed from 7zip/Compress/PPMD/PPMDContext.h)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDDecode.h154
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDDecoder.cpp184
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDDecoder.h89
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDEncode.h (renamed from 7zip/Compress/PPMD/PPMDEncode.h)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDEncoder.cpp (renamed from 7zip/Compress/PPMD/PPMDEncoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDEncoder.h (renamed from 7zip/Compress/PPMD/PPMDEncoder.h)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDSubAlloc.h292
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDType.h (renamed from 7zip/Compress/PPMD/PPMDType.h)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/StdAfx.cpp (renamed from 7zip/Compress/Rar29/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/StdAfx.h (renamed from 7zip/Compress/PPMD/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/makefile (renamed from 7zip/Compress/PPMD/makefile)0
-rwxr-xr-xCPP/7zip/Compress/PPMD/resource.rc (renamed from 7zip/Compress/PPMD/resource.rc)0
-rwxr-xr-xCPP/7zip/Compress/Quantum/QuantumDecoder.cpp (renamed from 7zip/Compress/Quantum/QuantumDecoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Quantum/QuantumDecoder.h (renamed from 7zip/Compress/Quantum/QuantumDecoder.h)0
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/RangeCoder.h (renamed from 7zip/Compress/RangeCoder/RangeCoder.h)0
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp (renamed from 7zip/Compress/RangeCoder/RangeCoderBit.cpp)0
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/RangeCoderBit.h (renamed from 7zip/Compress/RangeCoder/RangeCoderBit.h)0
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h (renamed from 7zip/Compress/RangeCoder/RangeCoderBitTree.h)0
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/RangeCoderOpt.h (renamed from 7zip/Compress/RangeCoder/RangeCoderOpt.h)0
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/StdAfx.h (renamed from 7zip/Compress/RangeCoder/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/Rar/DllExports.cpp91
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar1Decoder.cpp485
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar1Decoder.h90
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar29.dsp297
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar29.dsw29
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar2Decoder.cpp401
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar2Decoder.h176
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar3Decoder.cpp832
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar3Decoder.h294
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar3Vm.cpp1089
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar3Vm.h219
-rwxr-xr-xCPP/7zip/Compress/Rar/StdAfx.cpp (renamed from 7zip/Compress/Shrink/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Rar/StdAfx.h (renamed from 7zip/Compress/Rar20/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/Rar/makefile49
-rwxr-xr-xCPP/7zip/Compress/Rar/resource.rc (renamed from 7zip/Compress/Rar29/resource.rc)0
-rwxr-xr-xCPP/7zip/Compress/Shrink/DllExports.cpp64
-rwxr-xr-xCPP/7zip/Compress/Shrink/ShrinkDecoder.cpp (renamed from 7zip/Compress/Shrink/ShrinkDecoder.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Shrink/ShrinkDecoder.h (renamed from 7zip/Compress/Shrink/ShrinkDecoder.h)0
-rwxr-xr-xCPP/7zip/Compress/Shrink/StdAfx.cpp (renamed from 7zip/Compress/Z/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Shrink/StdAfx.h (renamed from 7zip/Compress/Rar29/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/Z/StdAfx.cpp (renamed from 7zip/Crypto/7zAES/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Compress/Z/StdAfx.h (renamed from 7zip/Compress/Shrink/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Compress/Z/ZDecoder.cpp172
-rwxr-xr-xCPP/7zip/Compress/Z/ZDecoder.h44
-rwxr-xr-xCPP/7zip/Compress/makefile14
-rwxr-xr-xCPP/7zip/Crypto/7zAES/7zAES.cpp (renamed from 7zip/Crypto/7zAES/7zAES.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/7zAES/7zAES.dsp (renamed from 7zip/Crypto/7zAES/7zAES.dsp)0
-rwxr-xr-xCPP/7zip/Crypto/7zAES/7zAES.dsw (renamed from 7zip/Crypto/7zAES/7zAES.dsw)0
-rwxr-xr-xCPP/7zip/Crypto/7zAES/7zAES.h (renamed from 7zip/Crypto/7zAES/7zAES.h)0
-rwxr-xr-xCPP/7zip/Crypto/7zAES/DllExports.cpp (renamed from 7zip/Crypto/7zAES/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/7zAES/StdAfx.cpp (renamed from 7zip/Crypto/AES/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/7zAES/StdAfx.h (renamed from 7zip/Compress/Z/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Crypto/7zAES/makefile (renamed from 7zip/Crypto/7zAES/makefile)0
-rwxr-xr-xCPP/7zip/Crypto/7zAES/resource.rc (renamed from 7zip/Crypto/7zAES/resource.rc)0
-rwxr-xr-xCPP/7zip/Crypto/AES/AES.dsp (renamed from 7zip/Crypto/AES/AES.dsp)0
-rwxr-xr-xCPP/7zip/Crypto/AES/AES.dsw (renamed from 7zip/Crypto/AES/AES.dsw)0
-rwxr-xr-xCPP/7zip/Crypto/AES/AES_CBC.h (renamed from 7zip/Crypto/AES/AES_CBC.h)0
-rwxr-xr-xCPP/7zip/Crypto/AES/DllExports.cpp (renamed from 7zip/Crypto/AES/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/AES/MyAES.cpp (renamed from 7zip/Crypto/AES/MyAES.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/AES/MyAES.h (renamed from 7zip/Crypto/AES/MyAES.h)0
-rwxr-xr-xCPP/7zip/Crypto/AES/StdAfx.cpp (renamed from 7zip/Crypto/WzAES/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/AES/StdAfx.h (renamed from 7zip/Crypto/7zAES/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Crypto/AES/aes.h (renamed from 7zip/Crypto/AES/aes.h)0
-rwxr-xr-xCPP/7zip/Crypto/AES/aescpp.h (renamed from 7zip/Crypto/AES/aescpp.h)0
-rwxr-xr-xCPP/7zip/Crypto/AES/aescrypt.c (renamed from 7zip/Crypto/AES/aescrypt.c)0
-rwxr-xr-xCPP/7zip/Crypto/AES/aeskey.c (renamed from 7zip/Crypto/AES/aeskey.c)0
-rwxr-xr-xCPP/7zip/Crypto/AES/aesopt.h (renamed from 7zip/Crypto/AES/aesopt.h)0
-rwxr-xr-xCPP/7zip/Crypto/AES/aestab.c (renamed from 7zip/Crypto/AES/aestab.c)0
-rwxr-xr-xCPP/7zip/Crypto/AES/makefile (renamed from 7zip/Crypto/AES/makefile)0
-rwxr-xr-xCPP/7zip/Crypto/AES/resource.rc (renamed from 7zip/Crypto/AES/resource.rc)0
-rwxr-xr-xCPP/7zip/Crypto/Codec.def (renamed from 7zip/Crypto/Codec.def)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/HmacSha1.cpp (renamed from 7zip/Crypto/Hash/HmacSha1.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/HmacSha1.h (renamed from 7zip/Crypto/Hash/HmacSha1.h)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp (renamed from 7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h (renamed from 7zip/Crypto/Hash/Pbkdf2HmacSha1.h)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/RandGen.cpp (renamed from 7zip/Crypto/Hash/RandGen.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/RandGen.h (renamed from 7zip/Crypto/Hash/RandGen.h)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/RotateDefs.h (renamed from 7zip/Crypto/Hash/RotateDefs.h)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/Sha1.cpp (renamed from 7zip/Crypto/Hash/Sha1.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/Sha1.h (renamed from 7zip/Crypto/Hash/Sha1.h)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/Sha256.cpp (renamed from 7zip/Crypto/Hash/Sha256.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/Sha256.h (renamed from 7zip/Crypto/Hash/Sha256.h)0
-rwxr-xr-xCPP/7zip/Crypto/Hash/StdAfx.h (renamed from 7zip/Crypto/AES/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Crypto/Rar20/Rar20Cipher.cpp (renamed from 7zip/Crypto/Rar20/Rar20Cipher.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/Rar20/Rar20Cipher.h (renamed from 7zip/Crypto/Rar20/Rar20Cipher.h)0
-rwxr-xr-xCPP/7zip/Crypto/Rar20/Rar20Crypto.cpp (renamed from 7zip/Crypto/Rar20/Rar20Crypto.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/Rar20/Rar20Crypto.h (renamed from 7zip/Crypto/Rar20/Rar20Crypto.h)0
-rwxr-xr-xCPP/7zip/Crypto/Rar20/StdAfx.h (renamed from 7zip/Crypto/Hash/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Crypto/RarAES/RarAES.cpp (renamed from 7zip/Crypto/RarAES/RarAES.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/RarAES/RarAES.h (renamed from 7zip/Crypto/RarAES/RarAES.h)0
-rwxr-xr-xCPP/7zip/Crypto/RarAES/StdAfx.h (renamed from 7zip/Crypto/Rar20/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Crypto/WzAES/StdAfx.cpp (renamed from 7zip/UI/Client7z/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/WzAES/StdAfx.h (renamed from 7zip/Crypto/RarAES/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Crypto/WzAES/WzAES.cpp (renamed from 7zip/Crypto/WzAES/WzAES.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/WzAES/WzAES.h (renamed from 7zip/Crypto/WzAES/WzAES.h)0
-rwxr-xr-xCPP/7zip/Crypto/Zip/StdAfx.h (renamed from 7zip/Crypto/WzAES/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Crypto/Zip/ZipCipher.cpp (renamed from 7zip/Crypto/Zip/ZipCipher.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/Zip/ZipCipher.h (renamed from 7zip/Crypto/Zip/ZipCipher.h)0
-rwxr-xr-xCPP/7zip/Crypto/Zip/ZipCrypto.cpp (renamed from 7zip/Crypto/Zip/ZipCrypto.cpp)0
-rwxr-xr-xCPP/7zip/Crypto/Zip/ZipCrypto.h (renamed from 7zip/Crypto/Zip/ZipCrypto.h)0
-rwxr-xr-xCPP/7zip/Crypto/makefile (renamed from 7zip/Crypto/makefile)0
-rwxr-xr-xCPP/7zip/FileManager/7zFM.exe.manifest (renamed from 7zip/FileManager/7zFM.exe.manifest)0
-rwxr-xr-xCPP/7zip/FileManager/7zipLogo.ico (renamed from 7zip/FileManager/7zipLogo.ico)bin9150 -> 9150 bytes
-rwxr-xr-xCPP/7zip/FileManager/Add.bmp (renamed from 7zip/FileManager/Add.bmp)bin982 -> 982 bytes
-rwxr-xr-xCPP/7zip/FileManager/Add2.bmp (renamed from 7zip/FileManager/Add2.bmp)bin406 -> 406 bytes
-rwxr-xr-xCPP/7zip/FileManager/App.cpp759
-rwxr-xr-xCPP/7zip/FileManager/App.h332
-rwxr-xr-xCPP/7zip/FileManager/AppState.h (renamed from 7zip/FileManager/AppState.h)0
-rwxr-xr-xCPP/7zip/FileManager/ClassDefs.cpp (renamed from 7zip/FileManager/ClassDefs.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Copy.bmp (renamed from 7zip/FileManager/Copy.bmp)bin982 -> 982 bytes
-rwxr-xr-xCPP/7zip/FileManager/Copy2.bmp (renamed from 7zip/FileManager/Copy2.bmp)bin406 -> 406 bytes
-rwxr-xr-xCPP/7zip/FileManager/Delete.bmp (renamed from 7zip/FileManager/Delete.bmp)bin982 -> 982 bytes
-rwxr-xr-xCPP/7zip/FileManager/Delete2.bmp (renamed from 7zip/FileManager/Delete2.bmp)bin406 -> 406 bytes
-rwxr-xr-xCPP/7zip/FileManager/EnumFormatEtc.cpp108
-rwxr-xr-xCPP/7zip/FileManager/EnumFormatEtc.h (renamed from 7zip/FileManager/EnumFormatEtc.h)0
-rwxr-xr-xCPP/7zip/FileManager/Extract.bmp (renamed from 7zip/FileManager/Extract.bmp)bin982 -> 982 bytes
-rwxr-xr-xCPP/7zip/FileManager/Extract2.bmp (renamed from 7zip/FileManager/Extract2.bmp)bin406 -> 406 bytes
-rwxr-xr-xCPP/7zip/FileManager/ExtractCallback.cpp382
-rwxr-xr-xCPP/7zip/FileManager/ExtractCallback.h124
-rwxr-xr-xCPP/7zip/FileManager/FM.cpp788
-rwxr-xr-xCPP/7zip/FileManager/FM.dsp1251
-rwxr-xr-xCPP/7zip/FileManager/FM.dsw (renamed from 7zip/FileManager/FM.dsw)0
-rwxr-xr-xCPP/7zip/FileManager/FM.ico (renamed from 7zip/FileManager/FM.ico)bin4846 -> 4846 bytes
-rwxr-xr-xCPP/7zip/FileManager/FSDrives.cpp (renamed from 7zip/FileManager/FSDrives.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/FSDrives.h (renamed from 7zip/FileManager/FSDrives.h)0
-rwxr-xr-xCPP/7zip/FileManager/FSFolder.cpp655
-rwxr-xr-xCPP/7zip/FileManager/FSFolder.h141
-rwxr-xr-xCPP/7zip/FileManager/FSFolderCopy.cpp490
-rwxr-xr-xCPP/7zip/FileManager/FileFolderPluginOpen.cpp111
-rwxr-xr-xCPP/7zip/FileManager/FileFolderPluginOpen.h9
-rwxr-xr-xCPP/7zip/FileManager/FilePlugins.cpp (renamed from 7zip/FileManager/FilePlugins.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/FilePlugins.h (renamed from 7zip/FileManager/FilePlugins.h)0
-rwxr-xr-xCPP/7zip/FileManager/FormatUtils.cpp (renamed from 7zip/FileManager/FormatUtils.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/FormatUtils.h (renamed from 7zip/FileManager/FormatUtils.h)0
-rwxr-xr-xCPP/7zip/FileManager/HelpUtils.cpp (renamed from 7zip/FileManager/HelpUtils.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/HelpUtils.h (renamed from 7zip/FileManager/HelpUtils.h)0
-rwxr-xr-xCPP/7zip/FileManager/IFolder.h (renamed from 7zip/FileManager/IFolder.h)0
-rwxr-xr-xCPP/7zip/FileManager/Info.bmp (renamed from 7zip/FileManager/Info.bmp)bin982 -> 982 bytes
-rwxr-xr-xCPP/7zip/FileManager/Info2.bmp (renamed from 7zip/FileManager/Info2.bmp)bin406 -> 406 bytes
-rwxr-xr-xCPP/7zip/FileManager/LangUtils.cpp (renamed from 7zip/FileManager/LangUtils.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/LangUtils.h (renamed from 7zip/FileManager/LangUtils.h)0
-rwxr-xr-xCPP/7zip/FileManager/Move.bmp (renamed from 7zip/FileManager/Move.bmp)bin982 -> 982 bytes
-rwxr-xr-xCPP/7zip/FileManager/Move2.bmp (renamed from 7zip/FileManager/Move2.bmp)bin406 -> 406 bytes
-rwxr-xr-xCPP/7zip/FileManager/MyCom2.h (renamed from 7zip/FileManager/MyCom2.h)0
-rwxr-xr-xCPP/7zip/FileManager/MyLoadMenu.cpp694
-rwxr-xr-xCPP/7zip/FileManager/MyLoadMenu.h (renamed from 7zip/FileManager/MyLoadMenu.h)0
-rwxr-xr-xCPP/7zip/FileManager/NetFolder.cpp (renamed from 7zip/FileManager/NetFolder.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/NetFolder.h (renamed from 7zip/FileManager/NetFolder.h)0
-rwxr-xr-xCPP/7zip/FileManager/OpenCallback.cpp113
-rwxr-xr-xCPP/7zip/FileManager/OpenCallback.h85
-rwxr-xr-xCPP/7zip/FileManager/OptionsDialog.cpp (renamed from 7zip/FileManager/OptionsDialog.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Panel.cpp856
-rwxr-xr-xCPP/7zip/FileManager/Panel.h510
-rwxr-xr-xCPP/7zip/FileManager/PanelCopy.cpp208
-rwxr-xr-xCPP/7zip/FileManager/PanelCrc.cpp (renamed from 7zip/FileManager/PanelCrc.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/PanelDrag.cpp796
-rwxr-xr-xCPP/7zip/FileManager/PanelFolderChange.cpp414
-rwxr-xr-xCPP/7zip/FileManager/PanelItemOpen.cpp546
-rwxr-xr-xCPP/7zip/FileManager/PanelItems.cpp822
-rwxr-xr-xCPP/7zip/FileManager/PanelKey.cpp (renamed from 7zip/FileManager/PanelKey.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/PanelListNotify.cpp (renamed from 7zip/FileManager/PanelListNotify.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/PanelMenu.cpp (renamed from 7zip/FileManager/PanelMenu.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/PanelOperations.cpp396
-rwxr-xr-xCPP/7zip/FileManager/PanelSelect.cpp (renamed from 7zip/FileManager/PanelSelect.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/PanelSort.cpp (renamed from 7zip/FileManager/PanelSort.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/PanelSplitFile.cpp477
-rwxr-xr-xCPP/7zip/FileManager/PhysDriveFolder.cpp (renamed from 7zip/FileManager/PhysDriveFolder.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/PhysDriveFolder.h (renamed from 7zip/FileManager/PhysDriveFolder.h)0
-rwxr-xr-xCPP/7zip/FileManager/PluginInterface.h (renamed from 7zip/FileManager/PluginInterface.h)0
-rwxr-xr-xCPP/7zip/FileManager/PluginLoader.h (renamed from 7zip/FileManager/PluginLoader.h)0
-rwxr-xr-xCPP/7zip/FileManager/ProgramLocation.cpp (renamed from 7zip/FileManager/ProgramLocation.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/ProgramLocation.h (renamed from 7zip/FileManager/ProgramLocation.h)0
-rwxr-xr-xCPP/7zip/FileManager/PropertyName.cpp (renamed from 7zip/FileManager/PropertyName.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/PropertyName.h (renamed from 7zip/FileManager/PropertyName.h)0
-rwxr-xr-xCPP/7zip/FileManager/RegistryAssociations.cpp (renamed from 7zip/FileManager/RegistryAssociations.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/RegistryAssociations.h (renamed from 7zip/FileManager/RegistryAssociations.h)0
-rwxr-xr-xCPP/7zip/FileManager/RegistryPlugins.cpp (renamed from 7zip/FileManager/RegistryPlugins.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/RegistryPlugins.h (renamed from 7zip/FileManager/RegistryPlugins.h)0
-rwxr-xr-xCPP/7zip/FileManager/RegistryUtils.cpp (renamed from 7zip/FileManager/RegistryUtils.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/RegistryUtils.h (renamed from 7zip/FileManager/RegistryUtils.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/AboutDialog/7zipLogo.ico (renamed from 7zip/FileManager/Resource/AboutDialog/7zipLogo.ico)bin9150 -> 9150 bytes
-rwxr-xr-xCPP/7zip/FileManager/Resource/AboutDialog/AboutDialog.cpp (renamed from 7zip/FileManager/Resource/AboutDialog/AboutDialog.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/AboutDialog/AboutDialog.h (renamed from 7zip/FileManager/Resource/AboutDialog/AboutDialog.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/AboutDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/AboutDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/AboutDialog/resource.h (renamed from 7zip/FileManager/Resource/AboutDialog/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/AboutDialog/resource.rc (renamed from 7zip/FileManager/Resource/AboutDialog/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp976
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h136
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/resource.h (renamed from 7zip/FileManager/Resource/BenchmarkDialog/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/resource.rc (renamed from 7zip/FileManager/Resource/BenchmarkDialog/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ComboDialog/ComboDialog.cpp (renamed from 7zip/FileManager/Resource/ComboDialog/ComboDialog.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ComboDialog/ComboDialog.h (renamed from 7zip/FileManager/Resource/ComboDialog/ComboDialog.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ComboDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/ComboDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ComboDialog/resource.h (renamed from 7zip/FileManager/Resource/ComboDialog/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ComboDialog/resource.rc (renamed from 7zip/FileManager/Resource/ComboDialog/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp81
-rwxr-xr-xCPP/7zip/FileManager/Resource/CopyDialog/CopyDialog.h (renamed from 7zip/FileManager/Resource/CopyDialog/CopyDialog.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/CopyDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/CopyDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/CopyDialog/resource.h7
-rwxr-xr-xCPP/7zip/FileManager/Resource/CopyDialog/resource.rc28
-rwxr-xr-xCPP/7zip/FileManager/Resource/EditPage/EditPage.cpp (renamed from 7zip/FileManager/Resource/EditPage/EditPage.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/EditPage/EditPage.h (renamed from 7zip/FileManager/Resource/EditPage/EditPage.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/EditPage/StdAfx.h (renamed from 7zip/FileManager/Resource/EditPage/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/EditPage/resource.h (renamed from 7zip/FileManager/Resource/EditPage/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/EditPage/resource.rc (renamed from 7zip/FileManager/Resource/EditPage/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/LangPage/LangPage.cpp (renamed from 7zip/FileManager/Resource/LangPage/LangPage.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/LangPage/LangPage.h (renamed from 7zip/FileManager/Resource/LangPage/LangPage.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/LangPage/StdAfx.h (renamed from 7zip/FileManager/Resource/LangPage/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/LangPage/resource.h (renamed from 7zip/FileManager/Resource/LangPage/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/LangPage/resource.rc (renamed from 7zip/FileManager/Resource/LangPage/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ListBoxDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/ListBoxDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ListBoxDialog/resource.h (renamed from 7zip/FileManager/Resource/ListBoxDialog/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ListBoxDialog/resource.rc (renamed from 7zip/FileManager/Resource/ListBoxDialog/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp (renamed from 7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h (renamed from 7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ListViewDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/ListViewDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ListViewDialog/resource.h (renamed from 7zip/FileManager/Resource/ListViewDialog/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ListViewDialog/resource.rc (renamed from 7zip/FileManager/Resource/ListViewDialog/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp100
-rwxr-xr-xCPP/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h22
-rwxr-xr-xCPP/7zip/FileManager/Resource/MessagesDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/MessagesDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/MessagesDialog/resource.h (renamed from 7zip/FileManager/Resource/MessagesDialog/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/MessagesDialog/resource.rc25
-rwxr-xr-xCPP/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp124
-rwxr-xr-xCPP/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h34
-rwxr-xr-xCPP/7zip/FileManager/Resource/OverwriteDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/OverwriteDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/OverwriteDialog/resource.h (renamed from 7zip/FileManager/Resource/OverwriteDialog/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/OverwriteDialog/resource.rc (renamed from 7zip/FileManager/Resource/OverwriteDialog/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp (renamed from 7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h (renamed from 7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PasswordDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/PasswordDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PasswordDialog/resource.h (renamed from 7zip/FileManager/Resource/PasswordDialog/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PasswordDialog/resource.rc (renamed from 7zip/FileManager/Resource/PasswordDialog/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp (renamed from 7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PluginsPage/PluginsPage.h (renamed from 7zip/FileManager/Resource/PluginsPage/PluginsPage.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PluginsPage/StdAfx.h (renamed from 7zip/FileManager/Resource/PluginsPage/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PluginsPage/resource.h (renamed from 7zip/FileManager/Resource/PluginsPage/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PluginsPage/resource.rc (renamed from 7zip/FileManager/Resource/PluginsPage/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp175
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h129
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog/StdAfx.h (renamed from 7zip/FileManager/Resource/ProgressDialog/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog/resource.h (renamed from 7zip/FileManager/Resource/ProgressDialog/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog/resource.rc (renamed from 7zip/FileManager/Resource/ProgressDialog/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp432
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h184
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog2/StdAfx.h (renamed from 7zip/FileManager/Resource/ProgressDialog2/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog2/resource.h (renamed from 7zip/FileManager/Resource/ProgressDialog2/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog2/resource.rc56
-rwxr-xr-xCPP/7zip/FileManager/Resource/PropertyName/resource.h (renamed from 7zip/FileManager/Resource/PropertyName/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/PropertyName/resource.rc (renamed from 7zip/FileManager/Resource/PropertyName/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp (renamed from 7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SettingsPage/SettingsPage.h (renamed from 7zip/FileManager/Resource/SettingsPage/SettingsPage.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SettingsPage/StdAfx.h (renamed from 7zip/FileManager/Resource/SettingsPage/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SettingsPage/resource.h (renamed from 7zip/FileManager/Resource/SettingsPage/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SettingsPage/resource.rc (renamed from 7zip/FileManager/Resource/SettingsPage/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp89
-rwxr-xr-xCPP/7zip/FileManager/Resource/SplitDialog/SplitDialog.h (renamed from 7zip/FileManager/Resource/SplitDialog/SplitDialog.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SplitDialog/StdAfx.h18
-rwxr-xr-xCPP/7zip/FileManager/Resource/SplitDialog/resource.h8
-rwxr-xr-xCPP/7zip/FileManager/Resource/SplitDialog/resource.rc32
-rwxr-xr-xCPP/7zip/FileManager/Resource/SystemPage/StdAfx.h (renamed from 7zip/FileManager/Resource/SystemPage/StdAfx.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SystemPage/SystemPage.cpp (renamed from 7zip/FileManager/Resource/SystemPage/SystemPage.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SystemPage/SystemPage.h (renamed from 7zip/FileManager/Resource/SystemPage/SystemPage.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SystemPage/resource.h (renamed from 7zip/FileManager/Resource/SystemPage/resource.h)0
-rwxr-xr-xCPP/7zip/FileManager/Resource/SystemPage/resource.rc (renamed from 7zip/FileManager/Resource/SystemPage/resource.rc)0
-rwxr-xr-xCPP/7zip/FileManager/RootFolder.cpp (renamed from 7zip/FileManager/RootFolder.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/RootFolder.h (renamed from 7zip/FileManager/RootFolder.h)0
-rwxr-xr-xCPP/7zip/FileManager/SplitUtils.cpp85
-rwxr-xr-xCPP/7zip/FileManager/SplitUtils.h15
-rwxr-xr-xCPP/7zip/FileManager/StdAfx.cpp (renamed from 7zip/UI/Console/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/StdAfx.h23
-rwxr-xr-xCPP/7zip/FileManager/StringUtils.cpp (renamed from 7zip/FileManager/StringUtils.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/StringUtils.h (renamed from 7zip/FileManager/StringUtils.h)0
-rwxr-xr-xCPP/7zip/FileManager/SysIconUtils.cpp (renamed from 7zip/FileManager/SysIconUtils.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/SysIconUtils.h (renamed from 7zip/FileManager/SysIconUtils.h)0
-rwxr-xr-xCPP/7zip/FileManager/Test.bmp (renamed from 7zip/FileManager/Test.bmp)bin982 -> 982 bytes
-rwxr-xr-xCPP/7zip/FileManager/Test2.bmp (renamed from 7zip/FileManager/Test2.bmp)bin406 -> 406 bytes
-rwxr-xr-xCPP/7zip/FileManager/TextPairs.cpp (renamed from 7zip/FileManager/TextPairs.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/TextPairs.h (renamed from 7zip/FileManager/TextPairs.h)0
-rwxr-xr-xCPP/7zip/FileManager/UpdateCallback100.cpp (renamed from 7zip/FileManager/UpdateCallback100.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/UpdateCallback100.h (renamed from 7zip/FileManager/UpdateCallback100.h)0
-rwxr-xr-xCPP/7zip/FileManager/ViewSettings.cpp (renamed from 7zip/FileManager/ViewSettings.cpp)0
-rwxr-xr-xCPP/7zip/FileManager/ViewSettings.h (renamed from 7zip/FileManager/ViewSettings.h)0
-rwxr-xr-xCPP/7zip/FileManager/makefile187
-rwxr-xr-xCPP/7zip/FileManager/resource.h154
-rwxr-xr-xCPP/7zip/FileManager/resource.rc232
-rwxr-xr-xCPP/7zip/GuiCommon.rc (renamed from 7zip/GuiCommon.rc)0
-rwxr-xr-xCPP/7zip/Guid.txt (renamed from 7zip/Guid.txt)0
-rwxr-xr-xCPP/7zip/ICoder.h (renamed from 7zip/ICoder.h)0
-rwxr-xr-xCPP/7zip/IPassword.h (renamed from 7zip/IPassword.h)0
-rwxr-xr-xCPP/7zip/IProgress.h (renamed from 7zip/IProgress.h)0
-rwxr-xr-xCPP/7zip/IStream.h (renamed from 7zip/IStream.h)0
-rwxr-xr-xCPP/7zip/MyVersion.h8
-rwxr-xr-xCPP/7zip/MyVersionInfo.rc (renamed from 7zip/MyVersionInfo.rc)0
-rwxr-xr-xCPP/7zip/PropID.h (renamed from 7zip/PropID.h)0
-rwxr-xr-xCPP/7zip/SubBuild.mak (renamed from 7zip/SubBuild.mak)0
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.cpp578
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.h (renamed from 7zip/UI/Agent/Agent.h)0
-rwxr-xr-xCPP/7zip/UI/Agent/AgentOut.cpp (renamed from 7zip/UI/Agent/AgentOut.cpp)0
-rwxr-xr-xCPP/7zip/UI/Agent/AgentProxy.cpp203
-rwxr-xr-xCPP/7zip/UI/Agent/AgentProxy.h (renamed from 7zip/UI/Agent/AgentProxy.h)0
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolder.cpp (renamed from 7zip/UI/Agent/ArchiveFolder.cpp)0
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOpen.cpp (renamed from 7zip/UI/Agent/ArchiveFolderOpen.cpp)0
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOut.cpp (renamed from 7zip/UI/Agent/ArchiveFolderOut.cpp)0
-rwxr-xr-xCPP/7zip/UI/Agent/IFolderArchive.h (renamed from 7zip/UI/Agent/IFolderArchive.h)0
-rwxr-xr-xCPP/7zip/UI/Agent/UpdateCallbackAgent.cpp (renamed from 7zip/UI/Agent/UpdateCallbackAgent.cpp)0
-rwxr-xr-xCPP/7zip/UI/Agent/UpdateCallbackAgent.h (renamed from 7zip/UI/Agent/UpdateCallbackAgent.h)0
-rwxr-xr-xCPP/7zip/UI/Client7z/Client7z.cpp (renamed from 7zip/UI/Client7z/Client7z.cpp)0
-rwxr-xr-xCPP/7zip/UI/Client7z/Client7z.dsp (renamed from 7zip/UI/Client7z/Client7z.dsp)0
-rwxr-xr-xCPP/7zip/UI/Client7z/Client7z.dsw (renamed from 7zip/UI/Client7z/Client7z.dsw)0
-rwxr-xr-xCPP/7zip/UI/Client7z/StdAfx.cpp (renamed from 7zip/UI/Far/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/UI/Client7z/StdAfx.h (renamed from 7zip/UI/Client7z/StdAfx.h)0
-rwxr-xr-xCPP/7zip/UI/Client7z/makefile (renamed from 7zip/UI/Client7z/makefile)0
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveCommandLine.cpp985
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveCommandLine.h (renamed from 7zip/UI/Common/ArchiveCommandLine.h)0
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveExtractCallback.cpp448
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveExtractCallback.h (renamed from 7zip/UI/Common/ArchiveExtractCallback.h)0
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveName.cpp (renamed from 7zip/UI/Common/ArchiveName.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveName.h (renamed from 7zip/UI/Common/ArchiveName.h)0
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveOpenCallback.cpp (renamed from 7zip/UI/Common/ArchiveOpenCallback.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveOpenCallback.h89
-rwxr-xr-xCPP/7zip/UI/Common/ArchiverInfo.cpp372
-rwxr-xr-xCPP/7zip/UI/Common/ArchiverInfo.h (renamed from 7zip/UI/Common/ArchiverInfo.h)0
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall.cpp (renamed from 7zip/UI/Common/CompressCall.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall.h (renamed from 7zip/UI/Common/CompressCall.h)0
-rwxr-xr-xCPP/7zip/UI/Common/DefaultName.cpp26
-rwxr-xr-xCPP/7zip/UI/Common/DefaultName.h (renamed from 7zip/UI/Common/DefaultName.h)0
-rwxr-xr-xCPP/7zip/UI/Common/DirItem.h (renamed from 7zip/UI/Common/DirItem.h)0
-rwxr-xr-xCPP/7zip/UI/Common/EnumDirItems.cpp (renamed from 7zip/UI/Common/EnumDirItems.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/EnumDirItems.h (renamed from 7zip/UI/Common/EnumDirItems.h)0
-rwxr-xr-xCPP/7zip/UI/Common/ExitCode.h (renamed from 7zip/UI/Common/ExitCode.h)0
-rwxr-xr-xCPP/7zip/UI/Common/Extract.cpp152
-rwxr-xr-xCPP/7zip/UI/Common/Extract.h (renamed from 7zip/UI/Common/Extract.h)0
-rwxr-xr-xCPP/7zip/UI/Common/ExtractMode.h (renamed from 7zip/UI/Common/ExtractMode.h)0
-rwxr-xr-xCPP/7zip/UI/Common/ExtractingFilePath.cpp (renamed from 7zip/UI/Common/ExtractingFilePath.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/ExtractingFilePath.h (renamed from 7zip/UI/Common/ExtractingFilePath.h)0
-rwxr-xr-xCPP/7zip/UI/Common/HandlerLoader.h (renamed from 7zip/UI/Common/HandlerLoader.h)0
-rwxr-xr-xCPP/7zip/UI/Common/IFileExtractCallback.h46
-rwxr-xr-xCPP/7zip/UI/Common/OpenArchive.cpp531
-rwxr-xr-xCPP/7zip/UI/Common/OpenArchive.h (renamed from 7zip/UI/Common/OpenArchive.h)0
-rwxr-xr-xCPP/7zip/UI/Common/PropIDUtils.cpp (renamed from 7zip/UI/Common/PropIDUtils.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/PropIDUtils.h (renamed from 7zip/UI/Common/PropIDUtils.h)0
-rwxr-xr-xCPP/7zip/UI/Common/Property.h (renamed from 7zip/UI/Common/Property.h)0
-rwxr-xr-xCPP/7zip/UI/Common/SetProperties.cpp (renamed from 7zip/UI/Common/SetProperties.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/SetProperties.h (renamed from 7zip/UI/Common/SetProperties.h)0
-rwxr-xr-xCPP/7zip/UI/Common/SortUtils.cpp78
-rwxr-xr-xCPP/7zip/UI/Common/SortUtils.h (renamed from 7zip/UI/Common/SortUtils.h)0
-rwxr-xr-xCPP/7zip/UI/Common/StdAfx.h (renamed from 7zip/UI/Common/StdAfx.h)0
-rwxr-xr-xCPP/7zip/UI/Common/TempFiles.cpp (renamed from 7zip/UI/Common/TempFiles.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/TempFiles.h (renamed from 7zip/UI/Common/TempFiles.h)0
-rwxr-xr-xCPP/7zip/UI/Common/Update.cpp (renamed from 7zip/UI/Common/Update.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/Update.h (renamed from 7zip/UI/Common/Update.h)0
-rwxr-xr-xCPP/7zip/UI/Common/UpdateAction.cpp (renamed from 7zip/UI/Common/UpdateAction.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/UpdateAction.h (renamed from 7zip/UI/Common/UpdateAction.h)0
-rwxr-xr-xCPP/7zip/UI/Common/UpdateCallback.cpp (renamed from 7zip/UI/Common/UpdateCallback.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/UpdateCallback.h (renamed from 7zip/UI/Common/UpdateCallback.h)0
-rwxr-xr-xCPP/7zip/UI/Common/UpdatePair.cpp (renamed from 7zip/UI/Common/UpdatePair.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/UpdatePair.h (renamed from 7zip/UI/Common/UpdatePair.h)0
-rwxr-xr-xCPP/7zip/UI/Common/UpdateProduce.cpp (renamed from 7zip/UI/Common/UpdateProduce.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/UpdateProduce.h (renamed from 7zip/UI/Common/UpdateProduce.h)0
-rwxr-xr-xCPP/7zip/UI/Common/WorkDir.cpp (renamed from 7zip/UI/Common/WorkDir.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/WorkDir.h (renamed from 7zip/UI/Common/WorkDir.h)0
-rwxr-xr-xCPP/7zip/UI/Common/ZipRegistry.cpp (renamed from 7zip/UI/Common/ZipRegistry.cpp)0
-rwxr-xr-xCPP/7zip/UI/Common/ZipRegistry.h (renamed from 7zip/UI/Common/ZipRegistry.h)0
-rwxr-xr-xCPP/7zip/UI/Console/Console.dsp (renamed from 7zip/UI/Console/Console.dsp)0
-rwxr-xr-xCPP/7zip/UI/Console/Console.dsw (renamed from 7zip/UI/Console/Console.dsw)0
-rwxr-xr-xCPP/7zip/UI/Console/ConsoleClose.cpp (renamed from 7zip/UI/Console/ConsoleClose.cpp)0
-rwxr-xr-xCPP/7zip/UI/Console/ConsoleClose.h (renamed from 7zip/UI/Console/ConsoleClose.h)0
-rwxr-xr-xCPP/7zip/UI/Console/ExtractCallbackConsole.cpp235
-rwxr-xr-xCPP/7zip/UI/Console/ExtractCallbackConsole.h65
-rwxr-xr-xCPP/7zip/UI/Console/List.cpp (renamed from 7zip/UI/Console/List.cpp)0
-rwxr-xr-xCPP/7zip/UI/Console/List.h (renamed from 7zip/UI/Console/List.h)0
-rwxr-xr-xCPP/7zip/UI/Console/Main.cpp382
-rwxr-xr-xCPP/7zip/UI/Console/MainAr.cpp169
-rwxr-xr-xCPP/7zip/UI/Console/OpenCallbackConsole.cpp58
-rwxr-xr-xCPP/7zip/UI/Console/OpenCallbackConsole.h27
-rwxr-xr-xCPP/7zip/UI/Console/PercentPrinter.cpp90
-rwxr-xr-xCPP/7zip/UI/Console/PercentPrinter.h31
-rwxr-xr-xCPP/7zip/UI/Console/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/UI/Console/StdAfx.h (renamed from 7zip/UI/Console/StdAfx.h)0
-rwxr-xr-xCPP/7zip/UI/Console/UpdateCallbackConsole.cpp196
-rwxr-xr-xCPP/7zip/UI/Console/UpdateCallbackConsole.h75
-rwxr-xr-xCPP/7zip/UI/Console/UserInputUtils.cpp (renamed from 7zip/UI/Console/UserInputUtils.cpp)0
-rwxr-xr-xCPP/7zip/UI/Console/UserInputUtils.h (renamed from 7zip/UI/Console/UserInputUtils.h)0
-rwxr-xr-xCPP/7zip/UI/Console/afxres.h (renamed from 7zip/UI/Console/afxres.h)0
-rwxr-xr-xCPP/7zip/UI/Console/makefile93
-rwxr-xr-xCPP/7zip/UI/Console/resource.rc (renamed from 7zip/UI/Console/resource.rc)0
-rwxr-xr-xCPP/7zip/UI/Explorer/7-zip.dll.manifest (renamed from 7zip/UI/Explorer/7-zip.dll.manifest)0
-rwxr-xr-xCPP/7zip/UI/Explorer/ContextMenu.cpp (renamed from 7zip/UI/Explorer/ContextMenu.cpp)0
-rwxr-xr-xCPP/7zip/UI/Explorer/ContextMenu.h (renamed from 7zip/UI/Explorer/ContextMenu.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/ContextMenuFlags.h (renamed from 7zip/UI/Explorer/ContextMenuFlags.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/DllExports.cpp (renamed from 7zip/UI/Explorer/DllExports.cpp)0
-rwxr-xr-xCPP/7zip/UI/Explorer/Explorer.def (renamed from 7zip/UI/Explorer/Explorer.def)0
-rwxr-xr-xCPP/7zip/UI/Explorer/Explorer.dsp818
-rwxr-xr-xCPP/7zip/UI/Explorer/Explorer.dsw (renamed from 7zip/UI/Explorer/Explorer.dsw)0
-rwxr-xr-xCPP/7zip/UI/Explorer/FoldersPage/FoldersPage.cpp (renamed from 7zip/UI/Explorer/FoldersPage/FoldersPage.cpp)0
-rwxr-xr-xCPP/7zip/UI/Explorer/FoldersPage/FoldersPage.h (renamed from 7zip/UI/Explorer/FoldersPage/FoldersPage.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/FoldersPage/resource.h (renamed from 7zip/UI/Explorer/FoldersPage/resource.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/FoldersPage/resource.rc (renamed from 7zip/UI/Explorer/FoldersPage/resource.rc)0
-rwxr-xr-xCPP/7zip/UI/Explorer/MyMessages.cpp (renamed from 7zip/UI/Explorer/MyMessages.cpp)0
-rwxr-xr-xCPP/7zip/UI/Explorer/MyMessages.h (renamed from 7zip/UI/Explorer/MyMessages.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/OptionsDialog.cpp (renamed from 7zip/UI/Explorer/OptionsDialog.cpp)0
-rwxr-xr-xCPP/7zip/UI/Explorer/OptionsDialog.h (renamed from 7zip/UI/Explorer/OptionsDialog.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/RegistryContextMenu.cpp (renamed from 7zip/UI/Explorer/RegistryContextMenu.cpp)0
-rwxr-xr-xCPP/7zip/UI/Explorer/RegistryContextMenu.h (renamed from 7zip/UI/Explorer/RegistryContextMenu.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/StdAfx.cpp (renamed from 7zip/UI/Explorer/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/UI/Explorer/StdAfx.h (renamed from 7zip/UI/Explorer/StdAfx.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/SystemPage/SystemPage.cpp (renamed from 7zip/UI/Explorer/SystemPage/SystemPage.cpp)0
-rwxr-xr-xCPP/7zip/UI/Explorer/SystemPage/SystemPage.h (renamed from 7zip/UI/Explorer/SystemPage/SystemPage.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/SystemPage/resource.h (renamed from 7zip/UI/Explorer/SystemPage/resource.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/SystemPage/resource.rc (renamed from 7zip/UI/Explorer/SystemPage/resource.rc)0
-rwxr-xr-xCPP/7zip/UI/Explorer/makefile137
-rwxr-xr-xCPP/7zip/UI/Explorer/resource.h (renamed from 7zip/UI/Explorer/resource.h)0
-rwxr-xr-xCPP/7zip/UI/Explorer/resource.rc (renamed from 7zip/UI/Explorer/resource.rc)0
-rwxr-xr-xCPP/7zip/UI/Far/CLSIDConst.cpp (renamed from 7zip/UI/Far/CLSIDConst.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/ExtractEngine.cpp (renamed from 7zip/UI/Far/ExtractEngine.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/ExtractEngine.h (renamed from 7zip/UI/Far/ExtractEngine.h)0
-rwxr-xr-xCPP/7zip/UI/Far/Far.def (renamed from 7zip/UI/Far/Far.def)0
-rwxr-xr-xCPP/7zip/UI/Far/Far.dsp (renamed from 7zip/UI/Far/Far.dsp)0
-rwxr-xr-xCPP/7zip/UI/Far/Far.dsw (renamed from 7zip/UI/Far/Far.dsw)0
-rwxr-xr-xCPP/7zip/UI/Far/FarPlugin.h (renamed from 7zip/UI/Far/FarPlugin.h)0
-rwxr-xr-xCPP/7zip/UI/Far/FarUtils.cpp (renamed from 7zip/UI/Far/FarUtils.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/FarUtils.h (renamed from 7zip/UI/Far/FarUtils.h)0
-rwxr-xr-xCPP/7zip/UI/Far/Main.cpp (renamed from 7zip/UI/Far/Main.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/Messages.h (renamed from 7zip/UI/Far/Messages.h)0
-rwxr-xr-xCPP/7zip/UI/Far/OverwriteDialog.cpp (renamed from 7zip/UI/Far/OverwriteDialog.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/OverwriteDialog.h (renamed from 7zip/UI/Far/OverwriteDialog.h)0
-rwxr-xr-xCPP/7zip/UI/Far/Plugin.cpp (renamed from 7zip/UI/Far/Plugin.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/Plugin.h (renamed from 7zip/UI/Far/Plugin.h)0
-rwxr-xr-xCPP/7zip/UI/Far/PluginCommon.cpp (renamed from 7zip/UI/Far/PluginCommon.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/PluginDelete.cpp (renamed from 7zip/UI/Far/PluginDelete.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/PluginRead.cpp (renamed from 7zip/UI/Far/PluginRead.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/PluginWrite.cpp (renamed from 7zip/UI/Far/PluginWrite.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/ProgressBox.cpp (renamed from 7zip/UI/Far/ProgressBox.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/ProgressBox.h (renamed from 7zip/UI/Far/ProgressBox.h)0
-rwxr-xr-xCPP/7zip/UI/Far/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/UI/Far/StdAfx.h (renamed from 7zip/UI/Far/StdAfx.h)0
-rwxr-xr-xCPP/7zip/UI/Far/UpdateCallback100.cpp (renamed from 7zip/UI/Far/UpdateCallback100.cpp)0
-rwxr-xr-xCPP/7zip/UI/Far/UpdateCallback100.h (renamed from 7zip/UI/Far/UpdateCallback100.h)0
-rwxr-xr-xCPP/7zip/UI/Far/makefile102
-rwxr-xr-xCPP/7zip/UI/Far/resource.rc (renamed from 7zip/UI/Far/resource.rc)0
-rwxr-xr-xCPP/7zip/UI/GUI/7zG.exe.manifest (renamed from 7zip/UI/GUI/7zG.exe.manifest)0
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.cpp1373
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.h171
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractDialog.cpp (renamed from 7zip/UI/GUI/ExtractDialog.cpp)0
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractDialog.h77
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractGUI.cpp (renamed from 7zip/UI/GUI/ExtractGUI.cpp)0
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractGUI.h (renamed from 7zip/UI/GUI/ExtractGUI.h)0
-rwxr-xr-xCPP/7zip/UI/GUI/FM.ico (renamed from 7zip/UI/GUI/FM.ico)bin4846 -> 4846 bytes
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.cpp (renamed from 7zip/UI/GUI/GUI.cpp)0
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.dsp904
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.dsw (renamed from 7zip/UI/GUI/GUI.dsw)0
-rwxr-xr-xCPP/7zip/UI/GUI/OpenCallbackGUI.cpp65
-rwxr-xr-xCPP/7zip/UI/GUI/OpenCallbackGUI.h35
-rwxr-xr-xCPP/7zip/UI/GUI/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/UI/GUI/StdAfx.h (renamed from 7zip/UI/GUI/StdAfx.h)0
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateCallbackGUI.cpp (renamed from 7zip/UI/GUI/UpdateCallbackGUI.cpp)0
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateCallbackGUI.h (renamed from 7zip/UI/GUI/UpdateCallbackGUI.h)0
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateGUI.cpp (renamed from 7zip/UI/GUI/UpdateGUI.cpp)0
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateGUI.h (renamed from 7zip/UI/GUI/UpdateGUI.h)0
-rwxr-xr-xCPP/7zip/UI/GUI/makefile135
-rwxr-xr-xCPP/7zip/UI/GUI/resource.h45
-rwxr-xr-xCPP/7zip/UI/GUI/resource.rc57
-rwxr-xr-xCPP/7zip/UI/Resource/CompressDialog/resource.h (renamed from 7zip/UI/Resource/CompressDialog/resource.h)0
-rwxr-xr-xCPP/7zip/UI/Resource/CompressDialog/resource.rc (renamed from 7zip/UI/Resource/CompressDialog/resource.rc)0
-rwxr-xr-xCPP/7zip/UI/Resource/Extract/resource.h15
-rwxr-xr-xCPP/7zip/UI/Resource/Extract/resource.rc19
-rwxr-xr-xCPP/7zip/UI/Resource/ExtractDialog/resource.h (renamed from 7zip/UI/Resource/ExtractDialog/resource.h)0
-rwxr-xr-xCPP/7zip/UI/Resource/ExtractDialog/resource.rc80
-rwxr-xr-xCPP/7zip/UI/makefile (renamed from 7zip/UI/makefile)0
-rwxr-xr-xCPP/7zip/makefile (renamed from 7zip/makefile)0
-rwxr-xr-xCPP/Build.mak (renamed from Build.mak)0
-rwxr-xr-xCPP/Common/AlignedBuffer.cpp (renamed from Common/AlignedBuffer.cpp)0
-rwxr-xr-xCPP/Common/AlignedBuffer.h (renamed from Common/AlignedBuffer.h)0
-rwxr-xr-xCPP/Common/Alloc.cpp (renamed from Common/Alloc.cpp)0
-rwxr-xr-xCPP/Common/Alloc.h (renamed from Common/Alloc.h)0
-rwxr-xr-xCPP/Common/AutoPtr.h35
-rwxr-xr-xCPP/Common/Buffer.h77
-rwxr-xr-xCPP/Common/CRC.cpp (renamed from Common/CRC.cpp)0
-rwxr-xr-xCPP/Common/CRC.h36
-rwxr-xr-xCPP/Common/C_FileIO.cpp (renamed from Common/C_FileIO.cpp)0
-rwxr-xr-xCPP/Common/C_FileIO.h (renamed from Common/C_FileIO.h)0
-rwxr-xr-xCPP/Common/ComTry.h (renamed from Common/ComTry.h)0
-rwxr-xr-xCPP/Common/CommandLineParser.cpp (renamed from Common/CommandLineParser.cpp)0
-rwxr-xr-xCPP/Common/CommandLineParser.h (renamed from Common/CommandLineParser.h)0
-rwxr-xr-xCPP/Common/Defs.h (renamed from Common/Defs.h)0
-rwxr-xr-xCPP/Common/DynamicBuffer.h (renamed from Common/DynamicBuffer.h)0
-rwxr-xr-xCPP/Common/Exception.h (renamed from Common/Exception.h)0
-rwxr-xr-xCPP/Common/IntToString.cpp (renamed from Common/IntToString.cpp)0
-rwxr-xr-xCPP/Common/IntToString.h (renamed from Common/IntToString.h)0
-rwxr-xr-xCPP/Common/Lang.cpp142
-rwxr-xr-xCPP/Common/Lang.h (renamed from Common/Lang.h)0
-rwxr-xr-xCPP/Common/ListFileUtils.cpp (renamed from Common/ListFileUtils.cpp)0
-rwxr-xr-xCPP/Common/ListFileUtils.h (renamed from Common/ListFileUtils.h)0
-rwxr-xr-xCPP/Common/MyCom.h (renamed from Common/MyCom.h)0
-rwxr-xr-xCPP/Common/MyGuidDef.h (renamed from Common/MyGuidDef.h)0
-rwxr-xr-xCPP/Common/MyInitGuid.h (renamed from Common/MyInitGuid.h)0
-rwxr-xr-xCPP/Common/MyUnknown.h (renamed from Common/MyUnknown.h)0
-rwxr-xr-xCPP/Common/MyWindows.cpp (renamed from Common/MyWindows.cpp)0
-rwxr-xr-xCPP/Common/MyWindows.h203
-rwxr-xr-xCPP/Common/NewHandler.cpp (renamed from Common/NewHandler.cpp)0
-rwxr-xr-xCPP/Common/NewHandler.h (renamed from Common/NewHandler.h)0
-rwxr-xr-xCPP/Common/Random.cpp (renamed from Common/Random.cpp)0
-rwxr-xr-xCPP/Common/Random.h (renamed from Common/Random.h)0
-rwxr-xr-xCPP/Common/StdAfx.h (renamed from Common/StdAfx.h)0
-rwxr-xr-xCPP/Common/StdInStream.cpp (renamed from Common/StdInStream.cpp)0
-rwxr-xr-xCPP/Common/StdInStream.h (renamed from Common/StdInStream.h)0
-rwxr-xr-xCPP/Common/StdOutStream.cpp (renamed from Common/StdOutStream.cpp)0
-rwxr-xr-xCPP/Common/StdOutStream.h (renamed from Common/StdOutStream.h)0
-rwxr-xr-xCPP/Common/String.cpp (renamed from Common/String.cpp)0
-rwxr-xr-xCPP/Common/String.h631
-rwxr-xr-xCPP/Common/StringConvert.cpp94
-rwxr-xr-xCPP/Common/StringConvert.h (renamed from Common/StringConvert.h)0
-rwxr-xr-xCPP/Common/StringToInt.cpp (renamed from Common/StringToInt.cpp)0
-rwxr-xr-xCPP/Common/StringToInt.h (renamed from Common/StringToInt.h)0
-rwxr-xr-xCPP/Common/TextConfig.cpp (renamed from Common/TextConfig.cpp)0
-rwxr-xr-xCPP/Common/TextConfig.h (renamed from Common/TextConfig.h)0
-rwxr-xr-xCPP/Common/Types.h (renamed from Common/Types.h)0
-rwxr-xr-xCPP/Common/UTFConvert.cpp (renamed from Common/UTFConvert.cpp)0
-rwxr-xr-xCPP/Common/UTFConvert.h (renamed from Common/UTFConvert.h)0
-rwxr-xr-xCPP/Common/Vector.cpp (renamed from Common/Vector.cpp)0
-rwxr-xr-xCPP/Common/Vector.h237
-rwxr-xr-xCPP/Common/Wildcard.cpp (renamed from Common/Wildcard.cpp)0
-rwxr-xr-xCPP/Common/Wildcard.h (renamed from Common/Wildcard.h)0
-rwxr-xr-xCPP/Windows/COM.cpp (renamed from Windows/COM.cpp)0
-rwxr-xr-xCPP/Windows/COM.h (renamed from Windows/COM.h)0
-rwxr-xr-xCPP/Windows/CommonDialog.cpp (renamed from Windows/CommonDialog.cpp)0
-rwxr-xr-xCPP/Windows/CommonDialog.h (renamed from Windows/CommonDialog.h)0
-rwxr-xr-xCPP/Windows/Console.cpp (renamed from Windows/Console.cpp)0
-rwxr-xr-xCPP/Windows/Console.h (renamed from Windows/Console.h)0
-rwxr-xr-xCPP/Windows/Control/ComboBox.cpp (renamed from Windows/Control/ComboBox.cpp)0
-rwxr-xr-xCPP/Windows/Control/ComboBox.h (renamed from Windows/Control/ComboBox.h)0
-rwxr-xr-xCPP/Windows/Control/Dialog.cpp (renamed from Windows/Control/Dialog.cpp)0
-rwxr-xr-xCPP/Windows/Control/Dialog.h (renamed from Windows/Control/Dialog.h)0
-rwxr-xr-xCPP/Windows/Control/Edit.h (renamed from Windows/Control/Edit.h)0
-rwxr-xr-xCPP/Windows/Control/ImageList.cpp (renamed from Windows/Control/ImageList.cpp)0
-rwxr-xr-xCPP/Windows/Control/ImageList.h (renamed from Windows/Control/ImageList.h)0
-rwxr-xr-xCPP/Windows/Control/ListView.cpp (renamed from Windows/Control/ListView.cpp)0
-rwxr-xr-xCPP/Windows/Control/ListView.h138
-rwxr-xr-xCPP/Windows/Control/ProgressBar.h (renamed from Windows/Control/ProgressBar.h)0
-rwxr-xr-xCPP/Windows/Control/PropertyPage.cpp (renamed from Windows/Control/PropertyPage.cpp)0
-rwxr-xr-xCPP/Windows/Control/PropertyPage.h (renamed from Windows/Control/PropertyPage.h)0
-rwxr-xr-xCPP/Windows/Control/ReBar.h (renamed from Windows/Control/ReBar.h)0
-rwxr-xr-xCPP/Windows/Control/Static.h (renamed from Windows/Control/Static.h)0
-rwxr-xr-xCPP/Windows/Control/StatusBar.h (renamed from Windows/Control/StatusBar.h)0
-rwxr-xr-xCPP/Windows/Control/StdAfx.h (renamed from Windows/Control/StdAfx.h)0
-rwxr-xr-xCPP/Windows/Control/ToolBar.h (renamed from Windows/Control/ToolBar.h)0
-rwxr-xr-xCPP/Windows/Control/Trackbar.h (renamed from Windows/Control/Trackbar.h)0
-rwxr-xr-xCPP/Windows/Control/Window2.cpp203
-rwxr-xr-xCPP/Windows/Control/Window2.h (renamed from Windows/Control/Window2.h)0
-rwxr-xr-xCPP/Windows/DLL.cpp (renamed from Windows/DLL.cpp)0
-rwxr-xr-xCPP/Windows/DLL.h (renamed from Windows/DLL.h)0
-rwxr-xr-xCPP/Windows/Defs.h (renamed from Windows/Defs.h)0
-rwxr-xr-xCPP/Windows/Error.cpp (renamed from Windows/Error.cpp)0
-rwxr-xr-xCPP/Windows/Error.h (renamed from Windows/Error.h)0
-rwxr-xr-xCPP/Windows/FileDevice.cpp (renamed from Windows/FileDevice.cpp)0
-rwxr-xr-xCPP/Windows/FileDevice.h (renamed from Windows/FileDevice.h)0
-rwxr-xr-xCPP/Windows/FileDir.cpp835
-rwxr-xr-xCPP/Windows/FileDir.h178
-rwxr-xr-xCPP/Windows/FileFind.cpp408
-rwxr-xr-xCPP/Windows/FileFind.h153
-rwxr-xr-xCPP/Windows/FileIO.cpp305
-rwxr-xr-xCPP/Windows/FileIO.h97
-rwxr-xr-xCPP/Windows/FileMapping.cpp (renamed from Windows/FileMapping.cpp)0
-rwxr-xr-xCPP/Windows/FileMapping.h (renamed from Windows/FileMapping.h)0
-rwxr-xr-xCPP/Windows/FileName.cpp (renamed from Windows/FileName.cpp)0
-rwxr-xr-xCPP/Windows/FileName.h (renamed from Windows/FileName.h)0
-rwxr-xr-xCPP/Windows/FileSystem.cpp (renamed from Windows/FileSystem.cpp)0
-rwxr-xr-xCPP/Windows/FileSystem.h (renamed from Windows/FileSystem.h)0
-rwxr-xr-xCPP/Windows/Handle.h (renamed from Windows/Handle.h)0
-rwxr-xr-xCPP/Windows/Memory.cpp (renamed from Windows/Memory.cpp)0
-rwxr-xr-xCPP/Windows/Memory.h (renamed from Windows/Memory.h)0
-rwxr-xr-xCPP/Windows/MemoryLock.cpp (renamed from Windows/MemoryLock.cpp)0
-rwxr-xr-xCPP/Windows/MemoryLock.h (renamed from Windows/MemoryLock.h)0
-rwxr-xr-xCPP/Windows/Menu.cpp (renamed from Windows/Menu.cpp)0
-rwxr-xr-xCPP/Windows/Menu.h (renamed from Windows/Menu.h)0
-rwxr-xr-xCPP/Windows/NationalTime.cpp (renamed from Windows/NationalTime.cpp)0
-rwxr-xr-xCPP/Windows/NationalTime.h (renamed from Windows/NationalTime.h)0
-rwxr-xr-xCPP/Windows/Net.cpp (renamed from Windows/Net.cpp)0
-rwxr-xr-xCPP/Windows/Net.h (renamed from Windows/Net.h)0
-rwxr-xr-xCPP/Windows/ProcessMessages.cpp (renamed from Windows/ProcessMessages.cpp)0
-rwxr-xr-xCPP/Windows/ProcessMessages.h (renamed from Windows/ProcessMessages.h)0
-rwxr-xr-xCPP/Windows/PropVariant.cpp312
-rwxr-xr-xCPP/Windows/PropVariant.h57
-rwxr-xr-xCPP/Windows/PropVariantConversions.cpp (renamed from Windows/PropVariantConversions.cpp)0
-rwxr-xr-xCPP/Windows/PropVariantConversions.h (renamed from Windows/PropVariantConversions.h)0
-rwxr-xr-xCPP/Windows/Registry.cpp (renamed from Windows/Registry.cpp)0
-rwxr-xr-xCPP/Windows/Registry.h (renamed from Windows/Registry.h)0
-rwxr-xr-xCPP/Windows/ResourceString.cpp (renamed from Windows/ResourceString.cpp)0
-rwxr-xr-xCPP/Windows/ResourceString.h (renamed from Windows/ResourceString.h)0
-rwxr-xr-xCPP/Windows/Security.cpp181
-rwxr-xr-xCPP/Windows/Security.h (renamed from Windows/Security.h)0
-rwxr-xr-xCPP/Windows/Shell.cpp (renamed from Windows/Shell.cpp)0
-rwxr-xr-xCPP/Windows/Shell.h (renamed from Windows/Shell.h)0
-rwxr-xr-xCPP/Windows/StdAfx.h (renamed from Windows/StdAfx.h)0
-rwxr-xr-xCPP/Windows/Synchronization.cpp (renamed from Windows/Synchronization.cpp)0
-rwxr-xr-xCPP/Windows/Synchronization.h (renamed from Windows/Synchronization.h)0
-rwxr-xr-xCPP/Windows/System.h (renamed from Windows/System.h)0
-rwxr-xr-xCPP/Windows/Thread.h51
-rwxr-xr-xCPP/Windows/Time.h (renamed from Windows/Time.h)0
-rwxr-xr-xCPP/Windows/Window.cpp (renamed from Windows/Window.cpp)0
-rwxr-xr-xCPP/Windows/Window.h (renamed from Windows/Window.h)0
-rwxr-xr-xCommon/AutoPtr.h35
-rwxr-xr-xCommon/Buffer.h77
-rwxr-xr-xCommon/CRC.h36
-rwxr-xr-xCommon/Lang.cpp144
-rwxr-xr-xCommon/MyWindows.h200
-rwxr-xr-xCommon/String.h631
-rwxr-xr-xCommon/StringConvert.cpp93
-rwxr-xr-xCommon/Vector.h229
-rwxr-xr-xDOC/7zip.nsi8
-rwxr-xr-xDOC/7zip.wxs7
-rwxr-xr-xDOC/License.txt79
-rwxr-xr-xDOC/lzma.txt74
-rwxr-xr-xDOC/readme.txt76
-rwxr-xr-xWindows/Control/ListView.h138
-rwxr-xr-xWindows/Control/Window2.cpp203
-rwxr-xr-xWindows/FileDir.cpp693
-rwxr-xr-xWindows/FileDir.h191
-rwxr-xr-xWindows/FileFind.cpp368
-rwxr-xr-xWindows/FileFind.h176
-rwxr-xr-xWindows/FileIO.cpp245
-rwxr-xr-xWindows/FileIO.h98
-rwxr-xr-xWindows/PropVariant.cpp310
-rwxr-xr-xWindows/PropVariant.h57
-rwxr-xr-xWindows/Security.cpp181
-rwxr-xr-xWindows/Thread.h52
1512 files changed, 57877 insertions, 61133 deletions
diff --git a/7zip/Archive/7z/7zEncode.h b/7zip/Archive/7z/7zEncode.h
deleted file mode 100755
index 04a8c37b..00000000
--- a/7zip/Archive/7z/7zEncode.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// 7zEncode.h
-
-#ifndef __7Z_ENCODE_H
-#define __7Z_ENCODE_H
-
-// #include "../../Common/StreamObjects.h"
-
-#include "7zCompressionMode.h"
-
-#include "../Common/CoderMixer2.h"
-#include "../Common/CoderMixer2MT.h"
-#include "../Common/CoderMixer2ST.h"
-#ifndef EXCLUDE_COM
-#include "../Common/CoderLoader.h"
-#endif
-#include "7zMethods.h"
-#include "7zItem.h"
-
-namespace NArchive {
-namespace N7z {
-
-class CEncoder
-{
- #ifndef EXCLUDE_COM
- // CMethodMap _methodMap;
- // it must be in top of objects
- CCoderLibraries _libraries;
- #endif
-
- NCoderMixer2::CCoderMixer2MT *_mixerCoderSpec;
- CMyComPtr<ICompressCoder2> _mixerCoder;
-
- CObjectVector<CCoderInfo> _codersInfo;
-
- CCompressionMethodMode _options;
- NCoderMixer2::CBindInfo _bindInfo;
- NCoderMixer2::CBindInfo _decompressBindInfo;
- NCoderMixer2::CBindReverseConverter *_bindReverseConverter;
- CRecordVector<CMethodID> _decompressionMethods;
-
- HRESULT CreateMixerCoder(const UInt64 *inSizeForReduce);
-
-public:
- CEncoder(const CCompressionMethodMode &options);
- ~CEncoder();
- HRESULT Encode(ISequentialInStream *inStream,
- const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
- CFolder &folderItem,
- ISequentialOutStream *outStream,
- CRecordVector<UInt64> &packSizes,
- ICompressProgressInfo *compressProgress);
-};
-
-}}
-
-#endif
diff --git a/7zip/Archive/7z/7zHandlerOut.cpp b/7zip/Archive/7z/7zHandlerOut.cpp
deleted file mode 100755
index fdd336ea..00000000
--- a/7zip/Archive/7z/7zHandlerOut.cpp
+++ /dev/null
@@ -1,1155 +0,0 @@
-// 7z/OutHandler.cpp
-
-#include "StdAfx.h"
-
-#include "7zHandler.h"
-#include "7zOut.h"
-#include "7zUpdate.h"
-#include "7zMethods.h"
-
-#include "../../../Windows/PropVariant.h"
-
-#include "../../../Common/ComTry.h"
-#include "../../../Common/StringToInt.h"
-#include "../../IPassword.h"
-#include "../../ICoder.h"
-
-#include "../Common/ItemNameUtils.h"
-#include "../Common/ParseProperties.h"
-
-using namespace NWindows;
-
-namespace NArchive {
-namespace N7z {
-
-#ifdef COMPRESS_LZMA
-static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
-static CMethodID k_LZMA2 = { { 0x3, 0x1, 0x2 }, 3 };
-#endif
-
-#ifdef COMPRESS_PPMD
-static CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
-#endif
-
-#ifdef COMPRESS_BCJ_X86
-static CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
-#endif
-
-#ifdef COMPRESS_BCJ2
-static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
-#endif
-
-#ifdef COMPRESS_COPY
-static CMethodID k_Copy = { { 0x0 }, 1 };
-#endif
-
-#ifdef COMPRESS_DEFLATE
-#ifndef COMPRESS_DEFLATE_ENCODER
-#define COMPRESS_DEFLATE_ENCODER
-#endif
-#endif
-
-#ifdef COMPRESS_DEFLATE_ENCODER
-static CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
-#endif
-
-#ifdef COMPRESS_BZIP2
-#ifndef COMPRESS_BZIP2_ENCODER
-#define COMPRESS_BZIP2_ENCODER
-#endif
-#endif
-
-#ifdef COMPRESS_BZIP2_ENCODER
-static CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
-#endif
-
-const wchar_t *kCopyMethod = L"Copy";
-const wchar_t *kLZMAMethodName = L"LZMA";
-const wchar_t *kLZMA2MethodName = L"LZMA2";
-const wchar_t *kBZip2MethodName = L"BZip2";
-const wchar_t *kPpmdMethodName = L"PPMd";
-const wchar_t *kDeflateMethodName = L"Deflate";
-const wchar_t *kDeflate64MethodName = L"Deflate64";
-
-static const wchar_t *kLzmaMatchFinderX1 = L"HC4";
-static const wchar_t *kLzmaMatchFinderX5 = L"BT4";
-
-static const UInt32 kLzmaAlgorithmX1 = 0;
-static const UInt32 kLzmaAlgorithmX5 = 1;
-
-static const UInt32 kLzmaDicSizeX1 = 1 << 16;
-static const UInt32 kLzmaDicSizeX3 = 1 << 20;
-static const UInt32 kLzmaDicSizeX5 = 1 << 22;
-static const UInt32 kLzmaDicSizeX7 = 1 << 24;
-static const UInt32 kLzmaDicSizeX9 = 1 << 26;
-
-static const UInt32 kLzmaFastBytesX1 = 32;
-static const UInt32 kLzmaFastBytesX7 = 64;
-
-static const UInt32 kPpmdMemSizeX1 = (1 << 22);
-static const UInt32 kPpmdMemSizeX5 = (1 << 24);
-static const UInt32 kPpmdMemSizeX7 = (1 << 26);
-static const UInt32 kPpmdMemSizeX9 = (192 << 20);
-
-static const UInt32 kPpmdOrderX1 = 4;
-static const UInt32 kPpmdOrderX5 = 6;
-static const UInt32 kPpmdOrderX7 = 16;
-static const UInt32 kPpmdOrderX9 = 32;
-
-static const UInt32 kDeflateFastBytesX1 = 32;
-static const UInt32 kDeflateFastBytesX7 = 64;
-static const UInt32 kDeflateFastBytesX9 = 128;
-
-static const UInt32 kDeflatePassesX1 = 1;
-static const UInt32 kDeflatePassesX7 = 3;
-static const UInt32 kDeflatePassesX9 = 10;
-
-static const UInt32 kBZip2NumPassesX1 = 1;
-static const UInt32 kBZip2NumPassesX7 = 2;
-static const UInt32 kBZip2NumPassesX9 = 7;
-
-static const UInt32 kBZip2DicSizeX1 = 100000;
-static const UInt32 kBZip2DicSizeX3 = 500000;
-static const UInt32 kBZip2DicSizeX5 = 900000;
-
-const wchar_t *kDefaultMethodName = kLZMAMethodName;
-
-static const wchar_t *kLzmaMatchFinderForHeaders = L"BT2";
-static const UInt32 kDictionaryForHeaders = 1 << 20;
-static const UInt32 kNumFastBytesForHeaders = 273;
-static const UInt32 kAlgorithmForHeaders = kLzmaAlgorithmX5;
-
-static bool IsCopyMethod(const UString &methodName)
- { return (methodName.CompareNoCase(kCopyMethod) == 0); }
-
-static bool IsLZMAMethod(const UString &methodName)
-{
- return
- (methodName.CompareNoCase(kLZMAMethodName) == 0) ||
- (methodName.CompareNoCase(kLZMA2MethodName) == 0);
-}
-
-/*
-static bool IsLZMethod(const UString &methodName)
- { return IsLZMAMethod(methodName); }
-*/
-
-static bool IsBZip2Method(const UString &methodName)
- { return (methodName.CompareNoCase(kBZip2MethodName) == 0); }
-
-static bool IsPpmdMethod(const UString &methodName)
- { return (methodName.CompareNoCase(kPpmdMethodName) == 0); }
-
-static bool IsDeflateMethod(const UString &methodName)
- { return (methodName.CompareNoCase(kDeflateMethodName) == 0) ||
- (methodName.CompareNoCase(kDeflate64MethodName) == 0); }
-
-STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
-{
- *type = NFileTimeType::kWindows;
- return S_OK;
-}
-
-HRESULT CHandler::SetPassword(CCompressionMethodMode &methodMode,
- IArchiveUpdateCallback *updateCallback)
-{
- CMyComPtr<ICryptoGetTextPassword2> getTextPassword;
- if (!getTextPassword)
- {
- CMyComPtr<IArchiveUpdateCallback> udateCallback2(updateCallback);
- udateCallback2.QueryInterface(IID_ICryptoGetTextPassword2, &getTextPassword);
- }
-
- if (getTextPassword)
- {
- CMyComBSTR password;
- Int32 passwordIsDefined;
- RINOK(getTextPassword->CryptoGetTextPassword2(
- &passwordIsDefined, &password));
- methodMode.PasswordIsDefined = IntToBool(passwordIsDefined);
- if (methodMode.PasswordIsDefined)
- methodMode.Password = password;
- }
- else
- methodMode.PasswordIsDefined = false;
- return S_OK;
-}
-
-struct CNameToPropID
-{
- PROPID PropID;
- VARTYPE VarType;
- const wchar_t *Name;
-};
-
-CNameToPropID g_NameToPropID[] =
-{
- { NCoderPropID::kOrder, VT_UI4, L"O" },
- { NCoderPropID::kPosStateBits, VT_UI4, L"PB" },
- { NCoderPropID::kLitContextBits, VT_UI4, L"LC" },
- { NCoderPropID::kLitPosBits, VT_UI4, L"LP" },
-
- { NCoderPropID::kNumPasses, VT_UI4, L"Pass" },
- { NCoderPropID::kNumFastBytes, VT_UI4, L"fb" },
- { NCoderPropID::kMatchFinderCycles, VT_UI4, L"mc" },
- { NCoderPropID::kAlgorithm, VT_UI4, L"a" },
- { NCoderPropID::kMatchFinder, VT_BSTR, L"mf" },
- { NCoderPropID::kNumThreads, VT_UI4, L"mt" }
-};
-
-bool ConvertProperty(PROPVARIANT srcProp, VARTYPE varType,
- NCOM::CPropVariant &destProp)
-{
- if (varType == srcProp.vt)
- {
- destProp = srcProp;
- return true;
- }
- if (varType == VT_UI1)
- {
- if(srcProp.vt == VT_UI4)
- {
- UInt32 value = srcProp.ulVal;
- if (value > 0xFF)
- return false;
- destProp = Byte(value);
- return true;
- }
- }
- return false;
-}
-
-const int kNumNameToPropIDItems = sizeof(g_NameToPropID) / sizeof(g_NameToPropID[0]);
-
-int FindPropIdFromStringName(const UString &name)
-{
- for (int i = 0; i < kNumNameToPropIDItems; i++)
- if (name.CompareNoCase(g_NameToPropID[i].Name) == 0)
- return i;
- return -1;
-}
-
-HRESULT CHandler::SetCompressionMethod(
- CCompressionMethodMode &methodMode,
- CCompressionMethodMode &headerMethod)
-{
- HRESULT res = SetCompressionMethod(methodMode, _methods
- #ifdef COMPRESS_MT
- , _numThreads
- #endif
- );
- RINOK(res);
- methodMode.Binds = _binds;
- if (_compressHeadersFull)
- _compressHeaders = true;
-
- if (_compressHeaders)
- {
- // headerMethod.Methods.Add(methodMode.Methods.Back());
-
- CObjectVector<COneMethodInfo> headerMethodInfoVector;
- COneMethodInfo oneMethodInfo;
- oneMethodInfo.MethodName = kLZMAMethodName;
- {
- CProperty property;
- property.PropID = NCoderPropID::kMatchFinder;
- property.Value = kLzmaMatchFinderForHeaders;
- oneMethodInfo.CoderProperties.Add(property);
- }
- {
- CProperty property;
- property.PropID = NCoderPropID::kAlgorithm;
- property.Value = kAlgorithmForHeaders;
- oneMethodInfo.CoderProperties.Add(property);
- }
- {
- CProperty property;
- property.PropID = NCoderPropID::kNumFastBytes;
- property.Value = UInt32(kNumFastBytesForHeaders);
- oneMethodInfo.CoderProperties.Add(property);
- }
- {
- CProperty property;
- property.PropID = NCoderPropID::kDictionarySize;
- property.Value = UInt32(kDictionaryForHeaders);
- oneMethodInfo.CoderProperties.Add(property);
- }
- headerMethodInfoVector.Add(oneMethodInfo);
- HRESULT res = SetCompressionMethod(headerMethod, headerMethodInfoVector
- #ifdef COMPRESS_MT
- ,1
- #endif
- );
- RINOK(res);
- }
- return S_OK;
-}
-
-static void SetOneMethodProp(COneMethodInfo &oneMethodInfo, PROPID propID,
- const NWindows::NCOM::CPropVariant &value)
-{
- int j;
- for (j = 0; j < oneMethodInfo.CoderProperties.Size(); j++)
- if (oneMethodInfo.CoderProperties[j].PropID == propID)
- break;
- if (j != oneMethodInfo.CoderProperties.Size())
- return;
- CProperty property;
- property.PropID = propID;
- property.Value = value;
- oneMethodInfo.CoderProperties.Add(property);
-}
-
-HRESULT CHandler::SetCompressionMethod(
- CCompressionMethodMode &methodMode,
- CObjectVector<COneMethodInfo> &methodsInfo
- #ifdef COMPRESS_MT
- , UInt32 numThreads
- #endif
- )
-{
- #ifndef EXCLUDE_COM
- /*
- CObjectVector<CMethodInfo2> methodInfoVector;
- if (!NRegistryInfo::EnumerateAllMethods(methodInfoVector))
- return E_FAIL;
- */
- #endif
-
-
- UInt32 level = _level;
-
- if (methodsInfo.IsEmpty())
- {
- COneMethodInfo oneMethodInfo;
- oneMethodInfo.MethodName = ((level == 0) ? kCopyMethod : kDefaultMethodName);
- methodsInfo.Add(oneMethodInfo);
- }
-
- bool needSolid = false;
- for(int i = 0; i < methodsInfo.Size(); i++)
- {
- COneMethodInfo &oneMethodInfo = methodsInfo[i];
- if (oneMethodInfo.MethodName.IsEmpty())
- oneMethodInfo.MethodName = kDefaultMethodName;
-
- if (!IsCopyMethod(oneMethodInfo.MethodName))
- needSolid = true;
-
- if (IsLZMAMethod(oneMethodInfo.MethodName))
- {
- UInt32 dicSize =
- (level >= 9 ? kLzmaDicSizeX9 :
- (level >= 7 ? kLzmaDicSizeX7 :
- (level >= 5 ? kLzmaDicSizeX5 :
- (level >= 3 ? kLzmaDicSizeX3 :
- kLzmaDicSizeX1))));
-
- UInt32 algorithm =
- (level >= 5 ? kLzmaAlgorithmX5 :
- kLzmaAlgorithmX1);
-
- UInt32 fastBytes =
- (level >= 7 ? kLzmaFastBytesX7 :
- kLzmaFastBytesX1);
-
- const wchar_t *matchFinder =
- (level >= 5 ? kLzmaMatchFinderX5 :
- kLzmaMatchFinderX1);
-
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algorithm);
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kMatchFinder, matchFinder);
- #ifdef COMPRESS_MT
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
- #endif
- }
- else if (IsDeflateMethod(oneMethodInfo.MethodName))
- {
- UInt32 fastBytes =
- (level >= 9 ? kDeflateFastBytesX9 :
- (level >= 7 ? kDeflateFastBytesX7 :
- kDeflateFastBytesX1));
-
- UInt32 numPasses =
- (level >= 9 ? kDeflatePassesX9 :
- (level >= 7 ? kDeflatePassesX7 :
- kDeflatePassesX1));
-
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
- }
- else if (IsBZip2Method(oneMethodInfo.MethodName))
- {
- UInt32 numPasses =
- (level >= 9 ? kBZip2NumPassesX9 :
- (level >= 7 ? kBZip2NumPassesX7 :
- kBZip2NumPassesX1));
-
- UInt32 dicSize =
- (level >= 5 ? kBZip2DicSizeX5 :
- (level >= 3 ? kBZip2DicSizeX3 :
- kBZip2DicSizeX1));
-
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
- #ifdef COMPRESS_MT
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
- #endif
- }
- else if (IsPpmdMethod(oneMethodInfo.MethodName))
- {
- UInt32 useMemSize =
- (level >= 9 ? kPpmdMemSizeX9 :
- (level >= 7 ? kPpmdMemSizeX7 :
- (level >= 5 ? kPpmdMemSizeX5 :
- kPpmdMemSizeX1)));
-
- UInt32 order =
- (level >= 9 ? kPpmdOrderX9 :
- (level >= 7 ? kPpmdOrderX7 :
- (level >= 5 ? kPpmdOrderX5 :
- kPpmdOrderX1)));
-
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kUsedMemorySize, useMemSize);
- SetOneMethodProp(oneMethodInfo, NCoderPropID::kOrder, order);
- }
-
-
- CMethodFull methodFull;
- methodFull.NumInStreams = 1;
- methodFull.NumOutStreams = 1;
-
- bool defined = false;
-
- #ifdef COMPRESS_LZMA
- if (oneMethodInfo.MethodName.CompareNoCase(L"LZMA") == 0)
- {
- defined = true;
- methodFull.MethodID = k_LZMA;
- }
- #endif
-
- #ifdef COMPRESS_PPMD
- if (oneMethodInfo.MethodName.CompareNoCase(L"PPMD") == 0)
- {
- defined = true;
- methodFull.MethodID = k_PPMD;
- }
- #endif
-
- #ifdef COMPRESS_BCJ_X86
- if (oneMethodInfo.MethodName.CompareNoCase(L"BCJ") == 0)
- {
- defined = true;
- methodFull.MethodID = k_BCJ_X86;
- }
- #endif
-
- #ifdef COMPRESS_BCJ2
- if (oneMethodInfo.MethodName.CompareNoCase(L"BCJ2") == 0)
- {
- defined = true;
- methodFull.MethodID = k_BCJ2;
- methodFull.NumInStreams = 4;
- methodFull.NumOutStreams = 1;
- }
- #endif
-
- #ifdef COMPRESS_DEFLATE_ENCODER
- if (oneMethodInfo.MethodName.CompareNoCase(L"Deflate") == 0)
- {
- defined = true;
- methodFull.MethodID = k_Deflate;
- }
- #endif
-
- #ifdef COMPRESS_BZIP2_ENCODER
- if (oneMethodInfo.MethodName.CompareNoCase(L"BZip2") == 0)
- {
- defined = true;
- methodFull.MethodID = k_BZip2;
- }
- #endif
-
- #ifdef COMPRESS_COPY
- if (oneMethodInfo.MethodName.CompareNoCase(L"Copy") == 0)
- {
- defined = true;
- methodFull.MethodID = k_Copy;
- }
-
- #endif
-
- #ifdef EXCLUDE_COM
-
- if (defined)
- {
-
- methodFull.CoderProperties = oneMethodInfo.CoderProperties;
- methodMode.Methods.Add(methodFull);
- continue;
- }
-
- #else
-
- CMethodInfo2 methodInfo;
- if (!GetMethodInfo(oneMethodInfo.MethodName, methodInfo))
- return E_FAIL;
- if (!methodInfo.EncoderIsAssigned)
- return E_FAIL;
-
- methodFull.MethodID = methodInfo.MethodID;
- methodFull.NumInStreams = methodInfo.NumInStreams;
- methodFull.NumOutStreams = methodInfo.NumOutStreams;
-
- methodFull.EncoderClassID = methodInfo.Encoder;
- methodFull.FilePath = methodInfo.FilePath;
- methodFull.CoderProperties = oneMethodInfo.CoderProperties;
- defined = true;
-
- #endif
- if (!defined)
- return E_FAIL;
-
- methodMode.Methods.Add(methodFull);
-
- if (!_numSolidBytesDefined)
- {
- for (int j = 0; j < methodFull.CoderProperties.Size(); j++)
- {
- const CProperty &prop = methodFull.CoderProperties[j];
- if ((prop.PropID == NCoderPropID::kDictionarySize ||
- prop.PropID == NCoderPropID::kUsedMemorySize) && prop.Value.vt == VT_UI4)
- {
- _numSolidBytes = ((UInt64)prop.Value.ulVal) << 7;
- const UInt64 kMinSize = (1 << 24);
- if (_numSolidBytes < kMinSize)
- _numSolidBytes = kMinSize;
- _numSolidBytesDefined = true;
- break;
- }
- }
- }
- }
-
- if (!needSolid && !_numSolidBytesDefined)
- {
- _numSolidBytesDefined = true;
- _numSolidBytes = 0;
- }
- return S_OK;
-}
-
-static HRESULT GetTime(IArchiveUpdateCallback *updateCallback, int index, PROPID propID, CArchiveFileTime &filetime, bool &filetimeIsDefined)
-{
- filetimeIsDefined = false;
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(index, propID, &propVariant));
- if (propVariant.vt == VT_FILETIME)
- {
- filetime = propVariant.filetime;
- filetimeIsDefined = true;
- }
- else if (propVariant.vt != VT_EMPTY)
- return E_INVALIDARG;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
- IArchiveUpdateCallback *updateCallback)
-{
- COM_TRY_BEGIN
-
- const CArchiveDatabaseEx *database = 0;
- #ifdef _7Z_VOL
- if(_volumes.Size() > 1)
- return E_FAIL;
- const CVolume *volume = 0;
- if (_volumes.Size() == 1)
- {
- volume = &_volumes.Front();
- database = &volume->Database;
- }
- #else
- if (_inStream != 0)
- database = &_database;
- #endif
-
- // CRecordVector<bool> compressStatuses;
- CObjectVector<CUpdateItem> updateItems;
- // CRecordVector<UInt32> copyIndices;
-
- // CMyComPtr<IUpdateCallback2> updateCallback2;
- // updateCallback->QueryInterface(&updateCallback2);
-
- 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)
- {
- const CFileItem &fileItem = database->Files[updateItem.IndexInArchive];
- updateItem.Name = fileItem.Name;
- updateItem.IsDirectory = fileItem.IsDirectory;
- updateItem.Size = fileItem.UnPackSize;
- updateItem.IsAnti = fileItem.IsAnti;
-
- updateItem.CreationTime = fileItem.CreationTime;
- updateItem.IsCreationTimeDefined = fileItem.IsCreationTimeDefined;
- updateItem.LastWriteTime = fileItem.LastWriteTime;
- updateItem.IsLastWriteTimeDefined = fileItem.IsLastWriteTimeDefined;
- updateItem.LastAccessTime = fileItem.LastAccessTime;
- updateItem.IsLastAccessTimeDefined = fileItem.IsLastAccessTimeDefined;
- }
-
- if (updateItem.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)
- return E_INVALIDARG;
- else
- {
- updateItem.Attributes = propVariant.ulVal;
- updateItem.AttributesAreDefined = 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));
-
- {
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(i, kpidPath, &propVariant));
- if (propVariant.vt == VT_EMPTY)
- nameIsDefined = false;
- else if (propVariant.vt != VT_BSTR)
- return E_INVALIDARG;
- else
- {
- updateItem.Name = NItemName::MakeLegalName(propVariant.bstrVal);
- nameIsDefined = true;
- }
- }
- {
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(i, kpidIsFolder, &propVariant));
- if (propVariant.vt == VT_EMPTY)
- folderStatusIsDefined = false;
- else if (propVariant.vt != VT_BOOL)
- return E_INVALIDARG;
- else
- {
- updateItem.IsDirectory = (propVariant.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)
- return E_INVALIDARG;
- else
- updateItem.IsAnti = (propVariant.boolVal != VARIANT_FALSE);
- }
-
- if (updateItem.IsAnti)
- {
- updateItem.AttributesAreDefined = false;
-
- updateItem.IsCreationTimeDefined = false;
- updateItem.IsLastWriteTimeDefined = false;
- updateItem.IsLastAccessTimeDefined = false;
-
- updateItem.Size = 0;
- }
-
- if (!folderStatusIsDefined && updateItem.AttributesAreDefined)
- updateItem.SetDirectoryStatusFromAttributes();
- }
-
- if (updateItem.NewData)
- {
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(i, kpidSize, &propVariant));
- if (propVariant.vt != VT_UI8)
- return E_INVALIDARG;
- updateItem.Size = (UInt64)propVariant.uhVal.QuadPart;
- if (updateItem.Size != 0 && updateItem.IsAnti)
- return E_INVALIDARG;
- }
- updateItems.Add(updateItem);
- }
-
- CCompressionMethodMode methodMode, headerMethod;
- RINOK(SetCompressionMethod(methodMode, headerMethod));
- #ifdef COMPRESS_MT
- methodMode.NumThreads = _numThreads;
- headerMethod.NumThreads = 1;
- #endif
-
- RINOK(SetPassword(methodMode, updateCallback));
-
- bool useAdditionalHeaderStreams = true;
- bool compressMainHeader = false;
-
- if (_compressHeadersFull)
- {
- useAdditionalHeaderStreams = false;
- compressMainHeader = true;
- }
- if (methodMode.PasswordIsDefined)
- {
- useAdditionalHeaderStreams = false;
- compressMainHeader = true;
- if(_encryptHeaders)
- RINOK(SetPassword(headerMethod, updateCallback));
- }
-
- if (numItems < 2)
- compressMainHeader = false;
-
- CUpdateOptions options;
- options.Method = &methodMode;
- options.HeaderMethod = (_compressHeaders ||
- (methodMode.PasswordIsDefined && _encryptHeaders)) ?
- &headerMethod : 0;
- options.UseFilters = _level != 0 && _autoFilter;
- options.MaxFilter = _level >= 8;
-
- options.HeaderOptions.UseAdditionalHeaderStreams = useAdditionalHeaderStreams;
- options.HeaderOptions.CompressMainHeader = compressMainHeader;
- options.HeaderOptions.WriteModified = WriteModified;
- options.HeaderOptions.WriteCreated = WriteCreated;
- options.HeaderOptions.WriteAccessed = WriteAccessed;
-
- options.NumSolidFiles = _numSolidFiles;
- options.NumSolidBytes = _numSolidBytes;
- options.SolidExtension = _solidExtension;
- options.RemoveSfxBlock = _removeSfxBlock;
- options.VolumeMode = _volumeMode;
- return Update(
- #ifdef _7Z_VOL
- volume ? volume->Stream: 0,
- volume ? database: 0,
- #else
- _inStream,
- database,
- #endif
- updateItems, outStream, updateCallback, options);
- COM_TRY_END
-}
-
-static HRESULT GetBindInfoPart(UString &srcString, UInt32 &coder, UInt32 &stream)
-{
- stream = 0;
- int index = ParseStringToUInt32(srcString, coder);
- if (index == 0)
- return E_INVALIDARG;
- srcString.Delete(0, index);
- if (srcString[0] == 'S')
- {
- srcString.Delete(0);
- int index = ParseStringToUInt32(srcString, stream);
- if (index == 0)
- return E_INVALIDARG;
- srcString.Delete(0, index);
- }
- return S_OK;
-}
-
-static HRESULT GetBindInfo(UString &srcString, CBind &bind)
-{
- RINOK(GetBindInfoPart(srcString, bind.OutCoder, bind.OutStream));
- if (srcString[0] != ':')
- return E_INVALIDARG;
- srcString.Delete(0);
- RINOK(GetBindInfoPart(srcString, bind.InCoder, bind.InStream));
- if (!srcString.IsEmpty())
- return E_INVALIDARG;
- return S_OK;
-}
-
-static void SplitParams(const UString &srcString, UStringVector &subStrings)
-{
- subStrings.Clear();
- UString name;
- int len = srcString.Length();
- if (len == 0)
- return;
- for (int i = 0; i < len; i++)
- {
- wchar_t c = srcString[i];
- if (c == L':')
- {
- subStrings.Add(name);
- name.Empty();
- }
- else
- name += c;
- }
- subStrings.Add(name);
-}
-
-static void SplitParam(const UString &param, UString &name, UString &value)
-{
- int eqPos = param.Find(L'=');
- if (eqPos >= 0)
- {
- name = param.Left(eqPos);
- value = param.Mid(eqPos + 1);
- return;
- }
- for(int i = 0; i < param.Length(); i++)
- {
- wchar_t c = param[i];
- if (c >= L'0' && c <= L'9')
- {
- name = param.Left(i);
- value = param.Mid(i);
- return;
- }
- }
- name = param;
-}
-
-HRESULT CHandler::SetParam(COneMethodInfo &oneMethodInfo, const UString &name, const UString &value)
-{
- CProperty property;
- if (name.CompareNoCase(L"D") == 0 || name.CompareNoCase(L"MEM") == 0)
- {
- UInt32 dicSize;
- RINOK(ParsePropDictionaryValue(value, dicSize));
- if (name.CompareNoCase(L"D") == 0)
- property.PropID = NCoderPropID::kDictionarySize;
- else
- property.PropID = NCoderPropID::kUsedMemorySize;
- property.Value = dicSize;
- oneMethodInfo.CoderProperties.Add(property);
- }
- else
- {
- int index = FindPropIdFromStringName(name);
- if (index < 0)
- return E_INVALIDARG;
-
- const CNameToPropID &nameToPropID = g_NameToPropID[index];
- property.PropID = nameToPropID.PropID;
-
- NCOM::CPropVariant propValue;
-
-
- if (nameToPropID.VarType == VT_BSTR)
- propValue = value;
- else
- {
- UInt32 number;
- if (ParseStringToUInt32(value, number) == value.Length())
- propValue = number;
- else
- propValue = value;
- }
-
- if (!ConvertProperty(propValue, nameToPropID.VarType, property.Value))
- return E_INVALIDARG;
-
- oneMethodInfo.CoderProperties.Add(property);
- }
- return S_OK;
-}
-
-HRESULT CHandler::SetParams(COneMethodInfo &oneMethodInfo, const UString &srcString)
-{
- UStringVector params;
- SplitParams(srcString, params);
- if (params.Size() > 0)
- oneMethodInfo.MethodName = params[0];
- for (int i = 1; i < params.Size(); i++)
- {
- const UString &param = params[i];
- UString name, value;
- SplitParam(param, name, value);
- RINOK(SetParam(oneMethodInfo, name, value));
- }
- return S_OK;
-}
-
-HRESULT CHandler::SetSolidSettings(const UString &s)
-{
- UString s2 = s;
- s2.MakeUpper();
- if (s2.IsEmpty() || s2.Compare(L"ON") == 0)
- {
- InitSolid();
- return S_OK;
- }
- if (s2.Compare(L"OFF") == 0)
- {
- _numSolidFiles = 1;
- return S_OK;
- }
- for (int i = 0; i < s2.Length();)
- {
- const wchar_t *start = ((const wchar_t *)s2) + i;
- const wchar_t *end;
- UInt64 v = ConvertStringToUInt64(start, &end);
- if (start == end)
- {
- if (s2[i++] != 'E')
- return E_INVALIDARG;
- _solidExtension = true;
- continue;
- }
- i += (int)(end - start);
- if (i == s2.Length())
- return E_INVALIDARG;
- wchar_t c = s2[i++];
- switch(c)
- {
- case 'F':
- if (v < 1)
- v = 1;
- _numSolidFiles = v;
- break;
- case 'B':
- _numSolidBytes = v;
- _numSolidBytesDefined = true;
- break;
- case 'K':
- _numSolidBytes = (v << 10);
- _numSolidBytesDefined = true;
- break;
- case 'M':
- _numSolidBytes = (v << 20);
- _numSolidBytesDefined = true;
- break;
- case 'G':
- _numSolidBytes = (v << 30);
- _numSolidBytesDefined = true;
- break;
- default:
- return E_INVALIDARG;
- }
- }
- return S_OK;
-}
-
-HRESULT CHandler::SetSolidSettings(const PROPVARIANT &value)
-{
- switch(value.vt)
- {
- case VT_EMPTY:
- InitSolid();
- return S_OK;
- case VT_BSTR:
- return SetSolidSettings(value.bstrVal);
- default:
- return E_INVALIDARG;
- }
-}
-
-STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
-{
- COM_TRY_BEGIN
- _methods.Clear();
- _binds.Clear();
- Init();
- #ifdef COMPRESS_MT
- const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
- #endif
-
- UInt32 mainDicSize = 0xFFFFFFFF;
- UInt32 mainDicMethodIndex = 0xFFFFFFFF;
-
- UInt32 minNumber = 0;
-
- for (int i = 0; i < numProperties; i++)
- {
- UString name = names[i];
- name.MakeUpper();
- if (name.IsEmpty())
- return E_INVALIDARG;
-
- const PROPVARIANT &value = values[i];
-
- if (name[0] == 'X')
- {
- name.Delete(0);
- _level = 9;
- RINOK(ParsePropValue(name, value, _level));
- continue;
- }
-
- if (name[0] == 'B')
- {
- name.Delete(0);
- CBind bind;
- RINOK(GetBindInfo(name, bind));
- _binds.Add(bind);
- continue;
- }
-
- if (name[0] == L'S')
- {
- name.Delete(0);
- if (name.IsEmpty())
- {
- RINOK(SetSolidSettings(value));
- }
- else
- {
- RINOK(SetSolidSettings(name));
- }
- continue;
- }
-
-
- UInt32 number;
- int index = ParseStringToUInt32(name, number);
- UString realName = name.Mid(index);
- if (index == 0)
- {
- if(name.Left(2).CompareNoCase(L"MT") == 0)
- {
- #ifdef COMPRESS_MT
- RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
- #endif
- continue;
- }
- else if (name.CompareNoCase(L"RSFX") == 0)
- {
- RINOK(SetBoolProperty(_removeSfxBlock, value));
- continue;
- }
- else if (name.CompareNoCase(L"F") == 0)
- {
- RINOK(SetBoolProperty(_autoFilter, value));
- continue;
- }
- else if (name.CompareNoCase(L"HC") == 0)
- {
- RINOK(SetBoolProperty(_compressHeaders, value));
- continue;
- }
- else if (name.CompareNoCase(L"HCF") == 0)
- {
- RINOK(SetBoolProperty(_compressHeadersFull, value));
- continue;
- }
- else if (name.CompareNoCase(L"HE") == 0)
- {
- RINOK(SetBoolProperty(_encryptHeaders, value));
- continue;
- }
- else if (name.CompareNoCase(L"TM") == 0)
- {
- RINOK(SetBoolProperty(WriteModified, value));
- continue;
- }
- else if (name.CompareNoCase(L"TC") == 0)
- {
- RINOK(SetBoolProperty(WriteCreated, value));
- continue;
- }
- else if (name.CompareNoCase(L"TA") == 0)
- {
- RINOK(SetBoolProperty(WriteAccessed, value));
- continue;
- }
- else if (name.CompareNoCase(L"V") == 0)
- {
- RINOK(SetBoolProperty(_volumeMode, value));
- continue;
- }
- number = 0;
- }
- if (number > 10000)
- return E_FAIL;
- if (number < minNumber)
- return E_INVALIDARG;
- number -= minNumber;
- for(int j = _methods.Size(); j <= (int)number; j++)
- {
- COneMethodInfo oneMethodInfo;
- _methods.Add(oneMethodInfo);
- }
-
- COneMethodInfo &oneMethodInfo = _methods[number];
-
- if (realName.Length() == 0)
- {
- if (value.vt != VT_BSTR)
- return E_INVALIDARG;
-
- // oneMethodInfo.MethodName = UnicodeStringToMultiByte(UString(value.bstrVal));
- RINOK(SetParams(oneMethodInfo, value.bstrVal));
- }
- else
- {
- CProperty property;
- if (realName.Left(1).CompareNoCase(L"D") == 0)
- {
- UInt32 dicSize;
- RINOK(ParsePropDictionaryValue(realName.Mid(1), value, dicSize));
- property.PropID = NCoderPropID::kDictionarySize;
- property.Value = dicSize;
- oneMethodInfo.CoderProperties.Add(property);
- if (number <= mainDicMethodIndex)
- mainDicSize = dicSize;
- }
- else if (realName.Left(3).CompareNoCase(L"MEM") == 0)
- {
- UInt32 dicSize;
- RINOK(ParsePropDictionaryValue(realName.Mid(3), value, dicSize));
- property.PropID = NCoderPropID::kUsedMemorySize;
- property.Value = dicSize;
- oneMethodInfo.CoderProperties.Add(property);
- if (number <= mainDicMethodIndex)
- mainDicSize = dicSize;
- }
- else
- {
- int index = FindPropIdFromStringName(realName);
- if (index < 0)
- return E_INVALIDARG;
-
- const CNameToPropID &nameToPropID = g_NameToPropID[index];
- property.PropID = nameToPropID.PropID;
-
- if (!ConvertProperty(value, nameToPropID.VarType, property.Value))
- return E_INVALIDARG;
-
- oneMethodInfo.CoderProperties.Add(property);
- }
- }
- }
-
- return S_OK;
- COM_TRY_END
-}
-
-}}
diff --git a/7zip/Archive/7z/7zUpdate.cpp b/7zip/Archive/7z/7zUpdate.cpp
deleted file mode 100755
index 0b4866d8..00000000
--- a/7zip/Archive/7z/7zUpdate.cpp
+++ /dev/null
@@ -1,1099 +0,0 @@
-// UpdateMain.cpp
-
-#include "StdAfx.h"
-
-#include "7zUpdate.h"
-#include "7zFolderInStream.h"
-#include "7zEncode.h"
-#include "7zHandler.h"
-#include "7zOut.h"
-
-#ifndef EXCLUDE_COM
-#include "7zMethods.h"
-#endif
-
-#include "../../Compress/Copy/CopyCoder.h"
-#include "../../Common/ProgressUtils.h"
-#include "../../Common/LimitedStreams.h"
-#include "../../Common/LimitedStreams.h"
-#include "../Common/ItemNameUtils.h"
-
-namespace NArchive {
-namespace N7z {
-
-static const wchar_t *kMatchFinderForBCJ2_LZMA = L"BT2";
-static const UInt32 kDictionaryForBCJ2_LZMA = 1 << 20;
-static const UInt32 kAlgorithmForBCJ2_LZMA = 2;
-static const UInt32 kNumFastBytesForBCJ2_LZMA = 64;
-
-static HRESULT CopyBlock(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, ICompressProgressInfo *progress)
-{
- CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
- return copyCoder->Code(inStream, outStream, NULL, NULL, progress);
-}
-
-static HRESULT WriteRange(
- ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- UInt64 size,
- IProgress *progress,
- UInt64 &currentComplexity)
-{
- CLimitedSequentialInStream *streamSpec = new
- CLimitedSequentialInStream;
- CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
- streamSpec->SetStream(inStream);
- streamSpec->Init(size);
-
- CLocalProgress *localProgressSpec = new CLocalProgress;
- CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
- localProgressSpec->Init(progress, true);
-
- CLocalCompressProgressInfo *localCompressProgressSpec =
- new CLocalCompressProgressInfo;
- CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
-
- localCompressProgressSpec->Init(localProgress, &currentComplexity, &currentComplexity);
-
- HRESULT result = CopyBlock(inStreamLimited, outStream, compressProgress);
- currentComplexity += size;
- return result;
-}
-
-
-static HRESULT WriteRange(IInStream *inStream,
- ISequentialOutStream *outStream,
- UInt64 position,
- UInt64 size,
- IProgress *progress,
- UInt64 &currentComplexity)
-{
- inStream->Seek(position, STREAM_SEEK_SET, 0);
- return WriteRange(inStream, outStream,
- size, progress, currentComplexity);
-}
-
-static int GetReverseSlashPos(const UString &name)
-{
- int slashPos = name.ReverseFind(L'/');
- #ifdef _WIN32
- int slash1Pos = name.ReverseFind(L'\\');
- slashPos = MyMax(slashPos, slash1Pos);
- #endif
- return slashPos;
-}
-
-int CUpdateItem::GetExtensionPos() const
-{
- int slashPos = GetReverseSlashPos(Name);
- int dotPos = Name.ReverseFind(L'.');
- if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
- return Name.Length();
- return dotPos + 1;
-}
-
-UString CUpdateItem::GetExtension() const
-{
- return Name.Mid(GetExtensionPos());
-}
-
-/*
-struct CFolderRef
-{
- const CArchiveDatabaseEx *Database;
- int FolderIndex;
-};
-*/
-
-#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
-
-static int CompareMethodIDs(const CMethodID &a1, const CMethodID &a2)
-{
- for (int i = 0; i < a1.IDSize && i < a2.IDSize; i++)
- RINOZ(MyCompare(a1.ID[i], a2.ID[i]));
- return MyCompare(a1.IDSize, a2.IDSize);
-}
-
-static int CompareBuffers(const CByteBuffer &a1, const CByteBuffer &a2)
-{
- size_t c1 = a1.GetCapacity();
- size_t c2 = a2.GetCapacity();
- RINOZ(MyCompare(c1, c2));
- for (size_t i = 0; i < c1; i++)
- RINOZ(MyCompare(a1[i], a2[i]));
- return 0;
-}
-
-static int CompareAltCoders(const CAltCoderInfo &a1, const CAltCoderInfo &a2)
-{
- RINOZ(CompareMethodIDs(a1.MethodID, a2.MethodID));
- return CompareBuffers(a1.Properties, a2.Properties);
-}
-
-static int CompareCoders(const CCoderInfo &c1, const CCoderInfo &c2)
-{
- RINOZ(MyCompare(c1.NumInStreams, c2.NumInStreams));
- RINOZ(MyCompare(c1.NumOutStreams, c2.NumOutStreams));
- int s1 = c1.AltCoders.Size();
- int s2 = c2.AltCoders.Size();
- RINOZ(MyCompare(s1, s2));
- for (int i = 0; i < s1; i++)
- RINOZ(CompareAltCoders(c1.AltCoders[i], c2.AltCoders[i]));
- return 0;
-}
-
-static int CompareBindPairs(const CBindPair &b1, const CBindPair &b2)
-{
- RINOZ(MyCompare(b1.InIndex, b2.InIndex));
- return MyCompare(b1.OutIndex, b2.OutIndex);
-}
-
-static int CompareFolders(const CFolder &f1, const CFolder &f2)
-{
- int s1 = f1.Coders.Size();
- int s2 = f2.Coders.Size();
- RINOZ(MyCompare(s1, s2));
- int i;
- for (i = 0; i < s1; i++)
- RINOZ(CompareCoders(f1.Coders[i], f2.Coders[i]));
- s1 = f1.BindPairs.Size();
- s2 = f2.BindPairs.Size();
- RINOZ(MyCompare(s1, s2));
- for (i = 0; i < s1; i++)
- RINOZ(CompareBindPairs(f1.BindPairs[i], f2.BindPairs[i]));
- return 0;
-}
-
-static int CompareFiles(const CFileItem &f1, const CFileItem &f2)
-{
- return MyStringCompareNoCase(f1.Name, f2.Name);
-}
-
-static int CompareFolderRefs(const int *p1, const int *p2, void *param)
-{
- int i1 = *p1;
- int i2 = *p2;
- const CArchiveDatabaseEx &db = *(const CArchiveDatabaseEx *)param;
- RINOZ(CompareFolders(
- db.Folders[i1],
- db.Folders[i2]));
- RINOZ(MyCompare(
- db.NumUnPackStreamsVector[i1],
- db.NumUnPackStreamsVector[i2]));
- if (db.NumUnPackStreamsVector[i1] == 0)
- return 0;
- return CompareFiles(
- db.Files[db.FolderStartFileIndex[i1]],
- db.Files[db.FolderStartFileIndex[i2]]);
-}
-
-////////////////////////////////////////////////////////////
-
-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.IsAnti != u2.IsAnti)
- return (u1.IsAnti ? 1 : -1);
- int n = MyStringCompareNoCase(u1.Name, u2.Name);
- return -n;
- }
- if (u1.IsAnti != u2.IsAnti)
- return (u1.IsAnti ? 1 : -1);
- 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"
- " 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"
- " swf "
- " chm hxi hxs"
- " gif jpeg jpg jp2 png tiff bmp ico psd psp"
- " awg ps eps cgm dxf svg vrml wmf emf ai md"
- " cad dwg pps key sxi"
- " max 3ds"
- " 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"
- " f77 f f90 f95"
- " asm sql manifest dep "
- " mak clw csproj vcproj sln dsp dsw "
- " class "
- " bat cmd"
- " xml xsd xsl xslt hxk hxc htm html xhtml xht mht mhtml htw asp aspx css cgi jsp shtml"
- " awk sed hta js php php3 php4 php5 phptml pl pm py pyo rb sh tcl vbs"
- " text txt tex ans asc srt reg ini doc docx mcw dot rtf hlp xls xlr xlt xlw ppt pdf"
- " sxc sxd sxi sxg sxw stc sti stw stm odt ott odg otg odp otp ods ots odf"
- " abw afp cwk lwp wpd wps wpt wrf wri"
- " abf afm bdf fon mgf otf pcf pfa snf ttf"
- " dbf mdb nsf ntf wdb db fdb gdb"
- " exe dll ocx vbx sfx sys tlb awx com obj lib out o so "
- " pdb pch idb ncb opt";
-
-int GetExtIndex(const char *ext)
-{
- int extIndex = 1;
- const char *p = g_Exts;
- for (;;)
- {
- char c = *p++;
- if (c == 0)
- return extIndex;
- if (c == ' ')
- continue;
- int pos = 0;
- for (;;)
- {
- char c2 = ext[pos++];
- if (c2 == 0 && (c == 0 || c == ' '))
- return extIndex;
- if (c != c2)
- break;
- c = *p++;
- }
- extIndex++;
- for (;;)
- {
- if (c == 0)
- return extIndex;
- if (c == ' ')
- break;
- c = *p++;
- }
- }
-}
-
-struct CRefItem
-{
- UInt32 Index;
- const CUpdateItem *UpdateItem;
- UInt32 ExtensionPos;
- UInt32 NamePos;
- int ExtensionIndex;
- CRefItem(UInt32 index, const CUpdateItem &updateItem, bool sortByType):
- Index(index),
- UpdateItem(&updateItem),
- ExtensionPos(0),
- NamePos(0),
- ExtensionIndex(0)
- {
- if (sortByType)
- {
- int slashPos = GetReverseSlashPos(updateItem.Name);
- NamePos = ((slashPos >= 0) ? (slashPos + 1) : 0);
- int dotPos = updateItem.Name.ReverseFind(L'.');
- if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
- ExtensionPos = updateItem.Name.Length();
- else
- {
- ExtensionPos = dotPos + 1;
- UString us = updateItem.Name.Mid(ExtensionPos);
- if (!us.IsEmpty())
- {
- us.MakeLower();
- int i;
- AString s;
- for (i = 0; i < us.Length(); i++)
- {
- wchar_t c = us[i];
- if (c >= 0x80)
- break;
- s += (char)c;
- }
- if (i == us.Length())
- ExtensionIndex = GetExtIndex(s);
- else
- ExtensionIndex = 0;
- }
- }
- }
- }
-};
-
-static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *param)
-{
- const CRefItem &a1 = *p1;
- const CRefItem &a2 = *p2;
- 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.IsAnti != u2.IsAnti)
- return (u1.IsAnti ? 1 : -1);
- n = MyStringCompareNoCase(u1.Name, u2.Name);
- return -n;
- }
- bool sortByType = *(bool *)param;
- if (sortByType)
- {
- 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));
- RINOZ(MyCompare(u1.Size, u2.Size))
- }
- return MyStringCompareNoCase(u1.Name, u2.Name);
-}
-
-struct CSolidGroup
-{
- CCompressionMethodMode Method;
- CRecordVector<UInt32> Indices;
-};
-
-static wchar_t *g_ExeExts[] =
-{
- L"dll",
- L"exe",
- L"ocx",
- L"sfx",
- L"sys"
-};
-
-static bool IsExeFile(const UString &ext)
-{
- for (int i = 0; i < sizeof(g_ExeExts) / sizeof(g_ExeExts[0]); i++)
- if (ext.CompareNoCase(g_ExeExts[i]) == 0)
- return true;
- return false;
-}
-
-static CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
-static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
-static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
-
-static bool GetMethodFull(const CMethodID &methodID,
- UInt32 numInStreams, CMethodFull &methodResult)
-{
- methodResult.MethodID = methodID;
- methodResult.NumInStreams = numInStreams;
- methodResult.NumOutStreams = 1;
-
- #ifndef EXCLUDE_COM
- CMethodInfo methodInfo;
- if (!GetMethodInfo(methodID, methodInfo))
- return false;
- if (!methodInfo.EncoderIsAssigned)
- return false;
- methodResult.EncoderClassID = methodInfo.Encoder;
- methodResult.FilePath = methodInfo.FilePath;
- if (methodInfo.NumOutStreams != 1 || methodInfo.NumInStreams != numInStreams)
- return false;
- #endif
- return true;
-}
-
-static bool MakeExeMethod(const CCompressionMethodMode &method,
- bool bcj2Filter, CCompressionMethodMode &exeMethod)
-{
- exeMethod = method;
- if (bcj2Filter)
- {
- CMethodFull methodFull;
- if (!GetMethodFull(k_BCJ2, 4, methodFull))
- return false;
- exeMethod.Methods.Insert(0, methodFull);
- if (!GetMethodFull(k_LZMA, 1, methodFull))
- return false;
- {
- CProperty property;
- property.PropID = NCoderPropID::kAlgorithm;
- property.Value = kAlgorithmForBCJ2_LZMA;
- methodFull.CoderProperties.Add(property);
- }
- {
- CProperty property;
- property.PropID = NCoderPropID::kMatchFinder;
- property.Value = kMatchFinderForBCJ2_LZMA;
- methodFull.CoderProperties.Add(property);
- }
- {
- CProperty property;
- property.PropID = NCoderPropID::kDictionarySize;
- property.Value = kDictionaryForBCJ2_LZMA;
- methodFull.CoderProperties.Add(property);
- }
- {
- CProperty property;
- property.PropID = NCoderPropID::kNumFastBytes;
- property.Value = kNumFastBytesForBCJ2_LZMA;
- methodFull.CoderProperties.Add(property);
- }
-
- exeMethod.Methods.Add(methodFull);
- exeMethod.Methods.Add(methodFull);
- CBind bind;
-
- bind.OutCoder = 0;
- bind.InStream = 0;
-
- bind.InCoder = 1;
- bind.OutStream = 0;
- exeMethod.Binds.Add(bind);
-
- bind.InCoder = 2;
- bind.OutStream = 1;
- exeMethod.Binds.Add(bind);
-
- bind.InCoder = 3;
- bind.OutStream = 2;
- exeMethod.Binds.Add(bind);
- }
- else
- {
- CMethodFull methodFull;
- if (!GetMethodFull(k_BCJ_X86, 1, methodFull))
- return false;
- exeMethod.Methods.Insert(0, methodFull);
- CBind bind;
- bind.OutCoder = 0;
- bind.InStream = 0;
- bind.InCoder = 1;
- bind.OutStream = 0;
- exeMethod.Binds.Add(bind);
- }
- return true;
-}
-
-static void SplitFilesToGroups(
- const CCompressionMethodMode &method,
- bool useFilters, bool maxFilter,
- const CObjectVector<CUpdateItem> &updateItems,
- CObjectVector<CSolidGroup> &groups)
-{
- if (method.Methods.Size() != 1 || method.Binds.Size() != 0)
- useFilters = false;
- groups.Clear();
- groups.Add(CSolidGroup());
- groups.Add(CSolidGroup());
- CSolidGroup &generalGroup = groups[0];
- CSolidGroup &exeGroup = groups[1];
- generalGroup.Method = method;
- int i;
- for (i = 0; i < updateItems.Size(); i++)
- {
- const CUpdateItem &updateItem = updateItems[i];
- if (!updateItem.NewData)
- continue;
- if (!updateItem.HasStream())
- continue;
- if (useFilters)
- {
- const UString name = updateItem.Name;
- int dotPos = name.ReverseFind(L'.');
- if (dotPos >= 0)
- {
- UString ext = name.Mid(dotPos + 1);
- if (IsExeFile(ext))
- {
- exeGroup.Indices.Add(i);
- continue;
- }
- }
- }
- generalGroup.Indices.Add(i);
- }
- if (exeGroup.Indices.Size() > 0)
- if (!MakeExeMethod(method, maxFilter, exeGroup.Method))
- exeGroup.Method = method;
- for (i = 0; i < groups.Size();)
- if (groups[i].Indices.Size() == 0)
- groups.Delete(i);
- else
- i++;
-}
-
-static void FromUpdateItemToFileItem(const CUpdateItem &updateItem,
- CFileItem &file)
-{
- 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.UnPackSize = updateItem.Size;
- file.IsDirectory = updateItem.IsDirectory;
- file.IsAnti = updateItem.IsAnti;
- file.HasStream = updateItem.HasStream();
-}
-
-static HRESULT Update2(
- IInStream *inStream,
- const CArchiveDatabaseEx *database,
- const CObjectVector<CUpdateItem> &updateItems,
- ISequentialOutStream *seqOutStream,
- IArchiveUpdateCallback *updateCallback,
- const CUpdateOptions &options)
-{
- UInt64 numSolidFiles = options.NumSolidFiles;
- if (numSolidFiles == 0)
- numSolidFiles = 1;
- /*
- CMyComPtr<IOutStream> outStream;
- RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream));
- if (!outStream)
- return E_NOTIMPL;
- */
-
- UInt64 startBlockSize = database != 0 ?
- database->ArchiveInfo.StartPosition: 0;
- if (startBlockSize > 0 && !options.RemoveSfxBlock)
- {
- CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
- CMyComPtr<ISequentialInStream> limitedStream(streamSpec);
- RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
- streamSpec->SetStream(inStream);
- streamSpec->Init(startBlockSize);
- RINOK(CopyBlock(limitedStream, seqOutStream, NULL));
- }
-
- CRecordVector<int> fileIndexToUpdateIndexMap;
- if (database != 0)
- {
- fileIndexToUpdateIndexMap.Reserve(database->Files.Size());
- for (int i = 0; i < database->Files.Size(); i++)
- fileIndexToUpdateIndexMap.Add(-1);
- }
- int i;
- for(i = 0; i < updateItems.Size(); i++)
- {
- int index = updateItems[i].IndexInArchive;
- if (index != -1)
- fileIndexToUpdateIndexMap[index] = i;
- }
-
- CRecordVector<int> folderRefs;
- if (database != 0)
- {
- for(i = 0; i < database->Folders.Size(); i++)
- {
- CNum indexInFolder = 0;
- CNum numCopyItems = 0;
- CNum numUnPackStreams = database->NumUnPackStreamsVector[i];
- for (CNum fileIndex = database->FolderStartFileIndex[i];
- indexInFolder < numUnPackStreams; fileIndex++)
- {
- if (database->Files[fileIndex].HasStream)
- {
- indexInFolder++;
- int updateIndex = fileIndexToUpdateIndexMap[fileIndex];
- if (updateIndex >= 0)
- if (!updateItems[updateIndex].NewData)
- numCopyItems++;
- }
- }
- if (numCopyItems != numUnPackStreams && numCopyItems != 0)
- return E_NOTIMPL; // It needs repacking !!!
- if (numCopyItems > 0)
- folderRefs.Add(i);
- }
- folderRefs.Sort(CompareFolderRefs, (void *)database);
- }
-
- 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]);
- UInt64 inSizeForReduce = 0;
- for(i = 0; i < updateItems.Size(); i++)
- {
- const CUpdateItem &updateItem = updateItems[i];
- if (updateItem.NewData)
- {
- complexity += updateItem.Size;
- if (numSolidFiles == 1)
- {
- if (updateItem.Size > inSizeForReduce)
- inSizeForReduce = updateItem.Size;
- }
- else
- inSizeForReduce += updateItem.Size;
- }
- }
- RINOK(updateCallback->SetTotal(complexity));
- complexity = 0;
- RINOK(updateCallback->SetCompleted(&complexity));
-
- /////////////////////////////////////////
- // Write Copy Items
-
- for(i = 0; i < folderRefs.Size(); i++)
- {
- int folderIndex = folderRefs[i];
-
- RINOK(WriteRange(inStream, archive.SeqStream,
- database->GetFolderStreamPos(folderIndex, 0),
- database->GetFolderFullPackSize(folderIndex),
- updateCallback, complexity));
-
- const CFolder &folder = database->Folders[folderIndex];
- CNum startIndex = database->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.Folders.Add(folder);
-
- CNum numUnPackStreams = database->NumUnPackStreamsVector[folderIndex];
- newDatabase.NumUnPackStreamsVector.Add(numUnPackStreams);
-
- CNum indexInFolder = 0;
- for (CNum fi = database->FolderStartFileIndex[folderIndex];
- indexInFolder < numUnPackStreams; fi++)
- {
- CFileItem file = database->Files[fi];
- if (file.HasStream)
- {
- indexInFolder++;
- int updateIndex = fileIndexToUpdateIndexMap[fi];
- if (updateIndex >= 0)
- {
- const CUpdateItem &updateItem = updateItems[updateIndex];
- if (updateItem.NewProperties)
- {
- CFileItem file2;
- FromUpdateItemToFileItem(updateItem, file2);
- file2.UnPackSize = file.UnPackSize;
- file2.FileCRC = file.FileCRC;
- file2.IsFileCRCDefined = file.IsFileCRCDefined;
- file2.HasStream = file.HasStream;
- file = file2;
- }
- }
- newDatabase.Files.Add(file);
- }
- }
- }
-
- /////////////////////////////////////////
- // Compress New Files
-
- CObjectVector<CSolidGroup> groups;
- SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter,
- updateItems, groups);
-
- const UInt32 kMinReduceSize = (1 << 16);
- if (inSizeForReduce < kMinReduceSize)
- inSizeForReduce = kMinReduceSize;
-
- for (int groupIndex = 0; groupIndex < groups.Size(); groupIndex++)
- {
- const CSolidGroup &group = groups[groupIndex];
- int numFiles = group.Indices.Size();
- if (numFiles == 0)
- continue;
- CRecordVector<CRefItem> refItems;
- refItems.Reserve(numFiles);
- bool sortByType = (numSolidFiles > 1);
- for (i = 0; i < numFiles; i++)
- refItems.Add(CRefItem(group.Indices[i], updateItems[group.Indices[i]], sortByType));
- refItems.Sort(CompareUpdateItems, (void *)&sortByType);
-
- CRecordVector<UInt32> indices;
- indices.Reserve(numFiles);
-
- for (i = 0; i < numFiles; i++)
- {
- UInt32 index = refItems[i].Index;
- indices.Add(index);
- /*
- const CUpdateItem &updateItem = updateItems[index];
- CFileItem file;
- if (updateItem.NewProperties)
- FromUpdateItemToFileItem(updateItem, file);
- else
- file = database.Files[updateItem.IndexInArchive];
- if (file.IsAnti || file.IsDirectory)
- return E_FAIL;
- newDatabase.Files.Add(file);
- */
- }
-
- CEncoder encoder(group.Method);
-
- for (i = 0; i < numFiles;)
- {
- UInt64 totalSize = 0;
- int numSubFiles;
- UString prevExtension;
- for (numSubFiles = 0; i + numSubFiles < numFiles &&
- numSubFiles < numSolidFiles; numSubFiles++)
- {
- const CUpdateItem &updateItem = updateItems[indices[i + numSubFiles]];
- totalSize += updateItem.Size;
- if (totalSize > options.NumSolidBytes)
- break;
- if (options.SolidExtension)
- {
- UString ext = updateItem.GetExtension();
- if (numSubFiles == 0)
- prevExtension = ext;
- else
- if (ext.CompareNoCase(prevExtension) != 0)
- break;
- }
- }
- if (numSubFiles < 1)
- numSubFiles = 1;
-
- CFolderInStream *inStreamSpec = new CFolderInStream;
- CMyComPtr<ISequentialInStream> solidInStream(inStreamSpec);
- inStreamSpec->Init(updateCallback, &indices[i], numSubFiles);
-
- CFolder folderItem;
- CLocalProgress *localProgressSpec = new CLocalProgress;
- CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
- localProgressSpec->Init(updateCallback, true);
- CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
- CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
- localCompressProgressSpec->Init(localProgress, &complexity, NULL);
-
- RINOK(encoder.Encode(solidInStream, NULL, &inSizeForReduce, folderItem,
- archive.SeqStream, newDatabase.PackSizes, compressProgress));
- // for()
- // newDatabase.PackCRCsDefined.Add(false);
- // newDatabase.PackCRCs.Add(0);
-
- newDatabase.Folders.Add(folderItem);
-
- CNum numUnPackStreams = 0;
- for (int subIndex = 0; subIndex < numSubFiles; subIndex++)
- {
- const CUpdateItem &updateItem = updateItems[indices[i + subIndex]];
- CFileItem file;
- if (updateItem.NewProperties)
- FromUpdateItemToFileItem(updateItem, file);
- else
- file = database->Files[updateItem.IndexInArchive];
- if (file.IsAnti || file.IsDirectory)
- return E_FAIL;
-
- /*
- CFileItem &file = newDatabase.Files[
- startFileIndexInDatabase + i + subIndex];
- */
- if (!inStreamSpec->Processed[subIndex])
- {
- continue;
- // file.Name += L".locked";
- }
-
- file.FileCRC = inStreamSpec->CRCs[subIndex];
- file.UnPackSize = inStreamSpec->Sizes[subIndex];
- if (file.UnPackSize != 0)
- {
- file.IsFileCRCDefined = true;
- file.HasStream = true;
- numUnPackStreams++;
- complexity += file.UnPackSize;
- }
- else
- {
- file.IsFileCRCDefined = false;
- file.HasStream = false;
- }
- newDatabase.Files.Add(file);
- }
- // numUnPackStreams = 0 is very bad case for locked files
- // v3.13 doesn't understand it.
- newDatabase.NumUnPackStreamsVector.Add(numUnPackStreams);
- i += numSubFiles;
- }
- }
-
- {
- /////////////////////////////////////////
- // Write Empty Files & Folders
-
- CRecordVector<int> emptyRefs;
- for(i = 0; i < updateItems.Size(); i++)
- {
- const CUpdateItem &updateItem = updateItems[i];
- if (updateItem.NewData)
- {
- if (updateItem.HasStream())
- continue;
- }
- else
- if (updateItem.IndexInArchive != -1)
- if (database->Files[updateItem.IndexInArchive].HasStream)
- continue;
- emptyRefs.Add(i);
- }
- emptyRefs.Sort(CompareEmptyItems, (void *)&updateItems);
- for(i = 0; i < emptyRefs.Size(); i++)
- {
- const CUpdateItem &updateItem = updateItems[emptyRefs[i]];
- CFileItem file;
- if (updateItem.NewProperties)
- FromUpdateItemToFileItem(updateItem, file);
- else
- file = database->Files[updateItem.IndexInArchive];
- newDatabase.Files.Add(file);
- }
- }
-
- /*
- if (newDatabase.Files.Size() != updateItems.Size())
- return E_FAIL;
- */
-
- return archive.WriteDatabase(newDatabase, options.HeaderMethod, options.HeaderOptions);
-}
-
-#ifdef _7Z_VOL
-
-static HRESULT WriteVolumeHeader(COutArchive &archive, CFileItem &file, const CUpdateOptions &options)
-{
- CAltCoderInfo altCoder;
- altCoder.MethodID.IDSize = 1;
- altCoder.MethodID.ID[0] = 0;
- CCoderInfo coder;
- coder.NumInStreams = coder.NumOutStreams = 1;
- coder.AltCoders.Add(altCoder);
-
- 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());
- }
- }
- return S_OK;
-}
-
-#endif
-
-HRESULT Update(
- IInStream *inStream,
- const CArchiveDatabaseEx *database,
- const CObjectVector<CUpdateItem> &updateItems,
- ISequentialOutStream *seqOutStream,
- IArchiveUpdateCallback *updateCallback,
- const CUpdateOptions &options)
-{
- #ifdef _7Z_VOL
- if (seqOutStream)
- #endif
- return Update2(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
-}
-
-}}
diff --git a/7zip/Archive/7z/DllExports.cpp b/7zip/Archive/7z/DllExports.cpp
deleted file mode 100755
index c8d31b3b..00000000
--- a/7zip/Archive/7z/DllExports.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "../../../Common/MyInitGuid.h"
-#include "../../../Common/ComTry.h"
-#ifdef _WIN32
-#include "../../../Common/Alloc.h"
-#endif
-
-#include "../../ICoder.h"
-
-#include "7zHandler.h"
-
-#ifndef EXCLUDE_COM
-// {23170F69-40C1-278B-06F1-070100000100}
-DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
-0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00);
-#else
-#include "../../Compress/LZ/IMatchFinder.h"
-#endif
-
-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
- #ifdef _WIN32
- SetLargePageSize();
- #endif
- }
- return TRUE;
-}
-
-
-STDAPI CreateObject(
- const GUID *classID,
- const GUID *interfaceID,
- void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- if (*classID != NArchive::N7z::CLSID_CFormat7z)
- return CLASS_E_CLASSNOTAVAILABLE;
- if (*interfaceID == IID_IInArchive)
- {
- CMyComPtr<IInArchive> inArchive = new NArchive::N7z::CHandler;
- *outObject = inArchive.Detach();
- }
- #ifndef EXTRACT_ONLY
- else if (*interfaceID == IID_IOutArchive)
- {
- CMyComPtr<IOutArchive> outArchive = new NArchive::N7z::CHandler;
- *outObject = outArchive.Detach();
- }
- #endif
- else
- return E_NOINTERFACE;
- COM_TRY_END
- return S_OK;
-}
-
-STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
-{
- NWindows::NCOM::CPropVariant propVariant;
- switch(propID)
- {
- case NArchive::kName:
- propVariant = L"7z";
- break;
- case NArchive::kClassID:
- {
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&NArchive::N7z::CLSID_CFormat7z, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NArchive::kExtension:
- propVariant = L"7z";
- break;
- case NArchive::kUpdate:
- propVariant = true;
- break;
- case NArchive::kKeepName:
- propVariant = false;
- break;
- case NArchive::kStartSignature:
- {
- if ((value->bstrVal = ::SysAllocStringByteLen((const char *)NArchive::N7z::kSignature,
- NArchive::N7z::kSignatureSize)) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- }
- propVariant.Detach(value);
- return S_OK;
-}
diff --git a/7zip/Archive/7z_C/7zAlloc.h b/7zip/Archive/7z_C/7zAlloc.h
deleted file mode 100755
index 4ca4170c..00000000
--- a/7zip/Archive/7z_C/7zAlloc.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* 7zAlloc.h */
-
-#ifndef __7Z_ALLOC_H
-#define __7Z_ALLOC_H
-
-#include <stddef.h>
-
-typedef struct _ISzAlloc
-{
- void *(*Alloc)(size_t size);
- void (*Free)(void *address); /* address can be 0 */
-} ISzAlloc;
-
-void *SzAlloc(size_t size);
-void SzFree(void *address);
-
-void *SzAllocTemp(size_t size);
-void SzFreeTemp(void *address);
-
-#endif
diff --git a/7zip/Archive/7z_C/7zBuffer.h b/7zip/Archive/7z_C/7zBuffer.h
deleted file mode 100755
index 17e59060..00000000
--- a/7zip/Archive/7z_C/7zBuffer.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* 7zBuffer.h */
-
-#ifndef __7Z_BUFFER_H
-#define __7Z_BUFFER_H
-
-#include <stddef.h>
-#include "7zTypes.h"
-
-typedef struct _CSzByteBuffer
-{
- size_t Capacity;
- Byte *Items;
-}CSzByteBuffer;
-
-void SzByteBufferInit(CSzByteBuffer *buffer);
-int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size));
-void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *));
-
-#endif
diff --git a/7zip/Archive/7z_C/7zCrc.c b/7zip/Archive/7z_C/7zCrc.c
deleted file mode 100755
index 97738404..00000000
--- a/7zip/Archive/7z_C/7zCrc.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* 7zCrc.c */
-
-#include "7zCrc.h"
-
-#define kCrcPoly 0xEDB88320
-
-UInt32 g_CrcTable[256];
-
-void InitCrcTable()
-{
- UInt32 i;
- for (i = 0; i < 256; i++)
- {
- UInt32 r = i;
- int j;
- for (j = 0; j < 8; j++)
- if (r & 1)
- r = (r >> 1) ^ kCrcPoly;
- else
- r >>= 1;
- g_CrcTable[i] = r;
- }
-}
-
-void CrcInit(UInt32 *crc) { *crc = 0xFFFFFFFF; }
-UInt32 CrcGetDigest(UInt32 *crc) { return *crc ^ 0xFFFFFFFF; }
-
-void CrcUpdateByte(UInt32 *crc, Byte b)
-{
- *crc = g_CrcTable[((Byte)(*crc)) ^ b] ^ (*crc >> 8);
-}
-
-void CrcUpdateUInt16(UInt32 *crc, UInt16 v)
-{
- CrcUpdateByte(crc, (Byte)v);
- CrcUpdateByte(crc, (Byte)(v >> 8));
-}
-
-void CrcUpdateUInt32(UInt32 *crc, UInt32 v)
-{
- int i;
- for (i = 0; i < 4; i++)
- CrcUpdateByte(crc, (Byte)(v >> (8 * i)));
-}
-
-void CrcUpdateUInt64(UInt32 *crc, UInt64 v)
-{
- int i;
- for (i = 0; i < 8; i++)
- {
- CrcUpdateByte(crc, (Byte)(v));
- v >>= 8;
- }
-}
-
-void CrcUpdate(UInt32 *crc, const void *data, size_t size)
-{
- UInt32 v = *crc;
- const Byte *p = (const Byte *)data;
- for (; size > 0 ; size--, p++)
- v = g_CrcTable[((Byte)(v)) ^ *p] ^ (v >> 8);
- *crc = v;
-}
-
-UInt32 CrcCalculateDigest(const void *data, size_t size)
-{
- UInt32 crc;
- CrcInit(&crc);
- CrcUpdate(&crc, data, size);
- return CrcGetDigest(&crc);
-}
-
-int CrcVerifyDigest(UInt32 digest, const void *data, size_t size)
-{
- return (CrcCalculateDigest(data, size) == digest);
-}
diff --git a/7zip/Archive/7z_C/7zCrc.h b/7zip/Archive/7z_C/7zCrc.h
deleted file mode 100755
index adcc563a..00000000
--- a/7zip/Archive/7z_C/7zCrc.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* 7zCrc.h */
-
-#ifndef __7Z_CRC_H
-#define __7Z_CRC_H
-
-#include <stddef.h>
-
-#include "7zTypes.h"
-
-extern UInt32 g_CrcTable[256];
-void InitCrcTable();
-
-void CrcInit(UInt32 *crc);
-UInt32 CrcGetDigest(UInt32 *crc);
-void CrcUpdateByte(UInt32 *crc, Byte v);
-void CrcUpdateUInt16(UInt32 *crc, UInt16 v);
-void CrcUpdateUInt32(UInt32 *crc, UInt32 v);
-void CrcUpdateUInt64(UInt32 *crc, UInt64 v);
-void CrcUpdate(UInt32 *crc, const void *data, size_t size);
-
-UInt32 CrcCalculateDigest(const void *data, size_t size);
-int CrcVerifyDigest(UInt32 digest, const void *data, size_t size);
-
-#endif
diff --git a/7zip/Archive/7z_C/7zDecode.c b/7zip/Archive/7z_C/7zDecode.c
deleted file mode 100755
index b42ff927..00000000
--- a/7zip/Archive/7z_C/7zDecode.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/* 7zDecode.c */
-
-#include "7zDecode.h"
-#ifdef _SZ_ONE_DIRECTORY
-#include "LzmaDecode.h"
-#else
-#include "../../Compress/LZMA_C/LzmaDecode.h"
-#endif
-
-CMethodID k_Copy = { { 0x0 }, 1 };
-CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
-
-#ifdef _LZMA_IN_CB
-
-typedef struct _CLzmaInCallbackImp
-{
- ILzmaInCallback InCallback;
- ISzInStream *InStream;
- size_t Size;
-} CLzmaInCallbackImp;
-
-int LzmaReadImp(void *object, const unsigned char **buffer, SizeT *size)
-{
- CLzmaInCallbackImp *cb = (CLzmaInCallbackImp *)object;
- size_t processedSize;
- SZ_RESULT res;
- *size = 0;
- res = cb->InStream->Read((void *)cb->InStream, (void **)buffer, cb->Size, &processedSize);
- *size = (SizeT)processedSize;
- if (processedSize > cb->Size)
- return (int)SZE_FAIL;
- cb->Size -= processedSize;
- if (res == SZ_OK)
- return 0;
- return (int)res;
-}
-
-#endif
-
-SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder,
- #ifdef _LZMA_IN_CB
- ISzInStream *inStream,
- #else
- const Byte *inBuffer,
- #endif
- Byte *outBuffer, size_t outSize,
- size_t *outSizeProcessed, ISzAlloc *allocMain)
-{
- UInt32 si;
- size_t inSize = 0;
- CCoderInfo *coder;
- if (folder->NumPackStreams != 1)
- return SZE_NOTIMPL;
- if (folder->NumCoders != 1)
- return SZE_NOTIMPL;
- coder = folder->Coders;
- *outSizeProcessed = 0;
-
- for (si = 0; si < folder->NumPackStreams; si++)
- inSize += (size_t)packSizes[si];
-
- if (AreMethodsEqual(&coder->MethodID, &k_Copy))
- {
- size_t i;
- if (inSize != outSize)
- return SZE_DATA_ERROR;
- #ifdef _LZMA_IN_CB
- for (i = 0; i < inSize;)
- {
- size_t j;
- Byte *inBuffer;
- size_t bufferSize;
- RINOK(inStream->Read((void *)inStream, (void **)&inBuffer, inSize - i, &bufferSize));
- if (bufferSize == 0)
- return SZE_DATA_ERROR;
- if (bufferSize > inSize - i)
- return SZE_FAIL;
- *outSizeProcessed += bufferSize;
- for (j = 0; j < bufferSize && i < inSize; j++, i++)
- outBuffer[i] = inBuffer[j];
- }
- #else
- for (i = 0; i < inSize; i++)
- outBuffer[i] = inBuffer[i];
- *outSizeProcessed = inSize;
- #endif
- return SZ_OK;
- }
-
- if (AreMethodsEqual(&coder->MethodID, &k_LZMA))
- {
- #ifdef _LZMA_IN_CB
- CLzmaInCallbackImp lzmaCallback;
- #else
- SizeT inProcessed;
- #endif
-
- CLzmaDecoderState state; /* it's about 24-80 bytes structure, if int is 32-bit */
- int result;
- SizeT outSizeProcessedLoc;
-
- #ifdef _LZMA_IN_CB
- lzmaCallback.Size = inSize;
- lzmaCallback.InStream = inStream;
- lzmaCallback.InCallback.Read = LzmaReadImp;
- #endif
-
- if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items,
- coder->Properties.Capacity) != LZMA_RESULT_OK)
- return SZE_FAIL;
-
- state.Probs = (CProb *)allocMain->Alloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
- if (state.Probs == 0)
- return SZE_OUTOFMEMORY;
-
- #ifdef _LZMA_OUT_READ
- if (state.Properties.DictionarySize == 0)
- state.Dictionary = 0;
- else
- {
- state.Dictionary = (unsigned char *)allocMain->Alloc(state.Properties.DictionarySize);
- if (state.Dictionary == 0)
- {
- allocMain->Free(state.Probs);
- return SZE_OUTOFMEMORY;
- }
- }
- LzmaDecoderInit(&state);
- #endif
-
- result = LzmaDecode(&state,
- #ifdef _LZMA_IN_CB
- &lzmaCallback.InCallback,
- #else
- inBuffer, (SizeT)inSize, &inProcessed,
- #endif
- outBuffer, (SizeT)outSize, &outSizeProcessedLoc);
- *outSizeProcessed = (size_t)outSizeProcessedLoc;
- allocMain->Free(state.Probs);
- #ifdef _LZMA_OUT_READ
- allocMain->Free(state.Dictionary);
- #endif
- if (result == LZMA_RESULT_DATA_ERROR)
- return SZE_DATA_ERROR;
- if (result != LZMA_RESULT_OK)
- return SZE_FAIL;
- return SZ_OK;
- }
- return SZE_NOTIMPL;
-}
diff --git a/7zip/Archive/7z_C/7zDecode.h b/7zip/Archive/7z_C/7zDecode.h
deleted file mode 100755
index 74bb180f..00000000
--- a/7zip/Archive/7z_C/7zDecode.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* 7zDecode.h */
-
-#ifndef __7Z_DECODE_H
-#define __7Z_DECODE_H
-
-#include "7zItem.h"
-#include "7zAlloc.h"
-#ifdef _LZMA_IN_CB
-#include "7zIn.h"
-#endif
-
-SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder,
- #ifdef _LZMA_IN_CB
- ISzInStream *stream,
- #else
- const Byte *inBuffer,
- #endif
- Byte *outBuffer, size_t outSize,
- size_t *outSizeProcessed, ISzAlloc *allocMain);
-
-#endif
diff --git a/7zip/Archive/7z_C/7zExtract.c b/7zip/Archive/7z_C/7zExtract.c
deleted file mode 100755
index aa75659b..00000000
--- a/7zip/Archive/7z_C/7zExtract.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* 7zExtract.c */
-
-#include "7zExtract.h"
-#include "7zDecode.h"
-#include "7zCrc.h"
-
-SZ_RESULT SzExtract(
- ISzInStream *inStream,
- CArchiveDatabaseEx *db,
- UInt32 fileIndex,
- UInt32 *blockIndex,
- Byte **outBuffer,
- size_t *outBufferSize,
- size_t *offset,
- size_t *outSizeProcessed,
- ISzAlloc *allocMain,
- ISzAlloc *allocTemp)
-{
- UInt32 folderIndex = db->FileIndexToFolderIndexMap[fileIndex];
- SZ_RESULT res = SZ_OK;
- *offset = 0;
- *outSizeProcessed = 0;
- if (folderIndex == (UInt32)-1)
- {
- allocMain->Free(*outBuffer);
- *blockIndex = folderIndex;
- *outBuffer = 0;
- *outBufferSize = 0;
- return SZ_OK;
- }
-
- if (*outBuffer == 0 || *blockIndex != folderIndex)
- {
- CFolder *folder = db->Database.Folders + folderIndex;
- CFileSize unPackSize = SzFolderGetUnPackSize(folder);
- #ifndef _LZMA_IN_CB
- CFileSize packSize = SzArDbGetFolderFullPackSize(db, folderIndex);
- Byte *inBuffer = 0;
- size_t processedSize;
- #endif
- if (unPackSize != (size_t)unPackSize)
- return SZE_OUTOFMEMORY;
- *blockIndex = folderIndex;
- allocMain->Free(*outBuffer);
- *outBuffer = 0;
-
- RINOK(inStream->Seek(inStream, SzArDbGetFolderStreamPos(db, folderIndex, 0)));
-
- #ifndef _LZMA_IN_CB
- if (packSize != 0)
- {
- inBuffer = (Byte *)allocTemp->Alloc((size_t)packSize);
- if (inBuffer == 0)
- return SZE_OUTOFMEMORY;
- }
- res = inStream->Read(inStream, inBuffer, (size_t)packSize, &processedSize);
- if (res == SZ_OK && processedSize != (size_t)packSize)
- res = SZE_FAIL;
- #endif
- if (res == SZ_OK)
- {
- *outBufferSize = (size_t)unPackSize;
- if (unPackSize != 0)
- {
- *outBuffer = (Byte *)allocMain->Alloc((size_t)unPackSize);
- if (*outBuffer == 0)
- res = SZE_OUTOFMEMORY;
- }
- if (res == SZ_OK)
- {
- size_t outRealSize;
- res = SzDecode(db->Database.PackSizes +
- db->FolderStartPackStreamIndex[folderIndex], folder,
- #ifdef _LZMA_IN_CB
- inStream,
- #else
- inBuffer,
- #endif
- *outBuffer, (size_t)unPackSize, &outRealSize, allocTemp);
- if (res == SZ_OK)
- {
- if (outRealSize == (size_t)unPackSize)
- {
- if (folder->UnPackCRCDefined)
- {
- if (!CrcVerifyDigest(folder->UnPackCRC, *outBuffer, (size_t)unPackSize))
- res = SZE_FAIL;
- }
- }
- else
- res = SZE_FAIL;
- }
- }
- }
- #ifndef _LZMA_IN_CB
- allocTemp->Free(inBuffer);
- #endif
- }
- if (res == SZ_OK)
- {
- UInt32 i;
- CFileItem *fileItem = db->Database.Files + fileIndex;
- *offset = 0;
- for(i = db->FolderStartFileIndex[folderIndex]; i < fileIndex; i++)
- *offset += (UInt32)db->Database.Files[i].Size;
- *outSizeProcessed = (size_t)fileItem->Size;
- if (*offset + *outSizeProcessed > *outBufferSize)
- return SZE_FAIL;
- {
- if (fileItem->IsFileCRCDefined)
- {
- if (!CrcVerifyDigest(fileItem->FileCRC, *outBuffer + *offset, *outSizeProcessed))
- res = SZE_FAIL;
- }
- }
- }
- return res;
-}
diff --git a/7zip/Archive/7z_C/7zExtract.h b/7zip/Archive/7z_C/7zExtract.h
deleted file mode 100755
index e9a4fb4e..00000000
--- a/7zip/Archive/7z_C/7zExtract.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* 7zExtract.h */
-
-#ifndef __7Z_EXTRACT_H
-#define __7Z_EXTRACT_H
-
-#include "7zIn.h"
-
-/*
- SzExtract extracts file from archive
-
- *outBuffer must be 0 before first call for each new archive.
-
- Extracting cache:
- If you need to decompress more than one file, you can send
- these values from previous call:
- *blockIndex,
- *outBuffer,
- *outBufferSize
- You can consider "*outBuffer" as cache of solid block. If your archive is solid,
- it will increase decompression speed.
-
- If you use external function, you can declare these 3 cache variables
- (blockIndex, outBuffer, outBufferSize) as static in that external function.
-
- Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
-*/
-
-SZ_RESULT SzExtract(
- ISzInStream *inStream,
- CArchiveDatabaseEx *db,
- UInt32 fileIndex, /* index of file */
- UInt32 *blockIndex, /* index of solid block */
- Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
- size_t *outBufferSize, /* buffer size for output buffer */
- size_t *offset, /* offset of stream for required file in *outBuffer */
- size_t *outSizeProcessed, /* size of file in *outBuffer */
- ISzAlloc *allocMain,
- ISzAlloc *allocTemp);
-
-#endif
diff --git a/7zip/Archive/7z_C/7zHeader.h b/7zip/Archive/7z_C/7zHeader.h
deleted file mode 100755
index 0356aaa6..00000000
--- a/7zip/Archive/7z_C/7zHeader.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* 7zHeader.h */
-
-#ifndef __7Z_HEADER_H
-#define __7Z_HEADER_H
-
-#include "7zTypes.h"
-
-#define k7zSignatureSize 6
-extern Byte k7zSignature[k7zSignatureSize];
-
-#define k7zMajorVersion 0
-
-#define k7zStartHeaderSize 0x20
-
-enum EIdEnum
-{
- k7zIdEnd,
-
- k7zIdHeader,
-
- k7zIdArchiveProperties,
-
- k7zIdAdditionalStreamsInfo,
- k7zIdMainStreamsInfo,
- k7zIdFilesInfo,
-
- k7zIdPackInfo,
- k7zIdUnPackInfo,
- k7zIdSubStreamsInfo,
-
- k7zIdSize,
- k7zIdCRC,
-
- k7zIdFolder,
-
- k7zIdCodersUnPackSize,
- k7zIdNumUnPackStream,
-
- k7zIdEmptyStream,
- k7zIdEmptyFile,
- k7zIdAnti,
-
- k7zIdName,
- k7zIdCreationTime,
- k7zIdLastAccessTime,
- k7zIdLastWriteTime,
- k7zIdWinAttributes,
- k7zIdComment,
-
- k7zIdEncodedHeader,
-
- k7zIdStartPos
-};
-
-#endif
diff --git a/7zip/Archive/7z_C/7zIn.c b/7zip/Archive/7z_C/7zIn.c
deleted file mode 100755
index 0b9d9bd7..00000000
--- a/7zip/Archive/7z_C/7zIn.c
+++ /dev/null
@@ -1,1282 +0,0 @@
-/* 7zIn.c */
-
-#include "7zIn.h"
-#include "7zCrc.h"
-#include "7zDecode.h"
-
-#define RINOM(x) { if((x) == 0) return SZE_OUTOFMEMORY; }
-
-void SzArDbExInit(CArchiveDatabaseEx *db)
-{
- SzArchiveDatabaseInit(&db->Database);
- db->FolderStartPackStreamIndex = 0;
- db->PackStreamStartPositions = 0;
- db->FolderStartFileIndex = 0;
- db->FileIndexToFolderIndexMap = 0;
-}
-
-void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *))
-{
- freeFunc(db->FolderStartPackStreamIndex);
- freeFunc(db->PackStreamStartPositions);
- freeFunc(db->FolderStartFileIndex);
- freeFunc(db->FileIndexToFolderIndexMap);
- SzArchiveDatabaseFree(&db->Database, freeFunc);
- SzArDbExInit(db);
-}
-
-/*
-CFileSize GetFolderPackStreamSize(int folderIndex, int streamIndex) const
-{
- return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex];
-}
-
-CFileSize GetFilePackSize(int fileIndex) const
-{
- int folderIndex = FileIndexToFolderIndexMap[fileIndex];
- if (folderIndex >= 0)
- {
- const CFolder &folderInfo = Folders[folderIndex];
- if (FolderStartFileIndex[folderIndex] == fileIndex)
- return GetFolderFullPackSize(folderIndex);
- }
- return 0;
-}
-*/
-
-#define MY_ALLOC(T, p, size, allocFunc) { if ((size) == 0) p = 0; else \
- if ((p = (T *)allocFunc((size) * sizeof(T))) == 0) return SZE_OUTOFMEMORY; }
-
-SZ_RESULT SzArDbExFill(CArchiveDatabaseEx *db, void * (*allocFunc)(size_t size))
-{
- UInt32 startPos = 0;
- CFileSize startPosSize = 0;
- UInt32 i;
- UInt32 folderIndex = 0;
- UInt32 indexInFolder = 0;
- MY_ALLOC(UInt32, db->FolderStartPackStreamIndex, db->Database.NumFolders, allocFunc);
- for(i = 0; i < db->Database.NumFolders; i++)
- {
- db->FolderStartPackStreamIndex[i] = startPos;
- startPos += db->Database.Folders[i].NumPackStreams;
- }
-
- MY_ALLOC(CFileSize, db->PackStreamStartPositions, db->Database.NumPackStreams, allocFunc);
-
- for(i = 0; i < db->Database.NumPackStreams; i++)
- {
- db->PackStreamStartPositions[i] = startPosSize;
- startPosSize += db->Database.PackSizes[i];
- }
-
- MY_ALLOC(UInt32, db->FolderStartFileIndex, db->Database.NumFolders, allocFunc);
- MY_ALLOC(UInt32, db->FileIndexToFolderIndexMap, db->Database.NumFiles, allocFunc);
-
- for (i = 0; i < db->Database.NumFiles; i++)
- {
- CFileItem *file = db->Database.Files + i;
- int emptyStream = !file->HasStream;
- if (emptyStream && indexInFolder == 0)
- {
- db->FileIndexToFolderIndexMap[i] = (UInt32)-1;
- continue;
- }
- if (indexInFolder == 0)
- {
- /*
- v3.13 incorrectly worked with empty folders
- v4.07: Loop for skipping empty folders
- */
- for (;;)
- {
- if (folderIndex >= db->Database.NumFolders)
- return SZE_ARCHIVE_ERROR;
- db->FolderStartFileIndex[folderIndex] = i;
- if (db->Database.Folders[folderIndex].NumUnPackStreams != 0)
- break;
- folderIndex++;
- }
- }
- db->FileIndexToFolderIndexMap[i] = folderIndex;
- if (emptyStream)
- continue;
- indexInFolder++;
- if (indexInFolder >= db->Database.Folders[folderIndex].NumUnPackStreams)
- {
- folderIndex++;
- indexInFolder = 0;
- }
- }
- return SZ_OK;
-}
-
-
-CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder)
-{
- return db->ArchiveInfo.DataStartPosition +
- db->PackStreamStartPositions[db->FolderStartPackStreamIndex[folderIndex] + indexInFolder];
-}
-
-CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex)
-{
- UInt32 packStreamIndex = db->FolderStartPackStreamIndex[folderIndex];
- CFolder *folder = db->Database.Folders + folderIndex;
- CFileSize size = 0;
- UInt32 i;
- for (i = 0; i < folder->NumPackStreams; i++)
- size += db->Database.PackSizes[packStreamIndex + i];
- return size;
-}
-
-
-/*
-SZ_RESULT SzReadTime(const CObjectVector<CSzByteBuffer> &dataVector,
- CObjectVector<CFileItem> &files, UInt64 type)
-{
- CBoolVector boolVector;
- RINOK(ReadBoolVector2(files.Size(), boolVector))
-
- CStreamSwitch streamSwitch;
- RINOK(streamSwitch.Set(this, &dataVector));
-
- for(int i = 0; i < files.Size(); i++)
- {
- CFileItem &file = files[i];
- CArchiveFileTime fileTime;
- bool defined = boolVector[i];
- if (defined)
- {
- UInt32 low, high;
- RINOK(SzReadUInt32(low));
- RINOK(SzReadUInt32(high));
- fileTime.dwLowDateTime = low;
- fileTime.dwHighDateTime = high;
- }
- switch(type)
- {
- case k7zIdCreationTime:
- file.IsCreationTimeDefined = defined;
- if (defined)
- file.CreationTime = fileTime;
- break;
- case k7zIdLastWriteTime:
- file.IsLastWriteTimeDefined = defined;
- if (defined)
- file.LastWriteTime = fileTime;
- break;
- case k7zIdLastAccessTime:
- file.IsLastAccessTimeDefined = defined;
- if (defined)
- file.LastAccessTime = fileTime;
- break;
- }
- }
- return SZ_OK;
-}
-*/
-
-SZ_RESULT SafeReadDirect(ISzInStream *inStream, Byte *data, size_t size)
-{
- #ifdef _LZMA_IN_CB
- while (size > 0)
- {
- Byte *inBuffer;
- size_t processedSize;
- RINOK(inStream->Read(inStream, (void **)&inBuffer, size, &processedSize));
- if (processedSize == 0 || processedSize > size)
- return SZE_FAIL;
- size -= processedSize;
- do
- {
- *data++ = *inBuffer++;
- }
- while (--processedSize != 0);
- }
- #else
- size_t processedSize;
- RINOK(inStream->Read(inStream, data, size, &processedSize));
- if (processedSize != size)
- return SZE_FAIL;
- #endif
- return SZ_OK;
-}
-
-SZ_RESULT SafeReadDirectByte(ISzInStream *inStream, Byte *data)
-{
- return SafeReadDirect(inStream, data, 1);
-}
-
-SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value)
-{
- int i;
- *value = 0;
- for (i = 0; i < 4; i++)
- {
- Byte b;
- RINOK(SafeReadDirectByte(inStream, &b));
- *value |= ((UInt32)b << (8 * i));
- }
- return SZ_OK;
-}
-
-SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value)
-{
- int i;
- *value = 0;
- for (i = 0; i < 8; i++)
- {
- Byte b;
- RINOK(SafeReadDirectByte(inStream, &b));
- *value |= ((UInt64)b << (8 * i));
- }
- return SZ_OK;
-}
-
-int TestSignatureCandidate(Byte *testBytes)
-{
- size_t i;
- for (i = 0; i < k7zSignatureSize; i++)
- if (testBytes[i] != k7zSignature[i])
- return 0;
- return 1;
-}
-
-typedef struct _CSzState
-{
- Byte *Data;
- size_t Size;
-}CSzData;
-
-SZ_RESULT SzReadByte(CSzData *sd, Byte *b)
-{
- if (sd->Size == 0)
- return SZE_ARCHIVE_ERROR;
- sd->Size--;
- *b = *sd->Data++;
- return SZ_OK;
-}
-
-SZ_RESULT SzReadBytes(CSzData *sd, Byte *data, size_t size)
-{
- size_t i;
- for (i = 0; i < size; i++)
- {
- RINOK(SzReadByte(sd, data + i));
- }
- return SZ_OK;
-}
-
-SZ_RESULT SzReadUInt32(CSzData *sd, UInt32 *value)
-{
- int i;
- *value = 0;
- for (i = 0; i < 4; i++)
- {
- Byte b;
- RINOK(SzReadByte(sd, &b));
- *value |= ((UInt32)(b) << (8 * i));
- }
- return SZ_OK;
-}
-
-SZ_RESULT SzReadNumber(CSzData *sd, UInt64 *value)
-{
- Byte firstByte;
- Byte mask = 0x80;
- int i;
- RINOK(SzReadByte(sd, &firstByte));
- *value = 0;
- for (i = 0; i < 8; i++)
- {
- Byte b;
- if ((firstByte & mask) == 0)
- {
- UInt64 highPart = firstByte & (mask - 1);
- *value += (highPart << (8 * i));
- return SZ_OK;
- }
- RINOK(SzReadByte(sd, &b));
- *value |= ((UInt64)b << (8 * i));
- mask >>= 1;
- }
- return SZ_OK;
-}
-
-SZ_RESULT SzReadSize(CSzData *sd, CFileSize *value)
-{
- UInt64 value64;
- RINOK(SzReadNumber(sd, &value64));
- *value = (CFileSize)value64;
- return SZ_OK;
-}
-
-SZ_RESULT SzReadNumber32(CSzData *sd, UInt32 *value)
-{
- UInt64 value64;
- RINOK(SzReadNumber(sd, &value64));
- if (value64 >= 0x80000000)
- return SZE_NOTIMPL;
- if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 2)))
- return SZE_NOTIMPL;
- *value = (UInt32)value64;
- return SZ_OK;
-}
-
-SZ_RESULT SzReadID(CSzData *sd, UInt64 *value)
-{
- return SzReadNumber(sd, value);
-}
-
-SZ_RESULT SzSkeepDataSize(CSzData *sd, UInt64 size)
-{
- if (size > sd->Size)
- return SZE_ARCHIVE_ERROR;
- sd->Size -= (size_t)size;
- sd->Data += (size_t)size;
- return SZ_OK;
-}
-
-SZ_RESULT SzSkeepData(CSzData *sd)
-{
- UInt64 size;
- RINOK(SzReadNumber(sd, &size));
- return SzSkeepDataSize(sd, size);
-}
-
-SZ_RESULT SzReadArchiveProperties(CSzData *sd)
-{
- for (;;)
- {
- UInt64 type;
- RINOK(SzReadID(sd, &type));
- if (type == k7zIdEnd)
- break;
- SzSkeepData(sd);
- }
- return SZ_OK;
-}
-
-SZ_RESULT SzWaitAttribute(CSzData *sd, UInt64 attribute)
-{
- for (;;)
- {
- UInt64 type;
- RINOK(SzReadID(sd, &type));
- if (type == attribute)
- return SZ_OK;
- if (type == k7zIdEnd)
- return SZE_ARCHIVE_ERROR;
- RINOK(SzSkeepData(sd));
- }
-}
-
-SZ_RESULT SzReadBoolVector(CSzData *sd, size_t numItems, Byte **v, void * (*allocFunc)(size_t size))
-{
- Byte b = 0;
- Byte mask = 0;
- size_t i;
- MY_ALLOC(Byte, *v, numItems, allocFunc);
- for (i = 0; i < numItems; i++)
- {
- if (mask == 0)
- {
- RINOK(SzReadByte(sd, &b));
- mask = 0x80;
- }
- (*v)[i] = (Byte)(((b & mask) != 0) ? 1 : 0);
- mask >>= 1;
- }
- return SZ_OK;
-}
-
-SZ_RESULT SzReadBoolVector2(CSzData *sd, size_t numItems, Byte **v, void * (*allocFunc)(size_t size))
-{
- Byte allAreDefined;
- size_t i;
- RINOK(SzReadByte(sd, &allAreDefined));
- if (allAreDefined == 0)
- return SzReadBoolVector(sd, numItems, v, allocFunc);
- MY_ALLOC(Byte, *v, numItems, allocFunc);
- for(i = 0; i < numItems; i++)
- (*v)[i] = 1;
- return SZ_OK;
-}
-
-SZ_RESULT SzReadHashDigests(
- CSzData *sd,
- size_t numItems,
- Byte **digestsDefined,
- UInt32 **digests,
- void * (*allocFunc)(size_t size))
-{
- size_t i;
- RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, allocFunc));
- MY_ALLOC(UInt32, *digests, numItems, allocFunc);
- for(i = 0; i < numItems; i++)
- if ((*digestsDefined)[i])
- {
- RINOK(SzReadUInt32(sd, (*digests) + i));
- }
- return SZ_OK;
-}
-
-SZ_RESULT SzReadPackInfo(
- CSzData *sd,
- CFileSize *dataOffset,
- UInt32 *numPackStreams,
- CFileSize **packSizes,
- Byte **packCRCsDefined,
- UInt32 **packCRCs,
- void * (*allocFunc)(size_t size))
-{
- UInt32 i;
- RINOK(SzReadSize(sd, dataOffset));
- RINOK(SzReadNumber32(sd, numPackStreams));
-
- RINOK(SzWaitAttribute(sd, k7zIdSize));
-
- MY_ALLOC(CFileSize, *packSizes, (size_t)*numPackStreams, allocFunc);
-
- for(i = 0; i < *numPackStreams; i++)
- {
- RINOK(SzReadSize(sd, (*packSizes) + i));
- }
-
- for (;;)
- {
- UInt64 type;
- RINOK(SzReadID(sd, &type));
- if (type == k7zIdEnd)
- break;
- if (type == k7zIdCRC)
- {
- RINOK(SzReadHashDigests(sd, (size_t)*numPackStreams, packCRCsDefined, packCRCs, allocFunc));
- continue;
- }
- RINOK(SzSkeepData(sd));
- }
- if (*packCRCsDefined == 0)
- {
- MY_ALLOC(Byte, *packCRCsDefined, (size_t)*numPackStreams, allocFunc);
- MY_ALLOC(UInt32, *packCRCs, (size_t)*numPackStreams, allocFunc);
- for(i = 0; i < *numPackStreams; i++)
- {
- (*packCRCsDefined)[i] = 0;
- (*packCRCs)[i] = 0;
- }
- }
- return SZ_OK;
-}
-
-SZ_RESULT SzReadSwitch(CSzData *sd)
-{
- Byte external;
- RINOK(SzReadByte(sd, &external));
- return (external == 0) ? SZ_OK: SZE_ARCHIVE_ERROR;
-}
-
-SZ_RESULT SzGetNextFolderItem(CSzData *sd, CFolder *folder, void * (*allocFunc)(size_t size))
-{
- UInt32 numCoders;
- UInt32 numBindPairs;
- UInt32 numPackedStreams;
- UInt32 i;
- UInt32 numInStreams = 0;
- UInt32 numOutStreams = 0;
- RINOK(SzReadNumber32(sd, &numCoders));
- folder->NumCoders = numCoders;
-
- MY_ALLOC(CCoderInfo, folder->Coders, (size_t)numCoders, allocFunc);
-
- for (i = 0; i < numCoders; i++)
- SzCoderInfoInit(folder->Coders + i);
-
- for (i = 0; i < numCoders; i++)
- {
- Byte mainByte;
- CCoderInfo *coder = folder->Coders + i;
- {
- RINOK(SzReadByte(sd, &mainByte));
- coder->MethodID.IDSize = (Byte)(mainByte & 0xF);
- RINOK(SzReadBytes(sd, coder->MethodID.ID, coder->MethodID.IDSize));
- if ((mainByte & 0x10) != 0)
- {
- RINOK(SzReadNumber32(sd, &coder->NumInStreams));
- RINOK(SzReadNumber32(sd, &coder->NumOutStreams));
- }
- else
- {
- coder->NumInStreams = 1;
- coder->NumOutStreams = 1;
- }
- if ((mainByte & 0x20) != 0)
- {
- UInt64 propertiesSize = 0;
- RINOK(SzReadNumber(sd, &propertiesSize));
- if (!SzByteBufferCreate(&coder->Properties, (size_t)propertiesSize, allocFunc))
- return SZE_OUTOFMEMORY;
- RINOK(SzReadBytes(sd, coder->Properties.Items, (size_t)propertiesSize));
- }
- }
- while ((mainByte & 0x80) != 0)
- {
- RINOK(SzReadByte(sd, &mainByte));
- RINOK(SzSkeepDataSize(sd, (mainByte & 0xF)));
- if ((mainByte & 0x10) != 0)
- {
- UInt32 n;
- RINOK(SzReadNumber32(sd, &n));
- RINOK(SzReadNumber32(sd, &n));
- }
- if ((mainByte & 0x20) != 0)
- {
- UInt64 propertiesSize = 0;
- RINOK(SzReadNumber(sd, &propertiesSize));
- RINOK(SzSkeepDataSize(sd, propertiesSize));
- }
- }
- numInStreams += (UInt32)coder->NumInStreams;
- numOutStreams += (UInt32)coder->NumOutStreams;
- }
-
- numBindPairs = numOutStreams - 1;
- folder->NumBindPairs = numBindPairs;
-
-
- MY_ALLOC(CBindPair, folder->BindPairs, (size_t)numBindPairs, allocFunc);
-
- for (i = 0; i < numBindPairs; i++)
- {
- CBindPair *bindPair = folder->BindPairs + i;;
- RINOK(SzReadNumber32(sd, &bindPair->InIndex));
- RINOK(SzReadNumber32(sd, &bindPair->OutIndex));
- }
-
- numPackedStreams = numInStreams - (UInt32)numBindPairs;
-
- folder->NumPackStreams = numPackedStreams;
- MY_ALLOC(UInt32, folder->PackStreams, (size_t)numPackedStreams, allocFunc);
-
- if (numPackedStreams == 1)
- {
- UInt32 j;
- UInt32 pi = 0;
- for (j = 0; j < numInStreams; j++)
- if (SzFolderFindBindPairForInStream(folder, j) < 0)
- {
- folder->PackStreams[pi++] = j;
- break;
- }
- }
- else
- for(i = 0; i < numPackedStreams; i++)
- {
- RINOK(SzReadNumber32(sd, folder->PackStreams + i));
- }
- return SZ_OK;
-}
-
-SZ_RESULT SzReadUnPackInfo(
- CSzData *sd,
- UInt32 *numFolders,
- CFolder **folders, /* for allocFunc */
- void * (*allocFunc)(size_t size),
- ISzAlloc *allocTemp)
-{
- UInt32 i;
- RINOK(SzWaitAttribute(sd, k7zIdFolder));
- RINOK(SzReadNumber32(sd, numFolders));
- {
- RINOK(SzReadSwitch(sd));
-
- MY_ALLOC(CFolder, *folders, (size_t)*numFolders, allocFunc);
-
- for(i = 0; i < *numFolders; i++)
- SzFolderInit((*folders) + i);
-
- for(i = 0; i < *numFolders; i++)
- {
- RINOK(SzGetNextFolderItem(sd, (*folders) + i, allocFunc));
- }
- }
-
- RINOK(SzWaitAttribute(sd, k7zIdCodersUnPackSize));
-
- for(i = 0; i < *numFolders; i++)
- {
- UInt32 j;
- CFolder *folder = (*folders) + i;
- UInt32 numOutStreams = SzFolderGetNumOutStreams(folder);
-
- MY_ALLOC(CFileSize, folder->UnPackSizes, (size_t)numOutStreams, allocFunc);
-
- for(j = 0; j < numOutStreams; j++)
- {
- RINOK(SzReadSize(sd, folder->UnPackSizes + j));
- }
- }
-
- for (;;)
- {
- UInt64 type;
- RINOK(SzReadID(sd, &type));
- if (type == k7zIdEnd)
- return SZ_OK;
- if (type == k7zIdCRC)
- {
- SZ_RESULT res;
- Byte *crcsDefined = 0;
- UInt32 *crcs = 0;
- res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp->Alloc);
- if (res == SZ_OK)
- {
- for(i = 0; i < *numFolders; i++)
- {
- CFolder *folder = (*folders) + i;
- folder->UnPackCRCDefined = crcsDefined[i];
- folder->UnPackCRC = crcs[i];
- }
- }
- allocTemp->Free(crcs);
- allocTemp->Free(crcsDefined);
- RINOK(res);
- continue;
- }
- RINOK(SzSkeepData(sd));
- }
-}
-
-SZ_RESULT SzReadSubStreamsInfo(
- CSzData *sd,
- UInt32 numFolders,
- CFolder *folders,
- UInt32 *numUnPackStreams,
- CFileSize **unPackSizes,
- Byte **digestsDefined,
- UInt32 **digests,
- ISzAlloc *allocTemp)
-{
- UInt64 type = 0;
- UInt32 i;
- UInt32 si = 0;
- UInt32 numDigests = 0;
-
- for(i = 0; i < numFolders; i++)
- folders[i].NumUnPackStreams = 1;
- *numUnPackStreams = numFolders;
-
- for (;;)
- {
- RINOK(SzReadID(sd, &type));
- if (type == k7zIdNumUnPackStream)
- {
- *numUnPackStreams = 0;
- for(i = 0; i < numFolders; i++)
- {
- UInt32 numStreams;
- RINOK(SzReadNumber32(sd, &numStreams));
- folders[i].NumUnPackStreams = numStreams;
- *numUnPackStreams += numStreams;
- }
- continue;
- }
- if (type == k7zIdCRC || type == k7zIdSize)
- break;
- if (type == k7zIdEnd)
- break;
- RINOK(SzSkeepData(sd));
- }
-
- if (*numUnPackStreams == 0)
- {
- *unPackSizes = 0;
- *digestsDefined = 0;
- *digests = 0;
- }
- else
- {
- *unPackSizes = (CFileSize *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(CFileSize));
- RINOM(*unPackSizes);
- *digestsDefined = (Byte *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(Byte));
- RINOM(*digestsDefined);
- *digests = (UInt32 *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(UInt32));
- RINOM(*digests);
- }
-
- for(i = 0; i < numFolders; i++)
- {
- /*
- v3.13 incorrectly worked with empty folders
- v4.07: we check that folder is empty
- */
- CFileSize sum = 0;
- UInt32 j;
- UInt32 numSubstreams = folders[i].NumUnPackStreams;
- if (numSubstreams == 0)
- continue;
- if (type == k7zIdSize)
- for (j = 1; j < numSubstreams; j++)
- {
- CFileSize size;
- RINOK(SzReadSize(sd, &size));
- (*unPackSizes)[si++] = size;
- sum += size;
- }
- (*unPackSizes)[si++] = SzFolderGetUnPackSize(folders + i) - sum;
- }
- if (type == k7zIdSize)
- {
- RINOK(SzReadID(sd, &type));
- }
-
- for(i = 0; i < *numUnPackStreams; i++)
- {
- (*digestsDefined)[i] = 0;
- (*digests)[i] = 0;
- }
-
-
- for(i = 0; i < numFolders; i++)
- {
- UInt32 numSubstreams = folders[i].NumUnPackStreams;
- if (numSubstreams != 1 || !folders[i].UnPackCRCDefined)
- numDigests += numSubstreams;
- }
-
-
- si = 0;
- for (;;)
- {
- if (type == k7zIdCRC)
- {
- int digestIndex = 0;
- Byte *digestsDefined2 = 0;
- UInt32 *digests2 = 0;
- SZ_RESULT res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp->Alloc);
- if (res == SZ_OK)
- {
- for (i = 0; i < numFolders; i++)
- {
- CFolder *folder = folders + i;
- UInt32 numSubstreams = folder->NumUnPackStreams;
- if (numSubstreams == 1 && folder->UnPackCRCDefined)
- {
- (*digestsDefined)[si] = 1;
- (*digests)[si] = folder->UnPackCRC;
- si++;
- }
- else
- {
- UInt32 j;
- for (j = 0; j < numSubstreams; j++, digestIndex++)
- {
- (*digestsDefined)[si] = digestsDefined2[digestIndex];
- (*digests)[si] = digests2[digestIndex];
- si++;
- }
- }
- }
- }
- allocTemp->Free(digestsDefined2);
- allocTemp->Free(digests2);
- RINOK(res);
- }
- else if (type == k7zIdEnd)
- return SZ_OK;
- else
- {
- RINOK(SzSkeepData(sd));
- }
- RINOK(SzReadID(sd, &type));
- }
-}
-
-
-SZ_RESULT SzReadStreamsInfo(
- CSzData *sd,
- CFileSize *dataOffset,
- CArchiveDatabase *db,
- UInt32 *numUnPackStreams,
- CFileSize **unPackSizes, /* allocTemp */
- Byte **digestsDefined, /* allocTemp */
- UInt32 **digests, /* allocTemp */
- void * (*allocFunc)(size_t size),
- ISzAlloc *allocTemp)
-{
- for (;;)
- {
- UInt64 type;
- RINOK(SzReadID(sd, &type));
- if ((UInt64)(int)type != type)
- return SZE_FAIL;
- switch((int)type)
- {
- case k7zIdEnd:
- return SZ_OK;
- case k7zIdPackInfo:
- {
- RINOK(SzReadPackInfo(sd, dataOffset, &db->NumPackStreams,
- &db->PackSizes, &db->PackCRCsDefined, &db->PackCRCs, allocFunc));
- break;
- }
- case k7zIdUnPackInfo:
- {
- RINOK(SzReadUnPackInfo(sd, &db->NumFolders, &db->Folders, allocFunc, allocTemp));
- break;
- }
- case k7zIdSubStreamsInfo:
- {
- RINOK(SzReadSubStreamsInfo(sd, db->NumFolders, db->Folders,
- numUnPackStreams, unPackSizes, digestsDefined, digests, allocTemp));
- break;
- }
- default:
- return SZE_FAIL;
- }
- }
-}
-
-Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-
-SZ_RESULT SzReadFileNames(CSzData *sd, UInt32 numFiles, CFileItem *files,
- void * (*allocFunc)(size_t size))
-{
- UInt32 i;
- for(i = 0; i < numFiles; i++)
- {
- UInt32 len = 0;
- UInt32 pos = 0;
- CFileItem *file = files + i;
- while(pos + 2 <= sd->Size)
- {
- int numAdds;
- UInt32 value = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8));
- pos += 2;
- len++;
- if (value == 0)
- break;
- if (value < 0x80)
- continue;
- if (value >= 0xD800 && value < 0xE000)
- {
- UInt32 c2;
- if (value >= 0xDC00)
- return SZE_ARCHIVE_ERROR;
- if (pos + 2 > sd->Size)
- return SZE_ARCHIVE_ERROR;
- c2 = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8));
- pos += 2;
- if (c2 < 0xDC00 || c2 >= 0xE000)
- return SZE_ARCHIVE_ERROR;
- value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
- }
- for (numAdds = 1; numAdds < 5; numAdds++)
- if (value < (((UInt32)1) << (numAdds * 5 + 6)))
- break;
- len += numAdds;
- }
-
- MY_ALLOC(char, file->Name, (size_t)len, allocFunc);
-
- len = 0;
- while(2 <= sd->Size)
- {
- int numAdds;
- UInt32 value = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8));
- SzSkeepDataSize(sd, 2);
- if (value < 0x80)
- {
- file->Name[len++] = (char)value;
- if (value == 0)
- break;
- continue;
- }
- if (value >= 0xD800 && value < 0xE000)
- {
- UInt32 c2 = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8));
- SzSkeepDataSize(sd, 2);
- value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
- }
- for (numAdds = 1; numAdds < 5; numAdds++)
- if (value < (((UInt32)1) << (numAdds * 5 + 6)))
- break;
- file->Name[len++] = (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds)));
- do
- {
- numAdds--;
- file->Name[len++] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F));
- }
- while(numAdds > 0);
-
- len += numAdds;
- }
- }
- return SZ_OK;
-}
-
-SZ_RESULT SzReadHeader2(
- CSzData *sd,
- CArchiveDatabaseEx *db, /* allocMain */
- CFileSize **unPackSizes, /* allocTemp */
- Byte **digestsDefined, /* allocTemp */
- UInt32 **digests, /* allocTemp */
- Byte **emptyStreamVector, /* allocTemp */
- Byte **emptyFileVector, /* allocTemp */
- ISzAlloc *allocMain,
- ISzAlloc *allocTemp)
-{
- UInt64 type;
- UInt32 numUnPackStreams = 0;
- UInt32 numFiles = 0;
- CFileItem *files = 0;
- UInt32 numEmptyStreams = 0;
- UInt32 i;
-
- RINOK(SzReadID(sd, &type));
-
- if (type == k7zIdArchiveProperties)
- {
- RINOK(SzReadArchiveProperties(sd));
- RINOK(SzReadID(sd, &type));
- }
-
-
- if (type == k7zIdMainStreamsInfo)
- {
- RINOK(SzReadStreamsInfo(sd,
- &db->ArchiveInfo.DataStartPosition,
- &db->Database,
- &numUnPackStreams,
- unPackSizes,
- digestsDefined,
- digests, allocMain->Alloc, allocTemp));
- db->ArchiveInfo.DataStartPosition += db->ArchiveInfo.StartPositionAfterHeader;
- RINOK(SzReadID(sd, &type));
- }
-
- if (type == k7zIdEnd)
- return SZ_OK;
- if (type != k7zIdFilesInfo)
- return SZE_ARCHIVE_ERROR;
-
- RINOK(SzReadNumber32(sd, &numFiles));
- db->Database.NumFiles = numFiles;
-
- MY_ALLOC(CFileItem, files, (size_t)numFiles, allocMain->Alloc);
-
- db->Database.Files = files;
- for(i = 0; i < numFiles; i++)
- SzFileInit(files + i);
-
- for (;;)
- {
- UInt64 type;
- UInt64 size;
- RINOK(SzReadID(sd, &type));
- if (type == k7zIdEnd)
- break;
- RINOK(SzReadNumber(sd, &size));
-
- if ((UInt64)(int)type != type)
- {
- RINOK(SzSkeepDataSize(sd, size));
- }
- else
- switch((int)type)
- {
- case k7zIdName:
- {
- RINOK(SzReadSwitch(sd));
- RINOK(SzReadFileNames(sd, numFiles, files, allocMain->Alloc))
- break;
- }
- case k7zIdEmptyStream:
- {
- RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp->Alloc));
- numEmptyStreams = 0;
- for (i = 0; i < numFiles; i++)
- if ((*emptyStreamVector)[i])
- numEmptyStreams++;
- break;
- }
- case k7zIdEmptyFile:
- {
- RINOK(SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp->Alloc));
- break;
- }
- default:
- {
- RINOK(SzSkeepDataSize(sd, size));
- }
- }
- }
-
- {
- UInt32 emptyFileIndex = 0;
- UInt32 sizeIndex = 0;
- for(i = 0; i < numFiles; i++)
- {
- CFileItem *file = files + i;
- file->IsAnti = 0;
- if (*emptyStreamVector == 0)
- file->HasStream = 1;
- else
- file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1);
- if(file->HasStream)
- {
- file->IsDirectory = 0;
- file->Size = (*unPackSizes)[sizeIndex];
- file->FileCRC = (*digests)[sizeIndex];
- file->IsFileCRCDefined = (Byte)(*digestsDefined)[sizeIndex];
- sizeIndex++;
- }
- else
- {
- if (*emptyFileVector == 0)
- file->IsDirectory = 1;
- else
- file->IsDirectory = (Byte)((*emptyFileVector)[emptyFileIndex] ? 0 : 1);
- emptyFileIndex++;
- file->Size = 0;
- file->IsFileCRCDefined = 0;
- }
- }
- }
- return SzArDbExFill(db, allocMain->Alloc);
-}
-
-SZ_RESULT SzReadHeader(
- CSzData *sd,
- CArchiveDatabaseEx *db,
- ISzAlloc *allocMain,
- ISzAlloc *allocTemp)
-{
- CFileSize *unPackSizes = 0;
- Byte *digestsDefined = 0;
- UInt32 *digests = 0;
- Byte *emptyStreamVector = 0;
- Byte *emptyFileVector = 0;
- SZ_RESULT res = SzReadHeader2(sd, db,
- &unPackSizes, &digestsDefined, &digests,
- &emptyStreamVector, &emptyFileVector,
- allocMain, allocTemp);
- allocTemp->Free(unPackSizes);
- allocTemp->Free(digestsDefined);
- allocTemp->Free(digests);
- allocTemp->Free(emptyStreamVector);
- allocTemp->Free(emptyFileVector);
- return res;
-}
-
-SZ_RESULT SzReadAndDecodePackedStreams2(
- ISzInStream *inStream,
- CSzData *sd,
- CSzByteBuffer *outBuffer,
- CFileSize baseOffset,
- CArchiveDatabase *db,
- CFileSize **unPackSizes,
- Byte **digestsDefined,
- UInt32 **digests,
- #ifndef _LZMA_IN_CB
- Byte **inBuffer,
- #endif
- ISzAlloc *allocTemp)
-{
-
- UInt32 numUnPackStreams = 0;
- CFileSize dataStartPos;
- CFolder *folder;
- #ifndef _LZMA_IN_CB
- CFileSize packSize = 0;
- UInt32 i = 0;
- #endif
- CFileSize unPackSize;
- size_t outRealSize;
- SZ_RESULT res;
-
- RINOK(SzReadStreamsInfo(sd, &dataStartPos, db,
- &numUnPackStreams, unPackSizes, digestsDefined, digests,
- allocTemp->Alloc, allocTemp));
-
- dataStartPos += baseOffset;
- if (db->NumFolders != 1)
- return SZE_ARCHIVE_ERROR;
-
- folder = db->Folders;
- unPackSize = SzFolderGetUnPackSize(folder);
-
- RINOK(inStream->Seek(inStream, dataStartPos));
-
- #ifndef _LZMA_IN_CB
- for (i = 0; i < db->NumPackStreams; i++)
- packSize += db->PackSizes[i];
-
- MY_ALLOC(Byte, *inBuffer, (size_t)packSize, allocTemp->Alloc);
-
- RINOK(SafeReadDirect(inStream, *inBuffer, (size_t)packSize));
- #endif
-
- if (!SzByteBufferCreate(outBuffer, (size_t)unPackSize, allocTemp->Alloc))
- return SZE_OUTOFMEMORY;
-
- res = SzDecode(db->PackSizes, folder,
- #ifdef _LZMA_IN_CB
- inStream,
- #else
- *inBuffer,
- #endif
- outBuffer->Items, (size_t)unPackSize,
- &outRealSize, allocTemp);
- RINOK(res)
- if (outRealSize != (UInt32)unPackSize)
- return SZE_FAIL;
- if (folder->UnPackCRCDefined)
- if (!CrcVerifyDigest(folder->UnPackCRC, outBuffer->Items, (size_t)unPackSize))
- return SZE_FAIL;
- return SZ_OK;
-}
-
-SZ_RESULT SzReadAndDecodePackedStreams(
- ISzInStream *inStream,
- CSzData *sd,
- CSzByteBuffer *outBuffer,
- CFileSize baseOffset,
- ISzAlloc *allocTemp)
-{
- CArchiveDatabase db;
- CFileSize *unPackSizes = 0;
- Byte *digestsDefined = 0;
- UInt32 *digests = 0;
- #ifndef _LZMA_IN_CB
- Byte *inBuffer = 0;
- #endif
- SZ_RESULT res;
- SzArchiveDatabaseInit(&db);
- res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset,
- &db, &unPackSizes, &digestsDefined, &digests,
- #ifndef _LZMA_IN_CB
- &inBuffer,
- #endif
- allocTemp);
- SzArchiveDatabaseFree(&db, allocTemp->Free);
- allocTemp->Free(unPackSizes);
- allocTemp->Free(digestsDefined);
- allocTemp->Free(digests);
- #ifndef _LZMA_IN_CB
- allocTemp->Free(inBuffer);
- #endif
- return res;
-}
-
-SZ_RESULT SzArchiveOpen2(
- ISzInStream *inStream,
- CArchiveDatabaseEx *db,
- ISzAlloc *allocMain,
- ISzAlloc *allocTemp)
-{
- Byte signature[k7zSignatureSize];
- Byte version;
- UInt32 crcFromArchive;
- UInt64 nextHeaderOffset;
- UInt64 nextHeaderSize;
- UInt32 nextHeaderCRC;
- UInt32 crc;
- CFileSize pos = 0;
- CSzByteBuffer buffer;
- CSzData sd;
- SZ_RESULT res;
-
- RINOK(SafeReadDirect(inStream, signature, k7zSignatureSize));
-
- if (!TestSignatureCandidate(signature))
- return SZE_ARCHIVE_ERROR;
-
- /*
- db.Clear();
- db.ArchiveInfo.StartPosition = _arhiveBeginStreamPosition;
- */
- RINOK(SafeReadDirectByte(inStream, &version));
- if (version != k7zMajorVersion)
- return SZE_ARCHIVE_ERROR;
- RINOK(SafeReadDirectByte(inStream, &version));
-
- RINOK(SafeReadDirectUInt32(inStream, &crcFromArchive));
-
- CrcInit(&crc);
- RINOK(SafeReadDirectUInt64(inStream, &nextHeaderOffset));
- CrcUpdateUInt64(&crc, nextHeaderOffset);
- RINOK(SafeReadDirectUInt64(inStream, &nextHeaderSize));
- CrcUpdateUInt64(&crc, nextHeaderSize);
- RINOK(SafeReadDirectUInt32(inStream, &nextHeaderCRC));
- CrcUpdateUInt32(&crc, nextHeaderCRC);
-
- pos = k7zStartHeaderSize;
- db->ArchiveInfo.StartPositionAfterHeader = pos;
-
- if (CrcGetDigest(&crc) != crcFromArchive)
- return SZE_ARCHIVE_ERROR;
-
- if (nextHeaderSize == 0)
- return SZ_OK;
-
- RINOK(inStream->Seek(inStream, (CFileSize)(pos + nextHeaderOffset)));
-
- if (!SzByteBufferCreate(&buffer, (size_t)nextHeaderSize, allocTemp->Alloc))
- return SZE_OUTOFMEMORY;
-
- res = SafeReadDirect(inStream, buffer.Items, (size_t)nextHeaderSize);
- if (res == SZ_OK)
- {
- res = SZE_ARCHIVE_ERROR;
- if (CrcVerifyDigest(nextHeaderCRC, buffer.Items, (UInt32)nextHeaderSize))
- {
- for (;;)
- {
- UInt64 type;
- sd.Data = buffer.Items;
- sd.Size = buffer.Capacity;
- res = SzReadID(&sd, &type);
- if (res != SZ_OK)
- break;
- if (type == k7zIdHeader)
- {
- res = SzReadHeader(&sd, db, allocMain, allocTemp);
- break;
- }
- if (type != k7zIdEncodedHeader)
- {
- res = SZE_ARCHIVE_ERROR;
- break;
- }
- {
- CSzByteBuffer outBuffer;
- res = SzReadAndDecodePackedStreams(inStream, &sd, &outBuffer,
- db->ArchiveInfo.StartPositionAfterHeader,
- allocTemp);
- if (res != SZ_OK)
- {
- SzByteBufferFree(&outBuffer, allocTemp->Free);
- break;
- }
- SzByteBufferFree(&buffer, allocTemp->Free);
- buffer.Items = outBuffer.Items;
- buffer.Capacity = outBuffer.Capacity;
- }
- }
- }
- }
- SzByteBufferFree(&buffer, allocTemp->Free);
- return res;
-}
-
-SZ_RESULT SzArchiveOpen(
- ISzInStream *inStream,
- CArchiveDatabaseEx *db,
- ISzAlloc *allocMain,
- ISzAlloc *allocTemp)
-{
- SZ_RESULT res = SzArchiveOpen2(inStream, db, allocMain, allocTemp);
- if (res != SZ_OK)
- SzArDbExFree(db, allocMain->Free);
- return res;
-}
diff --git a/7zip/Archive/7z_C/7zIn.h b/7zip/Archive/7z_C/7zIn.h
deleted file mode 100755
index 6bfa2a70..00000000
--- a/7zip/Archive/7z_C/7zIn.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* 7zIn.h */
-
-#ifndef __7Z_IN_H
-#define __7Z_IN_H
-
-#include "7zHeader.h"
-#include "7zItem.h"
-#include "7zAlloc.h"
-
-typedef struct _CInArchiveInfo
-{
- CFileSize StartPositionAfterHeader;
- CFileSize DataStartPosition;
-}CInArchiveInfo;
-
-typedef struct _CArchiveDatabaseEx
-{
- CArchiveDatabase Database;
- CInArchiveInfo ArchiveInfo;
- UInt32 *FolderStartPackStreamIndex;
- CFileSize *PackStreamStartPositions;
- UInt32 *FolderStartFileIndex;
- UInt32 *FileIndexToFolderIndexMap;
-}CArchiveDatabaseEx;
-
-void SzArDbExInit(CArchiveDatabaseEx *db);
-void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *));
-CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder);
-CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex);
-
-typedef struct _ISzInStream
-{
- #ifdef _LZMA_IN_CB
- SZ_RESULT (*Read)(
- void *object, /* pointer to ISzInStream itself */
- void **buffer, /* out: pointer to buffer with data */
- size_t maxRequiredSize, /* max required size to read */
- size_t *processedSize); /* real processed size.
- processedSize can be less than maxRequiredSize.
- If processedSize == 0, then there are no more
- bytes in stream. */
- #else
- SZ_RESULT (*Read)(void *object, void *buffer, size_t size, size_t *processedSize);
- #endif
- SZ_RESULT (*Seek)(void *object, CFileSize pos);
-} ISzInStream;
-
-
-int SzArchiveOpen(
- ISzInStream *inStream,
- CArchiveDatabaseEx *db,
- ISzAlloc *allocMain,
- ISzAlloc *allocTemp);
-
-#endif
diff --git a/7zip/Archive/7z_C/7zItem.h b/7zip/Archive/7z_C/7zItem.h
deleted file mode 100755
index 876539a9..00000000
--- a/7zip/Archive/7z_C/7zItem.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* 7zItem.h */
-
-#ifndef __7Z_ITEM_H
-#define __7Z_ITEM_H
-
-#include "7zMethodID.h"
-#include "7zHeader.h"
-#include "7zBuffer.h"
-
-typedef struct _CCoderInfo
-{
- UInt32 NumInStreams;
- UInt32 NumOutStreams;
- CMethodID MethodID;
- CSzByteBuffer Properties;
-}CCoderInfo;
-
-void SzCoderInfoInit(CCoderInfo *coder);
-void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p));
-
-typedef struct _CBindPair
-{
- UInt32 InIndex;
- UInt32 OutIndex;
-}CBindPair;
-
-typedef struct _CFolder
-{
- UInt32 NumCoders;
- CCoderInfo *Coders;
- UInt32 NumBindPairs;
- CBindPair *BindPairs;
- UInt32 NumPackStreams;
- UInt32 *PackStreams;
- CFileSize *UnPackSizes;
- int UnPackCRCDefined;
- UInt32 UnPackCRC;
-
- UInt32 NumUnPackStreams;
-}CFolder;
-
-void SzFolderInit(CFolder *folder);
-CFileSize SzFolderGetUnPackSize(CFolder *folder);
-int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex);
-UInt32 SzFolderGetNumOutStreams(CFolder *folder);
-CFileSize SzFolderGetUnPackSize(CFolder *folder);
-
-/* #define CArchiveFileTime UInt64 */
-
-typedef struct _CFileItem
-{
- /*
- CArchiveFileTime LastWriteTime;
- CFileSize StartPos;
- UInt32 Attributes;
- */
- CFileSize Size;
- UInt32 FileCRC;
- char *Name;
-
- Byte IsFileCRCDefined;
- Byte HasStream;
- Byte IsDirectory;
- Byte IsAnti;
- /*
- int AreAttributesDefined;
- int IsLastWriteTimeDefined;
- int IsStartPosDefined;
- */
-}CFileItem;
-
-void SzFileInit(CFileItem *fileItem);
-
-typedef struct _CArchiveDatabase
-{
- UInt32 NumPackStreams;
- CFileSize *PackSizes;
- Byte *PackCRCsDefined;
- UInt32 *PackCRCs;
- UInt32 NumFolders;
- CFolder *Folders;
- UInt32 NumFiles;
- CFileItem *Files;
-}CArchiveDatabase;
-
-void SzArchiveDatabaseInit(CArchiveDatabase *db);
-void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *));
-
-
-#endif
diff --git a/7zip/Archive/7z_C/7zMain.c b/7zip/Archive/7z_C/7zMain.c
deleted file mode 100755
index 10900c54..00000000
--- a/7zip/Archive/7z_C/7zMain.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
-7zMain.c
-Test application for 7z Decoder
-LZMA SDK 4.43 Copyright (c) 1999-2006 Igor Pavlov (2006-06-04)
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef _WIN32
-#define USE_WINDOWS_FUNCTIONS
-#endif
-
-#ifdef USE_WINDOWS_FUNCTIONS
-#include <windows.h>
-#endif
-
-#include "7zCrc.h"
-#include "7zIn.h"
-#include "7zExtract.h"
-
-
-#ifdef USE_WINDOWS_FUNCTIONS
-typedef HANDLE MY_FILE_HANDLE;
-#else
-typedef FILE *MY_FILE_HANDLE;
-#endif
-
-void ConvertNumberToString(CFileSize value, char *s)
-{
- char temp[32];
- int pos = 0;
- do
- {
- temp[pos++] = (char)('0' + (int)(value % 10));
- value /= 10;
- }
- while (value != 0);
- do
- *s++ = temp[--pos];
- while(pos > 0);
- *s = '\0';
-}
-
-
-#ifdef USE_WINDOWS_FUNCTIONS
-// ReadFile and WriteFile functions in Windows have BUG:
-// If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
-// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
-// (Insufficient system resources exist to complete the requested service).
-#define kChunkSizeMax (1 << 24)
-#endif
-
-size_t MyReadFile(MY_FILE_HANDLE file, void *data, size_t size)
-{
- if (size == 0)
- return 0;
- #ifdef USE_WINDOWS_FUNCTIONS
- {
- size_t processedSize = 0;
- do
- {
- DWORD curSize = (size > kChunkSizeMax) ? kChunkSizeMax : (DWORD)size;
- DWORD processedLoc = 0;
- BOOL res = ReadFile(file, data, curSize, &processedLoc, NULL);
- data = (void *)((unsigned char *)data + processedLoc);
- size -= processedLoc;
- processedSize += processedLoc;
- if (!res || processedLoc == 0)
- break;
- }
- while (size > 0);
- return processedSize;
- }
- #else
- return fread(data, 1, size, file);
- #endif
-}
-
-size_t MyWriteFile(MY_FILE_HANDLE file, void *data, size_t size)
-{
- if (size == 0)
- return 0;
- #ifdef USE_WINDOWS_FUNCTIONS
- {
- size_t processedSize = 0;
- do
- {
- DWORD curSize = (size > kChunkSizeMax) ? kChunkSizeMax : (DWORD)size;
- DWORD processedLoc = 0;
- BOOL res = WriteFile(file, data, curSize, &processedLoc, NULL);
- data = (void *)((unsigned char *)data + processedLoc);
- size -= processedLoc;
- processedSize += processedLoc;
- if (!res)
- break;
- }
- while (size > 0);
- return processedSize;
- }
- #else
- return fwrite(data, 1, size, file);
- #endif
-}
-
-int MyCloseFile(MY_FILE_HANDLE file)
-{
- #ifdef USE_WINDOWS_FUNCTIONS
- return (CloseHandle(file) != FALSE) ? 0 : 1;
- #else
- return fclose(file);
- #endif
-}
-
-typedef struct _CFileInStream
-{
- ISzInStream InStream;
- MY_FILE_HANDLE File;
-} CFileInStream;
-
-#ifdef _LZMA_IN_CB
-
-#define kBufferSize (1 << 12)
-Byte g_Buffer[kBufferSize];
-
-SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxRequiredSize, size_t *processedSize)
-{
- CFileInStream *s = (CFileInStream *)object;
- size_t processedSizeLoc;
- if (maxRequiredSize > kBufferSize)
- maxRequiredSize = kBufferSize;
- processedSizeLoc = MyReadFile(s->File, g_Buffer, maxRequiredSize);
- *buffer = g_Buffer;
- if (processedSize != 0)
- *processedSize = processedSizeLoc;
- return SZ_OK;
-}
-
-#else
-
-SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size, size_t *processedSize)
-{
- CFileInStream *s = (CFileInStream *)object;
- size_t processedSizeLoc = MyReadFile(s->File, buffer, size);
- if (processedSize != 0)
- *processedSize = processedSizeLoc;
- return SZ_OK;
-}
-
-#endif
-
-SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
-{
- CFileInStream *s = (CFileInStream *)object;
-
- #ifdef USE_WINDOWS_FUNCTIONS
- {
- LARGE_INTEGER value;
- value.LowPart = (DWORD)pos;
- value.HighPart = (LONG)(pos >> 32);
- value.LowPart = SetFilePointer(s->File, value.LowPart, &value.HighPart, FILE_BEGIN);
- if (value.LowPart == 0xFFFFFFFF)
- if(GetLastError() != NO_ERROR)
- return SZE_FAIL;
- return SZ_OK;
- }
- #else
- int res = fseek(s->File, (long)pos, SEEK_SET);
- if (res == 0)
- return SZ_OK;
- return SZE_FAIL;
- #endif
-}
-
-void PrintError(char *sz)
-{
- printf("\nERROR: %s\n", sz);
-}
-
-int main(int numargs, char *args[])
-{
- CFileInStream archiveStream;
- CArchiveDatabaseEx db;
- SZ_RESULT res;
- ISzAlloc allocImp;
- ISzAlloc allocTempImp;
-
- printf("\n7z ANSI-C Decoder 4.44 Copyright (c) 1999-2006 Igor Pavlov 2006-08-27\n");
- if (numargs == 1)
- {
- printf(
- "\nUsage: 7zDec <command> <archive_name>\n\n"
- "<Commands>\n"
- " e: Extract files from archive\n"
- " l: List contents of archive\n"
- " t: Test integrity of archive\n");
- return 0;
- }
- if (numargs < 3)
- {
- PrintError("incorrect command");
- return 1;
- }
-
- archiveStream.File =
- #ifdef USE_WINDOWS_FUNCTIONS
- CreateFile(args[2], GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (archiveStream.File == INVALID_HANDLE_VALUE)
- #else
- archiveStream.File = fopen(args[2], "rb");
- if (archiveStream.File == 0)
- #endif
- {
- PrintError("can not open input file");
- return 1;
- }
-
- archiveStream.InStream.Read = SzFileReadImp;
- archiveStream.InStream.Seek = SzFileSeekImp;
-
- allocImp.Alloc = SzAlloc;
- allocImp.Free = SzFree;
-
- allocTempImp.Alloc = SzAllocTemp;
- allocTempImp.Free = SzFreeTemp;
-
- InitCrcTable();
- SzArDbExInit(&db);
- res = SzArchiveOpen(&archiveStream.InStream, &db, &allocImp, &allocTempImp);
- if (res == SZ_OK)
- {
- char *command = args[1];
- int listCommand = 0;
- int testCommand = 0;
- int extractCommand = 0;
- if (strcmp(command, "l") == 0)
- listCommand = 1;
- if (strcmp(command, "t") == 0)
- testCommand = 1;
- else if (strcmp(command, "e") == 0)
- extractCommand = 1;
-
- if (listCommand)
- {
- UInt32 i;
- for (i = 0; i < db.Database.NumFiles; i++)
- {
- CFileItem *f = db.Database.Files + i;
- char s[32];
- ConvertNumberToString(f->Size, s);
- printf("%10s %s\n", s, f->Name);
- }
- }
- else if (testCommand || extractCommand)
- {
- UInt32 i;
-
- /*
- if you need cache, use these 3 variables.
- if you use external function, you can make these variable as static.
- */
- UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
- Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
- size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
-
- printf("\n");
- for (i = 0; i < db.Database.NumFiles; i++)
- {
- size_t offset;
- size_t outSizeProcessed;
- CFileItem *f = db.Database.Files + i;
- if (f->IsDirectory)
- printf("Directory ");
- else
- printf(testCommand ?
- "Testing ":
- "Extracting");
- printf(" %s", f->Name);
- if (f->IsDirectory)
- {
- printf("\n");
- continue;
- }
- res = SzExtract(&archiveStream.InStream, &db, i,
- &blockIndex, &outBuffer, &outBufferSize,
- &offset, &outSizeProcessed,
- &allocImp, &allocTempImp);
- if (res != SZ_OK)
- break;
- if (!testCommand)
- {
- MY_FILE_HANDLE outputHandle;
- UInt32 processedSize;
- char *fileName = f->Name;
- size_t nameLen = strlen(f->Name);
- for (; nameLen > 0; nameLen--)
- if (f->Name[nameLen - 1] == '/')
- {
- fileName = f->Name + nameLen;
- break;
- }
-
- outputHandle =
- #ifdef USE_WINDOWS_FUNCTIONS
- CreateFile(fileName, GENERIC_WRITE, FILE_SHARE_READ,
- NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (outputHandle == INVALID_HANDLE_VALUE)
- #else
- fopen(fileName, "wb+");
- if (outputHandle == 0)
- #endif
- {
- PrintError("can not open output file");
- res = SZE_FAIL;
- break;
- }
- processedSize = MyWriteFile(outputHandle, outBuffer + offset, outSizeProcessed);
- if (processedSize != outSizeProcessed)
- {
- PrintError("can not write output file");
- res = SZE_FAIL;
- break;
- }
- if (MyCloseFile(outputHandle))
- {
- PrintError("can not close output file");
- res = SZE_FAIL;
- break;
- }
- }
- printf("\n");
- }
- allocImp.Free(outBuffer);
- }
- else
- {
- PrintError("incorrect command");
- res = SZE_FAIL;
- }
- }
- SzArDbExFree(&db, allocImp.Free);
-
- MyCloseFile(archiveStream.File);
- if (res == SZ_OK)
- {
- printf("\nEverything is Ok\n");
- return 0;
- }
- if (res == SZE_OUTOFMEMORY)
- PrintError("can not allocate memory");
- else
- printf("\nERROR #%d\n", res);
- return 1;
-}
diff --git a/7zip/Archive/7z_C/7zMethodID.h b/7zip/Archive/7z_C/7zMethodID.h
deleted file mode 100755
index 162fcd15..00000000
--- a/7zip/Archive/7z_C/7zMethodID.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* 7zMethodID.h */
-
-#ifndef __7Z_METHOD_ID_H
-#define __7Z_METHOD_ID_H
-
-#include "7zTypes.h"
-
-#define kMethodIDSize 15
-
-typedef struct _CMethodID
-{
- Byte ID[kMethodIDSize];
- Byte IDSize;
-} CMethodID;
-
-int AreMethodsEqual(CMethodID *a1, CMethodID *a2);
-
-#endif
diff --git a/7zip/Archive/7z_C/7zTypes.h b/7zip/Archive/7z_C/7zTypes.h
deleted file mode 100755
index 60dd68c3..00000000
--- a/7zip/Archive/7z_C/7zTypes.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* 7zTypes.h */
-
-#ifndef __COMMON_TYPES_H
-#define __COMMON_TYPES_H
-
-#ifndef _7ZIP_BYTE_DEFINED
-#define _7ZIP_BYTE_DEFINED
-typedef unsigned char Byte;
-#endif
-
-#ifndef _7ZIP_UINT16_DEFINED
-#define _7ZIP_UINT16_DEFINED
-typedef unsigned short UInt16;
-#endif
-
-#ifndef _7ZIP_UINT32_DEFINED
-#define _7ZIP_UINT32_DEFINED
-#ifdef _LZMA_UINT32_IS_ULONG
-typedef unsigned long UInt32;
-#else
-typedef unsigned int UInt32;
-#endif
-#endif
-
-/* #define _SZ_NO_INT_64 */
-/* define it your compiler doesn't support long long int */
-
-#ifndef _7ZIP_UINT64_DEFINED
-#define _7ZIP_UINT64_DEFINED
-#ifdef _SZ_NO_INT_64
-typedef unsigned long UInt64;
-#else
-#ifdef _MSC_VER
-typedef unsigned __int64 UInt64;
-#else
-typedef unsigned long long int UInt64;
-#endif
-#endif
-#endif
-
-
-/* #define _SZ_FILE_SIZE_64 */
-/* Use _SZ_FILE_SIZE_64 if you need support for files larger than 4 GB*/
-
-#ifndef CFileSize
-#ifdef _SZ_FILE_SIZE_64
-typedef UInt64 CFileSize;
-#else
-typedef UInt32 CFileSize;
-#endif
-#endif
-
-#define SZ_RESULT int
-
-#define SZ_OK (0)
-#define SZE_DATA_ERROR (1)
-#define SZE_OUTOFMEMORY (2)
-#define SZE_CRC_ERROR (3)
-
-#define SZE_NOTIMPL (4)
-#define SZE_FAIL (5)
-
-#define SZE_ARCHIVE_ERROR (6)
-
-#define RINOK(x) { int __result_ = (x); if(__result_ != 0) return __result_; }
-
-#endif
diff --git a/7zip/Archive/7z_C/7z_C.dsp b/7zip/Archive/7z_C/7z_C.dsp
deleted file mode 100755
index 6129fa86..00000000
--- a/7zip/Archive/7z_C/7z_C.dsp
+++ /dev/null
@@ -1,182 +0,0 @@
-# Microsoft Developer Studio Project File - Name="7z_C" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=7z_C - 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_C.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_C.mak" CFG="7z_C - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "7z_C - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "7z_C - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "7z_C - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /D "_SZ_FILE_SIZE_64" /YX /FD /c
-# 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 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 /subsystem:console /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 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 /subsystem:console /machine:I386 /out:"Release/7zDec.exe"
-
-!ELSEIF "$(CFG)" == "7z_C - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /D "_SZ_FILE_SIZE_64" /YX /FD /GZ /c
-# 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 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 /subsystem:console /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 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 /subsystem:console /debug /machine:I386 /out:"Debug/7zDec.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "7z_C - Win32 Release"
-# Name "7z_C - Win32 Debug"
-# Begin Group "LZMA"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_C\LzmaDecode.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_C\LzmaDecode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_C\LzmaTypes.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\7zAlloc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zAlloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zBuffer.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zBuffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zCrc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zCrc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zDecode.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zDecode.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zExtract.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zExtract.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zHeader.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zIn.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zItem.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zMain.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zMethodID.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zMethodID.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zTypes.h
-# End Source File
-# End Target
-# End Project
diff --git a/7zip/Archive/Arj/DllExports.cpp b/7zip/Archive/Arj/DllExports.cpp
deleted file mode 100755
index 31fbc495..00000000
--- a/7zip/Archive/Arj/DllExports.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-#include "Windows/PropVariant.h"
-#include "../../ICoder.h"
-#include "ArjHandler.h"
-
-// {23170F69-40C1-278A-1000-000110040000}
-DEFINE_GUID(CLSID_CArjHandler,
- 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x04, 0x00, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
-{
- return TRUE;
-}
-
-STDAPI CreateObject(
- const GUID *classID,
- const GUID *interfaceID,
- void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- if (*classID != CLSID_CArjHandler)
- return CLASS_E_CLASSNOTAVAILABLE;
- if (*interfaceID != IID_IInArchive)
- return E_NOINTERFACE;
- CMyComPtr<IInArchive> inArchive = (IInArchive *)new NArchive::NArj::CHandler;
- *outObject = inArchive.Detach();
- COM_TRY_END
- return S_OK;
-}
-
-STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
-{
- NWindows::NCOM::CPropVariant propVariant;
- switch(propID)
- {
- case NArchive::kName:
- propVariant = L"Arj";
- break;
- case NArchive::kClassID:
- {
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CArjHandler, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NArchive::kExtension:
- propVariant = L"arj";
- break;
- case NArchive::kAddExtension:
- propVariant = L".cpio.gz";
- break;
- case NArchive::kUpdate:
- propVariant = false;
- break;
- case NArchive::kKeepName:
- propVariant = false;
- break;
- case NArchive::kStartSignature:
- {
- const unsigned char sig[] = { 0x60, 0xEA };
- if ((value->bstrVal = ::SysAllocStringByteLen((const char *)sig, 2)) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- }
- propVariant.Detach(value);
- return S_OK;
-}
diff --git a/7zip/Archive/BZip2/BZip2Handler.cpp b/7zip/Archive/BZip2/BZip2Handler.cpp
deleted file mode 100755
index e1065f4f..00000000
--- a/7zip/Archive/BZip2/BZip2Handler.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-// BZip2Handler.cpp
-
-#include "StdAfx.h"
-
-#include "BZip2Handler.h"
-
-#include "Common/Defs.h"
-
-#include "../../Common/ProgressUtils.h"
-#include "../../Common/StreamUtils.h"
-
-#include "Windows/PropVariant.h"
-#include "Windows/Defs.h"
-#include "Common/ComTry.h"
-
-#include "../Common/DummyOutStream.h"
-
-#ifdef COMPRESS_BZIP2
-#include "../../Compress/BZip2/BZip2Decoder.h"
-#else
-// {23170F69-40C1-278B-0402-020000000000}
-DEFINE_GUID(CLSID_CCompressBZip2Decoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
-#include "../Common/CoderLoader.h"
-extern CSysString GetBZip2CodecPath();
-#endif
-
-using namespace NWindows;
-
-namespace NArchive {
-namespace NBZip2 {
-
-STATPROPSTG kProperties[] =
-{
- { NULL, kpidPath, VT_BSTR},
- // { NULL, kpidIsFolder, VT_BOOL},
- // { NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
-};
-
-STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value)
-{
- value->vt = VT_EMPTY;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
-{
- *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
- return E_INVALIDARG;
- const STATPROPSTG &srcItem = kProperties[index];
- *propID = srcItem.propid;
- *varType = srcItem.vt;
- *name = 0;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
-{
- *numProperties = 0;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 /* index */,
- BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */)
-{
- return E_INVALIDARG;
-}
-
-STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
-{
- *numItems = 1;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
-{
- COM_TRY_BEGIN
- NWindows::NCOM::CPropVariant propVariant;
- if (index != 0)
- return E_INVALIDARG;
- switch(propID)
- {
- case kpidIsFolder:
- propVariant = false;
- break;
- case kpidPackedSize:
- propVariant = _item.PackSize;
- break;
- }
- propVariant.Detach(value);
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CHandler::Open(IInStream *stream,
- const UInt64 * /* maxCheckStartPosition */,
- IArchiveOpenCallback * /* openArchiveCallback */)
-{
- COM_TRY_BEGIN
- try
- {
- RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_streamStartPosition));
- const int kSignatureSize = 3;
- Byte buffer[kSignatureSize];
- UInt32 processedSize;
- RINOK(ReadStream(stream, buffer, kSignatureSize, &processedSize));
- if (processedSize != kSignatureSize)
- return S_FALSE;
- if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h')
- return S_FALSE;
-
- UInt64 endPosition;
- RINOK(stream->Seek(0, STREAM_SEEK_END, &endPosition));
- _item.PackSize = endPosition - _streamStartPosition;
-
- _stream = stream;
- }
- catch(...)
- {
- return S_FALSE;
- }
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CHandler::Close()
-{
- _stream.Release();
- return S_OK;
-}
-
-
-STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
- Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
-{
- COM_TRY_BEGIN
- bool allFilesMode = (numItems == UInt32(-1));
- if (!allFilesMode)
- {
- if (numItems == 0)
- return S_OK;
- if (numItems != 1)
- return E_INVALIDARG;
- if (indices[0] != 0)
- return E_INVALIDARG;
- }
-
- bool testMode = (testModeSpec != 0);
-
- extractCallback->SetTotal(_item.PackSize);
-
- UInt64 currentTotalPacked = 0, currentTotalUnPacked = 0;
-
- RINOK(extractCallback->SetCompleted(&currentTotalPacked));
-
- CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode;
- askMode = testMode ? NArchive::NExtract::NAskMode::kTest :
- NArchive::NExtract::NAskMode::kExtract;
-
- RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
-
- if(!testMode && !realOutStream)
- return S_OK;
-
-
- extractCallback->PrepareOperation(askMode);
-
- #ifndef COMPRESS_BZIP2
- CCoderLibrary lib;
- #endif
- CMyComPtr<ICompressCoder> decoder;
- #ifdef COMPRESS_BZIP2
- decoder = new NCompress::NBZip2::CDecoder;
- #else
- HRESULT loadResult = lib.LoadAndCreateCoder(
- GetBZip2CodecPath(),
- CLSID_CCompressBZip2Decoder, &decoder);
- if (loadResult != S_OK)
- {
- RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
- return S_OK;
- }
- #endif
-
- #ifdef COMPRESS_MT
- {
- CMyComPtr<ICompressSetCoderMt> setCoderMt;
- decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
- if (setCoderMt)
- {
- RINOK(setCoderMt->SetNumberOfThreads(_numThreads));
- }
- }
- #endif
-
- CDummyOutStream *outStreamSpec = new CDummyOutStream;
- CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
- outStreamSpec->Init(realOutStream);
-
- realOutStream.Release();
-
- CLocalProgress *localProgressSpec = new CLocalProgress;
- CMyComPtr<ICompressProgressInfo> progress = localProgressSpec;
- localProgressSpec->Init(extractCallback, true);
-
- CLocalCompressProgressInfo *localCompressProgressSpec =
- new CLocalCompressProgressInfo;
- CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
-
- RINOK(_stream->Seek(_streamStartPosition, STREAM_SEEK_SET, NULL));
-
-
- HRESULT result = S_OK;
-
- bool firstItem = true;
- for (;;)
- {
- localCompressProgressSpec->Init(progress,
- &currentTotalPacked,
- &currentTotalUnPacked);
-
- const int kSignatureSize = 3;
- Byte buffer[kSignatureSize];
- UInt32 processedSize;
- RINOK(ReadStream(_stream, buffer, kSignatureSize, &processedSize));
- if (processedSize < kSignatureSize)
- {
- if (firstItem)
- return E_FAIL;
- break;
- }
- if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h')
- {
- if (firstItem)
- return E_FAIL;
- outStream.Release();
- RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK))
- return S_OK;
- }
- firstItem = false;
-
- UInt64 dataStartPos;
- RINOK(_stream->Seek((UInt64)(Int64)(-3), STREAM_SEEK_CUR, &dataStartPos));
-
- result = decoder->Code(_stream, outStream, NULL, NULL, compressProgress);
-
- if (result != S_OK)
- break;
-
- CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize;
- decoder.QueryInterface(IID_ICompressGetInStreamProcessedSize,
- &getInStreamProcessedSize);
- if (!getInStreamProcessedSize)
- break;
-
- UInt64 packSize;
- RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&packSize));
- UInt64 pos;
- RINOK(_stream->Seek(dataStartPos + packSize, STREAM_SEEK_SET, &pos));
- currentTotalPacked = pos - _streamStartPosition;
- }
- outStream.Release();
-
- int retResult;
- if (result == S_OK)
- retResult = NArchive::NExtract::NOperationResult::kOK;
- else
- retResult = NArchive::NExtract::NOperationResult::kDataError;
-
- RINOK(extractCallback->SetOperationResult(retResult));
-
- return S_OK;
- COM_TRY_END
-}
-
-}}
diff --git a/7zip/Archive/Cab/CabIn.cpp b/7zip/Archive/Cab/CabIn.cpp
deleted file mode 100755
index 447c1f42..00000000
--- a/7zip/Archive/Cab/CabIn.cpp
+++ /dev/null
@@ -1,343 +0,0 @@
-// Archive/CabIn.cpp
-
-#include "StdAfx.h"
-
-#include "Common/StringConvert.h"
-#include "Common/MyCom.h"
-#include "CabIn.h"
-#include "Windows/Defs.h"
-
-#include "../../Common/StreamUtils.h"
-
-namespace NArchive{
-namespace NCab{
-
-/*
-static HRESULT ReadBytes(IInStream *inStream, void *data, UInt32 size)
-{
- UInt32 realProcessedSize;
- RINOK(ReadStream(inStream, data, size, &realProcessedSize));
- if(realProcessedSize != size)
- return S_FALSE;
- return S_OK;
-}
-
-static HRESULT SafeRead(IInStream *inStream, void *data, UInt32 size)
-{
- UInt32 realProcessedSize;
- RINOK(ReadStream(inStream, data, size, &realProcessedSize));
- if(realProcessedSize != size)
- throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
- return S_OK;
-}
-
-static void SafeInByteRead(::CInBuffer &inBuffer, void *data, UInt32 size)
-{
- UInt32 realProcessedSize;
- inBuffer.ReadBytes(data, size, realProcessedSize);
- if(realProcessedSize != size)
- throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
-}
-*/
-
-Byte CInArchive::ReadByte()
-{
- Byte b;
- if (!inBuffer.ReadByte(b))
- throw CInArchiveException(CInArchiveException::kUnsupported);
- return b;
-}
-
-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;
-}
-
-AString CInArchive::SafeReadName()
-{
- AString name;
- for (;;)
- {
- Byte b = ReadByte();
- if (b == 0)
- return name;
- name += (char)b;
- }
-}
-
-void CInArchive::ReadOtherArchive(COtherArchive &oa)
-{
- oa.FileName = SafeReadName();
- oa.DiskName = SafeReadName();
-}
-
-void CInArchive::Skeep(size_t size)
-{
- while (size-- != 0)
- ReadByte();
-}
-
-HRESULT CInArchive::Open2(IInStream *inStream,
- const UInt64 *searchHeaderSizeLimit,
- CDatabase &database)
-{
- database.Clear();
- RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &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;
- }
-
- CInArchiveInfo &archiveInfo = database.ArchiveInfo;
-
- archiveInfo.Size = ReadUInt32(); // size of this cabinet file in bytes
- if (ReadUInt32() != 0)
- return S_FALSE;
- archiveInfo.FileHeadersOffset = ReadUInt32(); // offset of the first CFFILE entry
- if (ReadUInt32() != 0)
- return S_FALSE;
-
- archiveInfo.VersionMinor = ReadByte(); // cabinet file format version, minor
- 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.SetID = ReadUInt16(); // must be the same for all cabinets in a set
- archiveInfo.CabinetNumber = ReadUInt16(); // number of this cabinet file in a set
-
- if (archiveInfo.ReserveBlockPresent())
- {
- archiveInfo.PerCabinetAreaSize = ReadUInt16(); // (optional) size of per-cabinet reserved area
- archiveInfo.PerFolderAreaSize = ReadByte(); // (optional) size of per-folder reserved area
- archiveInfo.PerDataBlockAreaSize = ReadByte(); // (optional) size of per-datablock reserved area
-
- Skeep(archiveInfo.PerCabinetAreaSize);
- }
-
- {
- if (archiveInfo.IsTherePrev())
- ReadOtherArchive(archiveInfo.PreviousArchive);
- if (archiveInfo.IsThereNext())
- ReadOtherArchive(archiveInfo.NextArchive);
- }
-
- int i;
- for(i = 0; i < archiveInfo.NumFolders; i++)
- {
- CFolder folder;
-
- folder.DataStart = ReadUInt32();
- folder.NumDataBlocks = ReadUInt16();
- folder.CompressionTypeMajor = ReadByte();
- folder.CompressionTypeMinor = ReadByte();
-
- Skeep(archiveInfo.PerFolderAreaSize);
- database.Folders.Add(folder);
- }
-
- RINOK(inStream->Seek(database.StartPosition + archiveInfo.FileHeadersOffset, STREAM_SEEK_SET, NULL));
-
- inBuffer.SetStream(inStream);
- inBuffer.Init();
- for(i = 0; i < archiveInfo.NumFiles; i++)
- {
- CItem item;
- item.Size = ReadUInt32();
- item.Offset = ReadUInt32();
- item.FolderIndex = ReadUInt16();
- UInt16 pureDate = ReadUInt16();
- UInt16 pureTime = ReadUInt16();
- item.Time = ((UInt32(pureDate) << 16)) | pureTime;
- item.Attributes = ReadUInt16();
- item.Name = SafeReadName();
- int folderIndex = item.GetFolderIndex(database.Folders.Size());
- if (folderIndex >= database.Folders.Size())
- return S_FALSE;
- database.Items.Add(item);
- }
- return S_OK;
-}
-
-#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
-
-HRESULT CInArchive::Open(
- const UInt64 *searchHeaderSizeLimit,
- CDatabaseEx &database)
-{
- return Open2(database.Stream, searchHeaderSizeLimit, database);
-}
-
-
-static int CompareMvItems2(const CMvItem *p1, const CMvItem *p2)
-{
- RINOZ(MyCompare(p1->VolumeIndex, p2->VolumeIndex));
- return MyCompare(p1->ItemIndex, p2->ItemIndex);
-}
-
-static int CompareMvItems(const CMvItem *p1, const CMvItem *p2, void *param)
-{
- const CMvDatabaseEx &mvDb = *(const CMvDatabaseEx *)param;
- const CDatabaseEx &db1 = mvDb.Volumes[p1->VolumeIndex];
- 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();
- if (isDir1 && !isDir2)
- return -1;
- if (isDir2 && !isDir1)
- return 1;
- int f1 = mvDb.GetFolderIndex(p1);
- int f2 = mvDb.GetFolderIndex(p2);
- RINOZ(MyCompare(f1, f2));
- RINOZ(MyCompare(item1.Offset, item2.Offset));
- RINOZ(MyCompare(item1.Size, item2.Size));
- return CompareMvItems2(p1, p2);
-}
-
-bool CMvDatabaseEx::AreItemsEqual(int i1, int i2)
-{
- const CMvItem *p1 = &Items[i1];
- const CMvItem *p2 = &Items[i2];
- const CDatabaseEx &db1 = Volumes[p1->VolumeIndex];
- const CDatabaseEx &db2 = Volumes[p2->VolumeIndex];
- const CItem &item1 = db1.Items[p1->ItemIndex];
- const CItem &item2 = db2.Items[p2->ItemIndex];;
- int f1 = GetFolderIndex(p1);
- int f2 = GetFolderIndex(p2);
- if (f1 != f2)
- return false;
- if (item1.Offset != item2.Offset)
- return false;
- if (item1.Size != item2.Size)
- return false;
-
- return true;
-}
-
-void CMvDatabaseEx::FillSortAndShrink()
-{
- Items.Clear();
- StartFolderOfVol.Clear();
- FolderStartFileIndex.Clear();
- int offset = 0;
- for (int v = 0; v < Volumes.Size(); v++)
- {
- const CDatabaseEx &db = Volumes[v];
- int curOffset = offset;
- if (db.IsTherePrevFolder())
- curOffset--;
- StartFolderOfVol.Add(curOffset);
- offset += db.GetNumberOfNewFolders();
-
- CMvItem mvItem;
- mvItem.VolumeIndex = v;
- for (int i = 0 ; i < db.Items.Size(); i++)
- {
- mvItem.ItemIndex = i;
- Items.Add(mvItem);
- }
- }
-
- Items.Sort(CompareMvItems, (void *)this);
- int j = 1;
- int i;
- for (i = 1; i < Items.Size(); i++)
- if (!AreItemsEqual(i, i -1))
- Items[j++] = Items[i];
- Items.DeleteFrom(j);
-
- for (i = 0; i < Items.Size(); i++)
- {
- const CMvItem &mvItem = Items[i];
- int folderIndex = GetFolderIndex(&mvItem);
- if (folderIndex >= FolderStartFileIndex.Size())
- FolderStartFileIndex.Add(i);
- }
-}
-
-bool CMvDatabaseEx::Check()
-{
- for (int v = 1; v < Volumes.Size(); v++)
- {
- const CDatabaseEx &db1 = Volumes[v];
- if (db1.IsTherePrevFolder())
- {
- const CDatabaseEx &db0 = Volumes[v - 1];
- if (db0.Folders.IsEmpty() || db1.Folders.IsEmpty())
- return false;
- const CFolder &f0 = db0.Folders.Back();
- const CFolder &f1 = db1.Folders.Front();
- if (f0.CompressionTypeMajor != f1.CompressionTypeMajor ||
- f0.CompressionTypeMinor != f1.CompressionTypeMinor)
- return false;
- }
- }
- UInt64 maxPos = 0;
- int prevFolder = -2;
- for(int i = 0; i < Items.Size(); i++)
- {
- const CMvItem &mvItem = Items[i];
- int fIndex = GetFolderIndex(&mvItem);
- if (fIndex >= FolderStartFileIndex.Size())
- return false;
- const CItem &item = Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
- if (item.IsDirectory())
- continue;
- int folderIndex = GetFolderIndex(&mvItem);
- if (folderIndex != prevFolder)
- {
- prevFolder = folderIndex;
- maxPos = 0;
- continue;
- }
- if (item.Offset < maxPos)
- return false;
- maxPos = item.GetEndOffset();
- if (maxPos < item.Offset)
- return false;
- }
- return true;
-}
-
-}}
diff --git a/7zip/Archive/Cab/CabIn.h b/7zip/Archive/Cab/CabIn.h
deleted file mode 100755
index 4e817e94..00000000
--- a/7zip/Archive/Cab/CabIn.h
+++ /dev/null
@@ -1,166 +0,0 @@
-// Archive/CabIn.h
-
-#ifndef __ARCHIVE_CAB_IN_H
-#define __ARCHIVE_CAB_IN_H
-
-#include "../../IStream.h"
-#include "../../Common/InBuffer.h"
-#include "CabHeader.h"
-#include "CabItem.h"
-
-namespace NArchive {
-namespace NCab {
-
-class CInArchiveException
-{
-public:
- enum CCauseType
- {
- kUnexpectedEndOfArchive = 0,
- kIncorrectArchive,
- kUnsupported,
- } Cause;
- CInArchiveException(CCauseType cause) : Cause(cause) {}
-};
-
-struct COtherArchive
-{
- AString FileName;
- AString DiskName;
-};
-
-struct CArchiveInfo
-{
- Byte VersionMinor; /* cabinet file format version, minor */
- Byte VersionMajor; /* cabinet file format version, major */
- UInt16 NumFolders; /* number of CFFOLDER entries in this cabinet */
- UInt16 NumFiles; /* number of CFFILE entries in this cabinet */
- UInt16 Flags; /* cabinet file option indicators */
- UInt16 SetID; /* must be the same for all cabinets in a set */
- UInt16 CabinetNumber; /* number of this cabinet file in a set */
-
- bool ReserveBlockPresent() const { return (Flags & NHeader::NArchive::NFlags::kReservePresent) != 0; }
-
- bool IsTherePrev() const { return (Flags & NHeader::NArchive::NFlags::kPrevCabinet) != 0; }
- bool IsThereNext() const { return (Flags & NHeader::NArchive::NFlags::kNextCabinet) != 0; }
-
- UInt16 PerCabinetAreaSize; // (optional) size of per-cabinet reserved area
- Byte PerFolderAreaSize; // (optional) size of per-folder reserved area
- Byte PerDataBlockAreaSize; // (optional) size of per-datablock reserved area
-
- Byte GetDataBlockReserveSize() const { return (Byte)(ReserveBlockPresent() ? PerDataBlockAreaSize : 0); }
-
- COtherArchive PreviousArchive;
- COtherArchive NextArchive;
-
- CArchiveInfo()
- {
- Clear();
- }
-
- void Clear()
- {
- PerCabinetAreaSize = 0;
- PerFolderAreaSize = 0;
- PerDataBlockAreaSize = 0;
- }
-};
-
-struct CInArchiveInfo: public CArchiveInfo
-{
- UInt32 Size; /* size of this cabinet file in bytes */
- UInt32 FileHeadersOffset; //offset of the first CFFILE entry
-};
-
-
-class CDatabase
-{
-public:
- UInt64 StartPosition;
- CInArchiveInfo ArchiveInfo;
- CObjectVector<CFolder> Folders;
- CObjectVector<CItem> Items;
- void Clear()
- {
- ArchiveInfo.Clear();
- Folders.Clear();
- Items.Clear();
- }
- bool IsTherePrevFolder() const
- {
- for (int i = 0; i < Items.Size(); i++)
- if (Items[i].ContinuedFromPrev())
- return true;
- return false;
- }
- int GetNumberOfNewFolders() const
- {
- int res = Folders.Size();
- if (IsTherePrevFolder())
- res--;
- return res;
- }
- UInt32 GetFileOffset(int index) const { return Items[index].Offset; }
- UInt32 GetFileSize(int index) const { return Items[index].Size; }
-};
-
-class CDatabaseEx: public CDatabase
-{
-public:
- CMyComPtr<IInStream> Stream;
-};
-
-struct CMvItem
-{
- int VolumeIndex;
- int ItemIndex;
-};
-
-class CMvDatabaseEx
-{
- bool AreItemsEqual(int i1, int i2);
-public:
- CObjectVector<CDatabaseEx> Volumes;
- CRecordVector<CMvItem> Items;
- CRecordVector<int> StartFolderOfVol;
- CRecordVector<int> FolderStartFileIndex;
- int GetFolderIndex(const CMvItem *mvi) const
- {
- const CDatabaseEx &db = Volumes[mvi->VolumeIndex];
- return StartFolderOfVol[mvi->VolumeIndex] +
- db.Items[mvi->ItemIndex].GetFolderIndex(db.Folders.Size());
- }
- void Clear()
- {
- Volumes.Clear();
- Items.Clear();
- StartFolderOfVol.Clear();
- FolderStartFileIndex.Clear();
- }
- void FillSortAndShrink();
- bool Check();
-};
-
-class CInArchive
-{
- CInBuffer inBuffer;
-
- Byte ReadByte();
- UInt16 ReadUInt16();
- UInt32 ReadUInt32();
- AString SafeReadName();
- void Skeep(size_t size);
- void ReadOtherArchive(COtherArchive &oa);
-
- HRESULT Open2(IInStream *inStream,
- const UInt64 *searchHeaderSizeLimit,
- CDatabase &database);
-public:
- HRESULT Open(
- const UInt64 *searchHeaderSizeLimit,
- CDatabaseEx &database);
-};
-
-}}
-
-#endif
diff --git a/7zip/Archive/Cab/CabItem.h b/7zip/Archive/Cab/CabItem.h
deleted file mode 100755
index d8b56325..00000000
--- a/7zip/Archive/Cab/CabItem.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Archive/CabItem.h
-
-#ifndef __ARCHIVE_CAB_ITEM_H
-#define __ARCHIVE_CAB_ITEM_H
-
-#include "Common/Types.h"
-#include "Common/String.h"
-#include "CabHeader.h"
-
-namespace NArchive {
-namespace NCab {
-
-struct CFolder
-{
- UInt32 DataStart; // offset of the first CFDATA block in this folder
- UInt16 NumDataBlocks; // number of CFDATA blocks in this folder
- Byte CompressionTypeMajor;
- Byte CompressionTypeMinor;
- Byte GetCompressionMethod() const { return (Byte)(CompressionTypeMajor & 0xF); }
-};
-
-class CItem
-{
-public:
- AString Name;
- UInt32 Offset;
- UInt32 Size;
- UInt32 Time;
- 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 ContinuedFromPrev() const
- {
- return
- (FolderIndex == NHeader::NFolderIndex::kContinuedFromPrev) ||
- (FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext);
- }
- bool ContinuedToNext() const
- {
- return
- (FolderIndex == NHeader::NFolderIndex::kContinuedToNext) ||
- (FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext);
- }
-
- int GetFolderIndex(int numFolders) const
- {
- if (ContinuedFromPrev())
- return 0;
- if (ContinuedToNext())
- return (numFolders - 1);
- return FolderIndex;
- }
-};
-
-}}
-
-#endif
diff --git a/7zip/Archive/Common/CoderMixer2MT.cpp b/7zip/Archive/Common/CoderMixer2MT.cpp
deleted file mode 100755
index 28fd3d6a..00000000
--- a/7zip/Archive/Common/CoderMixer2MT.cpp
+++ /dev/null
@@ -1,359 +0,0 @@
-// CoderMixer2MT.cpp
-
-#include "StdAfx.h"
-
-#include "CoderMixer2MT.h"
-#include "CrossThreadProgress.h"
-
-using namespace NWindows;
-using namespace NSynchronization;
-
-namespace NCoderMixer2 {
-
-CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams):
- ExitEvent(NULL),
- CompressEvent(NULL),
- CompressionCompletedEvent(NULL),
- CCoderInfo(numInStreams, numOutStreams)
-{
- InStreams.Reserve(NumInStreams);
- InStreamPointers.Reserve(NumInStreams);
- OutStreams.Reserve(NumOutStreams);
- OutStreamPointers.Reserve(NumOutStreams);
-}
-
-void CThreadCoderInfo::CreateEvents()
-{
- CompressEvent = new CAutoResetEvent(false);
- CompressionCompletedEvent = new CAutoResetEvent(false);
-}
-
-CThreadCoderInfo::~CThreadCoderInfo()
-{
- if (CompressEvent != NULL)
- delete CompressEvent;
- if (CompressionCompletedEvent != NULL)
- delete CompressionCompletedEvent;
-}
-
-class CCoderInfoFlusher2
-{
- CThreadCoderInfo *m_CoderInfo;
-public:
- CCoderInfoFlusher2(CThreadCoderInfo *coderInfo): m_CoderInfo(coderInfo) {}
- ~CCoderInfoFlusher2()
- {
- int i;
- for (i = 0; i < m_CoderInfo->InStreams.Size(); i++)
- m_CoderInfo->InStreams[i].Release();
- for (i = 0; i < m_CoderInfo->OutStreams.Size(); i++)
- m_CoderInfo->OutStreams[i].Release();
- m_CoderInfo->CompressionCompletedEvent->Set();
- }
-};
-
-bool CThreadCoderInfo::WaitAndCode()
-{
- HANDLE events[2] = { ExitEvent, *CompressEvent };
- DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
- if (waitResult == WAIT_OBJECT_0 + 0)
- return false;
-
- {
- InStreamPointers.Clear();
- OutStreamPointers.Clear();
- UInt32 i;
- for (i = 0; i < NumInStreams; i++)
- {
- if (InSizePointers[i] != NULL)
- InSizePointers[i] = &InSizes[i];
- InStreamPointers.Add(InStreams[i]);
- }
- for (i = 0; i < NumOutStreams; i++)
- {
- if (OutSizePointers[i] != NULL)
- OutSizePointers[i] = &OutSizes[i];
- OutStreamPointers.Add(OutStreams[i]);
- }
- CCoderInfoFlusher2 coderInfoFlusher(this);
- if (Coder)
- Result = Coder->Code(InStreamPointers[0],
- OutStreamPointers[0],
- InSizePointers[0],
- OutSizePointers[0],
- Progress);
- else
- Result = Coder2->Code(&InStreamPointers.Front(),
- &InSizePointers.Front(),
- NumInStreams,
- &OutStreamPointers.Front(),
- &OutSizePointers.Front(),
- NumOutStreams,
- Progress);
- }
- return true;
-}
-
-static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
- CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems)
-{
- sizes.Clear();
- sizePointers.Clear();
- for(UInt32 i = 0; i < numItems; i++)
- {
- if (srcSizes == 0 || srcSizes[i] == NULL)
- {
- sizes.Add(0);
- sizePointers.Add(NULL);
- }
- else
- {
- sizes.Add(*srcSizes[i]);
- sizePointers.Add(&sizes.Back());
- }
- }
-}
-
-
-void CThreadCoderInfo::SetCoderInfo(const UInt64 **inSizes,
- const UInt64 **outSizes, ICompressProgressInfo *progress)
-{
- Progress = progress;
- SetSizes(inSizes, InSizes, InSizePointers, NumInStreams);
- SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
-}
-
-static DWORD WINAPI CoderThread(void *threadCoderInfo)
-{
- for (;;)
- {
- if (!((CThreadCoderInfo *)threadCoderInfo)->WaitAndCode())
- return 0;
- }
-}
-
-//////////////////////////////////////
-// CCoderMixer2MT
-
-static DWORD WINAPI MainCoderThread(void *threadCoderInfo)
-{
- for (;;)
- {
- if (!((CCoderMixer2MT *)threadCoderInfo)->MyCode())
- return 0;
- }
-}
-
-CCoderMixer2MT::CCoderMixer2MT()
-{
- if (!_mainThread.Create(MainCoderThread, this))
- throw 271825;
-}
-
-CCoderMixer2MT::~CCoderMixer2MT()
-{
- _exitEvent.Set();
- _mainThread.Wait();
- for(int i = 0; i < _threads.Size(); i++)
- {
- _threads[i].Wait();
- _threads[i].Close();
- }
-}
-
-void CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
-{
- _bindInfo = bindInfo;
- _streamBinders.Clear();
- for(int i = 0; i < _bindInfo.BindPairs.Size(); i++)
- {
- _streamBinders.Add(CStreamBinder());
- _streamBinders.Back().CreateEvents();
- }
-}
-
-void CCoderMixer2MT::AddCoderCommon()
-{
- int index = _coderInfoVector.Size();
- const CCoderStreamsInfo &CoderStreamsInfo = _bindInfo.Coders[index];
-
- CThreadCoderInfo threadCoderInfo(CoderStreamsInfo.NumInStreams,
- CoderStreamsInfo.NumOutStreams);
- _coderInfoVector.Add(threadCoderInfo);
- _coderInfoVector.Back().CreateEvents();
- _coderInfoVector.Back().ExitEvent = _exitEvent;
- _compressingCompletedEvents.Add(*_coderInfoVector.Back().CompressionCompletedEvent);
-
- NWindows::CThread newThread;
- _threads.Add(newThread);
- if (!_threads.Back().Create(CoderThread, &_coderInfoVector.Back()))
- throw 271824;
-}
-
-void CCoderMixer2MT::AddCoder(ICompressCoder *coder)
-{
- AddCoderCommon();
- _coderInfoVector.Back().Coder = coder;
-}
-
-void CCoderMixer2MT::AddCoder2(ICompressCoder2 *coder)
-{
- AddCoderCommon();
- _coderInfoVector.Back().Coder2 = coder;
-}
-
-/*
-void CCoderMixer2MT::FinishAddingCoders()
-{
- for(int i = 0; i < _coderInfoVector.Size(); i++)
- {
- DWORD id;
- HANDLE newThread = ::CreateThread(NULL, 0, CoderThread,
- &_coderInfoVector[i], 0, &id);
- if (newThread == 0)
- throw 271824;
- _threads.Add(newThread);
- }
-}
-*/
-
-void CCoderMixer2MT::ReInit()
-{
- for(int i = 0; i < _streamBinders.Size(); i++)
- _streamBinders[i].ReInit();
-}
-
-
-STDMETHODIMP CCoderMixer2MT::Init(ISequentialInStream **inStreams,
- ISequentialOutStream **outStreams)
-{
- if (_coderInfoVector.Size() != _bindInfo.Coders.Size())
- throw 0;
- int i;
- for(i = 0; i < _coderInfoVector.Size(); i++)
- {
- CThreadCoderInfo &coderInfo = _coderInfoVector[i];
- const CCoderStreamsInfo &coderStreamsInfo = _bindInfo.Coders[i];
- coderInfo.InStreams.Clear();
- UInt32 j;
- for(j = 0; j < coderStreamsInfo.NumInStreams; j++)
- coderInfo.InStreams.Add(NULL);
- coderInfo.OutStreams.Clear();
- for(j = 0; j < coderStreamsInfo.NumOutStreams; j++)
- coderInfo.OutStreams.Add(NULL);
- }
-
- for(i = 0; i < _bindInfo.BindPairs.Size(); i++)
- {
- const CBindPair &bindPair = _bindInfo.BindPairs[i];
- UInt32 inCoderIndex, inCoderStreamIndex;
- UInt32 outCoderIndex, outCoderStreamIndex;
- _bindInfo.FindInStream(bindPair.InIndex, inCoderIndex, inCoderStreamIndex);
- _bindInfo.FindOutStream(bindPair.OutIndex, outCoderIndex, outCoderStreamIndex);
-
- _streamBinders[i].CreateStreams(
- &_coderInfoVector[inCoderIndex].InStreams[inCoderStreamIndex],
- &_coderInfoVector[outCoderIndex].OutStreams[outCoderStreamIndex]);
- }
-
- for(i = 0; i < _bindInfo.InStreams.Size(); i++)
- {
- UInt32 inCoderIndex, inCoderStreamIndex;
- _bindInfo.FindInStream(_bindInfo.InStreams[i], inCoderIndex, inCoderStreamIndex);
- _coderInfoVector[inCoderIndex].InStreams[inCoderStreamIndex] = inStreams[i];
- }
-
- for(i = 0; i < _bindInfo.OutStreams.Size(); i++)
- {
- UInt32 outCoderIndex, outCoderStreamIndex;
- _bindInfo.FindOutStream(_bindInfo.OutStreams[i], outCoderIndex, outCoderStreamIndex);
- _coderInfoVector[outCoderIndex].OutStreams[outCoderStreamIndex] = outStreams[i];
- }
- return S_OK;
-}
-
-
-bool CCoderMixer2MT::MyCode()
-{
- HANDLE events[2] = { _exitEvent, _startCompressingEvent };
- DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
- if (waitResult == WAIT_OBJECT_0 + 0)
- return false;
-
- for(int i = 0; i < _coderInfoVector.Size(); i++)
- _coderInfoVector[i].CompressEvent->Set();
- /* DWORD result = */ ::WaitForMultipleObjects(_compressingCompletedEvents.Size(),
- &_compressingCompletedEvents.Front(), TRUE, INFINITE);
-
- _compressingFinishedEvent.Set();
-
- return true;
-}
-
-
-STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams,
- const UInt64 ** /* inSizes */,
- UInt32 numInStreams,
- ISequentialOutStream **outStreams,
- const UInt64 ** /* outSizes */,
- UInt32 numOutStreams,
- ICompressProgressInfo *progress)
-{
- if (numInStreams != (UInt32)_bindInfo.InStreams.Size() ||
- numOutStreams != (UInt32)_bindInfo.OutStreams.Size())
- return E_INVALIDARG;
-
- Init(inStreams, outStreams);
-
- _compressingFinishedEvent.Reset(); // ?
-
- CCrossThreadProgress *progressSpec = new CCrossThreadProgress;
- CMyComPtr<ICompressProgressInfo> crossProgress = progressSpec;
- progressSpec->Init();
- _coderInfoVector[_progressCoderIndex].Progress = crossProgress;
-
- _startCompressingEvent.Set();
-
-
- for (;;)
- {
- HANDLE events[2] = {_compressingFinishedEvent, progressSpec->ProgressEvent };
- DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
- if (waitResult == WAIT_OBJECT_0 + 0)
- break;
- if (progress != NULL)
- progressSpec->Result = progress->SetRatioInfo(progressSpec->InSize,
- progressSpec->OutSize);
- else
- progressSpec->Result = S_OK;
- progressSpec->WaitEvent.Set();
- }
-
- int i;
- for(i = 0; i < _coderInfoVector.Size(); i++)
- {
- HRESULT result = _coderInfoVector[i].Result;
- if (result == S_FALSE)
- return result;
- }
- for(i = 0; i < _coderInfoVector.Size(); i++)
- {
- HRESULT result = _coderInfoVector[i].Result;
- if (result != S_OK && result != E_FAIL)
- return result;
- }
- for(i = 0; i < _coderInfoVector.Size(); i++)
- {
- HRESULT result = _coderInfoVector[i].Result;
- if (result != S_OK)
- return result;
- }
- return S_OK;
-}
-
-UInt64 CCoderMixer2MT::GetWriteProcessedSize(UInt32 binderIndex) const
-{
- return _streamBinders[binderIndex].ProcessedSize;
-}
-
-}
diff --git a/7zip/Archive/Lzh/LzhCRC.h b/7zip/Archive/Lzh/LzhCRC.h
deleted file mode 100755
index bb5546db..00000000
--- a/7zip/Archive/Lzh/LzhCRC.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// LzhCRC.h
-
-#ifndef __LZH_CRC_H
-#define __LZH_CRC_H
-
-#include <stddef.h>
-#include "Common/Types.h"
-
-namespace NArchive {
-namespace NLzh {
-
-class CCRC
-{
- UInt16 _value;
-public:
- static UInt16 Table[256];
- static void InitTable();
-
- CCRC(): _value(0){};
- void Init() { _value = 0; }
- void Update(const void *data, size_t size);
- UInt16 GetDigest() const { return _value; }
-};
-
-}}
-
-#endif
diff --git a/7zip/Archive/Nsis/NsisIn.h b/7zip/Archive/Nsis/NsisIn.h
deleted file mode 100755
index b7e87e5d..00000000
--- a/7zip/Archive/Nsis/NsisIn.h
+++ /dev/null
@@ -1,166 +0,0 @@
-// Archive/NsisIn.h
-
-#ifndef __ARCHIVE_ISO_IN_H
-#define __ARCHIVE_ISO_IN_H
-
-#include "Common/MyCom.h"
-#include "Common/IntToString.h"
-#include "Common/Buffer.h"
-
-#include "../../IStream.h"
-
-#include "NsisDecode.h"
-
-// #define NSIS_SCRIPT
-
-namespace NArchive {
-namespace NNsis {
-
-const int kSignatureSize = 16;
-extern Byte kSignature[kSignatureSize];
-
-const UInt32 kFlagsMask = 0xF;
-namespace NFlags
-{
- const UInt32 kUninstall = 1;
- const UInt32 kSilent = 2;
- const UInt32 kNoCrc = 4;
- const UInt32 kForceCrc = 8;
-}
-
-struct CFirstHeader
-{
- UInt32 Flags;
- UInt32 HeaderLength;
-
- UInt32 ArchiveSize;
-
- bool ThereIsCrc() const
- {
- if ((Flags & NFlags::kForceCrc ) != 0)
- return true;
- return ((Flags & NFlags::kNoCrc) == 0);
- }
-
- UInt32 GetDataSize() const { return ArchiveSize - (ThereIsCrc() ? 4 : 0); }
-};
-
-
-struct CBlockHeader
-{
- UInt32 Offset;
- UInt32 Num;
-};
-
-struct CItem
-{
- AString Prefix;
- AString Name;
- UInt32 Pos;
- bool SizeIsDefined;
- bool CompressedSizeIsDefined;
- bool EstimatedSizeIsDefined;
- UInt32 Size;
- UInt32 CompressedSize;
- UInt32 EstimatedSize;
- FILETIME DateTime;
- UInt32 DictionarySize;
- bool IsCompressed;
- bool UseFilter;
- CItem(): UseFilter(false), SizeIsDefined(false), EstimatedSizeIsDefined(false),
- IsCompressed(true), CompressedSizeIsDefined(false), Size(0) {}
-
- bool IsINSTDIR() const
- {
- if (Prefix.Length() < 3)
- return false;
- return true;
- }
-
- AString GetReducedName() const
- {
- AString prefix = Prefix;
- if (prefix.Length() > 0)
- if (prefix[prefix.Length() - 1] != '\\')
- prefix += '\\';
- AString s2 = prefix + Name;
- const int len = 9;
- if (s2.Left(len).CompareNoCase("$INSTDIR\\") == 0)
- s2 = s2.Mid(len);
- return s2;
- }
-
-};
-
-class CInArchive
-{
- UInt64 _archiveSize;
- CMyComPtr<IInStream> _stream;
-
- Byte ReadByte();
- UInt32 ReadUInt32();
- HRESULT Open2();
- void ReadBlockHeader(CBlockHeader &bh);
- AString ReadString(UInt32 pos);
- AString ReadString2(UInt32 pos);
- HRESULT ReadEntries(const CBlockHeader &bh);
- HRESULT Parse();
-
- CByteBuffer _data;
- UInt64 _size;
-
- size_t _posInData;
-
- UInt32 _stringsPos;
-
-
- bool _headerIsCompressed;
- UInt32 _nonSolidStartOffset;
-public:
- HRESULT Open(IInStream *inStream, const UInt64 *maxCheckStartPosition);
- void Clear();
-
- UInt64 StreamOffset;
- CDecoder Decoder;
- CObjectVector<CItem> Items;
- bool IsSolid;
- CFirstHeader FirstHeader;
- NMethodType::EEnum Method;
- bool UseFilter;
- UInt32 DictionarySize;
- bool FilterFlag;
-
- #ifdef NSIS_SCRIPT
- AString Script;
- #endif
- UInt32 GetOffset() const { return IsSolid ? 4 : 0; }
- UInt64 GetDataPos(int index)
- {
- const CItem &item = Items[index];
- return GetOffset() + FirstHeader.HeaderLength + item.Pos;
- }
-
- UInt64 GetPosOfSolidItem(int index) const
- {
- const CItem &item = Items[index];
- return 4 + FirstHeader.HeaderLength + item.Pos;
- }
-
- UInt64 GetPosOfNonSolidItem(int index) const
- {
- const CItem &item = Items[index];
- return StreamOffset + _nonSolidStartOffset + 4 + item.Pos;
- }
-
- void Release()
- {
- Decoder.Release();
- }
-
-};
-
-UInt32 GetUInt32FromMemLE(const Byte *p);
-
-}}
-
-#endif
diff --git a/7zip/Archive/Zip/ZipUpdate.cpp b/7zip/Archive/Zip/ZipUpdate.cpp
deleted file mode 100755
index 349e780a..00000000
--- a/7zip/Archive/Zip/ZipUpdate.cpp
+++ /dev/null
@@ -1,718 +0,0 @@
-// ZipUpdate.cpp
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-
-#include "ZipUpdate.h"
-#include "ZipAddCommon.h"
-#include "ZipOut.h"
-
-#include "Common/Defs.h"
-#include "Common/AutoPtr.h"
-#include "Common/StringConvert.h"
-#include "Windows/Defs.h"
-#include "Windows/Thread.h"
-
-#include "../../Common/ProgressUtils.h"
-#ifdef COMPRESS_MT
-#include "../../Common/ProgressMt.h"
-#endif
-#include "../../Common/LimitedStreams.h"
-#include "../../Common/OutMemStream.h"
-
-#include "../../Compress/Copy/CopyCoder.h"
-
-using namespace NWindows;
-using namespace NSynchronization;
-
-namespace NArchive {
-namespace NZip {
-
-class CCriticalSectionLock2
-{
- CCriticalSection *_object;
- void Unlock() { if (_object != 0) _object->Leave(); }
-public:
- CCriticalSectionLock2(): _object(0) {}
- void Set(CCriticalSection &object) { _object = &object; _object->Enter(); }
- ~CCriticalSectionLock2() { Unlock(); }
-};
-
-static const Byte kMadeByHostOS = NFileHeader::NHostOS::kFAT;
-static const Byte kExtractHostOS = NFileHeader::NHostOS::kFAT;
-
-static const Byte kMethodForDirectory = NFileHeader::NCompressionMethod::kStored;
-static const Byte kExtractVersionForDirectory = NFileHeader::NCompressionMethod::kStoreExtractVersion;
-
-static HRESULT CopyBlockToArchive(ISequentialInStream *inStream,
- COutArchive &outArchive, ICompressProgressInfo *progress)
-{
- CMyComPtr<ISequentialOutStream> outStream;
- outArchive.CreateStreamForCopying(&outStream);
- CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
- return copyCoder->Code(inStream, outStream, NULL, NULL, progress);
-}
-
-static HRESULT WriteRange(IInStream *inStream, COutArchive &outArchive,
- const CUpdateRange &range, ICompressProgressInfo *progress)
-{
- UInt64 position;
- RINOK(inStream->Seek(range.Position, STREAM_SEEK_SET, &position));
-
- CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
- CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
- streamSpec->SetStream(inStream);
- streamSpec->Init(range.Size);
-
- RINOK(CopyBlockToArchive(inStreamLimited, outArchive, progress));
- return progress->SetRatioInfo(&range.Size, &range.Size);
-}
-
-static void SetFileHeader(
- COutArchive &archive,
- const CCompressionMethodMode &options,
- const CUpdateItem &updateItem,
- CItem &item)
-{
- item.UnPackSize = updateItem.Size;
- bool isDirectory;
-
- if (updateItem.NewProperties)
- {
- isDirectory = updateItem.IsDirectory;
- item.Name = updateItem.Name;
- item.ExternalAttributes = updateItem.Attributes;
- item.Time = updateItem.Time;
- }
- else
- isDirectory = item.IsDirectory();
-
- item.LocalHeaderPosition = archive.GetCurrentPosition();
- item.MadeByVersion.HostOS = kMadeByHostOS;
- item.MadeByVersion.Version = NFileHeader::NCompressionMethod::kMadeByProgramVersion;
-
- item.ExtractVersion.HostOS = kExtractHostOS;
-
- item.InternalAttributes = 0; // test it
- item.ClearFlags();
- item.SetEncrypted(!isDirectory && options.PasswordIsDefined);
- if (isDirectory)
- {
- item.ExtractVersion.Version = kExtractVersionForDirectory;
- item.CompressionMethod = kMethodForDirectory;
- item.PackSize = 0;
- item.FileCRC = 0; // test it
- }
-}
-
-static void SetItemInfoFromCompressingResult(const CCompressingResult &compressingResult,
- bool isAesMode, Byte aesKeyMode, CItem &item)
-{
- item.ExtractVersion.Version = compressingResult.ExtractVersion;
- item.CompressionMethod = compressingResult.Method;
- item.FileCRC = compressingResult.CRC;
- item.UnPackSize = compressingResult.UnpackSize;
- item.PackSize = compressingResult.PackSize;
-
- item.LocalExtra.Clear();
- item.CentralExtra.Clear();
-
- if (isAesMode)
- {
- CWzAesExtraField wzAesField;
- wzAesField.Strength = aesKeyMode;
- wzAesField.Method = compressingResult.Method;
- item.CompressionMethod = NFileHeader::NCompressionMethod::kWzAES;
- item.FileCRC = 0;
- CExtraSubBlock sb;
- wzAesField.SetSubBlock(sb);
- item.LocalExtra.SubBlocks.Add(sb);
- item.CentralExtra.SubBlocks.Add(sb);
- }
-}
-
-#ifdef COMPRESS_MT
-
-static DWORD WINAPI CoderThread(void *threadCoderInfo);
-
-struct CThreadInfo
-{
- NWindows::CThread Thread;
- CAutoResetEvent *CompressEvent;
- CAutoResetEvent *CompressionCompletedEvent;
- bool ExitThread;
-
- CMtCompressProgress *ProgressSpec;
- CMyComPtr<ICompressProgressInfo> Progress;
-
- COutMemStream *OutStreamSpec;
- CMyComPtr<IOutStream> OutStream;
- CMyComPtr<ISequentialInStream> InStream;
-
- CAddCommon Coder;
- HRESULT Result;
- CCompressingResult CompressingResult;
-
- bool IsFree;
- UInt32 UpdateIndex;
-
- CThreadInfo(const CCompressionMethodMode &options):
- CompressEvent(NULL),
- CompressionCompletedEvent(NULL),
- ExitThread(false),
- ProgressSpec(0),
- OutStreamSpec(0),
- Coder(options)
- {}
-
- void CreateEvents()
- {
- CompressEvent = new CAutoResetEvent(false);
- CompressionCompletedEvent = new CAutoResetEvent(false);
- }
- bool CreateThread() { return Thread.Create(CoderThread, this); }
- ~CThreadInfo();
-
- void WaitAndCode();
- void StopWaitClose()
- {
- ExitThread = true;
- if (OutStreamSpec != 0)
- OutStreamSpec->StopWriting(E_ABORT);
- if (CompressEvent != NULL)
- CompressEvent->Set();
- Thread.Wait();
- Thread.Close();
- }
-
-};
-
-CThreadInfo::~CThreadInfo()
-{
- if (CompressEvent != NULL)
- delete CompressEvent;
- if (CompressionCompletedEvent != NULL)
- delete CompressionCompletedEvent;
-}
-
-void CThreadInfo::WaitAndCode()
-{
- for (;;)
- {
- CompressEvent->Lock();
- if (ExitThread)
- return;
- Result = Coder.Compress(InStream, OutStream, Progress, CompressingResult);
- if (Result == S_OK && Progress)
- Result = Progress->SetRatioInfo(&CompressingResult.UnpackSize, &CompressingResult.PackSize);
- CompressionCompletedEvent->Set();
- }
-}
-
-static DWORD WINAPI CoderThread(void *threadCoderInfo)
-{
- ((CThreadInfo *)threadCoderInfo)->WaitAndCode();
- return 0;
-}
-
-class CThreads
-{
-public:
- CObjectVector<CThreadInfo> Threads;
- ~CThreads()
- {
- for (int i = 0; i < Threads.Size(); i++)
- Threads[i].StopWaitClose();
- }
-};
-
-struct CMemBlocks2: public CMemLockBlocks
-{
- CCompressingResult CompressingResult;
- bool Defined;
- bool Skip;
- CMemBlocks2(): Defined(false), Skip(false) {}
-};
-
-class CMemRefs
-{
-public:
- CMemBlockManagerMt *Manager;
- CObjectVector<CMemBlocks2> Refs;
- CMemRefs(CMemBlockManagerMt *manager): Manager(manager) {} ;
- ~CMemRefs()
- {
- for (int i = 0; i < Refs.Size(); i++)
- Refs[i].FreeOpt(Manager);
- }
-};
-
-#endif
-
-static HRESULT Update2(COutArchive &archive,
- CInArchive *inArchive,
- IInStream *inStream,
- const CObjectVector<CItemEx> &inputItems,
- const CObjectVector<CUpdateItem> &updateItems,
- const CCompressionMethodMode *options,
- const CByteBuffer &comment,
- IArchiveUpdateCallback *updateCallback)
-{
- UInt64 complexity = 0;
- UInt64 numFilesToCompress = 0;
- UInt64 numBytesToCompress = 0;
-
- int i;
- for(i = 0; i < updateItems.Size(); i++)
- {
- const CUpdateItem &updateItem = updateItems[i];
- if (updateItem.NewData)
- {
- complexity += updateItem.Size;
- numBytesToCompress += updateItem.Size;
- numFilesToCompress++;
- /*
- if (updateItem.Commented)
- complexity += updateItem.CommentRange.Size;
- */
- }
- else
- {
- CItemEx inputItem = inputItems[updateItem.IndexInArchive];
- if (inArchive->ReadLocalItemAfterCdItemFull(inputItem) != S_OK)
- return E_NOTIMPL;
- complexity += inputItem.GetLocalFullSize();
- // complexity += inputItem.GetCentralExtraPlusCommentSize();
- }
- complexity += NFileHeader::kLocalBlockSize;
- complexity += NFileHeader::kCentralBlockSize;
- }
-
- if (comment != 0)
- complexity += comment.GetCapacity();
- complexity++; // end of central
- updateCallback->SetTotal(complexity);
-
- CAddCommon compressor(*options);
-
- complexity = 0;
-
- CObjectVector<CItem> items;
-
- CLocalProgress *localProgressSpec = new CLocalProgress;
- CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
- localProgressSpec->Init(updateCallback, true);
-
- CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
- CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
-
-
- #ifdef COMPRESS_MT
-
- const size_t kNumMaxThreads = (1 << 10);
- UInt32 numThreads = options->NumThreads;
- if (numThreads > kNumMaxThreads)
- numThreads = kNumMaxThreads;
-
- const size_t kMemPerThread = (1 << 25);
- const size_t kBlockSize = 1 << 16;
-
- CCompressionMethodMode options2;
- if (options != 0)
- options2 = *options;
-
- bool mtMode = ((options != 0) && (numThreads > 1));
-
- if (numFilesToCompress <= 1)
- mtMode = false;
-
- if (mtMode)
- {
- Byte method = options->MethodSequence.Front();
- if (method == NFileHeader::NCompressionMethod::kStored && !options->PasswordIsDefined)
- mtMode = false;
- if (method == NFileHeader::NCompressionMethod::kBZip2)
- {
- UInt64 averageSize = numBytesToCompress / numFilesToCompress;
- UInt32 blockSize = options->DicSize;
- if (blockSize == 0)
- blockSize = 1;
- UInt64 averageNumberOfBlocks = averageSize / blockSize;
- UInt32 numBZip2Threads = 32;
- if (averageNumberOfBlocks < numBZip2Threads)
- numBZip2Threads = (UInt32)averageNumberOfBlocks;
- if (numBZip2Threads < 1)
- numBZip2Threads = 1;
- numThreads = numThreads / numBZip2Threads;
- options2.NumThreads = numBZip2Threads;
- if (numThreads <= 1)
- mtMode = false;
- }
- }
-
-
- CMtCompressProgressMixer mtCompressProgressMixer;
- mtCompressProgressMixer.Init(numThreads + 1, localProgress);
-
- // we need one item for main stream
- CMtCompressProgress *progressMainSpec = new CMtCompressProgress();
- CMyComPtr<ICompressProgressInfo> progressMain = progressMainSpec;
- progressMainSpec->Init(&mtCompressProgressMixer, (int)numThreads);
-
- CMemBlockManagerMt memManager(kBlockSize);
- CMemRefs refs(&memManager);
-
- CThreads threads;
- CRecordVector<HANDLE> compressingCompletedEvents;
- CRecordVector<int> threadIndices; // list threads in order of updateItems
-
- if (mtMode)
- {
- if (!memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize)))
- return E_OUTOFMEMORY;
- for(i = 0; i < updateItems.Size(); i++)
- refs.Refs.Add(CMemBlocks2());
-
- UInt32 i;
- for (i = 0; i < numThreads; i++)
- threads.Threads.Add(CThreadInfo(options2));
-
- for (i = 0; i < numThreads; i++)
- {
- CThreadInfo &threadInfo = threads.Threads[i];
- threadInfo.CreateEvents();
- threadInfo.OutStreamSpec = new COutMemStream(&memManager);
- threadInfo.OutStream = threadInfo.OutStreamSpec;
- threadInfo.IsFree = true;
- threadInfo.ProgressSpec = new CMtCompressProgress();
- threadInfo.Progress = threadInfo.ProgressSpec;
- threadInfo.ProgressSpec->Init(&mtCompressProgressMixer, (int)i);
- if (!threadInfo.CreateThread())
- return ::GetLastError();
- }
- }
- int mtItemIndex = 0;
-
- #endif
-
- int itemIndex = 0;
- int lastRealStreamItemIndex = -1;
-
- while(itemIndex < updateItems.Size())
- {
- #ifdef COMPRESS_MT
- if (!mtMode)
- #endif
- {
- RINOK(updateCallback->SetCompleted(&complexity));
- }
-
- #ifdef COMPRESS_MT
- if (mtMode && (UInt32)threadIndices.Size() < numThreads && mtItemIndex < updateItems.Size())
- {
- const CUpdateItem &updateItem = updateItems[mtItemIndex++];
- if (!updateItem.NewData)
- continue;
- CItemEx item;
- if (updateItem.NewProperties)
- {
- if (updateItem.IsDirectory)
- continue;
- }
- else
- {
- item = inputItems[updateItem.IndexInArchive];
- if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
- return E_NOTIMPL;
- if (item.IsDirectory())
- continue;
- }
- CMyComPtr<ISequentialInStream> fileInStream;
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(mtCompressProgressMixer.CriticalSection);
- HRESULT res = updateCallback->GetStream(updateItem.IndexInClient, &fileInStream);
- if (res == S_FALSE)
- {
- complexity += updateItem.Size;
- complexity++;
- RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
- refs.Refs[mtItemIndex - 1].Skip = true;
- continue;
- }
- RINOK(res);
- RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
- }
-
- for (UInt32 i = 0; i < numThreads; i++)
- {
- CThreadInfo &threadInfo = threads.Threads[i];
- if (threadInfo.IsFree)
- {
- threadInfo.IsFree = false;
- threadInfo.InStream = fileInStream;
- threadInfo.OutStreamSpec->Init();
- threadInfo.ProgressSpec->Reinit();
- threadInfo.CompressEvent->Set();
- threadInfo.UpdateIndex = mtItemIndex - 1;
-
- compressingCompletedEvents.Add(*threadInfo.CompressionCompletedEvent);
- threadIndices.Add(i);
- break;
- }
- }
- continue;
- }
- if (mtMode)
- if (refs.Refs[itemIndex].Skip)
- {
- itemIndex++;
- continue;
- }
- #endif
-
- const CUpdateItem &updateItem = updateItems[itemIndex];
-
- CItemEx item;
- if (!updateItem.NewProperties || !updateItem.NewData)
- {
- item = inputItems[updateItem.IndexInArchive];
- if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
- return E_NOTIMPL;
- }
-
-
- bool isDirectory;
- if (updateItem.NewProperties)
- isDirectory = updateItem.IsDirectory;
- else
- isDirectory = item.IsDirectory();
-
- if (updateItem.NewData)
- {
- #ifdef COMPRESS_MT
- if (mtMode && !isDirectory)
- {
- if (lastRealStreamItemIndex < itemIndex)
- {
- lastRealStreamItemIndex = itemIndex;
- SetFileHeader(archive, *options, updateItem, item);
- // file Size can be 64-bit !!!
- archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), updateItem.Size, options->IsAesMode);
- }
-
- CMemBlocks2 &memRef = refs.Refs[itemIndex];
- if (memRef.Defined)
- {
- CMyComPtr<IOutStream> outStream;
- archive.CreateStreamForCompressing(&outStream);
- memRef.WriteToStream(memManager.GetBlockSize(), outStream);
- SetItemInfoFromCompressingResult(memRef.CompressingResult,
- options->IsAesMode, options->AesKeyMode, item);
- SetFileHeader(archive, *options, updateItem, item);
- RINOK(archive.WriteLocalHeader(item));
- complexity += item.UnPackSize;
- // RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
- memRef.FreeOpt(&memManager);
- }
- else
- {
- {
- CThreadInfo &thread = threads.Threads[threadIndices.Front()];
- if (!thread.OutStreamSpec->WasUnlockEventSent())
- {
- CMyComPtr<IOutStream> outStream;
- archive.CreateStreamForCompressing(&outStream);
- thread.OutStreamSpec->SetOutStream(outStream);
- thread.OutStreamSpec->SetRealStreamMode();
- }
- }
-
- DWORD result = ::WaitForMultipleObjects(compressingCompletedEvents.Size(),
- &compressingCompletedEvents.Front(), FALSE, INFINITE);
- int t = (int)(result - WAIT_OBJECT_0);
- CThreadInfo &threadInfo = threads.Threads[threadIndices[t]];
- threadInfo.InStream.Release();
- threadInfo.IsFree = true;
- RINOK(threadInfo.Result);
- threadIndices.Delete(t);
- compressingCompletedEvents.Delete(t);
- if (t == 0)
- {
- RINOK(threadInfo.OutStreamSpec->WriteToRealStream());
- threadInfo.OutStreamSpec->ReleaseOutStream();
- SetItemInfoFromCompressingResult(threadInfo.CompressingResult,
- options->IsAesMode, options->AesKeyMode, item);
- SetFileHeader(archive, *options, updateItem, item);
- RINOK(archive.WriteLocalHeader(item));
- complexity += item.UnPackSize;
- }
- else
- {
- CMemBlocks2 &memRef = refs.Refs[threadInfo.UpdateIndex];
- threadInfo.OutStreamSpec->DetachData(memRef);
- memRef.CompressingResult = threadInfo.CompressingResult;
- memRef.Defined = true;
- continue;
- }
- }
- }
- else
- #endif
- {
- {
- CMyComPtr<ISequentialInStream> fileInStream;
- {
- #ifdef COMPRESS_MT
- CCriticalSectionLock2 lock;
- if (mtMode)
- lock.Set(mtCompressProgressMixer.CriticalSection);
- #endif
- HRESULT res = updateCallback->GetStream(updateItem.IndexInClient, &fileInStream);
- if (res == S_FALSE)
- {
- complexity += updateItem.Size;
- complexity++;
- RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
- itemIndex++;
- continue;
- }
- RINOK(res);
-
- #ifdef COMPRESS_MT
- if (mtMode)
- {
- RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
- }
- #endif
- }
- // file Size can be 64-bit !!!
- SetFileHeader(archive, *options, updateItem, item);
- archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), updateItem.Size, options->IsAesMode);
-
- if(!isDirectory)
- {
- CCompressingResult compressingResult;
- CMyComPtr<IOutStream> outStream;
- archive.CreateStreamForCompressing(&outStream);
-
- localCompressProgressSpec->Init(localProgress, &complexity, NULL);
-
- RINOK(compressor.Compress(fileInStream, outStream, compressProgress, compressingResult));
-
- SetItemInfoFromCompressingResult(compressingResult,
- options->IsAesMode, options->AesKeyMode, item);
- }
- }
- RINOK(archive.WriteLocalHeader(item));
- complexity += item.UnPackSize;
- #ifdef COMPRESS_MT
- if (!mtMode)
- #endif
- {
- RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
- }
- }
- }
- else
- {
- // item = inputItems[copyIndices[copyIndexIndex++]];
-
- #ifdef COMPRESS_MT
- if (mtMode)
- progressMainSpec->Reinit();
- #endif
-
- localCompressProgressSpec->Init(localProgress, &complexity, NULL);
- ICompressProgressInfo *progress = compressProgress;
- #ifdef COMPRESS_MT
- if (mtMode)
- progress = progressMain;
- #endif
-
- if (updateItem.NewProperties)
- {
- if (item.HasDescriptor())
- return E_NOTIMPL;
-
- // use old name size.
- // CUpdateRange range(item.GetLocalExtraPosition(), item.LocalExtraSize + item.PackSize);
- CUpdateRange range(item.GetDataPosition(), item.PackSize);
-
- // item.ExternalAttributes = updateItem.Attributes;
- // Test it
- item.Name = updateItem.Name;
- item.Time = updateItem.Time;
- item.CentralExtra.RemoveUnknownSubBlocks();
- item.LocalExtra.RemoveUnknownSubBlocks();
-
- archive.PrepareWriteCompressedData2((UInt16)item.Name.Length(), item.UnPackSize, item.PackSize, item.LocalExtra.HasWzAesField());
- item.LocalHeaderPosition = archive.GetCurrentPosition();
- archive.SeekToPackedDataPosition();
- RINOK(WriteRange(inStream, archive, range, progress));
- complexity += range.Size;
- archive.WriteLocalHeader(item);
- }
- else
- {
- CUpdateRange range(item.LocalHeaderPosition, item.GetLocalFullSize());
-
- // set new header position
- item.LocalHeaderPosition = archive.GetCurrentPosition();
-
- RINOK(WriteRange(inStream, archive, range, progress));
- complexity += range.Size;
- archive.MoveBasePosition(range.Size);
- }
- }
- items.Add(item);
- complexity += NFileHeader::kLocalBlockSize;
- itemIndex++;
- }
- archive.WriteCentralDir(items, comment);
- return S_OK;
-}
-
-HRESULT Update(
- const CObjectVector<CItemEx> &inputItems,
- const CObjectVector<CUpdateItem> &updateItems,
- ISequentialOutStream *seqOutStream,
- CInArchive *inArchive,
- CCompressionMethodMode *compressionMethodMode,
- IArchiveUpdateCallback *updateCallback)
-{
- CMyComPtr<IOutStream> outStream;
- RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream));
- if (!outStream)
- return E_NOTIMPL;
-
- CInArchiveInfo archiveInfo;
- if(inArchive != 0)
- {
- inArchive->GetArchiveInfo(archiveInfo);
- if (archiveInfo.Base != 0)
- return E_NOTIMPL;
- }
- else
- archiveInfo.StartPosition = 0;
-
- COutArchive outArchive;
- outArchive.Create(outStream);
- if (archiveInfo.StartPosition > 0)
- {
- CMyComPtr<ISequentialInStream> inStream;
- inStream.Attach(inArchive->CreateLimitedStream(0, archiveInfo.StartPosition));
- RINOK(CopyBlockToArchive(inStream, outArchive, NULL));
- outArchive.MoveBasePosition(archiveInfo.StartPosition);
- }
- CMyComPtr<IInStream> inStream;
- if(inArchive != 0)
- inStream.Attach(inArchive->CreateStream());
-
- return Update2(outArchive, inArchive, inStream,
- inputItems, updateItems,
- compressionMethodMode,
- archiveInfo.Comment, updateCallback);
-}
-
-}}
diff --git a/7zip/Bundles/Alone/Alone.dsp b/7zip/Bundles/Alone/Alone.dsp
deleted file mode 100755
index 42ce825c..00000000
--- a/7zip/Bundles/Alone/Alone.dsp
+++ /dev/null
@@ -1,2201 +0,0 @@
-# Microsoft Developer Studio Project File - Name="Alone" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=Alone - Win32 DebugU
-!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 "Alone.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 "Alone.mak" CFG="Alone - Win32 DebugU"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Alone - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "Alone - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "Alone - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
-!MESSAGE "Alone - Win32 DebugU" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "Alone - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /c
-# 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 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 /subsystem:console /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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7za.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "Alone - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /GZ /c
-# 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 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 /subsystem:console /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za.exe" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ReleaseU"
-# PROP BASE Intermediate_Dir "ReleaseU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ReleaseU"
-# PROP Intermediate_Dir "ReleaseU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /c
-# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7za.exe" /opt:NOWIN98
-# SUBTRACT BASE LINK32 /pdb:none
-# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7zan.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "DebugU"
-# PROP BASE Intermediate_Dir "DebugU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "DebugU"
-# PROP Intermediate_Dir "DebugU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /GZ /c
-# 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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za.exe" /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7zan.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "Alone - Win32 Release"
-# Name "Alone - Win32 Debug"
-# Name "Alone - Win32 ReleaseU"
-# Name "Alone - Win32 DebugU"
-# Begin Group "Console"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ArError.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\CompressionMode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ConsoleClose.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ConsoleClose.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ExtractCallbackConsole.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ExtractCallbackConsole.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\List.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\List.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\Main.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\MainAr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\OpenCallbackConsole.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\OpenCallbackConsole.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\PercentPrinter.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\PercentPrinter.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\UpdateCallbackConsole.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\UpdateCallbackConsole.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\UserInputUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\UserInputUtils.h
-# End Source File
-# End Group
-# Begin Group "Spec"
-
-# PROP Default_Filter ""
-# 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 "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Common\AlignedBuffer.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\AlignedBuffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\AutoPtr.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Buffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CommandLineParser.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CommandLineParser.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\ComTry.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Defs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\DynamicBuffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Exception.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\ListFileUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\ListFileUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyCom.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyGuidDef.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyInitGuid.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyUnknown.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyWindows.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyWindows.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\Random.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Random.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdInStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdInStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdOutStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdOutStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.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
-# Begin Source File
-
-SOURCE=..\..\..\Common\Types.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\UTFConvert.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\UTFConvert.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.h
-# End Source File
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Defs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Device.h
-# End Source File
-# 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\Error.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Error.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.cpp
-# 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\MemoryLock.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\MemoryLock.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\PropVariantConversions.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\PropVariantConversions.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\Thread.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Time.h
-# End Source File
-# End Group
-# Begin Group "7zip Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CrossThreadProgress.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.h
-# End Source File
-# 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\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\LSBFDecoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFEncoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFEncoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\MemBlocks.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\MSBFDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\MSBFEncoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OffsetStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OffsetStream.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\OutMemStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OutMemStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\ProgressMt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\ProgressMt.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\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
-# End Group
-# Begin Group "Compress"
-
-# PROP Default_Filter ""
-# Begin Group "Branch"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\BranchCoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\BranchCoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\Coder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86_2.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86_2.h
-# End Source File
-# End Group
-# Begin Group "BZip2"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2CRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2Decoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2Decoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2Encoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2Encoder.h
-# End Source File
-# End Group
-# Begin Group "Copy"
-
-# 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 "Deflate"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateConst.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateDecoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateEncoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateEncoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateExtConst.h
-# End Source File
-# End Group
-# Begin Group "Huffman"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Huffman\HuffmanDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Huffman\HuffmanEncoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Huffman\HuffmanEncoder.h
-# End Source File
-# End Group
-# Begin Group "Implode"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Implode\ImplodeDecoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Implode\ImplodeDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Implode\ImplodeHuffmanDecoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Implode\ImplodeHuffmanDecoder.h
-# End Source File
-# End Group
-# Begin Group "LZ"
-
-# PROP Default_Filter ""
-# Begin Group "MT"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\MT\MT.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\MT\MT.h
-# End Source File
-# End Group
-# Begin Group "HC"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC3.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC4.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC4b.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HCMain.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\IMatchFinder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZInWindow.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZInWindow.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZOutWindow.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZOutWindow.h
-# End Source File
-# End Group
-# Begin Group "LZMA"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMA.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMADecoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMADecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMAEncoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMAEncoder.h
-# End Source File
-# End Group
-# Begin Group "PPMd"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDContext.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDDecode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDDecoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDEncode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDEncoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDEncoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDSubAlloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDType.h
-# End Source File
-# End Group
-# Begin Group "RangeCoder"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderBitTree.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderOpt.h
-# End Source File
-# End Group
-# Begin Group "Shrink"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Shrink\ShrinkDecoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Shrink\ShrinkDecoder.h
-# End Source File
-# End Group
-# Begin Group "Z"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Z\ZDecoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Z\ZDecoder.h
-# End Source File
-# End Group
-# Begin Group "BWT"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\BWT\BlockSort.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BWT\BlockSort.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BWT\Mtf8.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "Archive"
-
-# PROP Default_Filter ""
-# Begin Group "7z"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zCompressionMode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zDecode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zDecode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zEncode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zEncode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zExtract.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderInStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderOutStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHeader.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zIn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zMethodID.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zMethodID.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zOut.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zProperties.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zProperties.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zSpecStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zSpecStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zUpdate.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zUpdate.h
-# End Source File
-# End Group
-# Begin Group "bz2"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\BZip2\BZip2Handler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\BZip2\BZip2Handler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\BZip2\BZip2HandlerOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\BZip2\BZip2Item.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\BZip2\BZip2Update.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\BZip2\BZip2Update.h
-# End Source File
-# End Group
-# Begin Group "gz"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipHandlerOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipHeader.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipIn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipOut.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipUpdate.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\GZip\GZipUpdate.h
-# End Source File
-# End Group
-# Begin Group "tar"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarHandlerOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarHeader.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarIn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarOut.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarUpdate.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Tar\TarUpdate.h
-# End Source File
-# End Group
-# Begin Group "zip"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipAddCommon.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipAddCommon.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipCompressionMode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipHandlerOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipHeader.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipIn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipItem.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipItemEx.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipOut.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipUpdate.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Zip\ZipUpdate.h
-# End Source File
-# End Group
-# Begin Group "Archive Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2MT.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2MT.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2ST.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2ST.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\DummyOutStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\DummyOutStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\FilterCoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\FilterCoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\InStreamWithCRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\InStreamWithCRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ItemNameUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\MultiStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\MultiStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ParseProperties.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ParseProperties.h
-# End Source File
-# End Group
-# Begin Group "split"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Split\SplitHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Split\SplitHandler.h
-# 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
-# End Group
-# End Group
-# Begin Group "UI Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveCommandLine.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveCommandLine.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveExtractCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveExtractCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveOpenCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveOpenCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiverInfo.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiverInfo.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\DefaultName.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\DefaultName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\EnumDirItems.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\EnumDirItems.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\Extract.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\Extract.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ExtractingFilePath.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ExtractingFilePath.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\OpenArchive.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\OpenArchive.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\PropIDUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\PropIDUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\SetProperties.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\SetProperties.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\SortUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\SortUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\TempFiles.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\TempFiles.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\Update.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\Update.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateAction.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateAction.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdatePair.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdatePair.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateProduce.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateProduce.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\WorkDir.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\WorkDir.h
-# End Source File
-# End Group
-# Begin Group "Crypto"
-
-# PROP Default_Filter ""
-# Begin Group "Zip Crypto"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Crypto\Zip\ZipCipher.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Zip\ZipCipher.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Zip\ZipCrypto.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Zip\ZipCrypto.h
-# End Source File
-# End Group
-# Begin Group "AES"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aes.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\AES_CBC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aescpp.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aescrypt.c
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aeskey.c
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aesopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aestab.c
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\MyAES.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\MyAES.h
-# End Source File
-# End Group
-# Begin Group "7z AES"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Crypto\7zAES\7zAES.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\7zAES\7zAES.h
-# End Source File
-# End Group
-# Begin Group "WzAES"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Crypto\WzAES\WzAES.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\WzAES\WzAES.h
-# End Source File
-# End Group
-# Begin Group "Hash"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\HmacSha1.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\HmacSha1.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\Pbkdf2HmacSha1.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\Pbkdf2HmacSha1.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\Sha1.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\Sha1.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\Sha256.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\Sha256.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "7-zip"
-
-# PROP Default_Filter ""
-# 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
-# End Target
-# End Project
diff --git a/7zip/Bundles/Alone/makefile b/7zip/Bundles/Alone/makefile
deleted file mode 100755
index e14b1104..00000000
--- a/7zip/Bundles/Alone/makefile
+++ /dev/null
@@ -1,357 +0,0 @@
-PROG = 7za.exe
-LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib
-
-CFLAGS = $(CFLAGS) -I ../../../ \
- -DEXCLUDE_COM \
- -DNO_REGISTRY \
- -DFORMAT_7Z \
- -DFORMAT_BZIP2 \
- -DFORMAT_GZIP \
- -DFORMAT_SPLIT \
- -DFORMAT_TAR \
- -DFORMAT_Z \
- -DFORMAT_ZIP \
- -DCOMPRESS_MT \
- -DCOMPRESS_BCJ_X86 \
- -DCOMPRESS_BCJ2 \
- -DCOMPRESS_BZIP2 \
- -DCOMPRESS_BZIP2_MT \
- -DCOMPRESS_COPY \
- -DCOMPRESS_DEFLATE \
- -DCOMPRESS_DEFLATE64 \
- -DCOMPRESS_IMPLODE \
- -DCOMPRESS_LZMA \
- -DCOMPRESS_MF_MT \
- -DCOMPRESS_PPMD \
- -DCRYPTO_7ZAES \
- -DCRYPTO_AES \
- -DCRYPTO_ZIP \
-
-
-CONSOLE_OBJS = \
- $O\ConsoleClose.obj \
- $O\ExtractCallbackConsole.obj \
- $O\List.obj \
- $O\Main.obj \
- $O\MainAr.obj \
- $O\OpenCallbackConsole.obj \
- $O\PercentPrinter.obj \
- $O\UpdateCallbackConsole.obj \
- $O\UserInputUtils.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CommandLineParser.obj \
- $O\CRC.obj \
- $O\IntToString.obj \
- $O\ListFileUtils.obj \
- $O\NewHandler.obj \
- $O\StdInStream.obj \
- $O\StdOutStream.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\UTFConvert.obj \
- $O\Vector.obj \
- $O\Wildcard.obj \
-
-WIN_OBJS = \
- $O\DLL.obj \
- $O\Error.obj \
- $O\FileDir.obj \
- $O\FileFind.obj \
- $O\FileIO.obj \
- $O\FileName.obj \
- $O\MemoryLock.obj \
- $O\PropVariant.obj \
- $O\PropVariantConversions.obj \
- $O\Synchronization.obj
-
-7ZIP_COMMON_OBJS = \
- $O\FilePathAutoRename.obj \
- $O\FileStreams.obj \
- $O\InBuffer.obj \
- $O\InOutTempBuffer.obj \
- $O\LimitedStreams.obj \
- $O\LockedStream.obj \
- $O\LSBFDecoder.obj \
- $O\LSBFEncoder.obj \
- $O\MemBlocks.obj \
- $O\OffsetStream.obj \
- $O\OutBuffer.obj \
- $O\OutMemStream.obj \
- $O\ProgressMt.obj \
- $O\ProgressUtils.obj \
- $O\StreamBinder.obj \
- $O\StreamObjects.obj \
- $O\StreamUtils.obj \
-
-UI_COMMON_OBJS = \
- $O\ArchiveCommandLine.obj \
- $O\ArchiveExtractCallback.obj \
- $O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
- $O\DefaultName.obj \
- $O\EnumDirItems.obj \
- $O\Extract.obj \
- $O\ExtractingFilePath.obj \
- $O\OpenArchive.obj \
- $O\PropIDUtils.obj \
- $O\SetProperties.obj \
- $O\SortUtils.obj \
- $O\TempFiles.obj \
- $O\Update.obj \
- $O\UpdateAction.obj \
- $O\UpdateCallback.obj \
- $O\UpdatePair.obj \
- $O\UpdateProduce.obj \
- $O\WorkDir.obj \
-
-AR_COMMON_OBJS = \
- $O\CoderMixer2.obj \
- $O\CoderMixer2MT.obj \
- $O\CrossThreadProgress.obj \
- $O\DummyOutStream.obj \
- $O\FilterCoder.obj \
- $O\InStreamWithCRC.obj \
- $O\ItemNameUtils.obj \
- $O\MultiStream.obj \
- $O\OutStreamWithCRC.obj \
- $O\ParseProperties.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\7zMethodID.obj \
- $O\7zOut.obj \
- $O\7zProperties.obj \
- $O\7zSpecStream.obj \
- $O\7zUpdate.obj \
-
-BZ2_OBJS = \
- $O\BZip2Handler.obj \
- $O\BZip2HandlerOut.obj \
- $O\BZip2Update.obj \
-
-GZ_OBJS = \
- $O\GZipHandler.obj \
- $O\GZipHandlerOut.obj \
- $O\GZipHeader.obj \
- $O\GZipIn.obj \
- $O\GZipOut.obj \
- $O\GZipUpdate.obj \
-
-SPLIT_OBJS = \
- $O\SplitHandler.obj \
- $O\SplitHandlerOut.obj \
-
-TAR_OBJS = \
- $O\TarHandler.obj \
- $O\TarHandlerOut.obj \
- $O\TarHeader.obj \
- $O\TarIn.obj \
- $O\TarOut.obj \
- $O\TarUpdate.obj \
-
-Z_OBJS = \
- $O\ZHandler.obj \
-
-ZIP_OBJS = \
- $O\ZipAddCommon.obj \
- $O\ZipHandler.obj \
- $O\ZipHandlerOut.obj \
- $O\ZipHeader.obj \
- $O\ZipIn.obj \
- $O\ZipItem.obj \
- $O\ZipOut.obj \
- $O\ZipUpdate.obj \
-
-
-BRANCH_OPT_OBJS = \
- $O\BranchCoder.obj \
- $O\x86.obj \
- $O\x86_2.obj \
-
-BZIP2_OBJS = \
- $O\BZip2CRC.obj \
-
-BZIP2_OPT_OBJS = \
- $O\BZip2Decoder.obj \
- $O\BZip2Encoder.obj \
-
-DEFLATE_OPT_OBJS = \
- $O\DeflateDecoder.obj \
- $O\DeflateEncoder.obj \
-
-LZ_OBJS = \
- $O\LZInWindow.obj \
- $O\LZOutWindow.obj \
-
-LZMA_OPT_OBJS = \
- $O\LZMADecoder.obj \
- $O\LZMAEncoder.obj \
-
-IMPLODE_OBJS = \
- $O\ImplodeDecoder.obj \
- $O\ImplodeHuffmanDecoder.obj \
-
-PPMD_OPT_OBJS = \
- $O\PPMDDecoder.obj \
- $O\PPMDEncoder.obj \
-
-SHRINK_OBJS = \
- $O\ShrinkDecoder.obj \
-
-COMPRESS_Z_OBJS = \
- $O\ZDecoder.obj \
-
-
-7ZAES_OPT_OBJS = \
- $O\7zAES.obj \
-
-AES_OPT_OBJS = \
- $O\MyAES.obj \
-
-AES_ORIG_OBJS = \
- $O\aescrypt.obj \
- $O\aeskey.obj \
- $O\aestab.obj \
-
-CRYPTO_HASH_OBJS = \
- $O\HmacSha1.obj \
- $O\Pbkdf2HmacSha1.obj \
- $O\RandGen.obj \
- $O\Sha1.obj \
- $O\Sha256.obj \
-
-CRYPTO_WZAES_OBJS = \
- $O\WzAES.obj \
-
-CRYPTO_ZIP_OBJS = \
- $O\ZipCipher.obj \
- $O\ZipCrypto.obj \
-
-
-OBJS = \
- $O\StdAfx.obj \
- $(CONSOLE_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(UI_COMMON_OBJS) \
- $(AR_COMMON_OBJS) \
- $(7Z_OBJS) \
- $(BZ2_OBJS) \
- $(GZ_OBJS) \
- $(SPLIT_OBJS) \
- $(TAR_OBJS) \
- $(Z_OBJS) \
- $(ZIP_OBJS) \
- $(BZIP2_OBJS) \
- $(BZIP2_OPT_OBJS) \
- $(BRANCH_OPT_OBJS) \
- $(DEFLATE_OPT_OBJS) \
- $(IMPLODE_OBJS) \
- $(LZ_OBJS) \
- $(LZMA_OPT_OBJS) \
- $(PPMD_OPT_OBJS) \
- $(SHRINK_OBJS) \
- $(COMPRESS_Z_OBJS) \
- $O\BlockSort.obj \
- $O\CopyCoder.obj \
- $O\HuffmanEncoder.obj \
- $O\MT.obj \
- $O\RangeCoderBit.obj \
- $(7ZAES_OPT_OBJS) \
- $(AES_OPT_OBJS) \
- $(AES_ORIG_OBJS) \
- $(CRYPTO_HASH_OBJS) \
- $(CRYPTO_ZIP_OBJS) \
- $(CRYPTO_WZAES_OBJS) \
- $O\resource.res
-
-
-!include "../../../Build.mak"
-
-$(CONSOLE_OBJS): ../../UI/Console/$(*B).cpp
- $(COMPL)
-
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp
- $(COMPL)
-$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
- $(COMPL)
-
-$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
- $(COMPL)
-$(BZ2_OBJS): ../../Archive/BZip2/$(*B).cpp
- $(COMPL)
-$(GZ_OBJS): ../../Archive/GZip/$(*B).cpp
- $(COMPL)
-$(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)
-
-$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
- $(COMPL_O2)
-$(BZIP2_OBJS): ../../Compress/BZip2/$(*B).cpp
- $(COMPL)
-$(BZIP2_OPT_OBJS): ../../Compress/BZip2/$(*B).cpp
- $(COMPL_O2)
-$(DEFLATE_OPT_OBJS): ../../Compress/Deflate/$(*B).cpp
- $(COMPL_O2)
-$(IMPLODE_OBJS): ../../Compress/Implode/$(*B).cpp
- $(COMPL)
-$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
- $(COMPL)
-$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
- $(COMPL_O2)
-$(PPMD_OPT_OBJS): ../../Compress/PPMD/$(*B).cpp
- $(COMPL_O2)
-$(SHRINK_OBJS): ../../Compress/Shrink/$(*B).cpp
- $(COMPL)
-$(COMPRESS_Z_OBJS): ../../Compress/Z/$(*B).cpp
- $(COMPL)
-
-$O\BlockSort.obj: ../../Compress/BWT/$(*B).cpp
- $(COMPL_O2)
-$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
- $(COMPL)
-$O\HuffmanEncoder.obj: ../../Compress/Huffman/$(*B).cpp
- $(COMPL_O2)
-$O\MT.obj: ../../Compress/LZ/MT/$(*B).cpp
- $(COMPL_O2)
-$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp
- $(COMPL)
-
-$(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp
- $(COMPL_O2)
-$(AES_ORIG_OBJS): ../../Crypto/AES/$(*B).c
- $(COMPL_O2_W3)
-$(7ZAES_OPT_OBJS): ../../Crypto/7zAES/$(*B).cpp
- $(COMPL_O2)
-$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp
- $(COMPL_O2)
-$(CRYPTO_ZIP_OBJS): ../../Crypto/Zip/$(*B).cpp
- $(COMPL)
-$(CRYPTO_WZAES_OBJS): ../../Crypto/WzAES/$(*B).cpp
- $(COMPL_O2)
diff --git a/7zip/Bundles/Alone7z/Alone.dsp b/7zip/Bundles/Alone7z/Alone.dsp
deleted file mode 100755
index 758fb198..00000000
--- a/7zip/Bundles/Alone7z/Alone.dsp
+++ /dev/null
@@ -1,1366 +0,0 @@
-# Microsoft Developer Studio Project File - Name="Alone" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=Alone - Win32 DebugU
-!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 "Alone.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 "Alone.mak" CFG="Alone - Win32 DebugU"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Alone - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "Alone - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "Alone - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
-!MESSAGE "Alone - Win32 DebugU" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "Alone - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMFORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
-# 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 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 /subsystem:console /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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7za.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "Alone - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMFORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
-# 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 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 /subsystem:console /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za.exe" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ReleaseU"
-# PROP BASE Intermediate_Dir "ReleaseU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ReleaseU"
-# PROP Intermediate_Dir "ReleaseU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMFORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
-# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7za.exe" /opt:NOWIN98
-# SUBTRACT BASE LINK32 /pdb:none
-# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7zan.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "DebugU"
-# PROP BASE Intermediate_Dir "DebugU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "DebugU"
-# PROP Intermediate_Dir "DebugU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /W4 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMFORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
-# 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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za.exe" /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7zan.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "Alone - Win32 Release"
-# Name "Alone - Win32 Debug"
-# Name "Alone - Win32 ReleaseU"
-# Name "Alone - Win32 DebugU"
-# Begin Group "Console"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ArError.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\CompressionMode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ConsoleClose.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ConsoleClose.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ExtractCallbackConsole.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\ExtractCallbackConsole.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\List.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\List.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\Main.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\MainAr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\OpenCallbackConsole.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\OpenCallbackConsole.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\PercentPrinter.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\PercentPrinter.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\UpdateCallbackConsole.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\UpdateCallbackConsole.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\UserInputUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Console\UserInputUtils.h
-# End Source File
-# End Group
-# Begin Group "Spec"
-
-# PROP Default_Filter ""
-# 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 "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Common\AlignedBuffer.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\AlignedBuffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\AutoPtr.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Buffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CommandLineParser.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CommandLineParser.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\ComTry.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Defs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\DynamicBuffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Exception.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\ListFileUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\ListFileUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyCom.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyGuidDef.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyInitGuid.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyUnknown.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyWindows.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyWindows.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\Random.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Random.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdInStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdInStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdOutStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdOutStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.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
-# Begin Source File
-
-SOURCE=..\..\..\Common\Types.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\UTFConvert.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\UTFConvert.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.h
-# End Source File
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Defs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Device.h
-# End Source File
-# 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\Error.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Error.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.cpp
-# 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\MemoryLock.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\MemoryLock.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\PropVariantConversions.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\PropVariantConversions.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\Thread.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Time.h
-# End Source File
-# End Group
-# Begin Group "7zip Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CrossThreadProgress.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.h
-# End Source File
-# 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\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\LSBFDecoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFEncoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFEncoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\MSBFDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\MSBFEncoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OffsetStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OffsetStream.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\OutMemStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OutMemStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\ProgressMt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\ProgressMt.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\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
-# End Group
-# Begin Group "Compress"
-
-# PROP Default_Filter ""
-# Begin Group "Branch"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\BranchCoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\BranchCoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\Coder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86_2.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86_2.h
-# End Source File
-# End Group
-# Begin Group "Copy"
-
-# 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 "LZ"
-
-# PROP Default_Filter ""
-# Begin Group "MT"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\MT\MT.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\MT\MT.h
-# End Source File
-# End Group
-# Begin Group "HC"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC3.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC4.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HC4b.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\HashChain\HCMain.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\IMatchFinder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZInWindow.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZInWindow.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZOutWindow.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZOutWindow.h
-# End Source File
-# End Group
-# Begin Group "LZMA"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMA.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMADecoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMADecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMAEncoder.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMAEncoder.h
-# End Source File
-# End Group
-# Begin Group "RangeCoder"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.cpp
-
-!IF "$(CFG)" == "Alone - Win32 Release"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
-
-# ADD CPP /O1
-
-!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderBitTree.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderOpt.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "Archive"
-
-# PROP Default_Filter ""
-# Begin Group "7z"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zCompressionMode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zDecode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zDecode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zEncode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zEncode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zExtract.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderInStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderOutStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHeader.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zIn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zMethodID.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zMethodID.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zOut.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zProperties.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zProperties.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zSpecStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zSpecStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zUpdate.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zUpdate.h
-# End Source File
-# End Group
-# Begin Group "Archive Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2MT.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2MT.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2ST.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2ST.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\DummyOutStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\DummyOutStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\FilterCoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\FilterCoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\InStreamWithCRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\InStreamWithCRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ItemNameUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\MultiStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\MultiStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ParseProperties.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ParseProperties.h
-# End Source File
-# End Group
-# Begin Group "split"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Split\SplitHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Split\SplitHandler.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "UI Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveCommandLine.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveCommandLine.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveExtractCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveExtractCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveOpenCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiveOpenCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiverInfo.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ArchiverInfo.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\DefaultName.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\DefaultName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\EnumDirItems.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\EnumDirItems.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\Extract.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\Extract.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ExtractingFilePath.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\ExtractingFilePath.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\OpenArchive.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\OpenArchive.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\PropIDUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\PropIDUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\SetProperties.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\SetProperties.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\SortUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\SortUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\TempFiles.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\TempFiles.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\Update.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\Update.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateAction.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateAction.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdatePair.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdatePair.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateProduce.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\UpdateProduce.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\WorkDir.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\Common\WorkDir.h
-# End Source File
-# End Group
-# Begin Group "7-zip"
-
-# PROP Default_Filter ""
-# 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
-# End Target
-# End Project
diff --git a/7zip/Bundles/Alone7z/makefile b/7zip/Bundles/Alone7z/makefile
deleted file mode 100755
index 465f7005..00000000
--- a/7zip/Bundles/Alone7z/makefile
+++ /dev/null
@@ -1,183 +0,0 @@
-PROG = 7za.exe
-LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib
-
-CFLAGS = $(CFLAGS) -I ../../../ \
- -DEXCLUDE_COM \
- -DNO_REGISTRY \
- -D_NO_CRYPTO \
- -DFORMAT_7Z \
- -DCOMPRESS_MT \
- -DCOMPRESS_BCJ_X86 \
- -DCOMPRESS_BCJ2 \
- -DCOMPRESS_COPY \
- -DCOMPRESS_LZMA \
- -DCOMPRESS_MF_MT \
-
-
-CONSOLE_OBJS = \
- $O\ConsoleClose.obj \
- $O\ExtractCallbackConsole.obj \
- $O\List.obj \
- $O\Main.obj \
- $O\MainAr.obj \
- $O\OpenCallbackConsole.obj \
- $O\PercentPrinter.obj \
- $O\UpdateCallbackConsole.obj \
- $O\UserInputUtils.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CommandLineParser.obj \
- $O\CRC.obj \
- $O\IntToString.obj \
- $O\ListFileUtils.obj \
- $O\NewHandler.obj \
- $O\Random.obj \
- $O\StdInStream.obj \
- $O\StdOutStream.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\UTFConvert.obj \
- $O\Vector.obj \
- $O\Wildcard.obj \
-
-WIN_OBJS = \
- $O\DLL.obj \
- $O\Error.obj \
- $O\FileDir.obj \
- $O\FileFind.obj \
- $O\FileIO.obj \
- $O\FileName.obj \
- $O\MemoryLock.obj \
- $O\PropVariant.obj \
- $O\PropVariantConversions.obj \
- $O\Synchronization.obj
-
-7ZIP_COMMON_OBJS = \
- $O\FilePathAutoRename.obj \
- $O\FileStreams.obj \
- $O\InBuffer.obj \
- $O\InOutTempBuffer.obj \
- $O\LimitedStreams.obj \
- $O\LockedStream.obj \
- $O\OffsetStream.obj \
- $O\OutBuffer.obj \
- $O\ProgressUtils.obj \
- $O\StreamBinder.obj \
- $O\StreamObjects.obj \
- $O\StreamUtils.obj \
-
-UI_COMMON_OBJS = \
- $O\ArchiveCommandLine.obj \
- $O\ArchiveExtractCallback.obj \
- $O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
- $O\DefaultName.obj \
- $O\EnumDirItems.obj \
- $O\Extract.obj \
- $O\ExtractingFilePath.obj \
- $O\OpenArchive.obj \
- $O\PropIDUtils.obj \
- $O\SetProperties.obj \
- $O\SortUtils.obj \
- $O\TempFiles.obj \
- $O\Update.obj \
- $O\UpdateAction.obj \
- $O\UpdateCallback.obj \
- $O\UpdatePair.obj \
- $O\UpdateProduce.obj \
- $O\WorkDir.obj \
-
-AR_COMMON_OBJS = \
- $O\CoderMixer2.obj \
- $O\CoderMixer2MT.obj \
- $O\CrossThreadProgress.obj \
- $O\DummyOutStream.obj \
- $O\FilterCoder.obj \
- $O\InStreamWithCRC.obj \
- $O\ItemNameUtils.obj \
- $O\MultiStream.obj \
- $O\OutStreamWithCRC.obj \
- $O\ParseProperties.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\7zMethodID.obj \
- $O\7zOut.obj \
- $O\7zProperties.obj \
- $O\7zSpecStream.obj \
- $O\7zUpdate.obj \
-
-
-BRANCH_OPT_OBJS = \
- $O\BranchCoder.obj \
- $O\x86.obj \
- $O\x86_2.obj \
-
-LZ_OBJS = \
- $O\LZInWindow.obj \
- $O\LZOutWindow.obj \
-
-LZMA_OPT_OBJS = \
- $O\LZMADecoder.obj \
- $O\LZMAEncoder.obj \
-
-OBJS = \
- $O\StdAfx.obj \
- $(CONSOLE_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(UI_COMMON_OBJS) \
- $(AR_COMMON_OBJS) \
- $(7Z_OBJS) \
- $(BRANCH_OPT_OBJS) \
- $(LZ_OBJS) \
- $(LZMA_OPT_OBJS) \
- $O\CopyCoder.obj \
- $O\MT.obj \
- $O\RangeCoderBit.obj \
- $O\resource.res
-
-
-!include "../../../Build.mak"
-
-$(CONSOLE_OBJS): ../../UI/Console/$(*B).cpp
- $(COMPL)
-
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp
- $(COMPL)
-$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
- $(COMPL)
-
-$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
- $(COMPL)
-$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
- $(COMPL_O2)
-$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
- $(COMPL)
-$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
- $(COMPL_O2)
-$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
- $(COMPL)
-$O\MT.obj: ../../Compress/LZ/MT/$(*B).cpp
- $(COMPL_O2)
-$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp
- $(COMPL)
diff --git a/7zip/Bundles/Format7z/Format7z.dsp b/7zip/Bundles/Format7z/Format7z.dsp
deleted file mode 100755
index 05a1b1fb..00000000
--- a/7zip/Bundles/Format7z/Format7z.dsp
+++ /dev/null
@@ -1,957 +0,0 @@
-# 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 "Format7z.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 "Format7z.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 /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /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\Formats\7za.dll" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none /debug
-
-!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 "..\..\..\..\SDK" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /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\Formats\7za.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\7z\7z.ico
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Archive.def
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\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 "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.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\NewHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.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
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.h
-# End Source File
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# 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\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
-# End Group
-# Begin Group "Archive common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2MT.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CoderMixer2MT.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\CrossThreadProgress.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\FilterCoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\FilterCoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\InStreamWithCRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\InStreamWithCRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ItemNameUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ParseProperties.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Common\ParseProperties.h
-# End Source File
-# End Group
-# Begin Group "Compress"
-
-# PROP Default_Filter ""
-# Begin Group "LZ"
-
-# PROP Default_Filter ""
-# Begin Group "MT"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\MT\MT.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\MT\MT.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZInWindow.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZInWindow.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZOutWindow.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZ\LZOutWindow.h
-# End Source File
-# End Group
-# Begin Group "PPMD"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDContext.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDDecode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDDecoder.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDEncode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDEncoder.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDEncoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDSubAlloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\PPMD\PPMDType.h
-# End Source File
-# End Group
-# Begin Group "Branch"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\BranchCoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\BranchCoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86_2.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Branch\x86_2.h
-# End Source File
-# End Group
-# Begin Group "LZMA"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMA.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMADecoder.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMADecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMAEncoder.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA\LZMAEncoder.h
-# End Source File
-# End Group
-# Begin Group "Copy"
-
-# 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 "RangeCoder"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderBitTree.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\RangeCoder\RangeCoderOpt.h
-# End Source File
-# End Group
-# Begin Group "Deflate"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateConst.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateDecoder.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Deflate\DeflateExtConst.h
-# End Source File
-# End Group
-# Begin Group "BZip2"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2Const.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2CRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2Decoder.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\BZip2\BZip2Decoder.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "Crypto"
-
-# PROP Default_Filter ""
-# Begin Group "AES"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aes.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\AES_CBC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aescpp.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aescrypt.c
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aeskey.c
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aesopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\aestab.c
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\MyAES.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\AES\MyAES.h
-# End Source File
-# End Group
-# Begin Group "7zAES"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Crypto\7zAES\7zAES.cpp
-
-!IF "$(CFG)" == "7z - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "7z - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\7zAES\7zAES.h
-# End Source File
-# End Group
-# Begin Group "Hash"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\Sha256.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Crypto\Hash\Sha256.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "7z"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zCompressionMode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zDecode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zDecode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zEncode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zEncode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zExtract.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderInStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zFolderOutStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHeader.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zIn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zMethodID.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zMethodID.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zMethods.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zOut.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zProperties.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zProperties.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zSpecStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zSpecStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zUpdate.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zUpdate.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\7z\7zUpdateItem.h
-# End Source File
-# End Group
-# Begin Group "7zip 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\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\LSBFDecoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFDecoder.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\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
-# End Group
-# End Target
-# End Project
diff --git a/7zip/Bundles/Format7z/makefile b/7zip/Bundles/Format7z/makefile
deleted file mode 100755
index 90d68362..00000000
--- a/7zip/Bundles/Format7z/makefile
+++ /dev/null
@@ -1,190 +0,0 @@
-PROG = 7za.dll
-DEF_FILE = ../../Archive/Archive.def
-LIBS = $(LIBS) user32.lib oleaut32.lib
-CFLAGS = $(CFLAGS) -I ../../../ \
- -DEXCLUDE_COM \
- -DNO_REGISTRY \
- -DFORMAT_7Z \
- -DCOMPRESS_MT \
- -DCOMPRESS_BCJ_X86 \
- -DCOMPRESS_BCJ2 \
- -DCOMPRESS_BZIP2_DECODER \
- -DCOMPRESS_BZIP2_MT \
- -DCOMPRESS_COPY \
- -DCOMPRESS_DEFLATE_DECODER \
- -DCOMPRESS_LZMA \
- -DCOMPRESS_MF_MT \
- -DCOMPRESS_PPMD \
- -DCRYPTO_7ZAES \
- -DCRYPTO_AES \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CRC.obj \
- $O\IntToString.obj \
- $O\NewHandler.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\Vector.obj \
- $O\Wildcard.obj \
-
-WIN_OBJS = \
- $O\FileDir.obj \
- $O\FileFind.obj \
- $O\FileIO.obj \
- $O\PropVariant.obj \
- $O\Synchronization.obj
-
-7ZIP_COMMON_OBJS = \
- $O\InBuffer.obj \
- $O\InOutTempBuffer.obj \
- $O\LimitedStreams.obj \
- $O\LockedStream.obj \
- $O\LSBFDecoder.obj \
- $O\OutBuffer.obj \
- $O\ProgressUtils.obj \
- $O\StreamBinder.obj \
- $O\StreamObjects.obj \
- $O\StreamUtils.obj \
-
-AR_COMMON_OBJS = \
- $O\CoderMixer2.obj \
- $O\CoderMixer2MT.obj \
- $O\CrossThreadProgress.obj \
- $O\FilterCoder.obj \
- $O\InStreamWithCRC.obj \
- $O\ItemNameUtils.obj \
- $O\OutStreamWithCRC.obj \
- $O\ParseProperties.obj \
-
-
-7Z_OBJS = \
- $O\DllExports.obj \
- $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\7zMethodID.obj \
- $O\7zOut.obj \
- $O\7zProperties.obj \
- $O\7zSpecStream.obj \
- $O\7zUpdate.obj \
-
-
-BRANCH_OPT_OBJS = \
- $O\BranchCoder.obj \
- $O\x86.obj \
- $O\x86_2.obj \
-
-BZIP2_OBJS = \
- $O\BZip2CRC.obj \
-
-BZIP2_OPT_OBJS = \
- $O\BZip2Decoder.obj \
-
-DEFLATE_OPT_OBJS = \
- $O\DeflateDecoder.obj \
-
-LZ_OBJS = \
- $O\LZInWindow.obj \
- $O\LZOutWindow.obj \
-
-LZMA_OPT_OBJS = \
- $O\LZMADecoder.obj \
- $O\LZMAEncoder.obj \
-
-PPMD_OPT_OBJS = \
- $O\PPMDDecoder.obj \
- $O\PPMDEncoder.obj \
-
-
-7ZAES_OPT_OBJS = \
- $O\7zAES.obj \
-
-AES_OPT_OBJS = \
- $O\MyAES.obj \
-
-AES_ORIG_OBJS = \
- $O\aescrypt.obj \
- $O\aeskey.obj \
- $O\aestab.obj \
-
-CRYPTO_HASH_OBJS = \
- $O\Sha256.obj \
-
-OBJS = \
- $O\StdAfx.obj \
- $(CONSOLE_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(AR_COMMON_OBJS) \
- $(7Z_OBJS) \
- $(BZIP2_OBJS) \
- $(BZIP2_OPT_OBJS) \
- $(BRANCH_OPT_OBJS) \
- $(DEFLATE_OPT_OBJS) \
- $(LZ_OBJS) \
- $(LZMA_OPT_OBJS) \
- $(PPMD_OPT_OBJS) \
- $O\CopyCoder.obj \
- $O\MT.obj \
- $O\RangeCoderBit.obj \
- $(7ZAES_OPT_OBJS) \
- $(AES_OPT_OBJS) \
- $(AES_ORIG_OBJS) \
- $(CRYPTO_HASH_OBJS) \
- $O\resource.res
-
-
-!include "../../../Build.mak"
-
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
- $(COMPL)
-
-$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
- $(COMPL)
-
-$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
- $(COMPL_O2)
-$(BZIP2_OBJS): ../../Compress/BZip2/$(*B).cpp
- $(COMPL)
-$(BZIP2_OPT_OBJS): ../../Compress/BZip2/$(*B).cpp
- $(COMPL_O2)
-$(DEFLATE_OPT_OBJS): ../../Compress/Deflate/$(*B).cpp
- $(COMPL_O2)
-$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
- $(COMPL)
-$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
- $(COMPL_O2)
-$(PPMD_OPT_OBJS): ../../Compress/PPMD/$(*B).cpp
- $(COMPL_O2)
-
-$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
- $(COMPL)
-$O\MT.obj: ../../Compress/LZ/MT/$(*B).cpp
- $(COMPL_O2)
-$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp
- $(COMPL)
-
-$(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp
- $(COMPL_O2)
-$(AES_ORIG_OBJS): ../../Crypto/AES/$(*B).c
- $(COMPL_O2_W3)
-$(7ZAES_OPT_OBJS): ../../Crypto/7zAES/$(*B).cpp
- $(COMPL_O2)
-$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp
- $(COMPL_O2)
diff --git a/7zip/Bundles/Format7zExtract/makefile b/7zip/Bundles/Format7zExtract/makefile
deleted file mode 100755
index 9a74f429..00000000
--- a/7zip/Bundles/Format7zExtract/makefile
+++ /dev/null
@@ -1,175 +0,0 @@
-PROG = 7zxa.dll
-DEF_FILE = ../../Archive/Archive.def
-LIBS = $(LIBS) user32.lib oleaut32.lib
-CFLAGS = $(CFLAGS) -I ../../../ \
- -DEXCLUDE_COM \
- -DNO_REGISTRY \
- -DEXTRACT_ONLY \
- -DFORMAT_7Z \
- -DCOMPRESS_MT \
- -DCOMPRESS_BCJ_X86 \
- -DCOMPRESS_BCJ2 \
- -DCOMPRESS_BZIP2_DECODER \
- -DCOMPRESS_BZIP2_MT \
- -DCOMPRESS_COPY \
- -DCOMPRESS_DEFLATE_DECODER \
- -DCOMPRESS_LZMA \
- -DCOMPRESS_MF_MT \
- -DCOMPRESS_PPMD \
- -DCRYPTO_7ZAES \
- -DCRYPTO_AES \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CRC.obj \
- $O\IntToString.obj \
- $O\NewHandler.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\Vector.obj \
- $O\Wildcard.obj \
-
-WIN_OBJS = \
- $O\FileDir.obj \
- $O\FileFind.obj \
- $O\FileIO.obj \
- $O\PropVariant.obj \
- $O\Synchronization.obj
-
-7ZIP_COMMON_OBJS = \
- $O\InBuffer.obj \
- $O\InOutTempBuffer.obj \
- $O\LimitedStreams.obj \
- $O\LockedStream.obj \
- $O\LSBFDecoder.obj \
- $O\OutBuffer.obj \
- $O\ProgressUtils.obj \
- $O\StreamBinder.obj \
- $O\StreamObjects.obj \
- $O\StreamUtils.obj \
-
-AR_COMMON_OBJS = \
- $O\CoderMixer2.obj \
- $O\CoderMixer2MT.obj \
- $O\CrossThreadProgress.obj \
- $O\FilterCoder.obj \
- $O\ItemNameUtils.obj \
- $O\OutStreamWithCRC.obj \
- $O\ParseProperties.obj \
-
-
-7Z_OBJS = \
- $O\DllExports.obj \
- $O\7zCompressionMode.obj \
- $O\7zDecode.obj \
- $O\7zExtract.obj \
- $O\7zFolderOutStream.obj \
- $O\7zHandler.obj \
- $O\7zHeader.obj \
- $O\7zIn.obj \
- $O\7zMethodID.obj \
- $O\7zProperties.obj \
-
-
-BRANCH_OPT_OBJS = \
- $O\BranchCoder.obj \
- $O\x86.obj \
- $O\x86_2.obj \
-
-BZIP2_OBJS = \
- $O\BZip2CRC.obj \
-
-BZIP2_OPT_OBJS = \
- $O\BZip2Decoder.obj \
-
-DEFLATE_OPT_OBJS = \
- $O\DeflateDecoder.obj \
-
-LZ_OBJS = \
- $O\LZOutWindow.obj \
-
-LZMA_OPT_OBJS = \
- $O\LZMADecoder.obj \
-
-PPMD_OPT_OBJS = \
- $O\PPMDDecoder.obj \
-
-
-7ZAES_OPT_OBJS = \
- $O\7zAES.obj \
-
-AES_OPT_OBJS = \
- $O\MyAES.obj \
-
-AES_ORIG_OBJS = \
- $O\aescrypt.obj \
- $O\aeskey.obj \
- $O\aestab.obj \
-
-CRYPTO_HASH_OBJS = \
- $O\Sha256.obj \
-
-OBJS = \
- $O\StdAfx.obj \
- $(CONSOLE_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(AR_COMMON_OBJS) \
- $(7Z_OBJS) \
- $(BZIP2_OBJS) \
- $(BZIP2_OPT_OBJS) \
- $(BRANCH_OPT_OBJS) \
- $(DEFLATE_OPT_OBJS) \
- $(LZ_OBJS) \
- $(LZMA_OPT_OBJS) \
- $(PPMD_OPT_OBJS) \
- $O\CopyCoder.obj \
- $(7ZAES_OPT_OBJS) \
- $(AES_OPT_OBJS) \
- $(AES_ORIG_OBJS) \
- $(CRYPTO_HASH_OBJS) \
- $O\resource.res
-
-
-!include "../../../Build.mak"
-
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
- $(COMPL)
-
-$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
- $(COMPL)
-
-$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
- $(COMPL_O2)
-$(BZIP2_OBJS): ../../Compress/BZip2/$(*B).cpp
- $(COMPL)
-$(BZIP2_OPT_OBJS): ../../Compress/BZip2/$(*B).cpp
- $(COMPL_O2)
-$(DEFLATE_OPT_OBJS): ../../Compress/Deflate/$(*B).cpp
- $(COMPL_O2)
-$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
- $(COMPL)
-$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
- $(COMPL_O2)
-$(PPMD_OPT_OBJS): ../../Compress/PPMD/$(*B).cpp
- $(COMPL_O2)
-
-$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
- $(COMPL)
-
-$(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp
- $(COMPL_O2)
-$(AES_ORIG_OBJS): ../../Crypto/AES/$(*B).c
- $(COMPL_O2_W3)
-$(7ZAES_OPT_OBJS): ../../Crypto/7zAES/$(*B).cpp
- $(COMPL_O2)
-$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp
- $(COMPL_O2)
diff --git a/7zip/Bundles/makefile b/7zip/Bundles/makefile
deleted file mode 100755
index 108cbd17..00000000
--- a/7zip/Bundles/makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-DIRS = \
- Alone\~ \
- Alone7z\~ \
- Format7z\~ \
- Format7zExtract\~ \
- SFXCon\~ \
- SFXSetup\~ \
- SFXWin\~ \
-
-all: $(DIRS)
-
-$(DIRS):
-!include "../SubBuild.mak"
diff --git a/7zip/Common/LSBFDecoder.cpp b/7zip/Common/LSBFDecoder.cpp
deleted file mode 100755
index 51e6aa9c..00000000
--- a/7zip/Common/LSBFDecoder.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// Stream/LSBFDecoder.cpp
-
-#include "StdAfx.h"
-
-#include "LSBFDecoder.h"
-
-namespace NStream {
-namespace NLSBF {
-
-Byte kInvertTable[256];
-
-class CInverterTableInitializer
-{
-public:
- CInverterTableInitializer()
- {
- for(int i = 0; i < 256; i++)
- {
- Byte b = Byte(i);
- Byte bInvert = 0;
- for(int j = 0; j < 8; j++)
- {
- bInvert <<= 1;
- if (b & 1)
- bInvert |= 1;
- b >>= 1;
- }
- kInvertTable[i] = bInvert;
- }
- }
-} g_InverterTableInitializer;
-
-
-}}
diff --git a/7zip/Compress/BWT/BlockSort.cpp b/7zip/Compress/BWT/BlockSort.cpp
deleted file mode 100755
index ffe7dd9d..00000000
--- a/7zip/Compress/BWT/BlockSort.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-// BlockSort.cpp
-
-#include "StdAfx.h"
-
-#include "BlockSort.h"
-
-#include "Common/Alloc.h"
-
-namespace NCompress {
-
-static const int kNumHashBytes = 2;
-static const UInt32 kNumHashValues = 1 << (kNumHashBytes * 8);
-
-static const int kNumFlagsBits = 5; // 32 Flags in UInt32 word
-static const UInt32 kNumFlagsInWord = (1 << kNumFlagsBits);
-static const UInt32 kFlagsMask = kNumFlagsInWord - 1;
-static const UInt32 kAllFlags = 0xFFFFFFFF;
-
-bool CBlockSorter::Create(UInt32 blockSizeMax)
-{
- if (Indices != 0 && blockSizeMax == BlockSizeMax)
- return true;
- Free();
- BlockSizeMax = blockSizeMax;
- Indices = (UInt32 *)::BigAlloc((blockSizeMax * 2 +
- ((blockSizeMax + kFlagsMask) >> kNumFlagsBits) + kNumHashValues) * sizeof(UInt32));
- return (Indices != 0);
-}
-
-void CBlockSorter::Free()
-{
- ::BigFree(Indices);
- Indices = 0;
-}
-
-// SortGroup - is recursive Radix-Range-Sort function with Bubble-Sort optimization
-// It uses both mask & maskSize (Range-Sort), since it can change values (Groups)
-// during sorting
-// returns: 0 - if there are groups, 1 - no more groups
-UInt32 CBlockSorter::SortGroup(UInt32 groupOffset, UInt32 groupSize, UInt32 mask, UInt32 maskSize)
-{
- if (groupSize <= 2)
- {
- if (groupSize <= 1)
- return 0;
- UInt32 *ind2 = Indices + groupOffset;
- UInt32 stringPos = ind2[0] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- UInt32 group = Groups[stringPos];
- stringPos = ind2[1] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- if (group == Groups[stringPos])
- return 1;
- if (group > Groups[stringPos])
- {
- UInt32 temp = ind2[0];
- ind2[0] = ind2[1];
- ind2[1] = temp;
- }
- Flags[groupOffset >> kNumFlagsBits] &= ~(1 << (groupOffset & kFlagsMask));
- Groups[ind2[1]] = groupOffset + 1;
- return 0;
- }
-
- // Check that all strings are in one group (cannot sort)
- UInt32 *ind2 = Indices + groupOffset;
- {
- UInt32 stringPos = ind2[0] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- UInt32 group = Groups[stringPos];
- UInt32 j;
- for (j = 1; j < groupSize; j++)
- {
- stringPos = ind2[j] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- if (Groups[stringPos] != group)
- break;
- }
- if (j == groupSize)
- return 1;
- }
-
- if (groupSize <= 15)
- {
- // Bubble-Sort
- UInt32 lastChange = groupSize;
- do
- {
- UInt32 stringPos = ind2[0] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- UInt32 group = Groups[stringPos];
-
- UInt32 sortSize = lastChange;
- lastChange = 0;
- for (UInt32 j = 1; j < sortSize; j++)
- {
- stringPos = ind2[j] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- if (Groups[stringPos] < group)
- {
- UInt32 temp = ind2[j];
- ind2[j] = ind2[j - 1];
- ind2[j - 1] = temp;
- lastChange = j;
- }
- else
- group = Groups[stringPos];
- }
- }
- while(lastChange > 1);
-
- // Write Flags
- UInt32 stringPos = ind2[0] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- UInt32 group = Groups[stringPos];
-
- UInt32 j;
- for (j = 1; j < groupSize; j++)
- {
- stringPos = ind2[j] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- if (Groups[stringPos] != group)
- {
- group = Groups[stringPos];
- UInt32 t = groupOffset + j - 1;
- Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
- }
- }
-
- // Write new Groups values and Check that there are groups
- UInt32 thereAreGroups = 0;
- for (j = 0; j < groupSize; j++)
- {
- UInt32 group = groupOffset + j;
- for (;;)
- {
- Groups[ind2[j]] = group;
- if ((Flags[(groupOffset + j) >> kNumFlagsBits] & (1 << ((groupOffset + j) & kFlagsMask))) == 0)
- break;
- j++;
- thereAreGroups = 1;
- }
- }
- return thereAreGroups;
- }
-
- // Radix-Range Sort
- UInt32 i;
- for (;;)
- {
- if (maskSize == 0)
- return 1;
- UInt32 j = groupSize;
- i = 0;
- do
- {
- UInt32 stringPos = ind2[i] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- if (Groups[stringPos] >= mask)
- {
- for (j--; j > i; j--)
- {
- stringPos = ind2[j] + NumSortedBytes;
- if (stringPos >= BlockSize)
- stringPos -= BlockSize;
- if (Groups[stringPos] < mask)
- {
- UInt32 temp = ind2[i];
- ind2[i] = ind2[j];
- ind2[j] = temp;
- break;
- }
- }
- if (i >= j)
- break;
- }
- }
- while(++i < j);
- maskSize >>= 1;
- if (i == 0)
- mask += maskSize;
- else if (i == groupSize)
- mask -= maskSize;
- else
- break;
- }
- UInt32 t = (groupOffset + i - 1);
- Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
-
- for (UInt32 j = i; j < groupSize; j++)
- Groups[ind2[j]] = groupOffset + i;
-
- UInt32 res = SortGroup(groupOffset, i, mask - maskSize, maskSize);
- return res | SortGroup(groupOffset + i, groupSize - i, mask + maskSize, maskSize);
-}
-
-UInt32 CBlockSorter::Sort(const Byte *data, UInt32 blockSize)
-{
- BlockSize = blockSize;
- UInt32 *counters = Indices + blockSize;
- Groups = counters + kNumHashValues;
- Flags = Groups + blockSize;
- UInt32 i;
-
- // Radix-Sort for 2 bytes
- for (i = 0; i < kNumHashValues; i++)
- counters[i] = 0;
- for (i = 0; i < blockSize - 1; i++)
- counters[((UInt32)data[i] << 8) | data[i + 1]]++;
- counters[((UInt32)data[i] << 8) | data[0]]++;
-
- {
- {
- UInt32 numWords = (blockSize + kFlagsMask) >> kNumFlagsBits;
- for (i = 0; i < numWords; i++)
- Flags[i] = kAllFlags;
- }
-
- UInt32 sum = 0;
- for (i = 0; i < kNumHashValues; i++)
- {
- UInt32 groupSize = counters[i];
- if (groupSize > 0)
- {
- UInt32 t = sum + groupSize - 1;
- Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
- sum += groupSize;
- }
- counters[i] = sum - groupSize;
- }
-
- for (i = 0; i < blockSize - 1; i++)
- Groups[i] = counters[((UInt32)data[i] << 8) | data[i + 1]];
- Groups[i] = counters[((UInt32)data[i] << 8) | data[0]];
-
- for (i = 0; i < blockSize - 1; i++)
- Indices[counters[((UInt32)data[i] << 8) | data[i + 1]]++] = i;
- Indices[counters[((UInt32)data[i] << 8) | data[0]]++] = i;
- }
-
- UInt32 mask;
- for (mask = 2; mask < blockSize; mask <<= 1);
- mask >>= 1;
- for (NumSortedBytes = kNumHashBytes; ; NumSortedBytes <<= 1)
- {
- UInt32 newLimit = 0;
- for (i = 0; i < blockSize;)
- {
- if ((Flags[i >> kNumFlagsBits] & (1 << (i & kFlagsMask))) == 0)
- {
- i++;
- continue;
- }
- UInt32 groupSize;
- for(groupSize = 1;
- (Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0;
- groupSize++);
-
- groupSize++;
-
- if (NumSortedBytes >= blockSize)
- for (UInt32 j = 0; j < groupSize; j++)
- {
- UInt32 t = (i + j);
- Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
- Groups[Indices[t]] = t;
- }
- else
- if (SortGroup(i, groupSize, mask, mask) != 0)
- newLimit = i + groupSize;
- i += groupSize;
- }
- if (newLimit == 0)
- break;
- }
- return Groups[0];
-}
-
-}
diff --git a/7zip/Compress/BWT/BlockSort.h b/7zip/Compress/BWT/BlockSort.h
deleted file mode 100755
index 599c3b60..00000000
--- a/7zip/Compress/BWT/BlockSort.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// BlockSort.h
-
-#ifndef __BLOCKSORT_H
-#define __BLOCKSORT_H
-
-#include "Common/Types.h"
-
-namespace NCompress {
-
-class CBlockSorter
-{
- UInt32 *Groups;
- UInt32 *Flags;
- UInt32 BlockSize;
- UInt32 NumSortedBytes;
- UInt32 BlockSizeMax;
- UInt32 SortGroup(UInt32 groupOffset, UInt32 groupSize, UInt32 mask, UInt32 maskSize);
-public:
- UInt32 *Indices;
- CBlockSorter(): Indices(0) {}
- ~CBlockSorter() { Free(); }
- bool Create(UInt32 blockSizeMax);
- void Free();
- UInt32 Sort(const Byte *data, UInt32 blockSize);
-};
-
-}
-
-#endif
diff --git a/7zip/Compress/BWT/Mtf8.h b/7zip/Compress/BWT/Mtf8.h
deleted file mode 100755
index d6c1c41a..00000000
--- a/7zip/Compress/BWT/Mtf8.h
+++ /dev/null
@@ -1,140 +0,0 @@
-// Mtf8.h
-
-#ifndef __MTF8_H
-#define __MTF8_H
-
-#include "Common/Types.h"
-
-namespace NCompress {
-
-class CMtf8Encoder
-{
-public:
- Byte Buffer[256];
- int FindAndMove(Byte v)
- {
- int pos;
- for (pos = 0; Buffer[pos] != v; pos++);
- int resPos = pos;
- for (; pos >= 8; pos -= 8)
- {
- Buffer[pos] = Buffer[pos - 1];
- Buffer[pos - 1] = Buffer[pos - 2];
- Buffer[pos - 2] = Buffer[pos - 3];
- Buffer[pos - 3] = Buffer[pos - 4];
- Buffer[pos - 4] = Buffer[pos - 5];
- Buffer[pos - 5] = Buffer[pos - 6];
- Buffer[pos - 6] = Buffer[pos - 7];
- Buffer[pos - 7] = Buffer[pos - 8];
- }
- for (; pos > 0; pos--)
- Buffer[pos] = Buffer[pos - 1];
- Buffer[0] = v;
- return resPos;
- }
-};
-
-class CMtf8Decoder
-{
-public:
- Byte Buffer[256];
- void Init(int /* size */) {};
- Byte GetHead() const { return Buffer[0]; }
- Byte GetAndMove(int pos)
- {
- Byte res = Buffer[pos];
- for (; pos >= 8; pos -= 8)
- {
- Buffer[pos] = Buffer[pos - 1];
- Buffer[pos - 1] = Buffer[pos - 2];
- Buffer[pos - 2] = Buffer[pos - 3];
- Buffer[pos - 3] = Buffer[pos - 4];
- Buffer[pos - 4] = Buffer[pos - 5];
- Buffer[pos - 5] = Buffer[pos - 6];
- Buffer[pos - 6] = Buffer[pos - 7];
- Buffer[pos - 7] = Buffer[pos - 8];
- }
- for (; pos > 0; pos--)
- Buffer[pos] = Buffer[pos - 1];
- Buffer[0] = res;
- return res;
- }
-};
-
-/*
-const int kSmallSize = 64;
-class CMtf8Decoder
-{
- Byte SmallBuffer[kSmallSize];
- int SmallSize;
- Byte Counts[16];
- int Size;
-public:
- Byte Buffer[256];
-
- Byte GetHead() const
- {
- if (SmallSize > 0)
- return SmallBuffer[kSmallSize - SmallSize];
- return Buffer[0];
- }
-
- void Init(int size)
- {
- Size = size;
- SmallSize = 0;
- for (int i = 0; i < 16; i++)
- {
- Counts[i] = ((size >= 16) ? 16 : size);
- size -= Counts[i];
- }
- }
-
- Byte GetAndMove(int pos)
- {
- if (pos < SmallSize)
- {
- Byte *p = SmallBuffer + kSmallSize - SmallSize;
- Byte res = p[pos];
- for (; pos > 0; pos--)
- p[pos] = p[pos - 1];
- SmallBuffer[kSmallSize - SmallSize] = res;
- return res;
- }
- if (SmallSize == kSmallSize)
- {
- int i = Size - 1;
- int g = 16;
- do
- {
- g--;
- int offset = (g << 4);
- for (int t = Counts[g] - 1; t >= 0; t--, i--)
- Buffer[i] = Buffer[offset + t];
- }
- while(g != 0);
-
- for (i = kSmallSize - 1; i >= 0; i--)
- Buffer[i] = SmallBuffer[i];
- Init(Size);
- }
- pos -= SmallSize;
- int g;
- for (g = 0; pos >= Counts[g]; g++)
- pos -= Counts[g];
- int offset = (g << 4);
- Byte res = Buffer[offset + pos];
- for (pos; pos < 16 - 1; pos++)
- Buffer[offset + pos] = Buffer[offset + pos + 1];
-
- SmallSize++;
- SmallBuffer[kSmallSize - SmallSize] = res;
-
- Counts[g]--;
- return res;
- }
-};
-*/
-
-}
-#endif
diff --git a/7zip/Compress/BZip2/BZip2.dsp b/7zip/Compress/BZip2/BZip2.dsp
deleted file mode 100755
index c8d1bd1e..00000000
--- a/7zip/Compress/BZip2/BZip2.dsp
+++ /dev/null
@@ -1,281 +0,0 @@
-# Microsoft Developer Studio Project File - Name="BZip2" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=BZip2 - 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 "BZip2.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 "BZip2.mak" CFG="BZip2 - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "BZip2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "BZip2 - 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)" == "BZip2 - 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 "BZIP2_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "BZ_NO_STDIO" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /D "COMPRESS_BZIP2_MT" /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\BZip2.dll" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "BZip2 - 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 "BZIP2_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /D "COMPRESS_BZIP2_MT" /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\BZip2.dll" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "BZip2 - Win32 Release"
-# Name "BZip2 - Win32 Debug"
-# Begin Group "Spec"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Codec.def
-# 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 "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\NewHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\NewHandler.h
-# End Source File
-# End Group
-# Begin Group "Huffman"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Huffman\HuffmanDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Huffman\HuffmanEncoder.cpp
-
-!IF "$(CFG)" == "BZip2 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\Huffman\HuffmanEncoder.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\MSBFDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\MSBFEncoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OutBuffer.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OutBuffer.h
-# End Source File
-# End Group
-# Begin Group "BWT"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\BWT\BlockSort.cpp
-
-!IF "$(CFG)" == "BZip2 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\BWT\BlockSort.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\BWT\Mtf8.h
-# End Source File
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# 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\Thread.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\BZip2Const.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BZip2CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BZip2CRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BZip2Decoder.cpp
-
-!IF "$(CFG)" == "BZip2 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\BZip2Decoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BZip2Encoder.cpp
-
-!IF "$(CFG)" == "BZip2 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\BZip2Encoder.h
-# End Source File
-# End Target
-# End Project
diff --git a/7zip/Compress/BZip2/BZip2CRC.h b/7zip/Compress/BZip2/BZip2CRC.h
deleted file mode 100755
index 7170fb1a..00000000
--- a/7zip/Compress/BZip2/BZip2CRC.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// BZip2CRC.h
-
-#ifndef __BZIP2_CRC_H
-#define __BZIP2_CRC_H
-
-#include "Common/Types.h"
-
-class CBZip2CRC
-{
- UInt32 _value;
- static UInt32 Table[256];
-public:
- static void InitTable();
- CBZip2CRC(): _value(0xFFFFFFFF) {};
- void Init() { _value = 0xFFFFFFFF; }
- void UpdateByte(Byte b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
- UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
-};
-
-class CBZip2CombinedCRC
-{
- UInt32 _value;
-public:
- CBZip2CombinedCRC(): _value(0){};
- void Init() { _value = 0; }
- void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; }
- UInt32 GetDigest() const { return _value ; }
-};
-
-#endif
diff --git a/7zip/Compress/BZip2/BZip2Decoder.cpp b/7zip/Compress/BZip2/BZip2Decoder.cpp
deleted file mode 100755
index 3f45e665..00000000
--- a/7zip/Compress/BZip2/BZip2Decoder.cpp
+++ /dev/null
@@ -1,648 +0,0 @@
-// BZip2Decoder.cpp
-
-#include "StdAfx.h"
-
-#include "BZip2Decoder.h"
-
-#include "../../../Common/Alloc.h"
-#include "../../../Common/Defs.h"
-#include "../BWT/Mtf8.h"
-#include "BZip2CRC.h"
-
-namespace NCompress {
-namespace NBZip2 {
-
-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,
- 936, 638
-};
-
-bool CState::Alloc()
-{
- if (tt == 0)
- tt = (UInt32 *)BigAlloc(kBlockSizeMax * sizeof(UInt32));
- return (tt != 0);
-}
-
-void CState::Free()
-{
- ::BigFree(tt);
- tt = 0;
-}
-
-#ifdef COMPRESS_BZIP2_MT
-void CState::FinishStream(bool needLeave)
-{
- Decoder->StreamWasFinished = true;
- StreamWasFinishedEvent.Set();
- if (needLeave)
- Decoder->CS.Leave();
- Decoder->CanStartWaitingEvent.Lock();
- WaitingWasStartedEvent.Set();
-}
-
-DWORD CState::ThreadFunc()
-{
- for (;;)
- {
- Decoder->CS.Enter();
- if (Decoder->CloseThreads)
- {
- Decoder->CS.Leave();
- return 0;
- }
- if (Decoder->StreamWasFinished)
- {
- FinishStream(true);
- continue;
- }
- HRESULT res = S_OK;
- bool neadLeave = true;
- try
- {
- UInt32 blockIndex = Decoder->NextBlockIndex;
- UInt32 nextBlockIndex = blockIndex + 1;
- if (nextBlockIndex == Decoder->NumThreads)
- nextBlockIndex = 0;
- Decoder->NextBlockIndex = nextBlockIndex;
-
- bool wasFinished;
- UInt32 crc;
- res = Decoder->ReadSignatures(wasFinished, crc);
- if (res != S_OK)
- {
- Decoder->Result = res;
- FinishStream(true);
- continue;
- }
- if (wasFinished)
- {
- Decoder->Result = res;
- FinishStream(true);
- continue;
- }
-
- res = Decoder->ReadBlock(Decoder->BlockSizeMax, *this);
- UInt64 packSize = Decoder->m_InStream.GetProcessedSize();
- if (res != S_OK)
- {
- Decoder->Result = res;
- FinishStream(true);
- continue;
- }
- neadLeave = false;
- Decoder->CS.Leave();
-
- DecodeBlock1();
-
- Decoder->m_States[blockIndex].CanWriteEvent.Lock();
-
- if (DecodeBlock2(Decoder->m_OutStream) != crc)
- {
- Decoder->Result = S_FALSE;
- FinishStream(neadLeave);
- continue;
- }
-
- if (Decoder->Progress)
- {
- UInt64 unpackSize = Decoder->m_OutStream.GetProcessedSize();
- res = Decoder->Progress->SetRatioInfo(&packSize, &unpackSize);
- }
-
- Decoder->m_States[nextBlockIndex].CanWriteEvent.Set();
- }
- catch(const CInBufferException &e) { res = e.ErrorCode; }
- catch(const COutBufferException &e) { res = e.ErrorCode; }
- catch(...) { res = E_FAIL; }
- if (res != S_OK)
- {
- Decoder->Result = res;
- FinishStream(neadLeave);
- continue;
- }
- }
-}
-
-static DWORD WINAPI MFThread(void *threadCoderInfo)
-{
- return ((CState *)threadCoderInfo)->ThreadFunc();
-}
-#endif
-
-UInt32 CDecoder::ReadBits(int numBits) { return m_InStream.ReadBits(numBits); }
-Byte CDecoder::ReadByte() {return (Byte)ReadBits(8); }
-bool CDecoder::ReadBit() { return ReadBits(1) != 0; }
-
-UInt32 CDecoder::ReadCRC()
-{
- UInt32 crc = 0;
- for (int i = 0; i < 4; i++)
- {
- crc <<= 8;
- crc |= ReadByte();
- }
- return crc;
-}
-
-HRESULT CDecoder::ReadBlock(UInt32 blockSizeMax, CState &state)
-{
- state.BlockRandomised = ReadBit();
- state.OrigPtr = ReadBits(kNumOrigBits);
-
- // in original code it compares OrigPtr to (UInt32)(10 + blockSizeMax)) : why ?
- if (state.OrigPtr >= blockSizeMax)
- return S_FALSE;
-
- CMtf8Decoder mtf;
- int numInUse = 0;
- {
- bool inUse16[16];
- int i;
- for (i = 0; i < 16; i++)
- inUse16[i] = ReadBit();
- for (i = 0; i < 256; i++)
- if (inUse16[i >> 4])
- if (ReadBit())
- mtf.Buffer[numInUse++] = (Byte)i;
- if (numInUse == 0)
- return S_FALSE;
- mtf.Init(numInUse);
- }
- int alphaSize = numInUse + 2;
-
- int numTables = ReadBits(kNumTablesBits);
- if (numTables < kNumTablesMin || numTables > kNumTablesMax)
- return S_FALSE;
-
- UInt32 numSelectors = ReadBits(kNumSelectorsBits);
- if (numSelectors < 1 || numSelectors > kNumSelectorsMax)
- return S_FALSE;
-
- {
- Byte mtfPos[kNumTablesMax];
- int t = 0;
- do
- mtfPos[t] = (Byte)t;
- while(++t < numTables);
- UInt32 i = 0;
- do
- {
- int j = 0;
- while (ReadBit())
- if (++j >= numTables)
- return S_FALSE;
- Byte tmp = mtfPos[j];
- for (;j > 0; j--)
- mtfPos[j] = mtfPos[j - 1];
- state.m_Selectors[i] = mtfPos[0] = tmp;
- }
- while(++i < numSelectors);
- }
-
- int t = 0;
- do
- {
- Byte lens[kMaxAlphaSize];
- int len = (int)ReadBits(kNumLevelsBits);
- int i;
- for (i = 0; i < alphaSize; i++)
- {
- for (;;)
- {
- if (len < 1 || len > kMaxHuffmanLen)
- return S_FALSE;
- if (!ReadBit())
- break;
- if (ReadBit())
- len--;
- else
- len++;
- }
- lens[i] = (Byte)len;
- }
- for (; i < kMaxAlphaSize; i++)
- lens[i] = 0;
- if(!m_HuffmanDecoders[t].SetCodeLengths(lens))
- return S_FALSE;
- }
- while(++t < numTables);
-
- {
- for (int i = 0; i < 256; i++)
- state.CharCounters[i] = 0;
- }
-
- UInt32 blockSize = 0;
- {
- UInt32 groupIndex = 0;
- UInt32 groupSize = 0;
- CHuffmanDecoder *huffmanDecoder = 0;
- int runPower = 0;
- UInt32 runCounter = 0;
-
- for (;;)
- {
- if (groupSize == 0)
- {
- if (groupIndex >= numSelectors)
- return S_FALSE;
- groupSize = kGroupSize;
- huffmanDecoder = &m_HuffmanDecoders[state.m_Selectors[groupIndex++]];
- }
- groupSize--;
-
- UInt32 nextSym = huffmanDecoder->DecodeSymbol(&m_InStream);
-
- if (nextSym < 2)
- {
- runCounter += ((UInt32)(nextSym + 1) << runPower++);
- if (blockSizeMax - blockSize < runCounter)
- return S_FALSE;
- continue;
- }
- if (runCounter != 0)
- {
- Byte b = mtf.GetHead();
- state.CharCounters[b] += runCounter;
- do
- state.tt[blockSize++] = (UInt32)b;
- while(--runCounter != 0);
- runPower = 0;
- }
- if (nextSym <= (UInt32)numInUse)
- {
- Byte b = mtf.GetAndMove((int)nextSym - 1);
- if (blockSize >= blockSizeMax)
- return S_FALSE;
- state.CharCounters[b]++;
- state.tt[blockSize++] = (UInt32)b;
- }
- else if (nextSym == (UInt32)numInUse + 1)
- break;
- else
- return S_FALSE;
- }
- }
- if (state.OrigPtr >= blockSize)
- return S_FALSE;
- state.BlockSize = blockSize;
- return S_OK;
-}
-
-void CState::DecodeBlock1()
-{
- UInt32 *charCounters = this->CharCounters;
- {
- UInt32 sum = 0;
- for (UInt32 i = 0; i < 256; i++)
- {
- sum += charCounters[i];
- charCounters[i] = sum - charCounters[i];
- }
- }
-
- // Compute the T^(-1) vector
- UInt32 blockSize = this->BlockSize;
- UInt32 i = 0;
- do
- tt[charCounters[tt[i] & 0xFF]++] |= (i << 8);
- while(++i < blockSize);
-}
-
-UInt32 CState::DecodeBlock2(COutBuffer &m_OutStream)
-{
- UInt32 blockSize = this->BlockSize;
-
- CBZip2CRC crc;
-
- UInt32 randIndex = 1;
- UInt32 randToGo = kRandNums[0] - 2;
-
- int numReps = 0;
-
- // it's for speed optimization: prefetch & prevByte_init;
- UInt32 tPos = tt[tt[OrigPtr] >> 8];
- Byte prevByte = (Byte)(tPos & 0xFF);
-
- do
- {
- Byte b = (Byte)(tPos & 0xFF);
- tPos = tt[tPos >> 8];
-
- if (BlockRandomised)
- {
- if (randToGo == 0)
- {
- b ^= 1;
- randToGo = kRandNums[randIndex++];
- randIndex &= 0x1FF;
- }
- randToGo--;
- }
-
- if (numReps == kRleModeRepSize)
- {
- for (; b > 0; b--)
- {
- crc.UpdateByte(prevByte);
- m_OutStream.WriteByte(prevByte);
- }
- numReps = 0;
- continue;
- }
- if (prevByte == b)
- numReps++;
- else
- {
- numReps = 1;
- prevByte = b;
- }
- crc.UpdateByte(b);
- m_OutStream.WriteByte(b);
- }
- while(--blockSize != 0);
- return crc.GetDigest();
-}
-
-#ifdef COMPRESS_BZIP2_MT
-CDecoder::CDecoder():
- m_States(0)
-{
- m_NumThreadsPrev = 0;
- NumThreads = 1;
- CS.Enter();
-}
-
-CDecoder::~CDecoder()
-{
- Free();
-}
-
-bool CDecoder::Create()
-{
- try
- {
- if (m_States != 0 && m_NumThreadsPrev == NumThreads)
- return true;
- Free();
- MtMode = (NumThreads > 1);
- m_NumThreadsPrev = NumThreads;
- m_States = new CState[NumThreads];
- if (m_States == 0)
- return false;
- #ifdef COMPRESS_BZIP2_MT
- for (UInt32 t = 0; t < NumThreads; t++)
- {
- CState &ti = m_States[t];
- ti.Decoder = this;
- if (MtMode)
- if (!ti.Thread.Create(MFThread, &ti))
- {
- NumThreads = t;
- Free();
- return false;
- }
- }
- #endif
- }
- catch(...) { return false; }
- return true;
-}
-
-void CDecoder::Free()
-{
- if (!m_States)
- return;
- CloseThreads = true;
- CS.Leave();
- for (UInt32 t = 0; t < NumThreads; t++)
- {
- CState &s = m_States[t];
- if (MtMode)
- s.Thread.Wait();
- s.Free();
- }
- delete []m_States;
- m_States = 0;
-}
-#endif
-
-HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
-{
- wasFinished = false;
- Byte s[6];
- for (int i = 0; i < 6; i++)
- s[i] = ReadByte();
- crc = ReadCRC();
- if (s[0] == kFinSig0)
- {
- 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 ||
- s[5] != kBlockSig5)
- return S_FALSE;
- CombinedCRC.Update(crc);
- return S_OK;
-}
-
-HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
-{
- #ifdef COMPRESS_BZIP2_MT
- Progress = progress;
- if (!Create())
- return E_FAIL;
- for (UInt32 t = 0; t < NumThreads; t++)
- {
- CState &s = m_States[t];
- if (!s.Alloc())
- return E_OUTOFMEMORY;
- s.StreamWasFinishedEvent.Reset();
- s.WaitingWasStartedEvent.Reset();
- s.CanWriteEvent.Reset();
- }
- #else
- if (!m_States[0].Alloc())
- return E_OUTOFMEMORY;
- #endif
-
- isBZ = false;
- Byte s[6];
- int i;
- for (i = 0; i < 4; i++)
- s[i] = ReadByte();
- if (s[0] != kArSig0 ||
- s[1] != kArSig1 ||
- s[2] != kArSig2 ||
- s[3] <= kArSig3 ||
- s[3] > kArSig3 + kBlockSizeMultMax)
- return S_OK;
- isBZ = true;
- UInt32 dicSize = (UInt32)(s[3] - kArSig3) * kBlockSizeStep;
-
- CombinedCRC.Init();
- #ifdef COMPRESS_BZIP2_MT
- if (MtMode)
- {
- NextBlockIndex = 0;
- StreamWasFinished = false;
- CloseThreads = false;
- CanStartWaitingEvent.Reset();
- m_States[0].CanWriteEvent.Set();
- BlockSizeMax = dicSize;
- Result = S_OK;
- CS.Leave();
- UInt32 t;
- for (t = 0; t < NumThreads; t++)
- m_States[t].StreamWasFinishedEvent.Lock();
- CS.Enter();
- CanStartWaitingEvent.Set();
- for (t = 0; t < NumThreads; t++)
- m_States[t].WaitingWasStartedEvent.Lock();
- CanStartWaitingEvent.Reset();
- RINOK(Result);
- }
- else
- #endif
- {
- CState &state = m_States[0];
- for (;;)
- {
- if (progress)
- {
- UInt64 packSize = m_InStream.GetProcessedSize();
- UInt64 unpackSize = m_OutStream.GetProcessedSize();
- RINOK(progress->SetRatioInfo(&packSize, &unpackSize));
- }
- bool wasFinished;
- UInt32 crc;
- RINOK(ReadSignatures(wasFinished, crc));
- if (wasFinished)
- return S_OK;
-
- RINOK(ReadBlock(dicSize, state));
- state.DecodeBlock1();
- if (state.DecodeBlock2(m_OutStream) != crc)
- return S_FALSE;
- }
- }
- return S_OK;
-}
-
-HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
- ICompressProgressInfo *progress)
-{
- if (!m_InStream.Create(kBufferSize))
- return E_OUTOFMEMORY;
- if (!m_OutStream.Create(kBufferSize))
- return E_OUTOFMEMORY;
-
- m_InStream.SetStream(inStream);
- m_InStream.Init();
-
- m_OutStream.SetStream(outStream);
- m_OutStream.Init();
-
- CDecoderFlusher flusher(this);
-
- bool isBZ;
- RINOK(DecodeFile(isBZ, progress));
- return isBZ ? S_OK: S_FALSE;
-}
-
-STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
- catch(...) { return S_FALSE; }
-}
-
-STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
-{
- if (value == NULL)
- return E_INVALIDARG;
- *value = m_InStream.GetProcessedSize();
- return S_OK;
-}
-
-#ifdef COMPRESS_BZIP2_MT
-STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
-{
- NumThreads = numThreads;
- if (NumThreads < 1)
- NumThreads = 1;
- if (NumThreads > kNumThreadsMax)
- NumThreads = kNumThreadsMax;
- return S_OK;
-}
-#endif
-
-}}
diff --git a/7zip/Compress/BZip2/BZip2Decoder.h b/7zip/Compress/BZip2/BZip2Decoder.h
deleted file mode 100755
index c59819b4..00000000
--- a/7zip/Compress/BZip2/BZip2Decoder.h
+++ /dev/null
@@ -1,162 +0,0 @@
-// Compress/BZip2/Decoder.h
-
-#ifndef __COMPRESS_BZIP2_DECODER_H
-#define __COMPRESS_BZIP2_DECODER_H
-
-#include "../../ICoder.h"
-#include "../../../Common/MyCom.h"
-#include "../../Common/MSBFDecoder.h"
-#include "../../Common/InBuffer.h"
-#include "../../Common/OutBuffer.h"
-#include "../Huffman/HuffmanDecoder.h"
-#include "BZip2Const.h"
-#include "BZip2CRC.h"
-
-#ifdef COMPRESS_BZIP2_MT
-#include "../../../Windows/Thread.h"
-#include "../../../Windows/Synchronization.h"
-#endif
-
-namespace NCompress {
-namespace NBZip2 {
-
-typedef NCompress::NHuffman::CDecoder<kMaxHuffmanLen, kMaxAlphaSize> CHuffmanDecoder;
-
-class CDecoder;
-
-struct CState
-{
- UInt32 *tt;
- bool BlockRandomised;
- UInt32 OrigPtr;
- UInt32 BlockSize;
- UInt32 CharCounters[256];
- Byte m_Selectors[kNumSelectorsMax];
-
- #ifdef COMPRESS_BZIP2_MT
-
- CDecoder *Decoder;
- NWindows::CThread Thread;
- bool m_OptimizeNumTables;
-
- NWindows::NSynchronization::CAutoResetEvent StreamWasFinishedEvent;
- NWindows::NSynchronization::CAutoResetEvent WaitingWasStartedEvent;
-
- // it's not member of this thread. We just need one event per thread
- NWindows::NSynchronization::CAutoResetEvent CanWriteEvent;
-
- Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
-
- void FinishStream(bool needLeave);
- DWORD ThreadFunc();
-
- #endif
-
- CState(): tt(0) {}
- ~CState() { Free(); }
- bool Alloc();
- void Free();
- void DecodeBlock1();
- UInt32 DecodeBlock2(COutBuffer &m_OutStream);
-};
-
-class CDecoder :
- public ICompressCoder,
- #ifdef COMPRESS_BZIP2_MT
- public ICompressSetCoderMt,
- #endif
- public ICompressGetInStreamProcessedSize,
- public CMyUnknownImp
-{
-public:
- COutBuffer m_OutStream;
- Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
- NStream::NMSBF::CDecoder<CInBuffer> m_InStream;
-private:
- CHuffmanDecoder m_HuffmanDecoders[kNumTablesMax];
-
- UInt32 m_NumThreadsPrev;
-
- UInt32 ReadBits(int numBits);
- Byte ReadByte();
- bool ReadBit();
- UInt32 ReadCRC();
- HRESULT PrepareBlock(CState &state);
- HRESULT DecodeFile(bool &isBZ, ICompressProgressInfo *progress);
- HRESULT CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
- class CDecoderFlusher
- {
- CDecoder *_decoder;
- public:
- bool NeedFlush;
- CDecoderFlusher(CDecoder *decoder): _decoder(decoder), NeedFlush(true) {}
- ~CDecoderFlusher()
- {
- if (NeedFlush)
- _decoder->Flush();
- _decoder->ReleaseStreams();
- }
- };
-
-public:
- CBZip2CombinedCRC CombinedCRC;
-
- #ifdef COMPRESS_BZIP2_MT
- ICompressProgressInfo *Progress;
- CState *m_States;
-
- NWindows::NSynchronization::CCriticalSection CS;
- UInt32 NumThreads;
- bool MtMode;
- UInt32 NextBlockIndex;
- bool CloseThreads;
- bool StreamWasFinished;
- NWindows::NSynchronization::CManualResetEvent CanStartWaitingEvent;
-
- HRESULT Result;
-
- UInt32 BlockSizeMax;
- CDecoder();
- ~CDecoder();
- bool Create();
- void Free();
-
- #else
- CState m_States[1];
- #endif
-
- HRESULT ReadBlock(UInt32 blockSizeMax, CState &state);
-
- HRESULT ReadSignatures(bool &wasFinished, UInt32 &crc);
-
-
- HRESULT Flush() { return m_OutStream.Flush(); }
- void ReleaseStreams()
- {
- m_InStream.ReleaseStream();
- m_OutStream.ReleaseStream();
- }
-
- #ifdef COMPRESS_BZIP2_MT
- MY_UNKNOWN_IMP2(ICompressSetCoderMt, ICompressGetInStreamProcessedSize)
- #else
- MY_UNKNOWN_IMP1(ICompressGetInStreamProcessedSize)
- #endif
-
-
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
-
- #ifdef COMPRESS_BZIP2_MT
- STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
- #endif
-};
-
-}}
-
-#endif
diff --git a/7zip/Compress/BZip2/BZip2Encoder.cpp b/7zip/Compress/BZip2/BZip2Encoder.cpp
deleted file mode 100755
index 97009041..00000000
--- a/7zip/Compress/BZip2/BZip2Encoder.cpp
+++ /dev/null
@@ -1,876 +0,0 @@
-// BZip2Encoder.cpp
-
-#include "StdAfx.h"
-
-#include "../../../Common/Alloc.h"
-
-#include "BZip2Encoder.h"
-
-#include "../BWT/Mtf8.h"
-#include "BZip2CRC.h"
-
-namespace NCompress {
-namespace NBZip2 {
-
-static const UInt32 kBufferSize = (1 << 17);
-static const int kNumHuffPasses = 4;
-
-bool CThreadInfo::Create()
-{
- if (!m_BlockSorter.Create(kBlockSizeMax))
- return false;
-
- if (m_Block == 0)
- {
- m_Block = (Byte *)::BigAlloc(kBlockSizeMax * 5 + kBlockSizeMax / 10 + (20 << 10));
- if (m_Block == 0)
- return false;
- m_MtfArray = m_Block + kBlockSizeMax;
- m_TempArray = m_MtfArray + kBlockSizeMax * 2 + 2;
- }
- if (m_NeedHuffmanCreate)
- {
- for (int i = 0; i < kNumTablesMax; i++)
- if (!m_HuffEncoders[i].Create(kMaxAlphaSize, 0, 0, kMaxHuffmanLen))
- return false;
- m_NeedHuffmanCreate = false;
- }
- return true;
-}
-
-void CThreadInfo::Free()
-{
- m_BlockSorter.Free();
- ::BigFree(m_Block);
- m_Block = 0;
-}
-
-#ifdef COMPRESS_BZIP2_MT
-void CThreadInfo::FinishStream(bool needLeave)
-{
- Encoder->StreamWasFinished = true;
- StreamWasFinishedEvent.Set();
- if (needLeave)
- Encoder->CS.Leave();
- Encoder->CanStartWaitingEvent.Lock();
- WaitingWasStartedEvent.Set();
-}
-
-DWORD CThreadInfo::ThreadFunc()
-{
- for (;;)
- {
- Encoder->CS.Enter();
- if (Encoder->CloseThreads)
- {
- Encoder->CS.Leave();
- return 0;
- }
- if (Encoder->StreamWasFinished)
- {
- FinishStream(true);
- continue;
- }
- HRESULT res = S_OK;
- bool needLeave = true;
- try
- {
- UInt32 blockSize = Encoder->ReadRleBlock(m_Block);
- m_PackSize = Encoder->m_InStream.GetProcessedSize();
- m_BlockIndex = Encoder->NextBlockIndex;
- if (++Encoder->NextBlockIndex == Encoder->NumThreads)
- Encoder->NextBlockIndex = 0;
- if (blockSize == 0)
- {
- FinishStream(true);
- continue;
- }
- Encoder->CS.Leave();
- needLeave = false;
- res = EncodeBlock3(blockSize);
- }
- catch(const CInBufferException &e) { res = e.ErrorCode; }
- catch(const COutBufferException &e) { res = e.ErrorCode; }
- catch(...) { res = E_FAIL; }
- if (res != S_OK)
- {
- Encoder->Result = res;
- FinishStream(needLeave);
- continue;
- }
- }
-}
-
-static DWORD WINAPI MFThread(void *threadCoderInfo)
-{
- return ((CThreadInfo *)threadCoderInfo)->ThreadFunc();
-}
-#endif
-
-CEncoder::CEncoder():
- NumPasses(1),
- m_OptimizeNumTables(false),
- m_BlockSizeMult(kBlockSizeMultMax)
-{
- #ifdef COMPRESS_BZIP2_MT
- ThreadsInfo = 0;
- m_NumThreadsPrev = 0;
- NumThreads = 1;
- CS.Enter();
- #endif
-}
-
-#ifdef COMPRESS_BZIP2_MT
-CEncoder::~CEncoder()
-{
- Free();
-}
-
-bool CEncoder::Create()
-{
- try
- {
- if (ThreadsInfo != 0 && m_NumThreadsPrev == NumThreads)
- return true;
- Free();
- MtMode = (NumThreads > 1);
- m_NumThreadsPrev = NumThreads;
- ThreadsInfo = new CThreadInfo[NumThreads];
- if (ThreadsInfo == 0)
- return false;
- for (UInt32 t = 0; t < NumThreads; t++)
- {
- CThreadInfo &ti = ThreadsInfo[t];
- ti.Encoder = this;
- if (MtMode)
- if (!ti.Thread.Create(MFThread, &ti))
- {
- NumThreads = t;
- Free();
- return false;
- }
- }
- }
- catch(...) { return false; }
- return true;
-}
-
-void CEncoder::Free()
-{
- if (!ThreadsInfo)
- return;
- CloseThreads = true;
- CS.Leave();
- for (UInt32 t = 0; t < NumThreads; t++)
- {
- CThreadInfo &ti = ThreadsInfo[t];
- if (MtMode)
- ti.Thread.Wait();
- ti.Free();
- }
- delete []ThreadsInfo;
- ThreadsInfo = 0;
-}
-#endif
-
-UInt32 CEncoder::ReadRleBlock(Byte *buffer)
-{
- UInt32 i = 0;
- Byte prevByte;
- if (m_InStream.ReadByte(prevByte))
- {
- UInt32 blockSize = m_BlockSizeMult * kBlockSizeStep - 1;
- int numReps = 1;
- buffer[i++] = prevByte;
- while (i < blockSize) // "- 1" to support RLE
- {
- Byte b;
- if (!m_InStream.ReadByte(b))
- break;
- if (b != prevByte)
- {
- if (numReps >= kRleModeRepSize)
- buffer[i++] = (Byte)(numReps - kRleModeRepSize);
- buffer[i++] = b;
- numReps = 1;
- prevByte = b;
- continue;
- }
- numReps++;
- if (numReps <= kRleModeRepSize)
- buffer[i++] = b;
- else if (numReps == kRleModeRepSize + 255)
- {
- buffer[i++] = (Byte)(numReps - kRleModeRepSize);
- numReps = 0;
- }
- }
- // it's to support original BZip2 decoder
- if (numReps >= kRleModeRepSize)
- buffer[i++] = (Byte)(numReps - kRleModeRepSize);
- }
- return i;
-}
-
-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)
-{
- for (int i = 0; i < 4; i++)
- WriteByte2(((Byte)(v >> (24 - i * 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)
-{
- for (int i = 0; i < 4; i++)
- WriteByte(((Byte)(v >> (24 - i * 8))));
-}
-
-
-// blockSize > 0
-void CThreadInfo::EncodeBlock(Byte *block, UInt32 blockSize)
-{
- WriteBit2(false); // Randomised = false
-
- {
- UInt32 origPtr = m_BlockSorter.Sort(block, blockSize);
- WriteBits2(origPtr, kNumOrigBits);
- }
-
- CMtf8Encoder mtf;
- int numInUse = 0;
- {
- bool inUse[256];
- bool inUse16[16];
- UInt32 i;
- for (i = 0; i < 256; i++)
- inUse[i] = false;
- 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++)
- if (inUse[i])
- {
- inUse16[i >> 4] = true;
- mtf.Buffer[numInUse++] = (Byte)i;
- }
- for (i = 0; i < 16; i++)
- WriteBit2(inUse16[i]);
- for (i = 0; i < 256; i++)
- if (inUse16[i >> 4])
- WriteBit2(inUse[i]);
- }
- int alphaSize = numInUse + 2;
-
- Byte *mtfs = m_MtfArray;
- UInt32 mtfArraySize = 0;
- UInt32 symbolCounts[kMaxAlphaSize];
- {
- for (int i = 0; i < kMaxAlphaSize; i++)
- symbolCounts[i] = 0;
- }
-
- {
- UInt32 rleSize = 0;
- UInt32 i = 0;
- do
- {
- UInt32 index = m_BlockSorter.Indices[i];
- if (index == 0)
- index = blockSize - 1;
- else
- index--;
- int pos = mtf.FindAndMove(block[index]);
- if (pos == 0)
- rleSize++;
- else
- {
- while (rleSize != 0)
- {
- rleSize--;
- mtfs[mtfArraySize++] = (Byte)(rleSize & 1);
- symbolCounts[rleSize & 1]++;
- rleSize >>= 1;
- }
- if (pos >= 0xFE)
- {
- mtfs[mtfArraySize++] = 0xFF;
- mtfs[mtfArraySize++] = (Byte)(pos - 0xFE);
- }
- else
- mtfs[mtfArraySize++] = (Byte)(pos + 1);
- symbolCounts[pos + 1]++;
- }
- }
- while (++i < blockSize);
-
- while (rleSize != 0)
- {
- rleSize--;
- mtfs[mtfArraySize++] = (Byte)(rleSize & 1);
- symbolCounts[rleSize & 1]++;
- rleSize >>= 1;
- }
-
- if (alphaSize < 256)
- mtfs[mtfArraySize++] = (Byte)(alphaSize - 1);
- else
- {
- mtfs[mtfArraySize++] = 0xFF;
- mtfs[mtfArraySize++] = (Byte)(alphaSize - 256);
- }
- symbolCounts[alphaSize - 1]++;
- }
-
- UInt32 numSymbols = 0;
- {
- for (int i = 0; i < kMaxAlphaSize; i++)
- numSymbols += symbolCounts[i];
- }
-
- int bestNumTables = kNumTablesMin;
- UInt32 bestPrice = 0xFFFFFFFF;
- UInt32 startPos = m_OutStreamCurrent->GetPos();
- Byte startCurByte = m_OutStreamCurrent->GetCurByte();
- for (int nt = kNumTablesMin; nt <= kNumTablesMax + 1; nt++)
- {
- int numTables;
-
- if(m_OptimizeNumTables)
- {
- m_OutStreamCurrent->SetPos(startPos);
- m_OutStreamCurrent->SetCurState((startPos & 7), startCurByte);
- if (nt <= kNumTablesMax)
- numTables = nt;
- else
- numTables = bestNumTables;
- }
- else
- {
- 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;
- }
-
- WriteBits2(numTables, kNumTablesBits);
-
- UInt32 numSelectors = (numSymbols + kGroupSize - 1) / kGroupSize;
- WriteBits2(numSelectors, kNumSelectorsBits);
-
- {
- UInt32 remFreq = numSymbols;
- int gs = 0;
- int t = numTables;
- do
- {
- UInt32 tFreq = remFreq / t;
- int ge = gs;
- UInt32 aFreq = 0;
- while (aFreq < tFreq) // && ge < alphaSize)
- aFreq += symbolCounts[ge++];
-
- if (ge - 1 > gs && t != numTables && t != 1 && (((numTables - t) & 1) == 1))
- aFreq -= symbolCounts[--ge];
-
- NCompression::NHuffman::CEncoder &huffEncoder = m_HuffEncoders[t - 1];
- int i = 0;
- do
- huffEncoder.m_Items[i].Len = (i >= gs && i < ge) ? 0 : 1;
- while (++i < alphaSize);
- gs = ge;
- remFreq -= aFreq;
- }
- while(--t != 0);
- }
-
-
- for (int pass = 0; pass < kNumHuffPasses; pass++)
- {
- {
- int t = 0;
- do
- m_HuffEncoders[t].StartNewBlock();
- while(++t < numTables);
- }
-
- {
- UInt32 mtfPos = 0;
- UInt32 g = 0;
- do
- {
- UInt32 symbols[kGroupSize];
- int i = 0;
- do
- {
- UInt32 symbol = mtfs[mtfPos++];
- if (symbol >= 0xFF)
- symbol += mtfs[mtfPos++];
- symbols[i] = symbol;
- }
- while (++i < kGroupSize && mtfPos < mtfArraySize);
-
- UInt32 bestPrice = 0xFFFFFFFF;
- int t = 0;
- do
- {
- NCompression::NHuffman::CItem *items = m_HuffEncoders[t].m_Items;
- UInt32 price = 0;
- int j = 0;
- do
- price += items[symbols[j]].Len;
- while (++j < i);
- if (price < bestPrice)
- {
- m_Selectors[g] = (Byte)t;
- bestPrice = price;
- }
- }
- while(++t < numTables);
- NCompression::NHuffman::CEncoder &huffEncoder = m_HuffEncoders[m_Selectors[g++]];
- int j = 0;
- do
- huffEncoder.AddSymbol(symbols[j]);
- while (++j < i);
- }
- while (mtfPos < mtfArraySize);
- }
-
- int t = 0;
- do
- {
- NCompression::NHuffman::CEncoder &huffEncoder = m_HuffEncoders[t];
- int i = 0;
- do
- if (huffEncoder.m_Items[i].Freq == 0)
- huffEncoder.m_Items[i].Freq = 1;
- while(++i < alphaSize);
- Byte levels[kMaxAlphaSize];
- huffEncoder.BuildTree(levels);
- }
- while(++t < numTables);
- }
-
- {
- Byte mtfSel[kNumTablesMax];
- {
- int t = 0;
- do
- mtfSel[t] = (Byte)t;
- while(++t < numTables);
- }
-
- UInt32 i = 0;
- do
- {
- Byte sel = m_Selectors[i];
- int pos;
- for (pos = 0; mtfSel[pos] != sel; pos++)
- WriteBit2(true);
- WriteBit2(false);
- for (; pos > 0; pos--)
- mtfSel[pos] = mtfSel[pos - 1];
- mtfSel[0] = sel;
- }
- while(++i < numSelectors);
- }
-
- {
- int t = 0;
- do
- {
- NCompression::NHuffman::CItem *items = m_HuffEncoders[t].m_Items;
- UInt32 len = items[0].Len;
- WriteBits2(len, kNumLevelsBits);
- int i = 0;
- do
- {
- UInt32 level = items[i].Len;
- while (len != level)
- {
- WriteBit2(true);
- if (len < level)
- {
- WriteBit2(false);
- len++;
- }
- else
- {
- WriteBit2(true);
- len--;
- }
- }
- WriteBit2(false);
- }
- while (++i < alphaSize);
- }
- while(++t < numTables);
- }
-
- {
- UInt32 groupSize = 0;
- UInt32 groupIndex = 0;
- NCompression::NHuffman::CEncoder *huffEncoder = 0;
- UInt32 mtfPos = 0;
- do
- {
- UInt32 symbol = mtfs[mtfPos++];
- if (symbol >= 0xFF)
- symbol += mtfs[mtfPos++];
- if (groupSize == 0)
- {
- groupSize = kGroupSize;
- huffEncoder = &m_HuffEncoders[m_Selectors[groupIndex++]];
- }
- groupSize--; \
- huffEncoder->CodeOneValue(m_OutStreamCurrent, symbol);
- }
- while (mtfPos < mtfArraySize);
- }
-
- if (!m_OptimizeNumTables)
- break;
- UInt32 price = m_OutStreamCurrent->GetPos() - startPos;
- if (price <= bestPrice)
- {
- if (nt == kNumTablesMax)
- break;
- bestPrice = price;
- bestNumTables = nt;
- }
- }
-}
-
-// blockSize > 0
-UInt32 CThreadInfo::EncodeBlockWithHeaders(Byte *block, UInt32 blockSize)
-{
- WriteByte2(kBlockSig0);
- WriteByte2(kBlockSig1);
- WriteByte2(kBlockSig2);
- WriteByte2(kBlockSig3);
- WriteByte2(kBlockSig4);
- WriteByte2(kBlockSig5);
-
- CBZip2CRC crc;
- int numReps = 0;
- Byte prevByte = block[0];
- UInt32 i = 0;
- do
- {
- Byte b = block[i];
- if (numReps == kRleModeRepSize)
- {
- for (; b > 0; b--)
- crc.UpdateByte(prevByte);
- numReps = 0;
- continue;
- }
- if (prevByte == b)
- numReps++;
- else
- {
- numReps = 1;
- prevByte = b;
- }
- crc.UpdateByte(b);
- }
- while (++i < blockSize);
- UInt32 crcRes = crc.GetDigest();
- WriteCRC2(crcRes);
- EncodeBlock(block, blockSize);
- return crcRes;
-}
-
-void CThreadInfo::EncodeBlock2(Byte *block, UInt32 blockSize, UInt32 numPasses)
-{
- UInt32 numCrcs = m_NumCrcs;
- bool needCompare = false;
-
- UInt32 startBytePos = m_OutStreamCurrent->GetBytePos();
- UInt32 startPos = m_OutStreamCurrent->GetPos();
- Byte startCurByte = m_OutStreamCurrent->GetCurByte();
- Byte endCurByte = 0;
- UInt32 endPos = 0;
- if (numPasses > 1 && blockSize >= (1 << 10))
- {
- UInt32 blockSize0 = blockSize / 2;
- for (;(block[blockSize0] == block[blockSize0 - 1] ||
- block[blockSize0 - 1] == block[blockSize0 - 2]) &&
- blockSize0 < blockSize; blockSize0++);
- if (blockSize0 < blockSize)
- {
- EncodeBlock2(block, blockSize0, numPasses - 1);
- EncodeBlock2(block + blockSize0, blockSize - blockSize0, numPasses - 1);
- endPos = m_OutStreamCurrent->GetPos();
- endCurByte = m_OutStreamCurrent->GetCurByte();
- if ((endPos & 7) > 0)
- WriteBits2(0, 8 - (endPos & 7));
- m_OutStreamCurrent->SetCurState((startPos & 7), startCurByte);
- needCompare = true;
- }
- }
-
- UInt32 startBytePos2 = m_OutStreamCurrent->GetBytePos();
- UInt32 startPos2 = m_OutStreamCurrent->GetPos();
- UInt32 crcVal = EncodeBlockWithHeaders(block, blockSize);
- UInt32 endPos2 = m_OutStreamCurrent->GetPos();
-
- if (needCompare)
- {
- 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++)
- buffer[startBytePos + i] = buffer[startBytePos2 + i];
- m_OutStreamCurrent->SetPos(startPos + endPos2 - startPos2);
- m_NumCrcs = numCrcs;
- m_CRCs[m_NumCrcs++] = crcVal;
- }
- else
- {
- m_OutStreamCurrent->SetPos(endPos);
- m_OutStreamCurrent->SetCurState((endPos & 7), endCurByte);
- }
- }
- else
- {
- m_NumCrcs = numCrcs;
- m_CRCs[m_NumCrcs++] = crcVal;
- }
-}
-
-HRESULT CThreadInfo::EncodeBlock3(UInt32 blockSize)
-{
- CMsbfEncoderTemp outStreamTemp;
- outStreamTemp.SetStream(m_TempArray);
- outStreamTemp.Init();
- m_OutStreamCurrent = &outStreamTemp;
-
- m_NumCrcs = 0;
-
- EncodeBlock2(m_Block, blockSize, Encoder->NumPasses);
-
- #ifdef COMPRESS_BZIP2_MT
- if (Encoder->MtMode)
- Encoder->ThreadsInfo[m_BlockIndex].CanWriteEvent.Lock();
- #endif
- for (UInt32 i = 0; i < m_NumCrcs; i++)
- Encoder->CombinedCRC.Update(m_CRCs[i]);
- Encoder->WriteBytes(m_TempArray, outStreamTemp.GetPos(), outStreamTemp.GetCurByte());
- HRESULT res = S_OK;
- #ifdef COMPRESS_BZIP2_MT
- if (Encoder->MtMode)
- {
- UInt32 blockIndex = m_BlockIndex + 1;
- if (blockIndex == Encoder->NumThreads)
- blockIndex = 0;
-
- if (Encoder->Progress)
- {
- UInt64 unpackSize = Encoder->m_OutStream.GetProcessedSize();
- res = Encoder->Progress->SetRatioInfo(&m_PackSize, &unpackSize);
- }
-
- Encoder->ThreadsInfo[blockIndex].CanWriteEvent.Set();
- }
- #endif
- return res;
-}
-
-void CEncoder::WriteBytes(const Byte *data, UInt32 sizeInBits, Byte lastByte)
-{
- UInt32 bytesSize = (sizeInBits / 8);
- for (UInt32 i = 0; i < bytesSize; i++)
- m_OutStream.WriteBits(data[i], 8);
- WriteBits(lastByte, (sizeInBits & 7));
-}
-
-
-HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
- ICompressProgressInfo *progress)
-{
- #ifdef COMPRESS_BZIP2_MT
- Progress = progress;
- if (!Create())
- return E_FAIL;
- for (UInt32 t = 0; t < NumThreads; t++)
- #endif
- {
- #ifdef COMPRESS_BZIP2_MT
- CThreadInfo &ti = ThreadsInfo[t];
- ti.StreamWasFinishedEvent.Reset();
- ti.WaitingWasStartedEvent.Reset();
- ti.CanWriteEvent.Reset();
- #else
- CThreadInfo &ti = ThreadsInfo;
- ti.Encoder = this;
- #endif
-
- ti.m_OptimizeNumTables = m_OptimizeNumTables;
-
- if (!ti.Create())
- return E_OUTOFMEMORY;
- }
-
-
- if (!m_InStream.Create(kBufferSize))
- return E_OUTOFMEMORY;
- if (!m_OutStream.Create(kBufferSize))
- return E_OUTOFMEMORY;
-
-
- m_InStream.SetStream(inStream);
- m_InStream.Init();
-
- m_OutStream.SetStream(outStream);
- m_OutStream.Init();
-
- CFlusher flusher(this);
-
- CombinedCRC.Init();
- #ifdef COMPRESS_BZIP2_MT
- NextBlockIndex = 0;
- StreamWasFinished = false;
- CloseThreads = false;
- CanStartWaitingEvent.Reset();
- #endif
-
- WriteByte(kArSig0);
- WriteByte(kArSig1);
- WriteByte(kArSig2);
- WriteByte((Byte)(kArSig3 + m_BlockSizeMult));
-
- #ifdef COMPRESS_BZIP2_MT
-
- if (MtMode)
- {
- ThreadsInfo[0].CanWriteEvent.Set();
- Result = S_OK;
- CS.Leave();
- UInt32 t;
- for (t = 0; t < NumThreads; t++)
- ThreadsInfo[t].StreamWasFinishedEvent.Lock();
- CS.Enter();
- CanStartWaitingEvent.Set();
- for (t = 0; t < NumThreads; t++)
- ThreadsInfo[t].WaitingWasStartedEvent.Lock();
- CanStartWaitingEvent.Reset();
- RINOK(Result);
- }
- else
- #endif
- {
- for (;;)
- {
- CThreadInfo &ti =
- #ifdef COMPRESS_BZIP2_MT
- ThreadsInfo[0];
- #else
- ThreadsInfo;
- #endif
- UInt32 blockSize = ReadRleBlock(ti.m_Block);
- if (blockSize == 0)
- break;
- RINOK(ti.EncodeBlock3(blockSize));
- if (progress)
- {
- UInt64 packSize = m_InStream.GetProcessedSize();
- UInt64 unpackSize = m_OutStream.GetProcessedSize();
- RINOK(progress->SetRatioInfo(&packSize, &unpackSize));
- }
- }
- }
- WriteByte(kFinSig0);
- WriteByte(kFinSig1);
- WriteByte(kFinSig2);
- WriteByte(kFinSig3);
- WriteByte(kFinSig4);
- WriteByte(kFinSig5);
-
- WriteCRC(CombinedCRC.GetDigest());
- return S_OK;
-}
-
-STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
- catch(const CInBufferException &e) { return e.ErrorCode; }
- catch(const COutBufferException &e) { return e.ErrorCode; }
- catch(...) { return S_FALSE; }
-}
-
-HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties)
-{
- for(UInt32 i = 0; i < numProperties; i++)
- {
- const PROPVARIANT &property = properties[i];
- switch(propIDs[i])
- {
- case NCoderPropID::kNumPasses:
- {
- if (property.vt != VT_UI4)
- return E_INVALIDARG;
- UInt32 numPasses = property.ulVal;
- if (numPasses == 0)
- numPasses = 1;
- if (numPasses > kNumPassesMax)
- numPasses = kNumPassesMax;
- NumPasses = numPasses;
- m_OptimizeNumTables = (NumPasses > 1);
- break;
- }
- case NCoderPropID::kDictionarySize:
- {
- if (property.vt != VT_UI4)
- return E_INVALIDARG;
- UInt32 dictionary = property.ulVal / kBlockSizeStep;
- if (dictionary < kBlockSizeMultMin)
- dictionary = kBlockSizeMultMin;
- else if (dictionary > kBlockSizeMultMax)
- dictionary = kBlockSizeMultMax;
- m_BlockSizeMult = dictionary;
- break;
- }
- case NCoderPropID::kNumThreads:
- {
- #ifdef COMPRESS_BZIP2_MT
- if (property.vt != VT_UI4)
- return E_INVALIDARG;
- NumThreads = property.ulVal;
- if (NumThreads < 1)
- NumThreads = 1;
- #endif
- break;
- }
- default:
- return E_INVALIDARG;
- }
- }
- return S_OK;
-}
-
-#ifdef COMPRESS_BZIP2_MT
-STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads)
-{
- NumThreads = numThreads;
- if (NumThreads < 1)
- NumThreads = 1;
- return S_OK;
-}
-#endif
-
-}}
diff --git a/7zip/Compress/BZip2/BZip2Encoder.h b/7zip/Compress/BZip2/BZip2Encoder.h
deleted file mode 100755
index b1a73c59..00000000
--- a/7zip/Compress/BZip2/BZip2Encoder.h
+++ /dev/null
@@ -1,247 +0,0 @@
-// Compress/BZip2/Encoder.h
-
-#ifndef __COMPRESS_BZIP2_ENCODER_H
-#define __COMPRESS_BZIP2_ENCODER_H
-
-#include "../../ICoder.h"
-#include "../../../Common/MyCom.h"
-#include "../../Common/MSBFEncoder.h"
-#include "../../Common/InBuffer.h"
-#include "../../Common/OutBuffer.h"
-#include "../Huffman/HuffmanEncoder.h"
-#include "../BWT/BlockSort.h"
-#include "BZip2Const.h"
-#include "BZip2CRC.h"
-
-#ifdef COMPRESS_BZIP2_MT
-#include "../../../Windows/Thread.h"
-#include "../../../Windows/Synchronization.h"
-#endif
-
-namespace NCompress {
-namespace NBZip2 {
-
-class CMsbfEncoderTemp
-{
- UInt32 m_Pos;
- int m_BitPos;
- Byte m_CurByte;
- Byte *Buffer;
-public:
- void SetStream(Byte *buffer) { Buffer = buffer; }
- Byte *GetStream() const { return Buffer; }
-
- void Init()
- {
- m_Pos = 0;
- m_BitPos = 8;
- m_CurByte = 0;
- }
-
- void Flush()
- {
- if(m_BitPos < 8)
- WriteBits(0, m_BitPos);
- }
-
- void WriteBits(UInt32 value, int numBits)
- {
- while(numBits > 0)
- {
- int numNewBits = MyMin(numBits, m_BitPos);
- numBits -= numNewBits;
-
- m_CurByte <<= numNewBits;
- UInt32 newBits = value >> numBits;
- m_CurByte |= Byte(newBits);
- value -= (newBits << numBits);
-
- m_BitPos -= numNewBits;
-
- if (m_BitPos == 0)
- {
- Buffer[m_Pos++] = m_CurByte;
- m_BitPos = 8;
- }
- }
- }
-
- UInt32 GetBytePos() const { return m_Pos ; }
- 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 - (bitPos & 7);
- }
- void SetCurState(UInt32 bitPos, Byte curByte)
- {
- m_BitPos = 8 - bitPos;
- m_CurByte = curByte;
- }
-};
-
-class CEncoder;
-
-const int kNumPassesMax = 10;
-
-class CThreadInfo
-{
-public:
- Byte *m_Block;
-private:
- Byte *m_MtfArray;
- Byte *m_TempArray;
- CBlockSorter m_BlockSorter;
-
- CMsbfEncoderTemp *m_OutStreamCurrent;
-
- NCompression::NHuffman::CEncoder m_HuffEncoders[kNumTablesMax];
- Byte m_Selectors[kNumSelectorsMax];
-
- bool m_NeedHuffmanCreate;
-
- UInt32 m_CRCs[1 << kNumPassesMax];
- UInt32 m_NumCrcs;
-
- int m_BlockIndex;
-
- void FinishStream(bool needLeave);
-
- void WriteBits2(UInt32 value, UInt32 numBits);
- void WriteByte2(Byte b);
- void WriteBit2(bool v);
- void WriteCRC2(UInt32 v);
-
- void EncodeBlock(Byte *block, UInt32 blockSize);
- UInt32 EncodeBlockWithHeaders(Byte *block, UInt32 blockSize);
- void EncodeBlock2(Byte *block, UInt32 blockSize, UInt32 numPasses);
-public:
- bool m_OptimizeNumTables;
- CEncoder *Encoder;
- #ifdef COMPRESS_BZIP2_MT
- NWindows::CThread Thread;
-
- NWindows::NSynchronization::CAutoResetEvent StreamWasFinishedEvent;
- NWindows::NSynchronization::CAutoResetEvent WaitingWasStartedEvent;
-
- // it's not member of this thread. We just need one event per thread
- NWindows::NSynchronization::CAutoResetEvent CanWriteEvent;
-
- UInt64 m_PackSize;
-
- Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
- #endif
-
- CThreadInfo(): m_Block(0), m_NeedHuffmanCreate(true) {}
- ~CThreadInfo() { Free(); }
- bool Create();
- void Free();
-
- HRESULT EncodeBlock3(UInt32 blockSize);
- DWORD ThreadFunc();
-};
-
-class CEncoder :
- public ICompressCoder,
- public ICompressSetCoderProperties,
- #ifdef COMPRESS_BZIP2_MT
- public ICompressSetCoderMt,
- #endif
- public CMyUnknownImp
-{
- UInt32 m_BlockSizeMult;
- bool m_OptimizeNumTables;
-
- UInt32 m_NumPassesPrev;
-
- UInt32 m_NumThreadsPrev;
-public:
- CInBuffer m_InStream;
- Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
- NStream::NMSBF::CEncoder<COutBuffer> m_OutStream;
- UInt32 NumPasses;
- CBZip2CombinedCRC CombinedCRC;
-
- #ifdef COMPRESS_BZIP2_MT
- CThreadInfo *ThreadsInfo;
- NWindows::NSynchronization::CCriticalSection CS;
- UInt32 NumThreads;
- bool MtMode;
- UInt32 NextBlockIndex;
-
- bool CloseThreads;
- bool StreamWasFinished;
- NWindows::NSynchronization::CManualResetEvent CanStartWaitingEvent;
-
- HRESULT Result;
- ICompressProgressInfo *Progress;
- #else
- CThreadInfo ThreadsInfo;
- #endif
-
- UInt32 ReadRleBlock(Byte *buffer);
- void WriteBytes(const Byte *data, UInt32 sizeInBits, Byte lastByte);
-
- void WriteBits(UInt32 value, UInt32 numBits);
- void WriteByte(Byte b);
- void WriteBit(bool v);
- void WriteCRC(UInt32 v);
-
- #ifdef COMPRESS_BZIP2_MT
- bool Create();
- void Free();
- #endif
-
-public:
- CEncoder();
- #ifdef COMPRESS_BZIP2_MT
- ~CEncoder();
- #endif
-
- HRESULT Flush() { return m_OutStream.Flush(); }
-
- void ReleaseStreams()
- {
- m_InStream.ReleaseStream();
- m_OutStream.ReleaseStream();
- }
-
- class CFlusher
- {
- CEncoder *_coder;
- public:
- bool NeedFlush;
- CFlusher(CEncoder *coder): _coder(coder), NeedFlush(true) {}
- ~CFlusher()
- {
- if (NeedFlush)
- _coder->Flush();
- _coder->ReleaseStreams();
- }
- };
-
- #ifdef COMPRESS_BZIP2_MT
- MY_UNKNOWN_IMP2(ICompressSetCoderMt, ICompressSetCoderProperties)
- #else
- MY_UNKNOWN_IMP1(ICompressGetInStreamProcessedSize)
- #endif
-
- HRESULT CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties);
-
- #ifdef COMPRESS_BZIP2_MT
- STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
- #endif
-};
-
-}}
-
-#endif
diff --git a/7zip/Compress/BZip2/DllExports.cpp b/7zip/Compress/BZip2/DllExports.cpp
deleted file mode 100755
index c528e98c..00000000
--- a/7zip/Compress/BZip2/DllExports.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-#ifdef _WIN32
-#include "Common/Alloc.h"
-#endif
-
-#include "BZip2Encoder.h"
-#include "BZip2Decoder.h"
-
-// {23170F69-40C1-278B-0402-020000000000}
-DEFINE_GUID(CLSID_CCompressBZip2Decoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-// {23170F69-40C1-278B-0402-020000000100}
-DEFINE_GUID(CLSID_CCompressBZip2Encoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD dwReason, LPVOID /*lpReserved*/)
-{
- #ifdef _WIN32
- if (dwReason == DLL_PROCESS_ATTACH)
- SetLargePageSize();
- #endif
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- int correctInterface = (*iid == IID_ICompressCoder);
- CMyComPtr<ICompressCoder> coder;
- if (*clsid == CLSID_CCompressBZip2Decoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NBZip2::CDecoder;
- }
- else if (*clsid == CLSID_CCompressBZip2Encoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NBZip2::CEncoder;
- }
- else
- return CLASS_E_CLASSNOTAVAILABLE;
- *outObject = coder.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[] = { 0x04, 0x02, 0x02 };
- if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(L"BZip2")) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCompressBZip2Decoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kEncoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCompressBZip2Encoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- return S_OK;
-}
diff --git a/7zip/Compress/BZip2/makefile b/7zip/Compress/BZip2/makefile
deleted file mode 100755
index f355e7d9..00000000
--- a/7zip/Compress/BZip2/makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-PROG = BZip2.dll
-DEF_FILE = ../Codec.def
-CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_BZIP2_MT
-LIBS = $(LIBS) oleaut32.lib
-
-BZIP2_OBJS = \
- $O\DllExports.obj \
- $O\BZip2CRC.obj \
-
-BZIP2_OPT_OBJS = \
- $O\BZip2Decoder.obj \
- $O\BZip2Encoder.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
-
-WIN_OBJS = \
- $O\Synchronization.obj
-
-7ZIP_COMMON_OBJS = \
- $O\InBuffer.obj \
- $O\OutBuffer.obj \
-
-OBJS = \
- $O\StdAfx.obj \
- $(BZIP2_OBJS) \
- $(BZIP2_OPT_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $O\BlockSort.obj \
- $O\HuffmanEncoder.obj \
- $O\resource.res
-
-!include "../../../Build.mak"
-
-$(BZIP2_OBJS): $(*B).cpp
- $(COMPL)
-$(BZIP2_OPT_OBJS): $(*B).cpp
- $(COMPL_O2)
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$O\BlockSort.obj: ../BWT/$(*B).cpp
- $(COMPL_O2)
-$O\HuffmanEncoder.obj: ../Huffman/$(*B).cpp
- $(COMPL_O2)
diff --git a/7zip/Compress/BZip2Original/DllExports.cpp b/7zip/Compress/BZip2Original/DllExports.cpp
deleted file mode 100755
index 1f28a07c..00000000
--- a/7zip/Compress/BZip2Original/DllExports.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-
-#include "BZip2Encoder.h"
-#include "BZip2Decoder.h"
-
-// {23170F69-40C1-278B-0402-020000000000}
-DEFINE_GUID(CLSID_CCompressBZip2Decoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-// {23170F69-40C1-278B-0402-020000000100}
-DEFINE_GUID(CLSID_CCompressBZip2Encoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
-{
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- int correctInterface = (*iid == IID_ICompressCoder);
- CMyComPtr<ICompressCoder> coder;
- if (*clsid == CLSID_CCompressBZip2Decoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NBZip2::CDecoder;
- }
- else if (*clsid == CLSID_CCompressBZip2Encoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NBZip2::CEncoder;
- }
- else
- return CLASS_E_CLASSNOTAVAILABLE;
- *outObject = coder.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[] = { 0x04, 0x02, 0x02 };
- if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(L"BZip2")) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCompressBZip2Decoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kEncoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCompressBZip2Encoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- return S_OK;
-}
diff --git a/7zip/Compress/Branch/ARM.cpp b/7zip/Compress/Branch/ARM.cpp
deleted file mode 100755
index 4bd5e183..00000000
--- a/7zip/Compress/Branch/ARM.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// ARM.cpp
-
-#include "StdAfx.h"
-#include "ARM.h"
-
-#include "BranchARM.c"
-
-UInt32 CBC_ARM_Encoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::ARM_Convert(data, size, _bufferPos, 1);
-}
-
-UInt32 CBC_ARM_Decoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::ARM_Convert(data, size, _bufferPos, 0);
-}
diff --git a/7zip/Compress/Branch/ARMThumb.cpp b/7zip/Compress/Branch/ARMThumb.cpp
deleted file mode 100755
index fbd25701..00000000
--- a/7zip/Compress/Branch/ARMThumb.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// ARMThumb.cpp
-
-#include "StdAfx.h"
-#include "ARMThumb.h"
-
-#include "BranchARMThumb.c"
-
-UInt32 CBC_ARMThumb_Encoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::ARMThumb_Convert(data, size, _bufferPos, 1);
-}
-
-UInt32 CBC_ARMThumb_Decoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::ARMThumb_Convert(data, size, _bufferPos, 0);
-}
diff --git a/7zip/Compress/Branch/IA64.cpp b/7zip/Compress/Branch/IA64.cpp
deleted file mode 100755
index 75dfdcba..00000000
--- a/7zip/Compress/Branch/IA64.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// IA64.cpp
-
-#include "StdAfx.h"
-#include "IA64.h"
-
-#include "BranchIA64.c"
-
-UInt32 CBC_IA64_Encoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::IA64_Convert(data, size, _bufferPos, 1);
-}
-
-UInt32 CBC_IA64_Decoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::IA64_Convert(data, size, _bufferPos, 0);
-}
diff --git a/7zip/Compress/Branch/PPC.cpp b/7zip/Compress/Branch/PPC.cpp
deleted file mode 100755
index 197a8e58..00000000
--- a/7zip/Compress/Branch/PPC.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// PPC.cpp
-
-#include "StdAfx.h"
-#include "PPC.h"
-
-#include "Windows/Defs.h"
-#include "BranchPPC.c"
-
-UInt32 CBC_PPC_B_Encoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::PPC_B_Convert(data, size, _bufferPos, 1);
-}
-
-UInt32 CBC_PPC_B_Decoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::PPC_B_Convert(data, size, _bufferPos, 0);
-}
diff --git a/7zip/Compress/Branch/SPARC.cpp b/7zip/Compress/Branch/SPARC.cpp
deleted file mode 100755
index d054eaaf..00000000
--- a/7zip/Compress/Branch/SPARC.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// SPARC.cpp
-
-#include "StdAfx.h"
-#include "SPARC.h"
-
-#include "Windows/Defs.h"
-#include "BranchSPARC.c"
-
-UInt32 CBC_SPARC_Encoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::SPARC_Convert(data, size, _bufferPos, 1);
-}
-
-UInt32 CBC_SPARC_Decoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::SPARC_Convert(data, size, _bufferPos, 0);
-}
diff --git a/7zip/Compress/Branch/x86.cpp b/7zip/Compress/Branch/x86.cpp
deleted file mode 100755
index 013e42b6..00000000
--- a/7zip/Compress/Branch/x86.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// x86.cpp
-
-#include "StdAfx.h"
-#include "x86.h"
-
-#include "Windows/Defs.h"
-
-#include "BranchX86.c"
-
-UInt32 CBCJ_x86_Encoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 1);
-}
-
-UInt32 CBCJ_x86_Decoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 0);
-}
diff --git a/7zip/Compress/Branch/x86.h b/7zip/Compress/Branch/x86.h
deleted file mode 100755
index 10d03982..00000000
--- a/7zip/Compress/Branch/x86.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// x86.h
-
-#ifndef __X86_H
-#define __X86_H
-
-#include "BranchCoder.h"
-#include "BranchX86.h"
-
-struct CBranch86
-{
- UInt32 _prevMask;
- UInt32 _prevPos;
- void x86Init() { x86_Convert_Init(_prevMask, _prevPos); }
-};
-
-MyClassB(BCJ_x86, 0x01, 3, CBranch86 ,
- virtual void SubInit() { x86Init(); })
-
-#endif
diff --git a/7zip/Compress/Deflate/Deflate.dsp b/7zip/Compress/Deflate/Deflate.dsp
deleted file mode 100755
index ef33fb8c..00000000
--- a/7zip/Compress/Deflate/Deflate.dsp
+++ /dev/null
@@ -1,295 +0,0 @@
-# Microsoft Developer Studio Project File - Name="Deflate" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=Deflate - 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 "Deflate.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 "Deflate.mak" CFG="Deflate - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Deflate - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "Deflate - 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)" == "Deflate - 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 "DEFLATE_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /D "_ST_MODE" /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\Codecs\Deflate.dll" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "Deflate - 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 "DEFLATE_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /D "_ST_MODE" /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\Codecs\Deflate.dll" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "Deflate - Win32 Release"
-# Name "Deflate - Win32 Debug"
-# Begin Group "Spec"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Codec.def
-# 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 "Huffman"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Huffman\HuffmanDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Huffman\HuffmanEncoder.cpp
-
-!IF "$(CFG)" == "Deflate - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Deflate - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\Huffman\HuffmanEncoder.h
-# End Source File
-# End Group
-# Begin Group "Interface"
-
-# PROP Default_Filter ""
-# End Group
-# Begin Group "7zip 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\LSBFDecoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFEncoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\LSBFEncoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OutBuffer.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\OutBuffer.h
-# End Source File
-# End Group
-# Begin Group "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\NewHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\NewHandler.h
-# End Source File
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# End Group
-# Begin Group "LZ"
-
-# PROP Default_Filter ""
-# Begin Group "BinTree"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree3Z.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTreeMain.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\LZ\IMatchFinder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZInWindow.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZInWindow.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZOutWindow.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZOutWindow.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\DeflateConst.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\DeflateDecoder.cpp
-
-!IF "$(CFG)" == "Deflate - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Deflate - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\DeflateDecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\DeflateEncoder.cpp
-
-!IF "$(CFG)" == "Deflate - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Deflate - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\DeflateEncoder.h
-# End Source File
-# End Target
-# End Project
diff --git a/7zip/Compress/Deflate/DeflateEncoder.cpp b/7zip/Compress/Deflate/DeflateEncoder.cpp
deleted file mode 100755
index 8a0f4746..00000000
--- a/7zip/Compress/Deflate/DeflateEncoder.cpp
+++ /dev/null
@@ -1,885 +0,0 @@
-// DeflateEncoder.cpp
-
-#include "StdAfx.h"
-
-#include "DeflateEncoder.h"
-
-#include "Windows/Defs.h"
-#include "Common/ComTry.h"
-#include "../../../Common/Alloc.h"
-#include "../LZ/BinTree/BinTree3Z.h"
-
-namespace NCompress {
-namespace NDeflate {
-namespace NEncoder {
-
-const int kNumDivPassesMax = 10; // [0, 16); ratio/speed/ram tradeoff; use big value for better compression ratio.
-const UInt32 kNumTables = (1 << kNumDivPassesMax);
-
-static UInt32 kFixedHuffmanCodeBlockSizeMax = (1 << 8); // [0, (1 << 32)); ratio/speed tradeoff; use big value for better compression ratio.
-static UInt32 kDivideCodeBlockSizeMin = (1 << 6); // [1, (1 << 32)); ratio/speed tradeoff; use small value for better compression ratio.
-static UInt32 kDivideBlockSizeMin = (1 << 6); // [1, (1 << 32)); ratio/speed tradeoff; use small value for better compression ratio.
-
-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 -
- kMatchMaxLen - kNumOpts;
-
-static const int kMaxCodeBitLength = 15;
-static const int kMaxLevelBitLength = 7;
-
-struct CMatchFinderException
-{
- HRESULT ErrorCode;
- CMatchFinderException(HRESULT errorCode): ErrorCode(errorCode) {}
-};
-
-static Byte kNoLiteralStatPrice = 13;
-static Byte kNoLenStatPrice = 13;
-static Byte kNoPosStatPrice = 6;
-
-static Byte g_LenSlots[kNumLenSymbolsMax];
-static Byte g_FastPos[1 << 9];
-
-class CFastPosInit
-{
-public:
- CFastPosInit()
- {
- int i;
- for(i = 0; i < kNumLenSlots; i++)
- {
- int c = kLenStart32[i];
- int j = 1 << kLenDirectBits32[i];
- for(int k = 0; k < j; k++, c++)
- g_LenSlots[c] = (Byte)i;
- }
-
- const int kFastSlots = 18;
- int c = 0;
- for (Byte slotFast = 0; slotFast < kFastSlots; slotFast++)
- {
- UInt32 k = (1 << kDistDirectBits[slotFast]);
- for (UInt32 j = 0; j < k; j++, c++)
- g_FastPos[c] = slotFast;
- }
- }
-};
-
-static CFastPosInit g_FastPosInit;
-
-
-inline UInt32 GetPosSlot(UInt32 pos)
-{
- if (pos < 0x200)
- return g_FastPos[pos];
- return g_FastPos[pos >> 8] + 16;
-}
-
-CCoder::CCoder(bool deflate64Mode):
- m_Deflate64Mode(deflate64Mode),
- m_NumPasses(1),
- m_NumDivPasses(1),
- m_NumFastBytes(32),
- m_OnePosMatchesMemory(0),
- m_DistanceMemory(0),
- m_Created(false),
- m_Values(0),
- m_Tables(0),
- m_MatchFinderCycles(0),
- m_SetMfPasses(0)
-{
- m_MatchMaxLen = deflate64Mode ? kMatchMaxLen64 : kMatchMaxLen32;
- m_NumLenCombinations = deflate64Mode ? kNumLenSymbols64 : kNumLenSymbols32;
- m_LenStart = deflate64Mode ? kLenStart64 : kLenStart32;
- m_LenDirectBits = deflate64Mode ? kLenDirectBits64 : kLenDirectBits32;
-}
-
-HRESULT CCoder::Create()
-{
- COM_TRY_BEGIN
- if (!m_MatchFinder)
- {
- NBT3Z::CMatchFinder *matchFinderSpec = new NBT3Z::CMatchFinder;
- m_SetMfPasses = matchFinderSpec;
- m_MatchFinder = matchFinderSpec;
- if (m_MatchFinder == 0)
- return E_OUTOFMEMORY;
- }
- if (m_Values == 0)
- {
- m_Values = (CCodeValue *)MyAlloc((kMaxUncompressedBlockSize) * sizeof(CCodeValue));
- if (m_Values == 0)
- return E_OUTOFMEMORY;
- }
- if (m_Tables == 0)
- {
- m_Tables = (CTables *)MyAlloc((kNumTables) * sizeof(CTables));
- if (m_Tables == 0)
- return E_OUTOFMEMORY;
- }
-
- if (m_IsMultiPass)
- {
- if (m_OnePosMatchesMemory == 0)
- {
- m_OnePosMatchesMemory = (UInt16 *)::MidAlloc(kMatchArraySize * sizeof(UInt16));
- if (m_OnePosMatchesMemory == 0)
- return E_OUTOFMEMORY;
- }
- }
- else
- {
- if (m_DistanceMemory == 0)
- {
- m_DistanceMemory = (UInt16 *)MyAlloc((kMatchMaxLen + 2) * 2 * sizeof(UInt16));
- if (m_DistanceMemory == 0)
- return E_OUTOFMEMORY;
- m_MatchDistances = m_DistanceMemory;
- }
- }
-
- if (!m_Created)
- {
- RINOK(m_MatchFinder->Create(m_Deflate64Mode ? kHistorySize64 : kHistorySize32,
- kNumOpts + kMaxUncompressedBlockSize, m_NumFastBytes, m_MatchMaxLen - m_NumFastBytes));
- if (!m_OutStream.Create(1 << 20))
- return E_OUTOFMEMORY;
- if (!MainCoder.Create(kFixedMainTableSize, m_LenDirectBits, kSymbolMatch, kMaxCodeBitLength))
- return E_OUTOFMEMORY;
- if (!DistCoder.Create(kDistTableSize64, kDistDirectBits, 0, kMaxCodeBitLength))
- return E_OUTOFMEMORY;
- if (!LevelCoder.Create(kLevelTableSize, kLevelDirectBits, kTableDirectLevels, kMaxLevelBitLength))
- return E_OUTOFMEMORY;
- }
- if (m_MatchFinderCycles != 0 && m_SetMfPasses != 0)
- m_SetMfPasses->SetNumPasses(m_MatchFinderCycles);
- m_Created = true;
- return S_OK;
- COM_TRY_END
-}
-
-// ICompressSetEncoderProperties2
-HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties)
-{
- for(UInt32 i = 0; i < numProperties; i++)
- {
- const PROPVARIANT &prop = properties[i];
- switch(propIDs[i])
- {
- case NCoderPropID::kNumPasses:
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- m_NumDivPasses = prop.ulVal;
- if (m_NumDivPasses == 0)
- m_NumDivPasses = 1;
- if (m_NumDivPasses == 1)
- m_NumPasses = 1;
- else if (m_NumDivPasses <= kNumDivPassesMax)
- m_NumPasses = 2;
- else
- {
- m_NumPasses = 2 + (m_NumDivPasses - kNumDivPassesMax);
- m_NumDivPasses = kNumDivPassesMax;
- }
- break;
- case NCoderPropID::kNumFastBytes:
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- m_NumFastBytes = prop.ulVal;
- if(m_NumFastBytes < kMatchMinLen || m_NumFastBytes > m_MatchMaxLen)
- return E_INVALIDARG;
- break;
- case NCoderPropID::kMatchFinderCycles:
- {
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- m_MatchFinderCycles = prop.ulVal;
- break;
- }
- default:
- return E_INVALIDARG;
- }
- }
- return S_OK;
-}
-
-void CCoder::Free()
-{
- ::MidFree(m_OnePosMatchesMemory);
- m_OnePosMatchesMemory = 0;
- ::MyFree(m_DistanceMemory);
- m_DistanceMemory = 0;
- ::MyFree(m_Values);
- m_Values = 0;
- ::MyFree(m_Tables);
- m_Tables = 0;
-}
-
-CCoder::~CCoder()
-{
- Free();
-}
-
-void CCoder::GetMatches()
-{
- if (m_IsMultiPass)
- {
- m_MatchDistances = m_OnePosMatchesMemory + m_Pos;
- if (m_SecondPass)
- {
- m_Pos += *m_MatchDistances + 1;
- return;
- }
- }
-
- UInt32 distanceTmp[kMatchMaxLen * 2 + 3];
-
- HRESULT result = m_MatchFinder->GetMatches(distanceTmp);
- if (result != S_OK)
- throw CMatchFinderException(result);
- UInt32 numPairs = distanceTmp[0];
-
- *m_MatchDistances = (UInt16)numPairs;
-
- if (numPairs > 0)
- {
- UInt32 i = 1;
- for(i = 1; i < numPairs; i += 2)
- {
- m_MatchDistances[i] = (UInt16)distanceTmp[i];
- m_MatchDistances[i + 1] = (UInt16)distanceTmp[i + 1];
- }
- UInt32 len = distanceTmp[1 + numPairs - 2];
- if (len == m_NumFastBytes && m_NumFastBytes != m_MatchMaxLen)
- m_MatchDistances[i - 2] = (UInt16)(len + m_MatchFinder->GetMatchLen(len - 1,
- distanceTmp[1 + numPairs - 1], m_MatchMaxLen - len));
- }
- if (m_IsMultiPass)
- m_Pos += numPairs + 1;
- if (!m_SecondPass)
- m_AdditionalOffset++;
-}
-
-void CCoder::MovePos(UInt32 num)
-{
- if (!m_SecondPass && num > 0)
- {
- HRESULT result = m_MatchFinder->Skip(num);
- if (result != S_OK)
- throw CMatchFinderException(result);
- m_AdditionalOffset += num;
- }
-}
-
-static const UInt32 kIfinityPrice = 0xFFFFFFF;
-
-UInt32 CCoder::Backward(UInt32 &backRes, UInt32 cur)
-{
- m_OptimumEndIndex = cur;
- UInt32 posMem = m_Optimum[cur].PosPrev;
- UInt16 backMem = m_Optimum[cur].BackPrev;
- do
- {
- UInt32 posPrev = posMem;
- UInt16 backCur = backMem;
- backMem = m_Optimum[posPrev].BackPrev;
- posMem = m_Optimum[posPrev].PosPrev;
- m_Optimum[posPrev].BackPrev = backCur;
- m_Optimum[posPrev].PosPrev = (UInt16)cur;
- cur = posPrev;
- }
- while(cur > 0);
- backRes = m_Optimum[0].BackPrev;
- m_OptimumCurrentIndex = m_Optimum[0].PosPrev;
- return m_OptimumCurrentIndex;
-}
-
-UInt32 CCoder::GetOptimal(UInt32 &backRes)
-{
- if(m_OptimumEndIndex != m_OptimumCurrentIndex)
- {
- UInt32 len = m_Optimum[m_OptimumCurrentIndex].PosPrev - m_OptimumCurrentIndex;
- backRes = m_Optimum[m_OptimumCurrentIndex].BackPrev;
- m_OptimumCurrentIndex = m_Optimum[m_OptimumCurrentIndex].PosPrev;
- return len;
- }
- m_OptimumCurrentIndex = m_OptimumEndIndex = 0;
-
- GetMatches();
-
- UInt32 numDistancePairs = m_MatchDistances[0];
- if(numDistancePairs == 0)
- return 1;
-
- const UInt16 *matchDistances = m_MatchDistances + 1;
- UInt32 lenMain = matchDistances[numDistancePairs - 2];
-
- if(lenMain > m_NumFastBytes)
- {
- backRes = matchDistances[numDistancePairs - 1];
- MovePos(lenMain - 1);
- return lenMain;
- }
- m_Optimum[1].Price = m_LiteralPrices[m_MatchFinder->GetIndexByte(0 - m_AdditionalOffset)];
- m_Optimum[1].PosPrev = 0;
-
- m_Optimum[2].Price = kIfinityPrice;
- m_Optimum[2].PosPrev = 1;
-
-
- UInt32 offs = 0;
- for(UInt32 i = kMatchMinLen; i <= lenMain; i++)
- {
- UInt32 distance = matchDistances[offs + 1];
- m_Optimum[i].PosPrev = 0;
- m_Optimum[i].BackPrev = (UInt16)distance;
- m_Optimum[i].Price = m_LenPrices[i - kMatchMinLen] + m_PosPrices[GetPosSlot(distance)];
- if (i == matchDistances[offs])
- offs += 2;
- }
-
- UInt32 cur = 0;
- UInt32 lenEnd = lenMain;
- for (;;)
- {
- ++cur;
- if(cur == lenEnd || cur == kNumOptsBase || m_Pos >= kMatchArrayLimit)
- return Backward(backRes, cur);
- GetMatches();
- matchDistances = m_MatchDistances + 1;
-
- UInt32 numDistancePairs = m_MatchDistances[0];
- UInt32 newLen = 0;
- if(numDistancePairs != 0)
- {
- newLen = matchDistances[numDistancePairs - 2];
- if(newLen > m_NumFastBytes)
- {
- UInt32 len = Backward(backRes, cur);
- m_Optimum[cur].BackPrev = matchDistances[numDistancePairs - 1];
- m_OptimumEndIndex = cur + newLen;
- m_Optimum[cur].PosPrev = (UInt16)m_OptimumEndIndex;
- MovePos(newLen - 1);
- return len;
- }
- }
- UInt32 curPrice = m_Optimum[cur].Price;
- UInt32 curAnd1Price = curPrice + m_LiteralPrices[m_MatchFinder->GetIndexByte(cur - m_AdditionalOffset)];
- COptimal &optimum = m_Optimum[cur + 1];
- if (curAnd1Price < optimum.Price)
- {
- optimum.Price = curAnd1Price;
- optimum.PosPrev = (UInt16)cur;
- }
- if(numDistancePairs == 0)
- continue;
- while(lenEnd < cur + newLen)
- m_Optimum[++lenEnd].Price = kIfinityPrice;
- offs = 0;
- UInt32 distance = matchDistances[offs + 1];
- curPrice += m_PosPrices[GetPosSlot(distance)];
- for(UInt32 lenTest = kMatchMinLen; ; lenTest++)
- {
- UInt32 curAndLenPrice = curPrice + m_LenPrices[lenTest - kMatchMinLen];
- COptimal &optimum = m_Optimum[cur + lenTest];
- if (curAndLenPrice < optimum.Price)
- {
- optimum.Price = curAndLenPrice;
- optimum.PosPrev = (UInt16)cur;
- optimum.BackPrev = (UInt16)distance;
- }
- if (lenTest == matchDistances[offs])
- {
- offs += 2;
- if (offs == numDistancePairs)
- break;
- curPrice -= m_PosPrices[GetPosSlot(distance)];
- distance = matchDistances[offs + 1];
- curPrice += m_PosPrices[GetPosSlot(distance)];
- }
- }
- }
-}
-
-void CTables::InitStructures()
-{
- UInt32 i;
- for(i = 0; i < 256; i++)
- litLenLevels[i] = 8;
- litLenLevels[i++] = 13;
- for(;i < kFixedMainTableSize; i++)
- litLenLevels[i] = 5;
- for(i = 0; i < kFixedDistTableSize; i++)
- distLevels[i] = 5;
-}
-
-void CCoder::CodeLevelTable(NStream::NLSBF::CEncoder *outStream, const Byte *levels, int numLevels)
-{
- int prevLen = 0xFF;
- int nextLen = levels[0];
- int count = 0;
- int maxCount = 7;
- int minCount = 4;
- if (nextLen == 0)
- {
- maxCount = 138;
- minCount = 3;
- }
- for (int n = 0; n < numLevels; n++)
- {
- int curLen = nextLen;
- nextLen = (n < numLevels - 1) ? levels[n + 1] : 0xFF;
- count++;
- if (count < maxCount && curLen == nextLen)
- continue;
-
- if (count < minCount)
- for(int i = 0; i < count; i++)
- if (outStream != 0)
- LevelCoder.CodeOneValue(outStream, curLen);
- else
- LevelCoder.AddSymbol(curLen);
- else if (curLen != 0)
- {
- if (curLen != prevLen)
- {
- if (outStream != 0)
- LevelCoder.CodeOneValue(outStream, curLen);
- else
- LevelCoder.AddSymbol(curLen);
- count--;
- }
- if (outStream != 0)
- {
- LevelCoder.CodeOneValue(outStream, kTableLevelRepNumber);
- outStream->WriteBits(count - 3, 2);
- }
- else
- LevelCoder.AddSymbol(kTableLevelRepNumber);
- }
- else if (count <= 10)
- if (outStream != 0)
- {
- LevelCoder.CodeOneValue(outStream, kTableLevel0Number);
- outStream->WriteBits(count - 3, 3);
- }
- else
- LevelCoder.AddSymbol(kTableLevel0Number);
- else
- if (outStream != 0)
- {
- LevelCoder.CodeOneValue(outStream, kTableLevel0Number2);
- outStream->WriteBits(count - 11, 7);
- }
- else
- LevelCoder.AddSymbol(kTableLevel0Number2);
-
- count = 0;
- prevLen = curLen;
-
- if (nextLen == 0)
- {
- maxCount = 138;
- minCount = 3;
- }
- else if (curLen == nextLen)
- {
- maxCount = 6;
- minCount = 3;
- }
- else
- {
- maxCount = 7;
- minCount = 4;
- }
- }
-}
-
-void CCoder::MakeTables()
-{
- MainCoder.BuildTree(m_NewLevels.litLenLevels);
- DistCoder.BuildTree(m_NewLevels.distLevels);
- MainCoder.ReverseBits();
- DistCoder.ReverseBits();
-}
-
-UInt32 CCoder::GetLzBlockPrice()
-{
- LevelCoder.StartNewBlock();
-
- m_NumLitLenLevels = kMainTableSize;
- while(m_NumLitLenLevels > kNumLitLenCodesMin && m_NewLevels.litLenLevels[m_NumLitLenLevels - 1] == 0)
- m_NumLitLenLevels--;
-
- m_NumDistLevels = kDistTableSize64;
- while(m_NumDistLevels > kNumDistCodesMin && m_NewLevels.distLevels[m_NumDistLevels - 1] == 0)
- m_NumDistLevels--;
-
- CodeLevelTable(0, m_NewLevels.litLenLevels, m_NumLitLenLevels);
- CodeLevelTable(0, m_NewLevels.distLevels, m_NumDistLevels);
-
- Byte levelLevels[kLevelTableSize];
- LevelCoder.BuildTree(levelLevels);
- LevelCoder.ReverseBits();
-
- m_NumLevelCodes = kNumLevelCodesMin;
- for (UInt32 i = 0; i < kLevelTableSize; i++)
- {
- Byte level = levelLevels[kCodeLengthAlphabetOrder[i]];
- if (level > 0 && i >= m_NumLevelCodes)
- m_NumLevelCodes = i + 1;
- m_LevelLevels[i] = level;
- }
-
- return MainCoder.GetBlockBitLength() + DistCoder.GetBlockBitLength() + LevelCoder.GetBlockBitLength() +
- kNumLenCodesFieldSize + kNumDistCodesFieldSize + kNumLevelCodesFieldSize +
- m_NumLevelCodes * kLevelFieldSize + kFinalBlockFieldSize + kBlockTypeFieldSize;
-}
-
-void CCoder::TryBlock(bool staticMode)
-{
- MainCoder.StartNewBlock();
- DistCoder.StartNewBlock();
- m_ValueIndex = 0;
- UInt32 blockSize = BlockSizeRes;
- BlockSizeRes = 0;
- for (;;)
- {
- if (m_OptimumCurrentIndex == m_OptimumEndIndex)
- {
- if (m_Pos >= kMatchArrayLimit || BlockSizeRes >= blockSize || !m_SecondPass &&
- ((m_MatchFinder->GetNumAvailableBytes() == 0) || m_ValueIndex >= m_ValueBlockSize))
- break;
- }
- UInt32 pos;
- UInt32 len = GetOptimal(pos);
- CCodeValue &codeValue = m_Values[m_ValueIndex++];
- if (len >= kMatchMinLen)
- {
- UInt32 newLen = len - kMatchMinLen;
- codeValue.Len = (UInt16)newLen;
- MainCoder.AddSymbol(kSymbolMatch + g_LenSlots[newLen]);
- codeValue.Pos = (UInt16)pos;
- DistCoder.AddSymbol(GetPosSlot(pos));
- }
- else
- {
- Byte b = m_MatchFinder->GetIndexByte(0 - m_AdditionalOffset);
- MainCoder.AddSymbol(b);
- codeValue.SetAsLiteral();
- codeValue.Pos = b;
- }
- m_AdditionalOffset -= len;
- BlockSizeRes += len;
- }
- MainCoder.AddSymbol(kSymbolEndOfBlock);
- if (!staticMode)
- {
- MakeTables();
- SetPrices(m_NewLevels);
- }
- m_AdditionalOffset += BlockSizeRes;
- m_SecondPass = true;
-}
-
-void CCoder::SetPrices(const CLevels &levels)
-{
- UInt32 i;
- for(i = 0; i < 256; i++)
- {
- Byte price = levels.litLenLevels[i];
- m_LiteralPrices[i] = ((price != 0) ? price : kNoLiteralStatPrice);
- }
-
- for(i = 0; i < m_NumLenCombinations; i++)
- {
- UInt32 slot = g_LenSlots[i];
- Byte price = levels.litLenLevels[kSymbolMatch + slot];
- m_LenPrices[i] = (Byte)(((price != 0) ? price : kNoLenStatPrice) + m_LenDirectBits[slot]);
- }
-
- for(i = 0; i < kDistTableSize64; i++)
- {
- Byte price = levels.distLevels[i];
- m_PosPrices[i] = (Byte)(((price != 0) ? price: kNoPosStatPrice) + kDistDirectBits[i]);
- }
-}
-
-void CCoder::WriteBlock()
-{
- for (UInt32 i = 0; i < m_ValueIndex; i++)
- {
- const CCodeValue &codeValue = m_Values[i];
- if (codeValue.IsLiteral())
- MainCoder.CodeOneValue(&m_OutStream, codeValue.Pos);
- else
- {
- UInt32 len = codeValue.Len;
- UInt32 lenSlot = g_LenSlots[len];
- MainCoder.CodeOneValue(&m_OutStream, kSymbolMatch + lenSlot);
- m_OutStream.WriteBits(len - m_LenStart[lenSlot], m_LenDirectBits[lenSlot]);
- UInt32 dist = codeValue.Pos;
- UInt32 posSlot = GetPosSlot(dist);
- DistCoder.CodeOneValue(&m_OutStream, posSlot);
- m_OutStream.WriteBits(dist - kDistStart[posSlot], kDistDirectBits[posSlot]);
- }
- }
- MainCoder.CodeOneValue(&m_OutStream, kSymbolEndOfBlock);
-}
-
-void CCoder::WriteDynBlock(bool finalBlock)
-{
- m_OutStream.WriteBits((finalBlock ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
- m_OutStream.WriteBits(NBlockType::kDynamicHuffman, kBlockTypeFieldSize);
- m_OutStream.WriteBits(m_NumLitLenLevels - kNumLitLenCodesMin, kNumLenCodesFieldSize);
- m_OutStream.WriteBits(m_NumDistLevels - kNumDistCodesMin, kNumDistCodesFieldSize);
- m_OutStream.WriteBits(m_NumLevelCodes - kNumLevelCodesMin, kNumLevelCodesFieldSize);
-
- for (UInt32 i = 0; i < m_NumLevelCodes; i++)
- m_OutStream.WriteBits(m_LevelLevels[i], kLevelFieldSize);
-
- CodeLevelTable(&m_OutStream, m_NewLevels.litLenLevels, m_NumLitLenLevels);
- CodeLevelTable(&m_OutStream, m_NewLevels.distLevels, m_NumDistLevels);
-
- WriteBlock();
-}
-
-void CCoder::WriteFixedBlock(bool finalBlock)
-{
- int i;
- for (i = 0; i < kFixedMainTableSize; i++)
- MainCoder.SetFreq(i, (UInt32)1 << (kNumHuffmanBits - m_NewLevels.litLenLevels[i]));
- for (i = 0; i < kFixedDistTableSize; i++)
- DistCoder.SetFreq(i, (UInt32)1 << (kNumHuffmanBits - m_NewLevels.distLevels[i]));
- MakeTables();
-
- m_OutStream.WriteBits((finalBlock ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
- m_OutStream.WriteBits(NBlockType::kFixedHuffman, kBlockTypeFieldSize);
- WriteBlock();
-}
-
-static UInt32 GetStorePrice(UInt32 blockSize, int bitPosition)
-{
- UInt32 price = 0;
- do
- {
- UInt32 nextBitPosition = (bitPosition + kFinalBlockFieldSize + kBlockTypeFieldSize) & 7;
- int numBitsForAlign = nextBitPosition > 0 ? (8 - nextBitPosition): 0;
- UInt32 curBlockSize = (blockSize < (1 << 16)) ? blockSize : (1 << 16) - 1;
- price += kFinalBlockFieldSize + kBlockTypeFieldSize + numBitsForAlign + (2 + 2) * 8 + curBlockSize * 8;
- bitPosition = 0;
- blockSize -= curBlockSize;
- }
- while(blockSize != 0);
- return price;
-}
-
-void CCoder::WriteStoreBlock(UInt32 blockSize, UInt32 additionalOffset, bool finalBlock)
-{
- do
- {
- UInt32 curBlockSize = (blockSize < (1 << 16)) ? blockSize : (1 << 16) - 1;
- blockSize -= curBlockSize;
- m_OutStream.WriteBits((finalBlock && (blockSize == 0) ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
- m_OutStream.WriteBits(NBlockType::kStored, kBlockTypeFieldSize);
- m_OutStream.FlushByte();
- m_OutStream.WriteBits((UInt16)curBlockSize, kStoredBlockLengthFieldSize);
- m_OutStream.WriteBits((UInt16)~curBlockSize, kStoredBlockLengthFieldSize);
- const Byte *data = m_MatchFinder->GetPointerToCurrentPos() - additionalOffset;
- for(UInt32 i = 0; i < curBlockSize; i++)
- m_OutStream.WriteByte(data[i]);
- additionalOffset -= curBlockSize;
- }
- while(blockSize != 0);
-}
-
-UInt32 CCoder::TryDynBlock(int tableIndex, UInt32 numPasses)
-{
- CTables &t = m_Tables[tableIndex];
- BlockSizeRes = t.BlockSizeRes;
- m_Pos = t.m_Pos;
- SetPrices(t);
-
- for (UInt32 p = 0; p < numPasses; p++)
- {
- UInt32 posTemp = m_Pos;
- TryBlock(false);
- if (p != numPasses - 1)
- m_Pos = posTemp;
- }
- const UInt32 lzPrice = GetLzBlockPrice();
- (CLevels &)t = m_NewLevels;
- return lzPrice;
-}
-
-UInt32 CCoder::TryFixedBlock(int tableIndex)
-{
- CTables &t = m_Tables[tableIndex];
- BlockSizeRes = t.BlockSizeRes;
- m_Pos = t.m_Pos;
- m_NewLevels.SetFixedLevels();
- SetPrices(m_NewLevels);
-
- TryBlock(true);
- return kFinalBlockFieldSize + kBlockTypeFieldSize +
- MainCoder.GetPrice(m_NewLevels.litLenLevels) +
- DistCoder.GetPrice(m_NewLevels.distLevels);
-}
-
-UInt32 CCoder::GetBlockPrice(int tableIndex, int numDivPasses)
-{
- CTables &t = m_Tables[tableIndex];
- t.StaticMode = false;
- UInt32 price = TryDynBlock(tableIndex, m_NumPasses);
- t.BlockSizeRes = BlockSizeRes;
- UInt32 numValues = m_ValueIndex;
- UInt32 posTemp = m_Pos;
- UInt32 additionalOffsetEnd = m_AdditionalOffset;
-
- if (m_CheckStatic && m_ValueIndex <= kFixedHuffmanCodeBlockSizeMax)
- {
- const UInt32 fixedPrice = TryFixedBlock(tableIndex);
- t.StaticMode = (fixedPrice < price);
- if (t.StaticMode)
- price = fixedPrice;
- }
-
- const UInt32 storePrice = GetStorePrice(BlockSizeRes, 0); // bitPosition
- t.StoreMode = (storePrice <= price);
- if (t.StoreMode)
- price = storePrice;
-
- t.UseSubBlocks = false;
-
- if (numDivPasses > 1 && numValues >= kDivideCodeBlockSizeMin)
- {
- CTables &t0 = m_Tables[(tableIndex << 1)];
- (CLevels &)t0 = t;
- t0.BlockSizeRes = t.BlockSizeRes >> 1;
- t0.m_Pos = t.m_Pos;
- UInt32 subPrice = GetBlockPrice((tableIndex << 1), numDivPasses - 1);
-
- UInt32 blockSize2 = t.BlockSizeRes - t0.BlockSizeRes;
- if (t0.BlockSizeRes >= kDivideBlockSizeMin && blockSize2 >= kDivideBlockSizeMin)
- {
- CTables &t1 = m_Tables[(tableIndex << 1) + 1];
- (CLevels &)t1 = t;
- t1.BlockSizeRes = blockSize2;
- t1.m_Pos = m_Pos;
- m_AdditionalOffset -= t0.BlockSizeRes;
- subPrice += GetBlockPrice((tableIndex << 1) + 1, numDivPasses - 1);
- t.UseSubBlocks = (subPrice < price);
- if (t.UseSubBlocks)
- price = subPrice;
- }
- }
- m_AdditionalOffset = additionalOffsetEnd;
- m_Pos = posTemp;
- return price;
-}
-
-void CCoder::CodeBlock(int tableIndex, bool finalBlock)
-{
- CTables &t = m_Tables[tableIndex];
- if (t.UseSubBlocks)
- {
- CodeBlock((tableIndex << 1), false);
- CodeBlock((tableIndex << 1) + 1, finalBlock);
- }
- else
- {
- if (t.StoreMode)
- WriteStoreBlock(t.BlockSizeRes, m_AdditionalOffset, finalBlock);
- else
- if (t.StaticMode)
- {
- TryFixedBlock(tableIndex);
- WriteFixedBlock(finalBlock);
- }
- else
- {
- if (m_NumDivPasses > 1 || m_CheckStatic)
- TryDynBlock(tableIndex, 1);
- WriteDynBlock(finalBlock);
- }
- m_AdditionalOffset -= t.BlockSizeRes;
- }
-}
-
-HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 * /* inSize */ , const UInt64 * /* outSize */ ,
- ICompressProgressInfo *progress)
-{
- m_CheckStatic = (m_NumPasses != 1 || m_NumDivPasses != 1);
- m_IsMultiPass = (m_CheckStatic || (m_NumPasses != 1 || m_NumDivPasses != 1));
-
- RINOK(Create());
-
- m_ValueBlockSize = (1 << 13) + (1 << 12) * m_NumDivPasses;
-
- UInt64 nowPos = 0;
-
- RINOK(m_MatchFinder->SetStream(inStream));
- RINOK(m_MatchFinder->Init());
- m_OutStream.SetStream(outStream);
- m_OutStream.Init();
-
- CCoderReleaser coderReleaser(this);
-
- m_OptimumEndIndex = m_OptimumCurrentIndex = 0;
-
- CTables &t = m_Tables[1];
- t.m_Pos = 0;
- t.InitStructures();
-
- m_AdditionalOffset = 0;
- do
- {
- t.BlockSizeRes = kBlockUncompressedSizeThreshold;
- m_SecondPass = false;
- GetBlockPrice(1, m_NumDivPasses);
- CodeBlock(1, m_MatchFinder->GetNumAvailableBytes() == 0);
- nowPos += m_Tables[1].BlockSizeRes;
- if (progress != NULL)
- {
- UInt64 packSize = m_OutStream.GetProcessedSize();
- RINOK(progress->SetRatioInfo(&nowPos, &packSize));
- }
- }
- while(m_MatchFinder->GetNumAvailableBytes() != 0);
- return m_OutStream.Flush();
-}
-
-HRESULT CCoder::BaseCode(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
- catch(CMatchFinderException &e) { return e.ErrorCode; }
- catch(const COutBufferException &e) { return e.ErrorCode; }
- catch(...) { return E_FAIL; }
-}
-
-STDMETHODIMP CCOMCoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
- { return BaseCode(inStream, outStream, inSize, outSize, progress); }
-
-STDMETHODIMP CCOMCoder::SetCoderProperties(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties)
- { return BaseSetEncoderProperties2(propIDs, properties, numProperties); }
-
-STDMETHODIMP CCOMCoder64::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
- { return BaseCode(inStream, outStream, inSize, outSize, progress); }
-
-STDMETHODIMP CCOMCoder64::SetCoderProperties(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties)
- { return BaseSetEncoderProperties2(propIDs, properties, numProperties); }
-
-}}}
-
diff --git a/7zip/Compress/Deflate/DeflateEncoder.h b/7zip/Compress/Deflate/DeflateEncoder.h
deleted file mode 100755
index eb2ffbf1..00000000
--- a/7zip/Compress/Deflate/DeflateEncoder.h
+++ /dev/null
@@ -1,210 +0,0 @@
-// DeflateEncoder.h
-
-#ifndef __DEFLATE_ENCODER_H
-#define __DEFLATE_ENCODER_H
-
-#include "Common/MyCom.h"
-
-#include "../../ICoder.h"
-#include "../../Common/LSBFEncoder.h"
-#include "../LZ/IMatchFinder.h"
-#include "../Huffman/HuffmanEncoder.h"
-
-#include "DeflateConst.h"
-
-namespace NCompress {
-namespace NDeflate {
-namespace NEncoder {
-
-struct CCodeValue
-{
- UInt16 Len;
- UInt16 Pos;
- void SetAsLiteral() { Len = (1 << 15); }
- bool IsLiteral() const { return ((Len & (1 << 15)) != 0); }
-};
-
-struct COptimal
-{
- UInt32 Price;
- UInt16 PosPrev;
- UInt16 BackPrev;
-};
-
-const UInt32 kNumOptsBase = 1 << 12;
-const UInt32 kNumOpts = kNumOptsBase + kMatchMaxLen;
-
-class CCoder;
-
-struct CTables: public CLevels
-{
- bool UseSubBlocks;
- bool StoreMode;
- bool StaticMode;
- UInt32 BlockSizeRes;
- UInt32 m_Pos;
- void InitStructures();
-};
-
-class CCoder
-{
- CMyComPtr<IMatchFinder> m_MatchFinder;
- NStream::NLSBF::CEncoder m_OutStream;
-
-public:
- CCodeValue *m_Values;
-
- UInt16 *m_MatchDistances;
- UInt32 m_NumFastBytes;
-
- UInt16 *m_OnePosMatchesMemory;
- UInt16 *m_DistanceMemory;
-
- UInt32 m_Pos;
-
- int m_NumPasses;
- int m_NumDivPasses;
- bool m_CheckStatic;
- bool m_IsMultiPass;
- UInt32 m_ValueBlockSize;
-
- UInt32 m_NumLenCombinations;
- UInt32 m_MatchMaxLen;
- const Byte *m_LenStart;
- const Byte *m_LenDirectBits;
-
- bool m_Created;
- bool m_Deflate64Mode;
-
- NCompression::NHuffman::CEncoder MainCoder;
- NCompression::NHuffman::CEncoder DistCoder;
- NCompression::NHuffman::CEncoder LevelCoder;
-
- Byte m_LevelLevels[kLevelTableSize];
- int m_NumLitLenLevels;
- int m_NumDistLevels;
- UInt32 m_NumLevelCodes;
- UInt32 m_ValueIndex;
-
- bool m_SecondPass;
- UInt32 m_AdditionalOffset;
-
- UInt32 m_OptimumEndIndex;
- UInt32 m_OptimumCurrentIndex;
-
- Byte m_LiteralPrices[256];
- Byte m_LenPrices[kNumLenSymbolsMax];
- Byte m_PosPrices[kDistTableSize64];
-
- CLevels m_NewLevels;
- UInt32 BlockSizeRes;
-
- CTables *m_Tables;
- COptimal m_Optimum[kNumOpts];
-
- UInt32 m_MatchFinderCycles;
- IMatchFinderSetNumPasses *m_SetMfPasses;
-
- void GetMatches();
- void MovePos(UInt32 num);
- UInt32 Backward(UInt32 &backRes, UInt32 cur);
- UInt32 GetOptimal(UInt32 &backRes);
-
- void CodeLevelTable(NStream::NLSBF::CEncoder *outStream, const Byte *levels, int numLevels);
-
- void MakeTables();
- UInt32 GetLzBlockPrice();
- void TryBlock(bool staticMode);
- UInt32 TryDynBlock(int tableIndex, UInt32 numPasses);
-
- UInt32 TryFixedBlock(int tableIndex);
-
- void SetPrices(const CLevels &levels);
- void WriteBlock();
- void WriteDynBlock(bool finalBlock);
- void WriteFixedBlock(bool finalBlock);
-
-
-
- HRESULT Create();
- void Free();
-
- void WriteStoreBlock(UInt32 blockSize, UInt32 additionalOffset, bool finalBlock);
- void WriteTables(bool writeMode, bool finalBlock);
-
- void WriteBlockData(bool writeMode, bool finalBlock);
-
- void ReleaseStreams()
- {
- // m_MatchFinder.ReleaseStream();
- m_OutStream.ReleaseStream();
- }
- class CCoderReleaser
- {
- CCoder *m_Coder;
- public:
- CCoderReleaser(CCoder *coder): m_Coder(coder) {}
- ~CCoderReleaser() { m_Coder->ReleaseStreams(); }
- };
- friend class CCoderReleaser;
-
- UInt32 GetBlockPrice(int tableIndex, int numDivPasses);
- void CodeBlock(int tableIndex, bool finalBlock);
-
-public:
- CCoder(bool deflate64Mode = false);
- ~CCoder();
-
- HRESULT CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- HRESULT BaseCode(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- // ICompressSetCoderProperties
- HRESULT BaseSetEncoderProperties2(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties);
-};
-
-///////////////////////////////////////////////////////////////
-
-class CCOMCoder :
- public ICompressCoder,
- public ICompressSetCoderProperties,
- public CMyUnknownImp,
- public CCoder
-{
-public:
- MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
- CCOMCoder(): CCoder(false) {};
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
- // ICompressSetCoderProperties
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties);
-};
-
-class CCOMCoder64 :
- public ICompressCoder,
- public ICompressSetCoderProperties,
- public CMyUnknownImp,
- public CCoder
-{
-public:
- MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
- CCOMCoder64(): CCoder(true) {};
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
- // ICompressSetCoderProperties
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties);
-};
-
-
-}}}
-
-#endif
diff --git a/7zip/Compress/Deflate/DllExports.cpp b/7zip/Compress/Deflate/DllExports.cpp
deleted file mode 100755
index acc431ff..00000000
--- a/7zip/Compress/Deflate/DllExports.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-
-#include "DeflateEncoder.h"
-#include "DeflateDecoder.h"
-
-
-// {23170F69-40C1-278B-0401-080000000000}
-DEFINE_GUID(CLSID_CCompressDeflateDecoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-// {23170F69-40C1-278B-0401-090000000000}
-DEFINE_GUID(CLSID_CCompressDeflate64Decoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-// {23170F69-40C1-278B-0401-080000000100}
-DEFINE_GUID(CLSID_CCompressDeflateEncoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00);
-
-// {23170F69-40C1-278B-0401-090000000100}
-DEFINE_GUID(CLSID_CCompressDeflate64Encoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00);
-
-
-// {23170F69-40C1-278B-0409-010000000000}
-DEFINE_GUID(CLSID_CCompressDeflateNsisDecoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
-{
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- int correctInterface = (*iid == IID_ICompressCoder);
- CMyComPtr<ICompressCoder> coder;
- if (*clsid == CLSID_CCompressDeflateDecoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NDeflate::NDecoder::CCOMCoder();
- }
- else if (*clsid == CLSID_CCompressDeflateNsisDecoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NDeflate::NDecoder::CNsisCOMCoder();
- }
- else if (*clsid == CLSID_CCompressDeflateEncoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NDeflate::NEncoder::CCOMCoder();
- }
- else if (*clsid == CLSID_CCompressDeflate64Decoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NDeflate::NDecoder::CCOMCoder64();
- }
- else if (*clsid == CLSID_CCompressDeflate64Encoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NDeflate::NEncoder::CCOMCoder64();
- }
- else
- return CLASS_E_CLASSNOTAVAILABLE;
- *outObject = coder.Detach();
- COM_TRY_END
- return S_OK;
-}
-
-struct CDeflateMethodItem
-{
- char ID[3];
- const wchar_t *UserName;
- const GUID *Decoder;
- const GUID *Encoder;
-};
-
-#define METHOD_ITEM(Name, id, UserName) \
- { { 0x04, 0x01, id }, UserName, \
- &CLSID_CCompress ## Name ## Decoder, \
- &CLSID_CCompress ## Name ## Encoder }
-
-#define METHOD_ITEM_DE(Name, id1, id2, UserName) \
- { { 0x04, id1, id2 }, UserName, \
- &CLSID_CCompress ## Name ## Decoder, NULL }
-
-
-static CDeflateMethodItem g_Methods[] =
-{
- METHOD_ITEM(Deflate, 0x08, L"Deflate"),
- METHOD_ITEM(Deflate64, 0x09, L"Deflate64"),
- METHOD_ITEM_DE(DeflateNsis, 0x09, 0x01, L"DeflateNSIS")
-};
-
-STDAPI GetNumberOfMethods(UINT32 *numMethods)
-{
- *numMethods = sizeof(g_Methods) / sizeof(g_Methods[0]);
- return S_OK;
-}
-
-STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
-{
- if (index > sizeof(g_Methods) / sizeof(g_Methods[0]))
- return E_INVALIDARG;
- VariantClear((tagVARIANT *)value);
- const CDeflateMethodItem &method = g_Methods[index];
- switch(propID)
- {
- case NMethodPropID::kID:
- if ((value->bstrVal = ::SysAllocStringByteLen(method.ID,
- sizeof(method.ID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(method.UserName)) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)method.Decoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kEncoder:
- if (method.Encoder)
- {
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)method.Encoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- }
- return S_OK;
- }
- return S_OK;
-}
diff --git a/7zip/Compress/Deflate/makefile b/7zip/Compress/Deflate/makefile
deleted file mode 100755
index 74e243d6..00000000
--- a/7zip/Compress/Deflate/makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-PROG = Deflate.dll
-DEF_FILE = ../Codec.def
-CFLAGS = $(CFLAGS) -I ../../../ -D_ST_MODE
-LIBS = $(LIBS) oleaut32.lib
-
-DEFLATE_OBJS = \
- $O\DllExports.obj \
-
-DEFLATE_OPT_OBJS = \
- $O\DeflateDecoder.obj \
- $O\DeflateEncoder.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CRC.obj \
-
-7ZIP_COMMON_OBJS = \
- $O\InBuffer.obj \
- $O\OutBuffer.obj \
- $O\LSBFDecoder.obj \
- $O\LSBFEncoder.obj \
-
-LZ_OBJS = \
- $O\LZInWindow.obj \
- $O\LZOutWindow.obj \
-
-
-OBJS = \
- $O\StdAfx.obj \
- $(DEFLATE_OBJS) \
- $(DEFLATE_OPT_OBJS) \
- $(COMMON_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(LZ_OBJS) \
- $O\HuffmanEncoder.obj \
- $O\resource.res
-
-!include "../../../Build.mak"
-
-$(DEFLATE_OBJS): $(*B).cpp
- $(COMPL)
-$(DEFLATE_OPT_OBJS): $(*B).cpp
- $(COMPL_O2)
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(LZ_OBJS): ../LZ/$(*B).cpp
- $(COMPL)
-$O\HuffmanEncoder.obj: ../Huffman/$(*B).cpp
- $(COMPL_O2)
diff --git a/7zip/Compress/Huffman/HuffmanEncoder.cpp b/7zip/Compress/Huffman/HuffmanEncoder.cpp
deleted file mode 100755
index c0e42799..00000000
--- a/7zip/Compress/Huffman/HuffmanEncoder.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-// Compression/HuffmanEncoder.cpp
-
-#include "StdAfx.h"
-
-#include "HuffmanEncoder.h"
-#include "Common/Defs.h"
-#include "Common/Alloc.h"
-
-namespace NCompression {
-namespace NHuffman {
-
-static const char *kIncorrectBitLenCountsMessage = "Incorrect bit len counts";
-
-CEncoder::CEncoder():
- m_Items(0),
- m_Heap(0),
- m_Depth(0)
-{}
-
-void CEncoder::Free()
-{
- MyFree(m_Items);
- MyFree(m_Heap);
- MyFree(m_Depth);
- m_Items = 0;
- m_Heap = 0;
- m_Depth = 0;
-}
-
-bool CEncoder::Create(UInt32 numSymbols,
- const Byte *extraBits, UInt32 extraBase, UInt32 maxLength)
-{
- m_NumSymbols = numSymbols;
- m_ExtraBits = extraBits;
- m_ExtraBase = extraBase;
- m_MaxLength = maxLength;
- m_HeapSize = numSymbols * 2 + 1;
- Free();
- m_Items = (CItem *)MyAlloc(m_HeapSize * sizeof(CItem));
- m_Heap = (UInt32 *)MyAlloc(m_HeapSize * sizeof(UInt32));
- m_Depth = (Byte *)MyAlloc(m_HeapSize * sizeof(Byte));
- if (m_Items == 0 || m_Heap == 0 || m_Depth == 0)
- {
- Free();
- return false;
- }
- return true;
-}
-
-CEncoder::~CEncoder()
-{
- Free();
-}
-
-void CEncoder::StartNewBlock()
-{
- for (UInt32 i = 0; i < m_NumSymbols; i++)
- m_Items[i].Freq = 0;
-}
-
-static const int kSmallest = 1;
-
-// ===========================================================================
-// Remove the smallest element from the heap and recreate the heap with
-// one less element. Updates heap and m_HeapLength.
-
-UInt32 CEncoder::RemoveSmallest()
-{
- UInt32 top = m_Heap[kSmallest];
- m_Heap[kSmallest] = m_Heap[m_HeapLength--];
- DownHeap(kSmallest);
- return top;
-}
-
-// ===========================================================================
-// Compares to subtrees, using the tree m_Depth as tie breaker when
-// the subtrees have equal frequency. This minimizes the worst case length.
-
-bool CEncoder::Smaller(int n, int m)
-{
- return (m_Items[n].Freq < m_Items[m].Freq ||
- (m_Items[n].Freq == m_Items[m].Freq && m_Depth[n] <= m_Depth[m]));
-}
-
-// ===========================================================================
-// Restore the m_Heap property by moving down the tree starting at node k,
-// exchanging a node with the smallest of its two sons if necessary, stopping
-// when the m_Heap property is re-established (each father CompareFreqs than its
-// two sons).
-
-void CEncoder::DownHeap(UInt32 k)
-{
- UInt32 symbol = m_Heap[k];
- for (UInt32 j = k << 1; j <= m_HeapLength;) // j: left son of k
- {
- // Set j to the smallest of the two sons:
- if (j < m_HeapLength && Smaller(m_Heap[j+1], m_Heap[j]))
- j++;
- UInt32 htemp = m_Heap[j]; // htemp required because of bug in SASC compiler
- if (Smaller(symbol, htemp)) // Exit if v is smaller than both sons
- break;
- m_Heap[k] = htemp; // Exchange v with the smallest son
- k = j;
- j <<= 1; // And continue down the tree, setting j to the left son of k
- }
- m_Heap[k] = symbol;
-}
-
-// ===========================================================================
-// Compute the optimal bit lengths for a tree and update the total bit length
-// for the current block.
-// IN assertion: the fields freq and dad are set, heap[heapMax] and
-// above are the tree nodes sorted by increasing frequency.
-// OUT assertions: the field len is set to the optimal bit length, the
-// array m_BitLenCounters contains the frequencies for each bit length.
-// The length m_BlockBitLength is updated; static_len is also updated if stree is
-// not null.
-
-void CEncoder::GenerateBitLen(UInt32 maxCode, UInt32 heapMax)
-{
- int overflow = 0; // number of elements with bit length too large
-
- for (UInt32 i = 0; i <= kNumBitsInLongestCode; i++)
- m_BitLenCounters[i] = 0;
-
- /* In a first pass, compute the optimal bit lengths (which may
- * overflow in the case of the bit length tree).
- */
- m_Items[m_Heap[heapMax]].Len = 0; /* root of the heap */
- UInt32 h; /* heap index */
- for (h = heapMax+1; h < m_HeapSize; h++)
- {
- UInt32 symbol = m_Heap[h];
- UInt32 len = m_Items[m_Items[symbol].Dad].Len + 1;
- if (len > m_MaxLength)
- {
- len = m_MaxLength;
- overflow++;
- }
- m_Items[symbol].Len = len; // We overwrite m_Items[symbol].Dad which is no longer needed
- if (symbol > maxCode)
- continue; // not a leaf node
- m_BitLenCounters[len]++;
- UInt32 extraBits;
- if (m_ExtraBits != 0 && symbol >= m_ExtraBase)
- extraBits = m_ExtraBits[symbol - m_ExtraBase];
- else
- extraBits = 0;
- m_BlockBitLength += (m_Items[symbol].Freq * (len + extraBits));
- }
- if (overflow == 0)
- return;
-
- // This happens for example on obj2 and pic of the Calgary corpus
- // Find the first bit length which could increase:
- do
- {
- UInt32 bits = m_MaxLength-1;
- while (m_BitLenCounters[bits] == 0)
- bits--;
- m_BitLenCounters[bits]--; // move one leaf down the m_Items
- m_BitLenCounters[bits + 1] += 2; // move one overflow item as its brother
- m_BitLenCounters[m_MaxLength]--;
- // The brother of the overflow item also moves one step up,
- // but this does not affect m_BitLenCounters[m_MaxLength]
- overflow -= 2;
- }
- while (overflow > 0);
-
- // Now recompute all bit lengths, scanning in increasing frequency.
- // h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
- // lengths instead of fixing only the wrong ones. This idea is taken
- // from 'ar' written by Haruhiko Okumura.)
- for (UInt32 bits = m_MaxLength; bits != 0; bits--)
- {
- UInt32 numNodes = m_BitLenCounters[bits];
- while (numNodes != 0)
- {
- UInt32 m = m_Heap[--h];
- if (m > maxCode)
- continue;
- if (m_Items[m].Len != (unsigned) bits)
- {
- m_BlockBitLength += ((long)bits - (long)m_Items[m].Len) * (long)m_Items[m].Freq;
- m_Items[m].Len = bits;
- }
- numNodes--;
- }
- }
-}
-
-
-// ===========================================================================
-// Generate the codes for a given tree and bit counts (which need not be
-// optimal).
-// IN assertion: the array m_BitLenCounters contains the bit length statistics for
-// the given tree and the field len is set for all tree elements.
-// OUT assertion: the field code is set for all tree elements of non
-// zero code length.
-
-// UInt32 maxCode = largest code with non zero frequency
-
-
-void CEncoder::GenerateCodes(UInt32 maxCode)
-{
- UInt32 nextCodes[kNumBitsInLongestCode + 1]; // next code value for each bit length
- UInt32 code = 0; // running code value
- // The distribution counts are first used to generate the code values
- // without bit reversal.
- for (UInt32 bits = 1; bits <= kNumBitsInLongestCode; bits++)
- nextCodes[bits] = code = (code + m_BitLenCounters[bits - 1]) << 1;
- // Check that the bit counts in m_BitLenCounters are consistent. The last code
- // must be all ones.
- if (code + m_BitLenCounters[kNumBitsInLongestCode] - 1 != (1 << kNumBitsInLongestCode) - 1)
- throw kIncorrectBitLenCountsMessage;
- for (UInt32 n = 0; n <= maxCode; n++)
- {
- int len = m_Items[n].Len;
- if (len == 0)
- continue;
- m_Items[n].Code = nextCodes[len]++;
- }
-}
-
-
-// ===========================================================================
-// Construct one Huffman tree and assigns the code bit strings and lengths.
-// Update the total bit length for the current block.
-// IN assertion: the field freq is set for all tree elements.
-// OUT assertions: the fields len and code are set to the optimal bit length
-// and corresponding code. The length m_BlockBitLength is updated; static_len is
-// also updated if stree is not null. The field max_code is set.
-
-void CEncoder::BuildTree(Byte *levels)
-{
- m_BlockBitLength = 0;
- int maxCode = -1; // WAS = -1; largest code with non zero frequency */
-
- // Construct the initial m_Heap, with least frequent element in
- // m_Heap[kSmallest]. The sons of m_Heap[n] are m_Heap[2*n] and m_Heap[2*n+1].
- // m_Heap[0] is not used.
- //
-
- m_HeapLength = 0;
- UInt32 n; // iterate over m_Heap elements
- for (n = 0; n < m_NumSymbols; n++)
- {
- if (m_Items[n].Freq != 0)
- {
- m_Heap[++m_HeapLength] = maxCode = n;
- m_Depth[n] = 0;
- }
- else
- m_Items[n].Len = 0;
- }
-
- // The pkzip format requires that at least one distance code exists,
- // and that at least one bit should be sent even if there is only one
- // possible code. So to avoid special checks later on we force at least
- // two codes of non zero frequency.
- while (m_HeapLength < 2)
- {
- int aNewNode = m_Heap[++m_HeapLength] = (maxCode < 2 ? ++maxCode : 0);
- m_Items[aNewNode].Freq = 1;
- m_Depth[aNewNode] = 0;
- m_BlockBitLength--;
- // if (stree) static_len -= stree[aNewNode].Len;
- // aNewNode is 0 or 1 so it does not have m_ExtraBits bits
- }
-
- // The elements m_Heap[m_HeapLength/2+1 .. m_HeapLength] are leaves of the m_Items,
- // establish sub-heaps of increasing lengths:
- for (n = m_HeapLength / 2; n >= 1; n--)
- DownHeap(n);
-
- // Construct the Huffman tree by repeatedly combining the least two
- // frequent nodes.
- int node = m_NumSymbols; // next internal node of the tree
- UInt32 heapMax = m_NumSymbols * 2+ 1;
- do
- {
- n = RemoveSmallest(); /* n = node of least frequency */
- UInt32 m = m_Heap[kSmallest]; /* m = node of next least frequency */
-
- m_Heap[--heapMax] = n; /* keep the nodes sorted by frequency */
- m_Heap[--heapMax] = m;
-
- // Create a new node father of n and m
- m_Items[node].Freq = m_Items[n].Freq + m_Items[m].Freq;
- m_Depth[node] = (Byte) (MyMax(m_Depth[n], m_Depth[m]) + 1);
- m_Items[n].Dad = m_Items[m].Dad = node;
- // and insert the new node in the m_Heap
- m_Heap[kSmallest] = node++;
- DownHeap(kSmallest);
-
- }
- while (m_HeapLength >= 2);
-
- m_Heap[--heapMax] = m_Heap[kSmallest];
-
- // At this point, the fields freq and dad are set. We can now
- // generate the bit lengths.
- GenerateBitLen(maxCode, heapMax);
-
- // The field len is now set, we can generate the bit codes
- GenerateCodes (maxCode);
-
- for (n = 0; n < m_NumSymbols; n++)
- levels[n] = Byte(m_Items[n].Len);
-}
-
-void CEncoder::ReverseBits()
-{
- for (UInt32 symbol = 0; symbol < m_NumSymbols; symbol++)
- {
- CItem &item = m_Items[symbol];
- UInt32 value = item.Code;
- UInt32 reverseValue = 0;
- for(UInt32 i = item.Len; i != 0; i--, value >>= 1)
- reverseValue = (reverseValue << 1) | (value & 1);
- item.Code = reverseValue;
- }
-}
-
-}}
diff --git a/7zip/Compress/Huffman/HuffmanEncoder.h b/7zip/Compress/Huffman/HuffmanEncoder.h
deleted file mode 100755
index 76304a45..00000000
--- a/7zip/Compress/Huffman/HuffmanEncoder.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// Compression/HuffmanEncoder.h
-
-#ifndef __COMPRESSION_HUFFMANENCODER_H
-#define __COMPRESSION_HUFFMANENCODER_H
-
-#include "../../../Common/Types.h"
-
-namespace NCompression {
-namespace NHuffman {
-
-const int kNumBitsInLongestCode = 20;
-
-struct CItem
-{
- UInt32 Freq;
- UInt32 Code;
- UInt32 Dad;
- UInt32 Len;
-};
-
-class CEncoder
-{
-public:
- UInt32 m_NumSymbols; // number of symbols in adwSymbol
-
- CItem *m_Items;
- UInt32 *m_Heap;
- UInt32 m_HeapSize;
- Byte *m_Depth;
- const Byte *m_ExtraBits;
- UInt32 m_ExtraBase;
- UInt32 m_MaxLength;
-
- UInt32 m_HeapLength;
- UInt32 m_BitLenCounters[kNumBitsInLongestCode + 1];
-
- UInt32 RemoveSmallest();
- bool Smaller(int n, int m);
- void DownHeap(UInt32 k);
- void GenerateBitLen(UInt32 maxCode, UInt32 heapMax);
- void GenerateCodes(UInt32 maxCode);
-
- UInt32 m_BlockBitLength;
-
- void Free();
-
-public:
-
- CEncoder();
- ~CEncoder();
- bool Create(UInt32 numSymbols, const Byte *extraBits,
- UInt32 extraBase, UInt32 maxLength);
- void StartNewBlock();
-
- void AddSymbol(UInt32 symbol) { m_Items[symbol].Freq++; }
-
- UInt32 GetPrice(const Byte *length) const
- {
- UInt32 price = 0;
- for (UInt32 i = 0; i < m_NumSymbols; i++)
- {
- price += length[i] * m_Items[i].Freq;
- if (m_ExtraBits && i >= m_ExtraBase)
- price += m_ExtraBits[i - m_ExtraBase] * m_Items[i].Freq;
- }
- return price;
- };
- void SetFreq(UInt32 symbol, UInt32 value) { m_Items[symbol].Freq = value; };
-
- void BuildTree(Byte *levels);
- UInt32 GetBlockBitLength() const { return m_BlockBitLength; }
-
- template <class TBitEncoder>
- void CodeOneValue(TBitEncoder *bitEncoder, UInt32 symbol)
- { bitEncoder->WriteBits(m_Items[symbol].Code, m_Items[symbol].Len); }
-
- void ReverseBits();
-};
-
-}}
-
-#endif
diff --git a/7zip/Compress/Implode/DllExports.cpp b/7zip/Compress/Implode/DllExports.cpp
deleted file mode 100755
index 4560af3a..00000000
--- a/7zip/Compress/Implode/DllExports.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-#include "ImplodeDecoder.h"
-
-// {23170F69-40C1-278B-0401-060000000000}
-DEFINE_GUID(CLSID_CCompressImplodeDecoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
-{
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- if (*clsid != CLSID_CCompressImplodeDecoder)
- return CLASS_E_CLASSNOTAVAILABLE;
- if (*iid != IID_ICompressCoder)
- return E_NOINTERFACE;
- CMyComPtr<ICompressCoder> coder = (ICompressCoder *)new
- NCompress::NImplode::NDecoder::CCoder;
- *outObject = coder.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[] = { 0x04, 0x01, 0x06 };
- if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(L"Implode")) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCompressImplodeDecoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- return S_OK;
-}
diff --git a/7zip/Compress/LZ/BinTree/BinTree.h b/7zip/Compress/LZ/BinTree/BinTree.h
deleted file mode 100755
index b3b3f13a..00000000
--- a/7zip/Compress/LZ/BinTree/BinTree.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// BinTree.h
-
-#include "../LZInWindow.h"
-#include "../IMatchFinder.h"
-
-namespace BT_NAMESPACE {
-
-typedef UInt32 CIndex;
-const UInt32 kMaxValForNormalize = (UInt32(1) << 31) - 1;
-
-class CMatchFinder:
- public IMatchFinder,
- public CLZInWindow,
- public CMyUnknownImp,
- public IMatchFinderSetNumPasses
-{
- UInt32 _cyclicBufferPos;
- UInt32 _cyclicBufferSize; // it must be historySize + 1
- UInt32 _matchMaxLen;
- CIndex *_hash;
- CIndex *_son;
- UInt32 _hashMask;
- UInt32 _cutValue;
- UInt32 _hashSizeSum;
-
- void Normalize();
- void FreeThisClassMemory();
- void FreeMemory();
-
- MY_UNKNOWN_IMP
-
- STDMETHOD(SetStream)(ISequentialInStream *inStream);
- STDMETHOD_(void, ReleaseStream)();
- STDMETHOD(Init)();
- HRESULT MovePos();
- STDMETHOD_(Byte, GetIndexByte)(Int32 index);
- STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 back, UInt32 limit);
- STDMETHOD_(UInt32, GetNumAvailableBytes)();
- STDMETHOD_(const Byte *, GetPointerToCurrentPos)();
- STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes);
- STDMETHOD_(void, ChangeBufferPos)();
-
- STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore,
- UInt32 matchMaxLen, UInt32 keepAddBufferAfter);
- STDMETHOD(GetMatches)(UInt32 *distances);
- STDMETHOD(Skip)(UInt32 num);
-
-public:
- CMatchFinder();
- virtual ~CMatchFinder();
- virtual void SetNumPasses(UInt32 numPasses) { _cutValue = numPasses; }
-};
-
-}
diff --git a/7zip/Compress/LZ/BinTree/BinTree2.h b/7zip/Compress/LZ/BinTree/BinTree2.h
deleted file mode 100755
index 74ca8d9d..00000000
--- a/7zip/Compress/LZ/BinTree/BinTree2.h
+++ /dev/null
@@ -1,12 +0,0 @@
-// BinTree2.h
-
-#ifndef __BINTREE2_H
-#define __BINTREE2_H
-
-#define BT_NAMESPACE NBT2
-
-#include "BinTreeMain.h"
-
-#undef BT_NAMESPACE
-
-#endif
diff --git a/7zip/Compress/LZ/BinTree/BinTree3.h b/7zip/Compress/LZ/BinTree/BinTree3.h
deleted file mode 100755
index 76bd9ddd..00000000
--- a/7zip/Compress/LZ/BinTree/BinTree3.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// BinTree3.h
-
-#ifndef __BINTREE3_H
-#define __BINTREE3_H
-
-#define BT_NAMESPACE NBT3
-
-#define HASH_ARRAY_2
-
-#include "BinTreeMain.h"
-
-#undef HASH_ARRAY_2
-
-#undef BT_NAMESPACE
-
-#endif
diff --git a/7zip/Compress/LZ/BinTree/BinTree3Z.h b/7zip/Compress/LZ/BinTree/BinTree3Z.h
deleted file mode 100755
index d2c092b4..00000000
--- a/7zip/Compress/LZ/BinTree/BinTree3Z.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// BinTree3Z.h
-
-#ifndef __BINTREE3Z_H
-#define __BINTREE3Z_H
-
-#define BT_NAMESPACE NBT3Z
-
-#define HASH_ZIP
-
-#include "BinTreeMain.h"
-
-#undef HASH_ZIP
-
-#undef BT_NAMESPACE
-
-#endif
diff --git a/7zip/Compress/LZ/BinTree/BinTree4.h b/7zip/Compress/LZ/BinTree/BinTree4.h
deleted file mode 100755
index 08e2d1ce..00000000
--- a/7zip/Compress/LZ/BinTree/BinTree4.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// BinTree4.h
-
-#ifndef __BINTREE4_H
-#define __BINTREE4_H
-
-#define BT_NAMESPACE NBT4
-
-#define HASH_ARRAY_2
-#define HASH_ARRAY_3
-
-#include "BinTreeMain.h"
-
-#undef HASH_ARRAY_2
-#undef HASH_ARRAY_3
-
-#undef BT_NAMESPACE
-
-#endif
diff --git a/7zip/Compress/LZ/BinTree/BinTreeMain.h b/7zip/Compress/LZ/BinTree/BinTreeMain.h
deleted file mode 100755
index ef9f6ce2..00000000
--- a/7zip/Compress/LZ/BinTree/BinTreeMain.h
+++ /dev/null
@@ -1,531 +0,0 @@
-// BinTreeMain.h
-
-#include "../../../../Common/Defs.h"
-#include "../../../../Common/CRC.h"
-#include "../../../../Common/Alloc.h"
-
-#include "BinTree.h"
-
-// #include <xmmintrin.h>
-// It's for prefetch
-// But prefetch doesn't give big gain in K8.
-
-namespace BT_NAMESPACE {
-
-#ifdef HASH_ARRAY_2
- static const UInt32 kHash2Size = 1 << 10;
- #define kNumHashDirectBytes 0
- #ifdef HASH_ARRAY_3
- static const UInt32 kNumHashBytes = 4;
- static const UInt32 kHash3Size = 1 << 16;
- #else
- static const UInt32 kNumHashBytes = 3;
- #endif
- static const UInt32 kHashSize = 0;
- static const UInt32 kMinMatchCheck = kNumHashBytes;
- static const UInt32 kStartMaxLen = 1;
-#else
- #ifdef HASH_ZIP
- #define kNumHashDirectBytes 0
- static const UInt32 kNumHashBytes = 3;
- static const UInt32 kHashSize = 1 << 16;
- static const UInt32 kMinMatchCheck = kNumHashBytes;
- static const UInt32 kStartMaxLen = 1;
- #else
- #define kNumHashDirectBytes 2
- static const UInt32 kNumHashBytes = 2;
- static const UInt32 kHashSize = 1 << (8 * kNumHashBytes);
- static const UInt32 kMinMatchCheck = kNumHashBytes + 1;
- static const UInt32 kStartMaxLen = 1;
- #endif
-#endif
-
-#ifdef HASH_ARRAY_2
-#ifdef HASH_ARRAY_3
-static const UInt32 kHash3Offset = kHash2Size;
-#endif
-#endif
-
-static const UInt32 kFixHashSize = 0
- #ifdef HASH_ARRAY_2
- + kHash2Size
- #ifdef HASH_ARRAY_3
- + kHash3Size
- #endif
- #endif
- ;
-
-CMatchFinder::CMatchFinder():
- _hash(0)
-{
-}
-
-void CMatchFinder::FreeThisClassMemory()
-{
- BigFree(_hash);
- _hash = 0;
-}
-
-void CMatchFinder::FreeMemory()
-{
- FreeThisClassMemory();
- CLZInWindow::Free();
-}
-
-CMatchFinder::~CMatchFinder()
-{
- FreeMemory();
-}
-
-STDMETHODIMP CMatchFinder::Create(UInt32 historySize, UInt32 keepAddBufferBefore,
- UInt32 matchMaxLen, UInt32 keepAddBufferAfter)
-{
- if (historySize > kMaxValForNormalize - 256)
- {
- FreeMemory();
- return E_INVALIDARG;
- }
- _cutValue =
- #ifdef _HASH_CHAIN
- 8 + (matchMaxLen >> 2);
- #else
- 16 + (matchMaxLen >> 1);
- #endif
- UInt32 sizeReserv = (historySize + keepAddBufferBefore +
- matchMaxLen + keepAddBufferAfter) / 2 + 256;
- if (CLZInWindow::Create(historySize + keepAddBufferBefore,
- matchMaxLen + keepAddBufferAfter, sizeReserv))
- {
- _matchMaxLen = matchMaxLen;
- UInt32 newCyclicBufferSize = historySize + 1;
- if (_hash != 0 && newCyclicBufferSize == _cyclicBufferSize)
- return S_OK;
- FreeThisClassMemory();
- _cyclicBufferSize = newCyclicBufferSize; // don't change it
-
- UInt32 hs = kHashSize;
-
- #ifdef HASH_ARRAY_2
- hs = historySize - 1;
- hs |= (hs >> 1);
- hs |= (hs >> 2);
- hs |= (hs >> 4);
- hs |= (hs >> 8);
- hs >>= 1;
- hs |= 0xFFFF;
- if (hs > (1 << 24))
- {
- #ifdef HASH_ARRAY_3
- hs >>= 1;
- #else
- hs = (1 << 24) - 1;
- #endif
- }
- _hashMask = hs;
- hs++;
- #endif
- _hashSizeSum = hs + kFixHashSize;
- UInt32 numItems = _hashSizeSum + _cyclicBufferSize
- #ifndef _HASH_CHAIN
- * 2
- #endif
- ;
- size_t sizeInBytes = (size_t)numItems * sizeof(CIndex);
- if (sizeInBytes / sizeof(CIndex) != numItems)
- return E_OUTOFMEMORY;
- _hash = (CIndex *)BigAlloc(sizeInBytes);
- _son = _hash + _hashSizeSum;
- if (_hash != 0)
- return S_OK;
- }
- FreeMemory();
- return E_OUTOFMEMORY;
-}
-
-static const UInt32 kEmptyHashValue = 0;
-
-STDMETHODIMP CMatchFinder::SetStream(ISequentialInStream *stream)
-{
- CLZInWindow::SetStream(stream);
- return S_OK;
-}
-
-STDMETHODIMP CMatchFinder::Init()
-{
- RINOK(CLZInWindow::Init());
- for(UInt32 i = 0; i < _hashSizeSum; i++)
- _hash[i] = kEmptyHashValue;
- _cyclicBufferPos = 0;
- ReduceOffsets(-1);
- return S_OK;
-}
-
-STDMETHODIMP_(void) CMatchFinder::ReleaseStream()
-{
- // ReleaseStream();
-}
-
-#ifdef HASH_ARRAY_2
-#ifdef HASH_ARRAY_3
-
-#define HASH_CALC { \
- UInt32 temp = CCRC::Table[cur[0]] ^ cur[1]; \
- hash2Value = temp & (kHash2Size - 1); \
- hash3Value = (temp ^ (UInt32(cur[2]) << 8)) & (kHash3Size - 1); \
- hashValue = (temp ^ (UInt32(cur[2]) << 8) ^ (CCRC::Table[cur[3]] << 5)) & _hashMask; }
-
-#else // no HASH_ARRAY_3
-#define HASH_CALC { \
- UInt32 temp = CCRC::Table[cur[0]] ^ cur[1]; \
- hash2Value = temp & (kHash2Size - 1); \
- hashValue = (temp ^ (UInt32(cur[2]) << 8)) & _hashMask; }
-#endif // HASH_ARRAY_3
-#else // no HASH_ARRAY_2
-#ifdef HASH_ZIP
-inline UInt32 Hash(const Byte *pointer)
-{
- return ((UInt32(pointer[0]) << 8) ^ CCRC::Table[pointer[1]] ^ pointer[2]) & (kHashSize - 1);
-}
-#else // no HASH_ZIP
-inline UInt32 Hash(const Byte *pointer)
-{
- return pointer[0] ^ (UInt32(pointer[1]) << 8);
-}
-#endif // HASH_ZIP
-#endif // HASH_ARRAY_2
-
-STDMETHODIMP CMatchFinder::GetMatches(UInt32 *distances)
-{
- UInt32 lenLimit;
- if (_pos + _matchMaxLen <= _streamPos)
- lenLimit = _matchMaxLen;
- else
- {
- lenLimit = _streamPos - _pos;
- if(lenLimit < kMinMatchCheck)
- {
- distances[0] = 0;
- return MovePos();
- }
- }
-
- int offset = 1;
-
- UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
- const Byte *cur = _buffer + _pos;
-
- UInt32 maxLen = kStartMaxLen; // to avoid items for len < hashSize;
-
- #ifdef HASH_ARRAY_2
- UInt32 hash2Value;
- #ifdef HASH_ARRAY_3
- UInt32 hash3Value;
- #endif
- UInt32 hashValue;
- HASH_CALC;
- #else
- UInt32 hashValue = Hash(cur);
- #endif
-
- UInt32 curMatch = _hash[kFixHashSize + hashValue];
- #ifdef HASH_ARRAY_2
- UInt32 curMatch2 = _hash[hash2Value];
- #ifdef HASH_ARRAY_3
- UInt32 curMatch3 = _hash[kHash3Offset + hash3Value];
- #endif
- _hash[hash2Value] = _pos;
- if(curMatch2 > matchMinPos)
- if (_buffer[curMatch2] == cur[0])
- {
- distances[offset++] = maxLen = 2;
- distances[offset++] = _pos - curMatch2 - 1;
- }
-
- #ifdef HASH_ARRAY_3
- _hash[kHash3Offset + hash3Value] = _pos;
- if(curMatch3 > matchMinPos)
- if (_buffer[curMatch3] == cur[0])
- {
- if (curMatch3 == curMatch2)
- offset -= 2;
- distances[offset++] = maxLen = 3;
- distances[offset++] = _pos - curMatch3 - 1;
- curMatch2 = curMatch3;
- }
- #endif
- if (offset != 1 && curMatch2 == curMatch)
- {
- offset -= 2;
- maxLen = kStartMaxLen;
- }
- #endif
-
- _hash[kFixHashSize + hashValue] = _pos;
-
- CIndex *son = _son;
-
- #ifdef _HASH_CHAIN
- son[_cyclicBufferPos] = curMatch;
- #else
- CIndex *ptr0 = son + (_cyclicBufferPos << 1) + 1;
- CIndex *ptr1 = son + (_cyclicBufferPos << 1);
-
- UInt32 len0, len1;
- len0 = len1 = kNumHashDirectBytes;
- #endif
-
- #if kNumHashDirectBytes != 0
- if(curMatch > matchMinPos)
- {
- if (_buffer[curMatch + kNumHashDirectBytes] != cur[kNumHashDirectBytes])
- {
- distances[offset++] = maxLen = kNumHashDirectBytes;
- distances[offset++] = _pos - curMatch - 1;
- }
- }
- #endif
- UInt32 count = _cutValue;
- for (;;)
- {
- if(curMatch <= matchMinPos || count-- == 0)
- {
- #ifndef _HASH_CHAIN
- *ptr0 = *ptr1 = kEmptyHashValue;
- #endif
- break;
- }
- UInt32 delta = _pos - curMatch;
- UInt32 cyclicPos = (delta <= _cyclicBufferPos) ?
- (_cyclicBufferPos - delta):
- (_cyclicBufferPos - delta + _cyclicBufferSize);
- CIndex *pair = son +
- #ifdef _HASH_CHAIN
- cyclicPos;
- #else
- (cyclicPos << 1);
- #endif
-
- // _mm_prefetch((const char *)pair, _MM_HINT_T0);
-
- const Byte *pb = _buffer + curMatch;
- UInt32 len =
- #ifdef _HASH_CHAIN
- kNumHashDirectBytes;
- if (pb[maxLen] == cur[maxLen])
- #else
- MyMin(len0, len1);
- #endif
- if (pb[len] == cur[len])
- {
- while(++len != lenLimit)
- if (pb[len] != cur[len])
- break;
- if (maxLen < len)
- {
- distances[offset++] = maxLen = len;
- distances[offset++] = delta - 1;
- if (len == lenLimit)
- {
- #ifndef _HASH_CHAIN
- *ptr1 = pair[0];
- *ptr0 = pair[1];
- #endif
- break;
- }
- }
- }
- #ifdef _HASH_CHAIN
- curMatch = *pair;
- #else
- if (pb[len] < cur[len])
- {
- *ptr1 = curMatch;
- ptr1 = pair + 1;
- curMatch = *ptr1;
- len1 = len;
- }
- else
- {
- *ptr0 = curMatch;
- ptr0 = pair;
- curMatch = *ptr0;
- len0 = len;
- }
- #endif
- }
- distances[0] = offset - 1;
- if (++_cyclicBufferPos == _cyclicBufferSize)
- _cyclicBufferPos = 0;
- RINOK(CLZInWindow::MovePos());
- if (_pos == kMaxValForNormalize)
- Normalize();
- return S_OK;
-}
-
-STDMETHODIMP CMatchFinder::Skip(UInt32 num)
-{
- do
- {
- #ifdef _HASH_CHAIN
- if (_streamPos - _pos < kNumHashBytes)
- {
- RINOK(MovePos());
- continue;
- }
- #else
- UInt32 lenLimit;
- if (_pos + _matchMaxLen <= _streamPos)
- lenLimit = _matchMaxLen;
- else
- {
- lenLimit = _streamPos - _pos;
- if(lenLimit < kMinMatchCheck)
- {
- RINOK(MovePos());
- continue;
- }
- }
- UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
- #endif
- const Byte *cur = _buffer + _pos;
-
- #ifdef HASH_ARRAY_2
- UInt32 hash2Value;
- #ifdef HASH_ARRAY_3
- UInt32 hash3Value;
- UInt32 hashValue;
- HASH_CALC;
- _hash[kHash3Offset + hash3Value] = _pos;
- #else
- UInt32 hashValue;
- HASH_CALC;
- #endif
- _hash[hash2Value] = _pos;
- #else
- UInt32 hashValue = Hash(cur);
- #endif
-
- UInt32 curMatch = _hash[kFixHashSize + hashValue];
- _hash[kFixHashSize + hashValue] = _pos;
-
- #ifdef _HASH_CHAIN
- _son[_cyclicBufferPos] = curMatch;
- #else
- CIndex *son = _son;
- CIndex *ptr0 = son + (_cyclicBufferPos << 1) + 1;
- CIndex *ptr1 = son + (_cyclicBufferPos << 1);
-
- UInt32 len0, len1;
- len0 = len1 = kNumHashDirectBytes;
- UInt32 count = _cutValue;
- for (;;)
- {
- if(curMatch <= matchMinPos || count-- == 0)
- {
- *ptr0 = *ptr1 = kEmptyHashValue;
- break;
- }
-
- UInt32 delta = _pos - curMatch;
- UInt32 cyclicPos = (delta <= _cyclicBufferPos) ?
- (_cyclicBufferPos - delta):
- (_cyclicBufferPos - delta + _cyclicBufferSize);
- CIndex *pair = son + (cyclicPos << 1);
-
- // _mm_prefetch((const char *)pair, _MM_HINT_T0);
-
- const Byte *pb = _buffer + curMatch;
- UInt32 len = MyMin(len0, len1);
-
- if (pb[len] == cur[len])
- {
- while(++len != lenLimit)
- if (pb[len] != cur[len])
- break;
- if (len == lenLimit)
- {
- *ptr1 = pair[0];
- *ptr0 = pair[1];
- break;
- }
- }
- if (pb[len] < cur[len])
- {
- *ptr1 = curMatch;
- ptr1 = pair + 1;
- curMatch = *ptr1;
- len1 = len;
- }
- else
- {
- *ptr0 = curMatch;
- ptr0 = pair;
- curMatch = *ptr0;
- len0 = len;
- }
- }
- #endif
- if (++_cyclicBufferPos == _cyclicBufferSize)
- _cyclicBufferPos = 0;
- RINOK(CLZInWindow::MovePos());
- if (_pos == kMaxValForNormalize)
- Normalize();
- }
- while(--num != 0);
- return S_OK;
-}
-
-void CMatchFinder::Normalize()
-{
- UInt32 subValue = _pos - _cyclicBufferSize;
- CIndex *items = _hash;
- UInt32 numItems = (_hashSizeSum + _cyclicBufferSize
- #ifndef _HASH_CHAIN
- * 2
- #endif
- );
- for (UInt32 i = 0; i < numItems; i++)
- {
- UInt32 value = items[i];
- if (value <= subValue)
- value = kEmptyHashValue;
- else
- value -= subValue;
- items[i] = value;
- }
- ReduceOffsets(subValue);
-}
-
-HRESULT CMatchFinder::MovePos()
-{
- if (++_cyclicBufferPos == _cyclicBufferSize)
- _cyclicBufferPos = 0;
- RINOK(CLZInWindow::MovePos());
- if (_pos == kMaxValForNormalize)
- Normalize();
- return S_OK;
-}
-
-STDMETHODIMP_(Byte) CMatchFinder::GetIndexByte(Int32 index)
- { return CLZInWindow::GetIndexByte(index); }
-
-STDMETHODIMP_(UInt32) CMatchFinder::GetMatchLen(Int32 index,
- UInt32 back, UInt32 limit)
- { return CLZInWindow::GetMatchLen(index, back, limit); }
-
-STDMETHODIMP_(UInt32) CMatchFinder::GetNumAvailableBytes()
- { return CLZInWindow::GetNumAvailableBytes(); }
-
-STDMETHODIMP_(const Byte *) CMatchFinder::GetPointerToCurrentPos()
- { return CLZInWindow::GetPointerToCurrentPos(); }
-
-STDMETHODIMP_(Int32) CMatchFinder::NeedChangeBufferPos(UInt32 numCheckBytes)
- { return CLZInWindow::NeedMove(numCheckBytes) ? 1: 0; }
-
-STDMETHODIMP_(void) CMatchFinder::ChangeBufferPos()
- { CLZInWindow::MoveBlock();}
-
-#undef HASH_CALC
-#undef kNumHashDirectBytes
-
-}
diff --git a/7zip/Compress/LZ/HashChain/HC2.h b/7zip/Compress/LZ/HashChain/HC2.h
deleted file mode 100755
index d8e61a74..00000000
--- a/7zip/Compress/LZ/HashChain/HC2.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// HC2.h
-
-#ifndef __HC2_H
-#define __HC2_H
-
-#define BT_NAMESPACE NHC2
-
-#include "HCMain.h"
-
-#undef BT_NAMESPACE
-
-#endif
-
diff --git a/7zip/Compress/LZ/HashChain/HC3.h b/7zip/Compress/LZ/HashChain/HC3.h
deleted file mode 100755
index 263690af..00000000
--- a/7zip/Compress/LZ/HashChain/HC3.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// HC3.h
-
-#ifndef __HC3_H
-#define __HC3_H
-
-#define BT_NAMESPACE NHC3
-
-#define HASH_ARRAY_2
-
-#include "HCMain.h"
-
-#undef HASH_ARRAY_2
-#undef BT_NAMESPACE
-
-#endif
-
diff --git a/7zip/Compress/LZ/HashChain/HC4.h b/7zip/Compress/LZ/HashChain/HC4.h
deleted file mode 100755
index 1fda4ac6..00000000
--- a/7zip/Compress/LZ/HashChain/HC4.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// HC4.h
-
-#ifndef __HC4_H
-#define __HC4_H
-
-#define BT_NAMESPACE NHC4
-
-#define HASH_ARRAY_2
-#define HASH_ARRAY_3
-
-#include "HCMain.h"
-
-#undef HASH_ARRAY_2
-#undef HASH_ARRAY_3
-
-#undef BT_NAMESPACE
-
-#endif
-
diff --git a/7zip/Compress/LZ/HashChain/HCMain.h b/7zip/Compress/LZ/HashChain/HCMain.h
deleted file mode 100755
index d509befe..00000000
--- a/7zip/Compress/LZ/HashChain/HCMain.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// HCMain.h
-
-#define _HASH_CHAIN
-#include "../BinTree/BinTreeMain.h"
-#undef _HASH_CHAIN
-
diff --git a/7zip/Compress/LZ/IMatchFinder.h b/7zip/Compress/LZ/IMatchFinder.h
deleted file mode 100755
index 528b7b1c..00000000
--- a/7zip/Compress/LZ/IMatchFinder.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// MatchFinders/IMatchFinder.h
-
-#ifndef __IMATCHFINDER_H
-#define __IMATCHFINDER_H
-
-struct IInWindowStream: public IUnknown
-{
- STDMETHOD(SetStream)(ISequentialInStream *inStream) PURE;
- STDMETHOD_(void, ReleaseStream)() PURE;
- STDMETHOD(Init)() PURE;
- STDMETHOD_(Byte, GetIndexByte)(Int32 index) PURE;
- STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 distance, UInt32 limit) PURE;
- STDMETHOD_(UInt32, GetNumAvailableBytes)() PURE;
- STDMETHOD_(const Byte *, GetPointerToCurrentPos)() PURE;
- STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes) PURE;
- STDMETHOD_(void, ChangeBufferPos)() PURE;
-};
-
-struct IMatchFinder: public IInWindowStream
-{
- STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore,
- UInt32 matchMaxLen, UInt32 keepAddBufferAfter) PURE;
- STDMETHOD(GetMatches)(UInt32 *distances) PURE;
- STDMETHOD(Skip)(UInt32 num) PURE;
-};
-
-struct IMatchFinderSetNumPasses
-{
- virtual void SetNumPasses(UInt32 numPasses) PURE;
-};
-
-#endif
diff --git a/7zip/Compress/LZ/LZInWindow.cpp b/7zip/Compress/LZ/LZInWindow.cpp
deleted file mode 100755
index aacaea9d..00000000
--- a/7zip/Compress/LZ/LZInWindow.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-// LZInWindow.cpp
-
-#include "StdAfx.h"
-
-#include "LZInWindow.h"
-#include "../../../Common/MyCom.h"
-#include "../../../Common/Alloc.h"
-
-void CLZInWindow::Free()
-{
- ::BigFree(_bufferBase);
- _bufferBase = 0;
-}
-
-bool CLZInWindow::Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv)
-{
- _keepSizeBefore = keepSizeBefore;
- _keepSizeAfter = keepSizeAfter;
- UInt32 blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv;
- if (_bufferBase == 0 || _blockSize != blockSize)
- {
- Free();
- _blockSize = blockSize;
- if (_blockSize != 0)
- _bufferBase = (Byte *)::BigAlloc(_blockSize);
- }
- _pointerToLastSafePosition = _bufferBase + _blockSize - keepSizeAfter;
- if (_blockSize == 0)
- return true;
- return (_bufferBase != 0);
-}
-
-void CLZInWindow::SetStream(ISequentialInStream *stream)
-{
- _stream = stream;
-}
-
-HRESULT CLZInWindow::Init()
-{
- _buffer = _bufferBase;
- _pos = 0;
- _streamPos = 0;
- _streamEndWasReached = false;
- return ReadBlock();
-}
-
-/*
-void CLZInWindow::ReleaseStream()
-{
- _stream.Release();
-}
-*/
-
-///////////////////////////////////////////
-// ReadBlock
-
-// In State:
-// (_buffer + _streamPos) <= (_bufferBase + _blockSize)
-// Out State:
-// _posLimit <= _blockSize - _keepSizeAfter;
-// if(_streamEndWasReached == false):
-// _streamPos >= _pos + _keepSizeAfter
-// _posLimit = _streamPos - _keepSizeAfter;
-// else
-//
-
-HRESULT CLZInWindow::ReadBlock()
-{
- if(_streamEndWasReached)
- return S_OK;
- for (;;)
- {
- UInt32 size = (UInt32)(_bufferBase - _buffer) + _blockSize - _streamPos;
- if(size == 0)
- return S_OK;
- UInt32 numReadBytes;
- RINOK(_stream->Read(_buffer + _streamPos, size, &numReadBytes));
- if(numReadBytes == 0)
- {
- _posLimit = _streamPos;
- const Byte *pointerToPostion = _buffer + _posLimit;
- if(pointerToPostion > _pointerToLastSafePosition)
- _posLimit = (UInt32)(_pointerToLastSafePosition - _buffer);
- _streamEndWasReached = true;
- return S_OK;
- }
- _streamPos += numReadBytes;
- if(_streamPos >= _pos + _keepSizeAfter)
- {
- _posLimit = _streamPos - _keepSizeAfter;
- return S_OK;
- }
- }
-}
-
-void CLZInWindow::MoveBlock()
-{
- UInt32 offset = (UInt32)(_buffer - _bufferBase) + _pos - _keepSizeBefore;
- // we need one additional byte, since MovePos moves on 1 byte.
- if (offset > 0)
- offset--;
- UInt32 numBytes = (UInt32)(_buffer - _bufferBase) + _streamPos - offset;
- memmove(_bufferBase, _bufferBase + offset, numBytes);
- _buffer -= offset;
-}
diff --git a/7zip/Compress/LZ/LZInWindow.h b/7zip/Compress/LZ/LZInWindow.h
deleted file mode 100755
index 20e0331b..00000000
--- a/7zip/Compress/LZ/LZInWindow.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// LZInWindow.h
-
-#ifndef __LZ_IN_WINDOW_H
-#define __LZ_IN_WINDOW_H
-
-#include "../../IStream.h"
-
-class CLZInWindow
-{
- Byte *_bufferBase; // pointer to buffer with data
- ISequentialInStream *_stream;
- UInt32 _posLimit; // offset (from _buffer) when new block reading must be done
- bool _streamEndWasReached; // if (true) then _streamPos shows real end of stream
- const Byte *_pointerToLastSafePosition;
-protected:
- Byte *_buffer; // Pointer to virtual Buffer begin
- UInt32 _blockSize; // Size of Allocated memory block
- UInt32 _pos; // offset (from _buffer) of curent byte
- UInt32 _keepSizeBefore; // how many BYTEs must be kept in buffer before _pos
- UInt32 _keepSizeAfter; // how many BYTEs must be kept buffer after _pos
- UInt32 _streamPos; // offset (from _buffer) of first not read byte from Stream
-
- void MoveBlock();
- HRESULT ReadBlock();
- void Free();
-public:
- CLZInWindow(): _bufferBase(0) {}
- virtual ~CLZInWindow() { Free(); }
-
- // keepSizeBefore + keepSizeAfter + keepSizeReserv < 4G)
- bool Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv = (1<<17));
-
- void SetStream(ISequentialInStream *stream);
- HRESULT Init();
- // void ReleaseStream();
-
- Byte *GetBuffer() const { return _buffer; }
-
- const Byte *GetPointerToCurrentPos() const { return _buffer + _pos; }
-
- HRESULT MovePos()
- {
- _pos++;
- if (_pos > _posLimit)
- {
- const Byte *pointerToPostion = _buffer + _pos;
- if(pointerToPostion > _pointerToLastSafePosition)
- MoveBlock();
- return ReadBlock();
- }
- else
- return S_OK;
- }
- Byte GetIndexByte(Int32 index) const { return _buffer[(size_t)_pos + index]; }
-
- // index + limit have not to exceed _keepSizeAfter;
- // -2G <= index < 2G
- UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) const
- {
- if(_streamEndWasReached)
- if ((_pos + index) + limit > _streamPos)
- limit = _streamPos - (_pos + index);
- distance++;
- const Byte *pby = _buffer + (size_t)_pos + index;
- UInt32 i;
- for(i = 0; i < limit && pby[i] == pby[(size_t)i - distance]; i++);
- return i;
- }
-
- UInt32 GetNumAvailableBytes() const { return _streamPos - _pos; }
-
- void ReduceOffsets(Int32 subValue)
- {
- _buffer += subValue;
- _posLimit -= subValue;
- _pos -= subValue;
- _streamPos -= subValue;
- }
-
- bool NeedMove(UInt32 numCheckBytes)
- {
- size_t reserv = (size_t)(_pointerToLastSafePosition - (_buffer + _pos));
- return (reserv <= numCheckBytes);
- }
-};
-
-#endif
diff --git a/7zip/Compress/LZ/MT/MT.cpp b/7zip/Compress/LZ/MT/MT.cpp
deleted file mode 100755
index b0ac456d..00000000
--- a/7zip/Compress/LZ/MT/MT.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-// MT.cpp
-
-#include "StdAfx.h"
-
-#include "../../../../Common/Alloc.h"
-
-#include "MT.h"
-
-static const UInt32 kBlockSize = (1 << 14);
-
-static DWORD WINAPI MFThread(void *threadCoderInfo)
-{
- return ((CMatchFinderMT *)threadCoderInfo)->ThreadFunc();
-}
-
-CMatchFinderMT::CMatchFinderMT():
- m_Buffer(0),
- m_NeedStart(true)
-{
- m_BlockIndex = kNumMTBlocks - 1;
- m_CS[m_BlockIndex].Enter();
- if (!m_Thread.Create(MFThread, this))
- throw 271826;
-}
-
-CMatchFinderMT::~CMatchFinderMT()
-{
- m_Exit = true;
- m_CS[m_BlockIndex].Leave();
- m_CanChangeBufferPos.Set();
- if (m_NeedStart)
- m_MtCanStart.Set();
- m_Thread.Wait();
- FreeMem();
-}
-
-void CMatchFinderMT::FreeMem()
-{
- ::MyFree(m_Buffer);
- m_Buffer = 0;
-}
-
-STDMETHODIMP CMatchFinderMT::Create(UInt32 sizeHistory, UInt32 keepAddBufferBefore,
- UInt32 matchMaxLen, UInt32 keepAddBufferAfter)
-{
- FreeMem();
- m_MatchMaxLen = matchMaxLen;
- if (kBlockSize <= matchMaxLen * 4)
- return E_INVALIDARG;
- UInt32 bufferSize = kBlockSize * kNumMTBlocks;
- m_Buffer = (UInt32 *)::MyAlloc(bufferSize * sizeof(UInt32));
- if (m_Buffer == 0)
- return E_OUTOFMEMORY;
- keepAddBufferBefore += bufferSize;
- keepAddBufferAfter += (kBlockSize + 1);
- return m_MatchFinder->Create(sizeHistory, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter);
-}
-
-// UInt32 blockSizeMult = 800
-HRESULT CMatchFinderMT::SetMatchFinder(IMatchFinder *matchFinder)
-{
- m_MatchFinder = matchFinder;
- return S_OK;
-}
-
-STDMETHODIMP CMatchFinderMT::SetStream(ISequentialInStream *s)
-{
- return m_MatchFinder->SetStream(s);
-}
-
-// Call it after ReleaseStream / SetStream
-STDMETHODIMP CMatchFinderMT::Init()
-{
- m_NeedStart = true;
- m_Pos = 0;
- m_PosLimit = 0;
-
- HRESULT result = m_MatchFinder->Init();
- if (result == S_OK)
- m_DataCurrentPos = m_MatchFinder->GetPointerToCurrentPos();
- m_NumAvailableBytes = m_MatchFinder->GetNumAvailableBytes();
- return result;
-}
-
-// ReleaseStream is required to finish multithreading
-STDMETHODIMP_(void) CMatchFinderMT::ReleaseStream()
-{
- m_StopWriting = true;
- m_CS[m_BlockIndex].Leave();
- if (!m_NeedStart)
- {
- m_CanChangeBufferPos.Set();
- m_MtWasStopped.Lock();
- m_NeedStart = true;
- }
- m_MatchFinder->ReleaseStream();
- m_BlockIndex = kNumMTBlocks - 1;
- m_CS[m_BlockIndex].Enter();
-}
-
-STDMETHODIMP_(Byte) CMatchFinderMT::GetIndexByte(Int32 index)
-{
- return m_DataCurrentPos[index];
-}
-
-STDMETHODIMP_(UInt32) CMatchFinderMT::GetMatchLen(Int32 index, UInt32 distance, UInt32 limit)
-{
- if ((Int32)(index + limit) > m_NumAvailableBytes)
- limit = m_NumAvailableBytes - (index);
- distance++;
- const Byte *pby = m_DataCurrentPos + index;
- UInt32 i;
- for(i = 0; i < limit && pby[i] == pby[(size_t)i - distance]; i++);
- return i;
-}
-
-STDMETHODIMP_(const Byte *) CMatchFinderMT::GetPointerToCurrentPos()
-{
- return m_DataCurrentPos;
-}
-
-STDMETHODIMP_(UInt32) CMatchFinderMT::GetNumAvailableBytes()
-{
- return m_NumAvailableBytes;
-}
-
-void CMatchFinderMT::GetNextBlock()
-{
- if (m_NeedStart)
- {
- m_NeedStart = false;
- for (UInt32 i = 0; i < kNumMTBlocks; i++)
- m_StopReading[i] = false;
- m_StopWriting = false;
- m_Exit = false;
- m_MtWasStarted.Reset();
- m_MtWasStopped.Reset();
- m_CanChangeBufferPos.Reset();
- m_BufferPosWasChanged.Reset();
- m_MtCanStart.Set();
- m_MtWasStarted.Lock();
- m_Result = S_OK;
- }
- for (;;)
- {
- UInt32 nextIndex = (m_BlockIndex == kNumMTBlocks - 1) ? 0 : m_BlockIndex + 1;
- m_CS[nextIndex].Enter();
- if (!m_StopReading[nextIndex])
- {
- m_CS[m_BlockIndex].Leave();
- m_BlockIndex = nextIndex;
- break;
- }
- m_StopReading[nextIndex] = false;
- m_CS[nextIndex].Leave();
- m_CanChangeBufferPos.Set();
- m_BufferPosWasChanged.Lock();
- m_CS[nextIndex].Enter();
- m_CS[m_BlockIndex].Leave();
- m_BlockIndex = nextIndex;
- }
- m_Pos = m_BlockIndex * kBlockSize;
- m_PosLimit = m_Buffer[m_Pos++];
- m_NumAvailableBytes = m_Buffer[m_Pos++];
- m_Result = m_Results[m_BlockIndex];
-}
-
-STDMETHODIMP CMatchFinderMT::GetMatches(UInt32 *distances)
-{
- if (m_Pos == m_PosLimit)
- GetNextBlock();
-
- if (m_Result != S_OK)
- return m_Result;
- m_NumAvailableBytes--;
- m_DataCurrentPos++;
-
- const UInt32 *buffer = m_Buffer + m_Pos;
- UInt32 len = *buffer++;
- *distances++ = len;
- m_Pos += 1 + len;
- for (UInt32 i = 0; i != len; i += 2)
- {
- distances[i] = buffer[i];
- distances[i + 1] = buffer[i + 1];
- }
- return S_OK;
-}
-
-STDMETHODIMP CMatchFinderMT::Skip(UInt32 num)
-{
- do
- {
- if (m_Pos == m_PosLimit)
- GetNextBlock();
-
- if (m_Result != S_OK)
- return m_Result;
- m_NumAvailableBytes--;
- m_DataCurrentPos++;
-
- UInt32 len = m_Buffer[m_Pos++];
- m_Pos += len;
- }
- while(--num != 0);
- return S_OK;
-}
-
-STDMETHODIMP_(Int32) CMatchFinderMT::NeedChangeBufferPos(UInt32 /* numCheckBytes */)
-{
- throw 1;
-}
-
-STDMETHODIMP_(void) CMatchFinderMT::ChangeBufferPos()
-{
- throw 1;
-}
-
-
-DWORD CMatchFinderMT::ThreadFunc()
-{
- for (;;)
- {
- bool needStartEvent = true;
- m_MtCanStart.Lock();
- HRESULT result = S_OK;
- UInt32 blockIndex = 0;
- for (;;)
- {
- m_CS[blockIndex].Enter();
- if (needStartEvent)
- {
- m_MtWasStarted.Set();
- needStartEvent = false;
- }
- else
- m_CS[(blockIndex == 0) ? kNumMTBlocks - 1 : blockIndex - 1].Leave();
- if (m_Exit)
- return 0;
- if (m_StopWriting)
- {
- m_MtWasStopped.Set();
- m_CS[blockIndex].Leave();
- break;
- }
- if (result == S_OK)
- {
- IMatchFinder *mf = m_MatchFinder;
- if (mf->NeedChangeBufferPos(kBlockSize) != 0)
- {
- // m_AskChangeBufferPos.Set();
- m_StopReading[blockIndex] = true;
- m_CS[blockIndex].Leave();
- m_CanChangeBufferPos.Lock();
- m_CS[blockIndex].Enter();
- const Byte *bufferPosBefore = mf->GetPointerToCurrentPos();
- mf->ChangeBufferPos();
- m_DataCurrentPos += mf->GetPointerToCurrentPos() - bufferPosBefore;
- m_BufferPosWasChanged.Set();
- }
- else
- {
- UInt32 curPos = blockIndex * kBlockSize;
- UInt32 limit = curPos + kBlockSize - m_MatchMaxLen - m_MatchMaxLen - 1;
- UInt32 *buffer = m_Buffer;
- m_Results[blockIndex] = S_OK;
- curPos++;
- UInt32 numAvailableBytes = mf->GetNumAvailableBytes();
- buffer[curPos++] = numAvailableBytes;
-
- while (numAvailableBytes-- != 0 && curPos < limit)
- {
- result = mf->GetMatches(buffer + curPos);
- if (result != S_OK)
- {
- m_Results[blockIndex] = result;
- break;
- }
- curPos += buffer[curPos] + 1;
- }
- buffer[blockIndex * kBlockSize] = curPos;
- }
- }
- else
- {
- UInt32 curPos = blockIndex * kBlockSize;
- m_Buffer[curPos] = curPos + 2; // size of buffer
- m_Buffer[curPos + 1] = 0; // NumAvailableBytes
- m_Results[blockIndex] = result; // error
- }
- if (++blockIndex == kNumMTBlocks)
- blockIndex = 0;
- }
- }
-}
diff --git a/7zip/Compress/LZ/MT/MT.h b/7zip/Compress/LZ/MT/MT.h
deleted file mode 100755
index 1ba7b7c9..00000000
--- a/7zip/Compress/LZ/MT/MT.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// LZ/MT.h
-
-#ifndef __LZ_MT_H
-#define __LZ_MT_H
-
-#include "../../../../Common/MyCom.h"
-
-#include "../../../../Windows/Thread.h"
-#include "../../../../Windows/Synchronization.h"
-
-#include "../../../ICoder.h"
-#include "../IMatchFinder.h"
-
-const UInt32 kNumMTBlocks = (1 << 6);
-
-class CMatchFinderMT:
- public IMatchFinder,
- public CMyUnknownImp
-{
- MY_UNKNOWN_IMP
-
- STDMETHOD(SetStream)(ISequentialInStream *inStream);
- STDMETHOD_(void, ReleaseStream)();
- STDMETHOD(Init)();
- STDMETHOD_(Byte, GetIndexByte)(Int32 index);
- STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 distance, UInt32 limit);
- STDMETHOD_(UInt32, GetNumAvailableBytes)();
- STDMETHOD_(const Byte *, GetPointerToCurrentPos)();
- STDMETHOD(Create)(UInt32 sizeHistory, UInt32 keepAddBufferBefore,
- UInt32 matchMaxLen, UInt32 keepAddBufferAfter);
- STDMETHOD(GetMatches)(UInt32 *distances);
- STDMETHOD(Skip)(UInt32 num);
-
- STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes);
- STDMETHOD_(void, ChangeBufferPos)();
-
- UInt32 m_Pos;
- UInt32 m_PosLimit;
- UInt32 m_MatchMaxLen;
-
- UInt32 *m_Buffer;
-
- bool m_NeedStart;
- UInt32 m_BlockIndex;
- HRESULT m_Result;
- UInt32 m_NumAvailableBytes;
- const Byte *m_DataCurrentPos;
-
- // Common variables
-
- CMyComPtr<IMatchFinder> m_MatchFinder;
- NWindows::CThread m_Thread;
- NWindows::NSynchronization::CAutoResetEvent m_MtCanStart;
- NWindows::NSynchronization::CAutoResetEvent m_MtWasStarted;
- NWindows::NSynchronization::CAutoResetEvent m_MtWasStopped;
- NWindows::NSynchronization::CAutoResetEvent m_CanChangeBufferPos;
- NWindows::NSynchronization::CAutoResetEvent m_BufferPosWasChanged;
-
- NWindows::NSynchronization::CCriticalSection m_CS[kNumMTBlocks];
-
- HRESULT m_Results[kNumMTBlocks];
- bool m_StopReading[kNumMTBlocks];
- bool m_Exit;
- bool m_StopWriting;
-
- ////////////////////////////
-
- void FreeMem();
- void GetNextBlock();
-public:
-
- DWORD ThreadFunc();
-
- CMatchFinderMT();
- ~CMatchFinderMT();
- HRESULT SetMatchFinder(IMatchFinder *matchFinder);
-};
-
-#endif
diff --git a/7zip/Compress/LZ/MT/StdAfx.h b/7zip/Compress/LZ/MT/StdAfx.h
deleted file mode 100755
index a2f1e97b..00000000
--- a/7zip/Compress/LZ/MT/StdAfx.h
+++ /dev/null
@@ -1,8 +0,0 @@
-// StdAfx.h
-
-#ifndef __STDAFX_H
-#define __STDAFX_H
-
-#include "../../../../Common/MyWindows.h"
-
-#endif
diff --git a/7zip/Compress/LZMA/DllExports.cpp b/7zip/Compress/LZMA/DllExports.cpp
deleted file mode 100755
index 92260f9b..00000000
--- a/7zip/Compress/LZMA/DllExports.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "../../../Common/MyInitGuid.h"
-#include "../../../Common/ComTry.h"
-#ifdef _WIN32
-#include "../../../Common/Alloc.h"
-#endif
-
-#include "LZMAEncoder.h"
-#include "LZMADecoder.h"
-// #include "../../../Common/CRC.h"
-
-// {23170F69-40C1-278B-0301-010000000000}
-DEFINE_GUID(CLSID_CLZMADecoder,
-0x23170F69, 0x40C1, 0x278B, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-// {23170F69-40C1-278B-0301-010000000100}
-DEFINE_GUID(CLSID_CLZMAEncoder,
-0x23170F69, 0x40C1, 0x278B, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD dwReason, LPVOID /*lpReserved*/)
-{
- if (dwReason == DLL_PROCESS_ATTACH)
- {
- // NCompress::NRangeCoder::g_PriceTables.Init();
- // CCRC::InitTable();
- #ifdef _WIN32
- SetLargePageSize();
- #endif
- }
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- // NCompress::NRangeCoder::g_PriceTables.Init();
- // CCRC::InitTable();
- COM_TRY_BEGIN
- *outObject = 0;
- int correctInterface = (*iid == IID_ICompressCoder);
- CMyComPtr<ICompressCoder> coder;
- if (*clsid == CLSID_CLZMADecoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NLZMA::CDecoder();
- }
- else if (*clsid == CLSID_CLZMAEncoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NLZMA::CEncoder();
- }
- else
- return CLASS_E_CLASSNOTAVAILABLE;
- *outObject = coder.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[] = { 0x03, 0x01, 0x01 };
- if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(L"LZMA")) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CLZMADecoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kEncoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CLZMAEncoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- return S_OK;
-}
-
diff --git a/7zip/Compress/LZMA/LZMA.dsp b/7zip/Compress/LZMA/LZMA.dsp
deleted file mode 100755
index 12842272..00000000
--- a/7zip/Compress/LZMA/LZMA.dsp
+++ /dev/null
@@ -1,387 +0,0 @@
-# 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 "_ST_MODE" /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 "_ST_MODE" /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=.\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=..\MatchFinders\IMatchFinder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\IStream.h
-# End Source File
-# End Group
-# Begin Group "LZ"
-
-# PROP Default_Filter ""
-# Begin Group "MT"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\LZ\MT\MT.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=..\LZ\MT\MT.h
-# End Source File
-# End Group
-# Begin Group "BT"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree3.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree4.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTreeMain.h
-# End Source File
-# End Group
-# Begin Group "HC"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\LZ\HashChain\HC4.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\HashChain\HCMain.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\LZ\IMatchFinder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZInWindow.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZInWindow.h
-# End Source File
-# 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\AlignedBuffer.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\AlignedBuffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\ComTry.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.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
-# Begin Source File
-
-SOURCE=..\..\..\Common\NewHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\NewHandler.h
-# End Source File
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Handle.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\Thread.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
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\LZMAEncoder.h
-# End Source File
-# End Target
-# End Project
diff --git a/7zip/Compress/LZMA/LZMAEncoder.cpp b/7zip/Compress/LZMA/LZMAEncoder.cpp
deleted file mode 100755
index 4f0bcf0f..00000000
--- a/7zip/Compress/LZMA/LZMAEncoder.cpp
+++ /dev/null
@@ -1,1565 +0,0 @@
-// LZMA/Encoder.cpp
-
-#include "StdAfx.h"
-
-#include "../../../Common/Defs.h"
-#include "../../Common/StreamUtils.h"
-
-#include "LZMAEncoder.h"
-
-// for minimal compressing code size define these:
-// #define COMPRESS_MF_BT
-// #define COMPRESS_MF_BT4
-
-#if !defined(COMPRESS_MF_BT) && !defined(COMPRESS_MF_HC)
-#define COMPRESS_MF_BT
-#define COMPRESS_MF_HC
-#endif
-
-#ifdef COMPRESS_MF_BT
-#if !defined(COMPRESS_MF_BT2) && !defined(COMPRESS_MF_BT3) && !defined(COMPRESS_MF_BT4)
-#define COMPRESS_MF_BT2
-#define COMPRESS_MF_BT3
-#define COMPRESS_MF_BT4
-#endif
-#ifdef COMPRESS_MF_BT2
-#include "../LZ/BinTree/BinTree2.h"
-#endif
-#ifdef COMPRESS_MF_BT3
-#include "../LZ/BinTree/BinTree3.h"
-#endif
-#ifdef COMPRESS_MF_BT4
-#include "../LZ/BinTree/BinTree4.h"
-#endif
-#endif
-
-#ifdef COMPRESS_MF_HC
-#include "../LZ/HashChain/HC4.h"
-#endif
-
-#ifdef COMPRESS_MF_MT
-#include "../LZ/MT/MT.h"
-#endif
-
-namespace NCompress {
-namespace NLZMA {
-
-const int kDefaultDictionaryLogSize = 22;
-const UInt32 kNumFastBytesDefault = 0x20;
-
-enum
-{
- kBT2,
- kBT3,
- kBT4,
- kHC4
-};
-
-static const wchar_t *kMatchFinderIDs[] =
-{
- L"BT2",
- L"BT3",
- L"BT4",
- L"HC4"
-};
-
-Byte g_FastPos[1 << 11];
-
-class CFastPosInit
-{
-public:
- CFastPosInit() { Init(); }
- void Init()
- {
- const Byte kFastSlots = 22;
- int c = 2;
- g_FastPos[0] = 0;
- g_FastPos[1] = 1;
-
- for (Byte slotFast = 2; slotFast < kFastSlots; slotFast++)
- {
- UInt32 k = (1 << ((slotFast >> 1) - 1));
- for (UInt32 j = 0; j < k; j++, c++)
- g_FastPos[c] = slotFast;
- }
- }
-} g_FastPosInit;
-
-
-void CLiteralEncoder2::Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol)
-{
- UInt32 context = 1;
- int i = 8;
- do
- {
- i--;
- UInt32 bit = (symbol >> i) & 1;
- _encoders[context].Encode(rangeEncoder, bit);
- context = (context << 1) | bit;
- }
- while(i != 0);
-}
-
-void CLiteralEncoder2::EncodeMatched(NRangeCoder::CEncoder *rangeEncoder,
- Byte matchByte, Byte symbol)
-{
- UInt32 context = 1;
- int i = 8;
- do
- {
- i--;
- UInt32 bit = (symbol >> i) & 1;
- UInt32 matchBit = (matchByte >> i) & 1;
- _encoders[0x100 + (matchBit << 8) + context].Encode(rangeEncoder, bit);
- context = (context << 1) | bit;
- if (matchBit != bit)
- {
- while(i != 0)
- {
- i--;
- UInt32 bit = (symbol >> i) & 1;
- _encoders[context].Encode(rangeEncoder, bit);
- context = (context << 1) | bit;
- }
- break;
- }
- }
- while(i != 0);
-}
-
-UInt32 CLiteralEncoder2::GetPrice(bool matchMode, Byte matchByte, Byte symbol) const
-{
- UInt32 price = 0;
- UInt32 context = 1;
- int i = 8;
- if (matchMode)
- {
- do
- {
- i--;
- UInt32 matchBit = (matchByte >> i) & 1;
- UInt32 bit = (symbol >> i) & 1;
- price += _encoders[0x100 + (matchBit << 8) + context].GetPrice(bit);
- context = (context << 1) | bit;
- if (matchBit != bit)
- break;
- }
- while (i != 0);
- }
- while(i != 0)
- {
- i--;
- UInt32 bit = (symbol >> i) & 1;
- price += _encoders[context].GetPrice(bit);
- context = (context << 1) | bit;
- }
- return price;
-};
-
-
-namespace NLength {
-
-void CEncoder::Init(UInt32 numPosStates)
-{
- _choice.Init();
- _choice2.Init();
- for (UInt32 posState = 0; posState < numPosStates; posState++)
- {
- _lowCoder[posState].Init();
- _midCoder[posState].Init();
- }
- _highCoder.Init();
-}
-
-void CEncoder::Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState)
-{
- if(symbol < kNumLowSymbols)
- {
- _choice.Encode(rangeEncoder, 0);
- _lowCoder[posState].Encode(rangeEncoder, symbol);
- }
- else
- {
- _choice.Encode(rangeEncoder, 1);
- if(symbol < kNumLowSymbols + kNumMidSymbols)
- {
- _choice2.Encode(rangeEncoder, 0);
- _midCoder[posState].Encode(rangeEncoder, symbol - kNumLowSymbols);
- }
- else
- {
- _choice2.Encode(rangeEncoder, 1);
- _highCoder.Encode(rangeEncoder, symbol - kNumLowSymbols - kNumMidSymbols);
- }
- }
-}
-
-void CEncoder::SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const
-{
- UInt32 a0 = _choice.GetPrice0();
- UInt32 a1 = _choice.GetPrice1();
- UInt32 b0 = a1 + _choice2.GetPrice0();
- UInt32 b1 = a1 + _choice2.GetPrice1();
- UInt32 i = 0;
- for (i = 0; i < kNumLowSymbols; i++)
- {
- if (i >= numSymbols)
- return;
- prices[i] = a0 + _lowCoder[posState].GetPrice(i);
- }
- for (; i < kNumLowSymbols + kNumMidSymbols; i++)
- {
- if (i >= numSymbols)
- return;
- prices[i] = b0 + _midCoder[posState].GetPrice(i - kNumLowSymbols);
- }
- for (; i < numSymbols; i++)
- prices[i] = b1 + _highCoder.GetPrice(i - kNumLowSymbols - kNumMidSymbols);
-}
-
-}
-CEncoder::CEncoder():
- _numFastBytes(kNumFastBytesDefault),
- _distTableSize(kDefaultDictionaryLogSize * 2),
- _posStateBits(2),
- _posStateMask(4 - 1),
- _numLiteralPosStateBits(0),
- _numLiteralContextBits(3),
- _dictionarySize(1 << kDefaultDictionaryLogSize),
- _dictionarySizePrev(UInt32(-1)),
- _numFastBytesPrev(UInt32(-1)),
- _matchFinderCycles(0),
- _matchFinderIndex(kBT4),
- #ifdef COMPRESS_MF_MT
- _multiThread(false),
- #endif
- _writeEndMark(false),
- setMfPasses(0)
-{
- // _maxMode = false;
- _fastMode = false;
-}
-
-HRESULT CEncoder::Create()
-{
- if (!_rangeEncoder.Create(1 << 20))
- return E_OUTOFMEMORY;
- if (!_matchFinder)
- {
- switch(_matchFinderIndex)
- {
- #ifdef COMPRESS_MF_BT
- #ifdef COMPRESS_MF_BT2
- case kBT2:
- {
- NBT2::CMatchFinder *mfSpec = new NBT2::CMatchFinder;
- setMfPasses = mfSpec;
- _matchFinder = mfSpec;
- break;
- }
- #endif
- #ifdef COMPRESS_MF_BT3
- case kBT3:
- {
- NBT3::CMatchFinder *mfSpec = new NBT3::CMatchFinder;
- setMfPasses = mfSpec;
- _matchFinder = mfSpec;
- break;
- }
- #endif
- #ifdef COMPRESS_MF_BT4
- case kBT4:
- {
- NBT4::CMatchFinder *mfSpec = new NBT4::CMatchFinder;
- setMfPasses = mfSpec;
- _matchFinder = mfSpec;
- break;
- }
- #endif
- #endif
-
- #ifdef COMPRESS_MF_HC
- case kHC4:
- {
- NHC4::CMatchFinder *mfSpec = new NHC4::CMatchFinder;
- setMfPasses = mfSpec;
- _matchFinder = mfSpec;
- break;
- }
- #endif
- }
- if (_matchFinder == 0)
- return E_OUTOFMEMORY;
-
- #ifdef COMPRESS_MF_MT
- if (_multiThread && !(_fastMode && (_matchFinderIndex == kHC4)))
- {
- CMatchFinderMT *mfSpec = new CMatchFinderMT;
- if (mfSpec == 0)
- return E_OUTOFMEMORY;
- CMyComPtr<IMatchFinder> mf = mfSpec;
- RINOK(mfSpec->SetMatchFinder(_matchFinder));
- _matchFinder.Release();
- _matchFinder = mf;
- }
- #endif
- }
-
- if (!_literalEncoder.Create(_numLiteralPosStateBits, _numLiteralContextBits))
- return E_OUTOFMEMORY;
-
- if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes)
- return S_OK;
- RINOK(_matchFinder->Create(_dictionarySize, kNumOpts, _numFastBytes, kMatchMaxLen + 1)); // actually it's + _numFastBytes - _numFastBytes
- if (_matchFinderCycles != 0 && setMfPasses != 0)
- setMfPasses->SetNumPasses(_matchFinderCycles);
- _dictionarySizePrev = _dictionarySize;
- _numFastBytesPrev = _numFastBytes;
- return S_OK;
-}
-
-static bool AreStringsEqual(const wchar_t *base, const wchar_t *testString)
-{
- for (;;)
- {
- wchar_t c = *testString;
- if (c >= 'a' && c <= 'z')
- c -= 0x20;
- if (*base != c)
- return false;
- if (c == 0)
- return true;
- base++;
- testString++;
- }
-}
-
-static int FindMatchFinder(const wchar_t *s)
-{
- for (int m = 0; m < (int)(sizeof(kMatchFinderIDs) / sizeof(kMatchFinderIDs[0])); m++)
- if (AreStringsEqual(kMatchFinderIDs[m], s))
- return m;
- return -1;
-}
-
-STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties)
-{
- for (UInt32 i = 0; i < numProperties; i++)
- {
- const PROPVARIANT &prop = properties[i];
- switch(propIDs[i])
- {
- case NCoderPropID::kNumFastBytes:
- {
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- UInt32 numFastBytes = prop.ulVal;
- if(numFastBytes < 5 || numFastBytes > kMatchMaxLen)
- return E_INVALIDARG;
- _numFastBytes = numFastBytes;
- break;
- }
- case NCoderPropID::kMatchFinderCycles:
- {
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- _matchFinderCycles = prop.ulVal;
- break;
- }
- case NCoderPropID::kAlgorithm:
- {
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- UInt32 maximize = prop.ulVal;
- _fastMode = (maximize == 0);
- // _maxMode = (maximize >= 2);
- break;
- }
- case NCoderPropID::kMatchFinder:
- {
- if (prop.vt != VT_BSTR)
- return E_INVALIDARG;
- int matchFinderIndexPrev = _matchFinderIndex;
- int m = FindMatchFinder(prop.bstrVal);
- if (m < 0)
- return E_INVALIDARG;
- _matchFinderIndex = m;
- if (_matchFinder && matchFinderIndexPrev != _matchFinderIndex)
- {
- _dictionarySizePrev = (UInt32)-1;
- ReleaseMatchFinder();
- }
- break;
- }
- #ifdef COMPRESS_MF_MT
- case NCoderPropID::kMultiThread:
- {
- if (prop.vt != VT_BOOL)
- return E_INVALIDARG;
- bool newMultiThread = (prop.boolVal == VARIANT_TRUE);
- if (newMultiThread != _multiThread)
- {
- _dictionarySizePrev = (UInt32)-1;
- ReleaseMatchFinder();
- _multiThread = newMultiThread;
- }
- break;
- }
- case NCoderPropID::kNumThreads:
- {
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- bool newMultiThread = (prop.ulVal > 1);
- if (newMultiThread != _multiThread)
- {
- _dictionarySizePrev = (UInt32)-1;
- ReleaseMatchFinder();
- _multiThread = newMultiThread;
- }
- break;
- }
- #endif
- case NCoderPropID::kDictionarySize:
- {
- const int kDicLogSizeMaxCompress = 30;
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- UInt32 dictionarySize = prop.ulVal;
- if (dictionarySize < UInt32(1 << kDicLogSizeMin) ||
- dictionarySize > UInt32(1 << kDicLogSizeMaxCompress))
- return E_INVALIDARG;
- _dictionarySize = dictionarySize;
- UInt32 dicLogSize;
- for(dicLogSize = 0; dicLogSize < (UInt32)kDicLogSizeMaxCompress; dicLogSize++)
- if (dictionarySize <= (UInt32(1) << dicLogSize))
- break;
- _distTableSize = dicLogSize * 2;
- break;
- }
- case NCoderPropID::kPosStateBits:
- {
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- UInt32 value = prop.ulVal;
- if (value > (UInt32)NLength::kNumPosStatesBitsEncodingMax)
- return E_INVALIDARG;
- _posStateBits = value;
- _posStateMask = (1 << _posStateBits) - 1;
- break;
- }
- case NCoderPropID::kLitPosBits:
- {
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- UInt32 value = prop.ulVal;
- if (value > (UInt32)kNumLitPosStatesBitsEncodingMax)
- return E_INVALIDARG;
- _numLiteralPosStateBits = value;
- break;
- }
- case NCoderPropID::kLitContextBits:
- {
- if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- UInt32 value = prop.ulVal;
- if (value > (UInt32)kNumLitContextBitsMax)
- return E_INVALIDARG;
- _numLiteralContextBits = value;
- break;
- }
- case NCoderPropID::kEndMarker:
- {
- if (prop.vt != VT_BOOL)
- return E_INVALIDARG;
- SetWriteEndMarkerMode(prop.boolVal == VARIANT_TRUE);
- break;
- }
- default:
- return E_INVALIDARG;
- }
- }
- return S_OK;
-}
-
-STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
-{
- const UInt32 kPropSize = 5;
- Byte properties[kPropSize];
- properties[0] = (Byte)((_posStateBits * 5 + _numLiteralPosStateBits) * 9 + _numLiteralContextBits);
- for (int i = 0; i < 4; i++)
- properties[1 + i] = Byte(_dictionarySize >> (8 * i));
- return WriteStream(outStream, properties, kPropSize, NULL);
-}
-
-STDMETHODIMP CEncoder::SetOutStream(ISequentialOutStream *outStream)
-{
- _rangeEncoder.SetStream(outStream);
- return S_OK;
-}
-
-STDMETHODIMP CEncoder::ReleaseOutStream()
-{
- _rangeEncoder.ReleaseStream();
- return S_OK;
-}
-
-HRESULT CEncoder::Init()
-{
- CBaseState::Init();
-
- // RINOK(_matchFinder->Init(inStream));
- _rangeEncoder.Init();
-
- for(int i = 0; i < kNumStates; i++)
- {
- for (UInt32 j = 0; j <= _posStateMask; j++)
- {
- _isMatch[i][j].Init();
- _isRep0Long[i][j].Init();
- }
- _isRep[i].Init();
- _isRepG0[i].Init();
- _isRepG1[i].Init();
- _isRepG2[i].Init();
- }
-
- _literalEncoder.Init();
-
- {
- for(UInt32 i = 0; i < kNumLenToPosStates; i++)
- _posSlotEncoder[i].Init();
- }
- {
- for(UInt32 i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
- _posEncoders[i].Init();
- }
-
- _lenEncoder.Init(1 << _posStateBits);
- _repMatchLenEncoder.Init(1 << _posStateBits);
-
- _posAlignEncoder.Init();
-
- _longestMatchWasFound = false;
- _optimumEndIndex = 0;
- _optimumCurrentIndex = 0;
- _additionalOffset = 0;
-
- return S_OK;
-}
-
-HRESULT CEncoder::MovePos(UInt32 num)
-{
- if (num == 0)
- return S_OK;
- _additionalOffset += num;
- return _matchFinder->Skip(num);
-}
-
-UInt32 CEncoder::Backward(UInt32 &backRes, UInt32 cur)
-{
- _optimumEndIndex = cur;
- UInt32 posMem = _optimum[cur].PosPrev;
- UInt32 backMem = _optimum[cur].BackPrev;
- do
- {
- if (_optimum[cur].Prev1IsChar)
- {
- _optimum[posMem].MakeAsChar();
- _optimum[posMem].PosPrev = posMem - 1;
- if (_optimum[cur].Prev2)
- {
- _optimum[posMem - 1].Prev1IsChar = false;
- _optimum[posMem - 1].PosPrev = _optimum[cur].PosPrev2;
- _optimum[posMem - 1].BackPrev = _optimum[cur].BackPrev2;
- }
- }
- UInt32 posPrev = posMem;
- UInt32 backCur = backMem;
-
- backMem = _optimum[posPrev].BackPrev;
- posMem = _optimum[posPrev].PosPrev;
-
- _optimum[posPrev].BackPrev = backCur;
- _optimum[posPrev].PosPrev = cur;
- cur = posPrev;
- }
- while(cur != 0);
- backRes = _optimum[0].BackPrev;
- _optimumCurrentIndex = _optimum[0].PosPrev;
- return _optimumCurrentIndex;
-}
-
-/*
-Out:
- (lenRes == 1) && (backRes == 0xFFFFFFFF) means Literal
-*/
-
-HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
-{
- if(_optimumEndIndex != _optimumCurrentIndex)
- {
- const COptimal &optimum = _optimum[_optimumCurrentIndex];
- lenRes = optimum.PosPrev - _optimumCurrentIndex;
- backRes = optimum.BackPrev;
- _optimumCurrentIndex = optimum.PosPrev;
- return S_OK;
- }
- _optimumCurrentIndex = _optimumEndIndex = 0;
-
- UInt32 lenMain, numDistancePairs;
- if (!_longestMatchWasFound)
- {
- RINOK(ReadMatchDistances(lenMain, numDistancePairs));
- }
- else
- {
- lenMain = _longestMatchLength;
- numDistancePairs = _numDistancePairs;
- _longestMatchWasFound = false;
- }
-
- const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
- UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;
- if (numAvailableBytes < 2)
- {
- backRes = (UInt32)(-1);
- lenRes = 1;
- return S_OK;
- }
- if (numAvailableBytes > kMatchMaxLen)
- numAvailableBytes = kMatchMaxLen;
-
- UInt32 reps[kNumRepDistances];
- UInt32 repLens[kNumRepDistances];
- UInt32 repMaxIndex = 0;
- UInt32 i;
- for(i = 0; i < kNumRepDistances; i++)
- {
- reps[i] = _repDistances[i];
- UInt32 backOffset = reps[i] + 1;
- if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
- {
- repLens[i] = 0;
- continue;
- }
- UInt32 lenTest;
- for (lenTest = 2; lenTest < numAvailableBytes &&
- data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
- repLens[i] = lenTest;
- if (lenTest > repLens[repMaxIndex])
- repMaxIndex = i;
- }
- if(repLens[repMaxIndex] >= _numFastBytes)
- {
- backRes = repMaxIndex;
- lenRes = repLens[repMaxIndex];
- return MovePos(lenRes - 1);
- }
-
- UInt32 *matchDistances = _matchDistances + 1;
- if(lenMain >= _numFastBytes)
- {
- backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances;
- lenRes = lenMain;
- return MovePos(lenMain - 1);
- }
- Byte currentByte = *data;
- Byte matchByte = data[(size_t)0 - reps[0] - 1];
-
- if(lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2)
- {
- backRes = (UInt32)-1;
- lenRes = 1;
- return S_OK;
- }
-
- _optimum[0].State = _state;
-
- UInt32 posState = (position & _posStateMask);
-
- _optimum[1].Price = _isMatch[_state.Index][posState].GetPrice0() +
- _literalEncoder.GetSubCoder(position, _previousByte)->GetPrice(!_state.IsCharState(), matchByte, currentByte);
- _optimum[1].MakeAsChar();
-
- UInt32 matchPrice = _isMatch[_state.Index][posState].GetPrice1();
- UInt32 repMatchPrice = matchPrice + _isRep[_state.Index].GetPrice1();
-
- if(matchByte == currentByte)
- {
- UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(_state, posState);
- if(shortRepPrice < _optimum[1].Price)
- {
- _optimum[1].Price = shortRepPrice;
- _optimum[1].MakeAsShortRep();
- }
- }
- UInt32 lenEnd = ((lenMain >= repLens[repMaxIndex]) ? lenMain : repLens[repMaxIndex]);
-
- if(lenEnd < 2)
- {
- backRes = _optimum[1].BackPrev;
- lenRes = 1;
- return S_OK;
- }
-
- _optimum[1].PosPrev = 0;
- for (i = 0; i < kNumRepDistances; i++)
- _optimum[0].Backs[i] = reps[i];
-
- UInt32 len = lenEnd;
- do
- _optimum[len--].Price = kIfinityPrice;
- while (len >= 2);
-
- for(i = 0; i < kNumRepDistances; i++)
- {
- UInt32 repLen = repLens[i];
- if (repLen < 2)
- continue;
- UInt32 price = repMatchPrice + GetPureRepPrice(i, _state, posState);
- do
- {
- UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(repLen - 2, posState);
- COptimal &optimum = _optimum[repLen];
- if (curAndLenPrice < optimum.Price)
- {
- optimum.Price = curAndLenPrice;
- optimum.PosPrev = 0;
- optimum.BackPrev = i;
- optimum.Prev1IsChar = false;
- }
- }
- while(--repLen >= 2);
- }
-
- UInt32 normalMatchPrice = matchPrice + _isRep[_state.Index].GetPrice0();
-
- len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);
- if (len <= lenMain)
- {
- UInt32 offs = 0;
- while (len > matchDistances[offs])
- offs += 2;
- for(; ; len++)
- {
- UInt32 distance = matchDistances[offs + 1];
- UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState);
- COptimal &optimum = _optimum[len];
- if (curAndLenPrice < optimum.Price)
- {
- optimum.Price = curAndLenPrice;
- optimum.PosPrev = 0;
- optimum.BackPrev = distance + kNumRepDistances;
- optimum.Prev1IsChar = false;
- }
- if (len == matchDistances[offs])
- {
- offs += 2;
- if (offs == numDistancePairs)
- break;
- }
- }
- }
-
- UInt32 cur = 0;
-
- for (;;)
- {
- cur++;
- if(cur == lenEnd)
- {
- lenRes = Backward(backRes, cur);
- return S_OK;
- }
- UInt32 newLen, numDistancePairs;
- RINOK(ReadMatchDistances(newLen, numDistancePairs));
- if(newLen >= _numFastBytes)
- {
- _numDistancePairs = numDistancePairs;
- _longestMatchLength = newLen;
- _longestMatchWasFound = true;
- lenRes = Backward(backRes, cur);
- return S_OK;
- }
- position++;
- COptimal &curOptimum = _optimum[cur];
- UInt32 posPrev = curOptimum.PosPrev;
- CState state;
- if (curOptimum.Prev1IsChar)
- {
- posPrev--;
- if (curOptimum.Prev2)
- {
- state = _optimum[curOptimum.PosPrev2].State;
- if (curOptimum.BackPrev2 < kNumRepDistances)
- state.UpdateRep();
- else
- state.UpdateMatch();
- }
- else
- state = _optimum[posPrev].State;
- state.UpdateChar();
- }
- else
- state = _optimum[posPrev].State;
- if (posPrev == cur - 1)
- {
- if (curOptimum.IsShortRep())
- state.UpdateShortRep();
- else
- state.UpdateChar();
- }
- else
- {
- UInt32 pos;
- if (curOptimum.Prev1IsChar && curOptimum.Prev2)
- {
- posPrev = curOptimum.PosPrev2;
- pos = curOptimum.BackPrev2;
- state.UpdateRep();
- }
- else
- {
- pos = curOptimum.BackPrev;
- if (pos < kNumRepDistances)
- state.UpdateRep();
- else
- state.UpdateMatch();
- }
- const COptimal &prevOptimum = _optimum[posPrev];
- if (pos < kNumRepDistances)
- {
- reps[0] = prevOptimum.Backs[pos];
- UInt32 i;
- for(i = 1; i <= pos; i++)
- reps[i] = prevOptimum.Backs[i - 1];
- for(; i < kNumRepDistances; i++)
- reps[i] = prevOptimum.Backs[i];
- }
- else
- {
- reps[0] = (pos - kNumRepDistances);
- for(UInt32 i = 1; i < kNumRepDistances; i++)
- reps[i] = prevOptimum.Backs[i - 1];
- }
- }
- curOptimum.State = state;
- for(UInt32 i = 0; i < kNumRepDistances; i++)
- curOptimum.Backs[i] = reps[i];
- UInt32 curPrice = curOptimum.Price;
- const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
- const Byte currentByte = *data;
- const Byte matchByte = data[(size_t)0 - reps[0] - 1];
-
- UInt32 posState = (position & _posStateMask);
-
- UInt32 curAnd1Price = curPrice +
- _isMatch[state.Index][posState].GetPrice0() +
- _literalEncoder.GetSubCoder(position, data[(size_t)0 - 1])->GetPrice(!state.IsCharState(), matchByte, currentByte);
-
- COptimal &nextOptimum = _optimum[cur + 1];
-
- bool nextIsChar = false;
- if (curAnd1Price < nextOptimum.Price)
- {
- nextOptimum.Price = curAnd1Price;
- nextOptimum.PosPrev = cur;
- nextOptimum.MakeAsChar();
- nextIsChar = true;
- }
-
- UInt32 matchPrice = curPrice + _isMatch[state.Index][posState].GetPrice1();
- UInt32 repMatchPrice = matchPrice + _isRep[state.Index].GetPrice1();
-
- if(matchByte == currentByte &&
- !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0))
- {
- UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(state, posState);
- if(shortRepPrice <= nextOptimum.Price)
- {
- nextOptimum.Price = shortRepPrice;
- nextOptimum.PosPrev = cur;
- nextOptimum.MakeAsShortRep();
- nextIsChar = true;
- }
- }
- /*
- if(newLen == 2 && matchDistances[2] >= kDistLimit2) // test it maybe set 2000 ?
- continue;
- */
-
- UInt32 numAvailableBytesFull = _matchFinder->GetNumAvailableBytes() + 1;
- numAvailableBytesFull = MyMin(kNumOpts - 1 - cur, numAvailableBytesFull);
- UInt32 numAvailableBytes = numAvailableBytesFull;
-
- if (numAvailableBytes < 2)
- continue;
- if (numAvailableBytes > _numFastBytes)
- numAvailableBytes = _numFastBytes;
- if (!nextIsChar && matchByte != currentByte) // speed optimization
- {
- // try Literal + rep0
- UInt32 backOffset = reps[0] + 1;
- UInt32 limit = MyMin(numAvailableBytesFull, _numFastBytes + 1);
- UInt32 temp;
- for (temp = 1; temp < limit &&
- data[temp] == data[(size_t)temp - backOffset]; temp++);
- UInt32 lenTest2 = temp - 1;
- if (lenTest2 >= 2)
- {
- CState state2 = state;
- state2.UpdateChar();
- UInt32 posStateNext = (position + 1) & _posStateMask;
- UInt32 nextRepMatchPrice = curAnd1Price +
- _isMatch[state2.Index][posStateNext].GetPrice1() +
- _isRep[state2.Index].GetPrice1();
- // for (; lenTest2 >= 2; lenTest2--)
- {
- UInt32 offset = cur + 1 + lenTest2;
- while(lenEnd < offset)
- _optimum[++lenEnd].Price = kIfinityPrice;
- UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(
- 0, lenTest2, state2, posStateNext);
- COptimal &optimum = _optimum[offset];
- if (curAndLenPrice < optimum.Price)
- {
- optimum.Price = curAndLenPrice;
- optimum.PosPrev = cur + 1;
- optimum.BackPrev = 0;
- optimum.Prev1IsChar = true;
- optimum.Prev2 = false;
- }
- }
- }
- }
-
- UInt32 startLen = 2; // speed optimization
- for(UInt32 repIndex = 0; repIndex < kNumRepDistances; repIndex++)
- {
- // UInt32 repLen = _matchFinder->GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;
- UInt32 backOffset = reps[repIndex] + 1;
- if (data[0] != data[(size_t)0 - backOffset] ||
- data[1] != data[(size_t)1 - backOffset])
- continue;
- UInt32 lenTest;
- for (lenTest = 2; lenTest < numAvailableBytes &&
- data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
- while(lenEnd < cur + lenTest)
- _optimum[++lenEnd].Price = kIfinityPrice;
- UInt32 lenTestTemp = lenTest;
- UInt32 price = repMatchPrice + GetPureRepPrice(repIndex, state, posState);
- do
- {
- UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState);
- COptimal &optimum = _optimum[cur + lenTest];
- if (curAndLenPrice < optimum.Price)
- {
- optimum.Price = curAndLenPrice;
- optimum.PosPrev = cur;
- optimum.BackPrev = repIndex;
- optimum.Prev1IsChar = false;
- }
- }
- while(--lenTest >= 2);
- lenTest = lenTestTemp;
-
- if (repIndex == 0)
- startLen = lenTest + 1;
-
- // if (_maxMode)
- {
- UInt32 lenTest2 = lenTest + 1;
- UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
- for (; lenTest2 < limit &&
- data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
- lenTest2 -= lenTest + 1;
- if (lenTest2 >= 2)
- {
- CState state2 = state;
- state2.UpdateRep();
- UInt32 posStateNext = (position + lenTest) & _posStateMask;
- UInt32 curAndLenCharPrice =
- price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState) +
- _isMatch[state2.Index][posStateNext].GetPrice0() +
- _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(
- true, data[(size_t)lenTest - backOffset], data[lenTest]);
- state2.UpdateChar();
- posStateNext = (position + lenTest + 1) & _posStateMask;
- UInt32 nextRepMatchPrice = curAndLenCharPrice +
- _isMatch[state2.Index][posStateNext].GetPrice1() +
- _isRep[state2.Index].GetPrice1();
-
- // for(; lenTest2 >= 2; lenTest2--)
- {
- UInt32 offset = cur + lenTest + 1 + lenTest2;
- while(lenEnd < offset)
- _optimum[++lenEnd].Price = kIfinityPrice;
- UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(
- 0, lenTest2, state2, posStateNext);
- COptimal &optimum = _optimum[offset];
- if (curAndLenPrice < optimum.Price)
- {
- optimum.Price = curAndLenPrice;
- optimum.PosPrev = cur + lenTest + 1;
- optimum.BackPrev = 0;
- optimum.Prev1IsChar = true;
- optimum.Prev2 = true;
- optimum.PosPrev2 = cur;
- optimum.BackPrev2 = repIndex;
- }
- }
- }
- }
- }
-
- // for(UInt32 lenTest = 2; lenTest <= newLen; lenTest++)
- if (newLen > numAvailableBytes)
- {
- newLen = numAvailableBytes;
- for (numDistancePairs = 0; newLen > matchDistances[numDistancePairs]; numDistancePairs += 2);
- matchDistances[numDistancePairs] = newLen;
- numDistancePairs += 2;
- }
- if (newLen >= startLen)
- {
- UInt32 normalMatchPrice = matchPrice + _isRep[state.Index].GetPrice0();
- while(lenEnd < cur + newLen)
- _optimum[++lenEnd].Price = kIfinityPrice;
-
- UInt32 offs = 0;
- while(startLen > matchDistances[offs])
- offs += 2;
- UInt32 curBack = matchDistances[offs + 1];
- UInt32 posSlot = GetPosSlot2(curBack);
- for(UInt32 lenTest = /*2*/ startLen; ; lenTest++)
- {
- UInt32 curAndLenPrice = normalMatchPrice;
- UInt32 lenToPosState = GetLenToPosState(lenTest);
- if (curBack < kNumFullDistances)
- curAndLenPrice += _distancesPrices[lenToPosState][curBack];
- else
- curAndLenPrice += _posSlotPrices[lenToPosState][posSlot] + _alignPrices[curBack & kAlignMask];
-
- curAndLenPrice += _lenEncoder.GetPrice(lenTest - kMatchMinLen, posState);
-
- COptimal &optimum = _optimum[cur + lenTest];
- if (curAndLenPrice < optimum.Price)
- {
- optimum.Price = curAndLenPrice;
- optimum.PosPrev = cur;
- optimum.BackPrev = curBack + kNumRepDistances;
- optimum.Prev1IsChar = false;
- }
-
- if (/*_maxMode && */lenTest == matchDistances[offs])
- {
- // Try Match + Literal + Rep0
- UInt32 backOffset = curBack + 1;
- UInt32 lenTest2 = lenTest + 1;
- UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
- for (; lenTest2 < limit &&
- data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
- lenTest2 -= lenTest + 1;
- if (lenTest2 >= 2)
- {
- CState state2 = state;
- state2.UpdateMatch();
- UInt32 posStateNext = (position + lenTest) & _posStateMask;
- UInt32 curAndLenCharPrice = curAndLenPrice +
- _isMatch[state2.Index][posStateNext].GetPrice0() +
- _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(
- true, data[(size_t)lenTest - backOffset], data[lenTest]);
- state2.UpdateChar();
- posStateNext = (posStateNext + 1) & _posStateMask;
- UInt32 nextRepMatchPrice = curAndLenCharPrice +
- _isMatch[state2.Index][posStateNext].GetPrice1() +
- _isRep[state2.Index].GetPrice1();
-
- // for(; lenTest2 >= 2; lenTest2--)
- {
- UInt32 offset = cur + lenTest + 1 + lenTest2;
- while(lenEnd < offset)
- _optimum[++lenEnd].Price = kIfinityPrice;
- UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext);
- COptimal &optimum = _optimum[offset];
- if (curAndLenPrice < optimum.Price)
- {
- optimum.Price = curAndLenPrice;
- optimum.PosPrev = cur + lenTest + 1;
- optimum.BackPrev = 0;
- optimum.Prev1IsChar = true;
- optimum.Prev2 = true;
- optimum.PosPrev2 = cur;
- optimum.BackPrev2 = curBack + kNumRepDistances;
- }
- }
- }
- offs += 2;
- if (offs == numDistancePairs)
- break;
- curBack = matchDistances[offs + 1];
- if (curBack >= kNumFullDistances)
- posSlot = GetPosSlot2(curBack);
- }
- }
- }
- }
-}
-
-static inline bool ChangePair(UInt32 smallDist, UInt32 bigDist)
-{
- return ((bigDist >> 7) > smallDist);
-}
-
-
-HRESULT CEncoder::ReadMatchDistances(UInt32 &lenRes, UInt32 &numDistancePairs)
-{
- lenRes = 0;
- RINOK(_matchFinder->GetMatches(_matchDistances));
- numDistancePairs = _matchDistances[0];
- if (numDistancePairs > 0)
- {
- lenRes = _matchDistances[1 + numDistancePairs - 2];
- if (lenRes == _numFastBytes)
- lenRes += _matchFinder->GetMatchLen(lenRes - 1, _matchDistances[1 + numDistancePairs - 1],
- kMatchMaxLen - lenRes);
- }
- _additionalOffset++;
- return S_OK;
-}
-
-HRESULT CEncoder::GetOptimumFast(UInt32 &backRes, UInt32 &lenRes)
-{
- UInt32 lenMain, numDistancePairs;
- if (!_longestMatchWasFound)
- {
- RINOK(ReadMatchDistances(lenMain, numDistancePairs));
- }
- else
- {
- lenMain = _longestMatchLength;
- numDistancePairs = _numDistancePairs;
- _longestMatchWasFound = false;
- }
-
- const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
- UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;
- if (numAvailableBytes > kMatchMaxLen)
- numAvailableBytes = kMatchMaxLen;
- if (numAvailableBytes < 2)
- {
- backRes = (UInt32)(-1);
- lenRes = 1;
- return S_OK;
- }
-
- UInt32 repLens[kNumRepDistances];
- UInt32 repMaxIndex = 0;
-
- for(UInt32 i = 0; i < kNumRepDistances; i++)
- {
- UInt32 backOffset = _repDistances[i] + 1;
- if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
- {
- repLens[i] = 0;
- continue;
- }
- UInt32 len;
- for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
- if(len >= _numFastBytes)
- {
- backRes = i;
- lenRes = len;
- return MovePos(lenRes - 1);
- }
- repLens[i] = len;
- if (len > repLens[repMaxIndex])
- repMaxIndex = i;
- }
- UInt32 *matchDistances = _matchDistances + 1;
- if(lenMain >= _numFastBytes)
- {
- backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances;
- lenRes = lenMain;
- return MovePos(lenMain - 1);
- }
-
- UInt32 backMain = 0; // for GCC
- if (lenMain >= 2)
- {
- backMain = matchDistances[numDistancePairs - 1];
- while (numDistancePairs > 2 && lenMain == matchDistances[numDistancePairs - 4] + 1)
- {
- if (!ChangePair(matchDistances[numDistancePairs - 3], backMain))
- break;
- numDistancePairs -= 2;
- lenMain = matchDistances[numDistancePairs - 2];
- backMain = matchDistances[numDistancePairs - 1];
- }
- if (lenMain == 2 && backMain >= 0x80)
- lenMain = 1;
- }
-
- if (repLens[repMaxIndex] >= 2)
- {
- if (repLens[repMaxIndex] + 1 >= lenMain ||
- repLens[repMaxIndex] + 2 >= lenMain && (backMain > (1 << 9)) ||
- repLens[repMaxIndex] + 3 >= lenMain && (backMain > (1 << 15)))
- {
- backRes = repMaxIndex;
- lenRes = repLens[repMaxIndex];
- return MovePos(lenRes - 1);
- }
- }
-
- if (lenMain >= 2 && numAvailableBytes > 2)
- {
- RINOK(ReadMatchDistances(_longestMatchLength, _numDistancePairs));
- if (_longestMatchLength >= 2)
- {
- UInt32 newDistance = matchDistances[_numDistancePairs - 1];
- if (_longestMatchLength >= lenMain && newDistance < backMain ||
- _longestMatchLength == lenMain + 1 && !ChangePair(backMain, newDistance) ||
- _longestMatchLength > lenMain + 1 ||
- _longestMatchLength + 1 >= lenMain && lenMain >= 3 && ChangePair(newDistance, backMain))
- {
- _longestMatchWasFound = true;
- backRes = UInt32(-1);
- lenRes = 1;
- return S_OK;
- }
- }
- data++;
- numAvailableBytes--;
- for(UInt32 i = 0; i < kNumRepDistances; i++)
- {
- UInt32 backOffset = _repDistances[i] + 1;
- if (data[1] != data[(size_t)1 - backOffset] || data[2] != data[(size_t)2 - backOffset])
- {
- repLens[i] = 0;
- continue;
- }
- UInt32 len;
- for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
- if (len + 1 >= lenMain)
- {
- _longestMatchWasFound = true;
- backRes = UInt32(-1);
- lenRes = 1;
- return S_OK;
- }
- }
- backRes = backMain + kNumRepDistances;
- lenRes = lenMain;
- return MovePos(lenMain - 2);
- }
- backRes = UInt32(-1);
- lenRes = 1;
- return S_OK;
-}
-
-HRESULT CEncoder::Flush(UInt32 nowPos)
-{
- ReleaseMFStream();
- WriteEndMarker(nowPos & _posStateMask);
- _rangeEncoder.FlushData();
- return _rangeEncoder.FlushStream();
-}
-
-void CEncoder::WriteEndMarker(UInt32 posState)
-{
- // This function for writing End Mark for stream version of LZMA.
- // In current version this feature is not used.
- if (!_writeEndMark)
- return;
-
- _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);
- _isRep[_state.Index].Encode(&_rangeEncoder, 0);
- _state.UpdateMatch();
- UInt32 len = kMatchMinLen; // kMatchMaxLen;
- _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
- UInt32 posSlot = (1 << kNumPosSlotBits) - 1;
- UInt32 lenToPosState = GetLenToPosState(len);
- _posSlotEncoder[lenToPosState].Encode(&_rangeEncoder, posSlot);
- UInt32 footerBits = 30;
- UInt32 posReduced = (UInt32(1) << footerBits) - 1;
- _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
- _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);
-}
-
-HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- _needReleaseMFStream = false;
- CCoderReleaser coderReleaser(this);
- RINOK(SetStreams(inStream, outStream, inSize, outSize));
- for (;;)
- {
- UInt64 processedInSize;
- UInt64 processedOutSize;
- Int32 finished;
- RINOK(CodeOneBlock(&processedInSize, &processedOutSize, &finished));
- if (finished != 0)
- break;
- if (progress != 0)
- {
- RINOK(progress->SetRatioInfo(&processedInSize, &processedOutSize));
- }
- }
- return S_OK;
-}
-
-HRESULT CEncoder::SetStreams(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 * /* inSize */, const UInt64 * /* outSize */)
-{
- _inStream = inStream;
- _finished = false;
- RINOK(Create());
- RINOK(SetOutStream(outStream));
- RINOK(Init());
-
- // CCoderReleaser releaser(this);
-
- /*
- if (_matchFinder->GetNumAvailableBytes() == 0)
- return Flush();
- */
-
- if (!_fastMode)
- {
- FillDistancesPrices();
- FillAlignPrices();
- }
-
- _lenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
- _lenEncoder.UpdateTables(1 << _posStateBits);
- _repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
- _repMatchLenEncoder.UpdateTables(1 << _posStateBits);
-
- nowPos64 = 0;
- return S_OK;
-}
-
-HRESULT CEncoder::CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished)
-{
- if (_inStream != 0)
- {
- RINOK(_matchFinder->SetStream(_inStream));
- RINOK(_matchFinder->Init());
- _needReleaseMFStream = true;
- _inStream = 0;
- }
-
-
- *finished = 1;
- if (_finished)
- return S_OK;
- _finished = true;
-
- if (nowPos64 == 0)
- {
- if (_matchFinder->GetNumAvailableBytes() == 0)
- return Flush(UInt32(nowPos64));
- UInt32 len, numDistancePairs;
- RINOK(ReadMatchDistances(len, numDistancePairs));
- UInt32 posState = UInt32(nowPos64) & _posStateMask;
- _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);
- _state.UpdateChar();
- Byte curByte = _matchFinder->GetIndexByte(0 - _additionalOffset);
- _literalEncoder.GetSubCoder(UInt32(nowPos64), _previousByte)->Encode(&_rangeEncoder, curByte);
- _previousByte = curByte;
- _additionalOffset--;
- nowPos64++;
- }
-
- UInt32 nowPos32 = (UInt32)nowPos64;
- UInt32 progressPosValuePrev = nowPos32;
-
- if (_matchFinder->GetNumAvailableBytes() == 0)
- return Flush(nowPos32);
-
- for (;;)
- {
- #ifdef _NO_EXCEPTIONS
- if (_rangeEncoder.Stream.ErrorCode != S_OK)
- return _rangeEncoder.Stream.ErrorCode;
- #endif
- UInt32 pos, len;
- HRESULT result;
- if (_fastMode)
- result = GetOptimumFast(pos, len);
- else
- result = GetOptimum(nowPos32, pos, len);
- RINOK(result);
-
- UInt32 posState = nowPos32 & _posStateMask;
- if(len == 1 && pos == 0xFFFFFFFF)
- {
- _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);
- Byte curByte = _matchFinder->GetIndexByte(0 - _additionalOffset);
- CLiteralEncoder2 *subCoder = _literalEncoder.GetSubCoder(nowPos32, _previousByte);
- if(_state.IsCharState())
- subCoder->Encode(&_rangeEncoder, curByte);
- else
- {
- Byte matchByte = _matchFinder->GetIndexByte(0 - _repDistances[0] - 1 - _additionalOffset);
- subCoder->EncodeMatched(&_rangeEncoder, matchByte, curByte);
- }
- _state.UpdateChar();
- _previousByte = curByte;
- }
- else
- {
- _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);
- if(pos < kNumRepDistances)
- {
- _isRep[_state.Index].Encode(&_rangeEncoder, 1);
- if(pos == 0)
- {
- _isRepG0[_state.Index].Encode(&_rangeEncoder, 0);
- _isRep0Long[_state.Index][posState].Encode(&_rangeEncoder, ((len == 1) ? 0 : 1));
- }
- else
- {
- UInt32 distance = _repDistances[pos];
- _isRepG0[_state.Index].Encode(&_rangeEncoder, 1);
- if (pos == 1)
- _isRepG1[_state.Index].Encode(&_rangeEncoder, 0);
- else
- {
- _isRepG1[_state.Index].Encode(&_rangeEncoder, 1);
- _isRepG2[_state.Index].Encode(&_rangeEncoder, pos - 2);
- if (pos == 3)
- _repDistances[3] = _repDistances[2];
- _repDistances[2] = _repDistances[1];
- }
- _repDistances[1] = _repDistances[0];
- _repDistances[0] = distance;
- }
- if (len == 1)
- _state.UpdateShortRep();
- else
- {
- _repMatchLenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
- _state.UpdateRep();
- }
- }
- else
- {
- _isRep[_state.Index].Encode(&_rangeEncoder, 0);
- _state.UpdateMatch();
- _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
- pos -= kNumRepDistances;
- UInt32 posSlot = GetPosSlot(pos);
- _posSlotEncoder[GetLenToPosState(len)].Encode(&_rangeEncoder, posSlot);
-
- if (posSlot >= kStartPosModelIndex)
- {
- UInt32 footerBits = ((posSlot >> 1) - 1);
- UInt32 base = ((2 | (posSlot & 1)) << footerBits);
- UInt32 posReduced = pos - base;
-
- if (posSlot < kEndPosModelIndex)
- NRangeCoder::ReverseBitTreeEncode(_posEncoders + base - posSlot - 1,
- &_rangeEncoder, footerBits, posReduced);
- else
- {
- _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
- _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);
- _alignPriceCount++;
- }
- }
- _repDistances[3] = _repDistances[2];
- _repDistances[2] = _repDistances[1];
- _repDistances[1] = _repDistances[0];
- _repDistances[0] = pos;
- _matchPriceCount++;
- }
- _previousByte = _matchFinder->GetIndexByte(len - 1 - _additionalOffset);
- }
- _additionalOffset -= len;
- nowPos32 += len;
- if (_additionalOffset == 0)
- {
- if (!_fastMode)
- {
- if (_matchPriceCount >= (1 << 7))
- FillDistancesPrices();
- if (_alignPriceCount >= kAlignTableSize)
- FillAlignPrices();
- }
- if (_matchFinder->GetNumAvailableBytes() == 0)
- return Flush(nowPos32);
- if (nowPos32 - progressPosValuePrev >= (1 << 14))
- {
- nowPos64 += nowPos32 - progressPosValuePrev;
- *inSize = nowPos64;
- *outSize = _rangeEncoder.GetProcessedSize();
- _finished = false;
- *finished = 0;
- return S_OK;
- }
- }
- }
-}
-
-STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- #ifndef _NO_EXCEPTIONS
- try
- {
- #endif
- return CodeReal(inStream, outStream, inSize, outSize, progress);
- #ifndef _NO_EXCEPTIONS
- }
- catch(const COutBufferException &e) { return e.ErrorCode; }
- catch(...) { return E_FAIL; }
- #endif
-}
-
-void CEncoder::FillDistancesPrices()
-{
- UInt32 tempPrices[kNumFullDistances];
- for (UInt32 i = kStartPosModelIndex; i < kNumFullDistances; i++)
- {
- UInt32 posSlot = GetPosSlot(i);
- UInt32 footerBits = ((posSlot >> 1) - 1);
- UInt32 base = ((2 | (posSlot & 1)) << footerBits);
- tempPrices[i] = NRangeCoder::ReverseBitTreeGetPrice(_posEncoders +
- base - posSlot - 1, footerBits, i - base);
- }
-
- for (UInt32 lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
- {
- UInt32 posSlot;
- NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> &encoder = _posSlotEncoder[lenToPosState];
- UInt32 *posSlotPrices = _posSlotPrices[lenToPosState];
- for (posSlot = 0; posSlot < _distTableSize; posSlot++)
- posSlotPrices[posSlot] = encoder.GetPrice(posSlot);
- for (posSlot = kEndPosModelIndex; posSlot < _distTableSize; posSlot++)
- posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << NRangeCoder::kNumBitPriceShiftBits);
-
- UInt32 *distancesPrices = _distancesPrices[lenToPosState];
- UInt32 i;
- for (i = 0; i < kStartPosModelIndex; i++)
- distancesPrices[i] = posSlotPrices[i];
- for (; i < kNumFullDistances; i++)
- distancesPrices[i] = posSlotPrices[GetPosSlot(i)] + tempPrices[i];
- }
- _matchPriceCount = 0;
-}
-
-void CEncoder::FillAlignPrices()
-{
- for (UInt32 i = 0; i < kAlignTableSize; i++)
- _alignPrices[i] = _posAlignEncoder.ReverseGetPrice(i);
- _alignPriceCount = 0;
-}
-
-}}
diff --git a/7zip/Compress/LZMA/LZMAEncoder.h b/7zip/Compress/LZMA/LZMAEncoder.h
deleted file mode 100755
index 26d2033d..00000000
--- a/7zip/Compress/LZMA/LZMAEncoder.h
+++ /dev/null
@@ -1,411 +0,0 @@
-// LZMA/Encoder.h
-
-#ifndef __LZMA_ENCODER_H
-#define __LZMA_ENCODER_H
-
-#include "../../../Common/MyCom.h"
-#include "../../../Common/Alloc.h"
-#include "../../ICoder.h"
-#include "../LZ/IMatchFinder.h"
-#include "../RangeCoder/RangeCoderBitTree.h"
-
-#include "LZMA.h"
-
-namespace NCompress {
-namespace NLZMA {
-
-typedef NRangeCoder::CBitEncoder<kNumMoveBits> CMyBitEncoder;
-
-class CBaseState
-{
-protected:
- CState _state;
- Byte _previousByte;
- UInt32 _repDistances[kNumRepDistances];
- void Init()
- {
- _state.Init();
- _previousByte = 0;
- for(UInt32 i = 0 ; i < kNumRepDistances; i++)
- _repDistances[i] = 0;
- }
-};
-
-struct COptimal
-{
- CState State;
-
- bool Prev1IsChar;
- bool Prev2;
-
- UInt32 PosPrev2;
- UInt32 BackPrev2;
-
- UInt32 Price;
- UInt32 PosPrev; // posNext;
- UInt32 BackPrev;
- UInt32 Backs[kNumRepDistances];
- void MakeAsChar() { BackPrev = UInt32(-1); Prev1IsChar = false; }
- void MakeAsShortRep() { BackPrev = 0; ; Prev1IsChar = false; }
- bool IsShortRep() { return (BackPrev == 0); }
-};
-
-
-extern Byte g_FastPos[1 << 11];
-inline UInt32 GetPosSlot(UInt32 pos)
-{
- if (pos < (1 << 11))
- return g_FastPos[pos];
- if (pos < (1 << 21))
- return g_FastPos[pos >> 10] + 20;
- return g_FastPos[pos >> 20] + 40;
-}
-
-inline UInt32 GetPosSlot2(UInt32 pos)
-{
- if (pos < (1 << 17))
- return g_FastPos[pos >> 6] + 12;
- if (pos < (1 << 27))
- return g_FastPos[pos >> 16] + 32;
- return g_FastPos[pos >> 26] + 52;
-}
-
-const UInt32 kIfinityPrice = 0xFFFFFFF;
-
-const UInt32 kNumOpts = 1 << 12;
-
-
-class CLiteralEncoder2
-{
- CMyBitEncoder _encoders[0x300];
-public:
- void Init()
- {
- for (int i = 0; i < 0x300; i++)
- _encoders[i].Init();
- }
- void Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol);
- void EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, Byte matchByte, Byte symbol);
- UInt32 GetPrice(bool matchMode, Byte matchByte, Byte symbol) const;
-};
-
-class CLiteralEncoder
-{
- CLiteralEncoder2 *_coders;
- int _numPrevBits;
- int _numPosBits;
- UInt32 _posMask;
-public:
- CLiteralEncoder(): _coders(0) {}
- ~CLiteralEncoder() { Free(); }
- void Free()
- {
- MyFree(_coders);
- _coders = 0;
- }
- bool Create(int numPosBits, int numPrevBits)
- {
- if (_coders == 0 || (numPosBits + numPrevBits) != (_numPrevBits + _numPosBits))
- {
- Free();
- UInt32 numStates = 1 << (numPosBits + numPrevBits);
- _coders = (CLiteralEncoder2 *)MyAlloc(numStates * sizeof(CLiteralEncoder2));
- }
- _numPosBits = numPosBits;
- _posMask = (1 << numPosBits) - 1;
- _numPrevBits = numPrevBits;
- return (_coders != 0);
- }
- void Init()
- {
- UInt32 numStates = 1 << (_numPrevBits + _numPosBits);
- for (UInt32 i = 0; i < numStates; i++)
- _coders[i].Init();
- }
- CLiteralEncoder2 *GetSubCoder(UInt32 pos, Byte prevByte)
- { return &_coders[((pos & _posMask) << _numPrevBits) + (prevByte >> (8 - _numPrevBits))]; }
-};
-
-namespace NLength {
-
-class CEncoder
-{
- CMyBitEncoder _choice;
- CMyBitEncoder _choice2;
- NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumLowBits> _lowCoder[kNumPosStatesEncodingMax];
- NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumMidBits> _midCoder[kNumPosStatesEncodingMax];
- NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumHighBits> _highCoder;
-public:
- void Init(UInt32 numPosStates);
- void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState);
- void SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const;
-};
-
-const UInt32 kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols;
-
-class CPriceTableEncoder: public CEncoder
-{
- UInt32 _prices[kNumPosStatesEncodingMax][kNumSymbolsTotal];
- UInt32 _tableSize;
- UInt32 _counters[kNumPosStatesEncodingMax];
-public:
- void SetTableSize(UInt32 tableSize) { _tableSize = tableSize; }
- UInt32 GetPrice(UInt32 symbol, UInt32 posState) const { return _prices[posState][symbol]; }
- void UpdateTable(UInt32 posState)
- {
- SetPrices(posState, _tableSize, _prices[posState]);
- _counters[posState] = _tableSize;
- }
- void UpdateTables(UInt32 numPosStates)
- {
- for (UInt32 posState = 0; posState < numPosStates; posState++)
- UpdateTable(posState);
- }
- void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState, bool updatePrice)
- {
- CEncoder::Encode(rangeEncoder, symbol, posState);
- if (updatePrice)
- if (--_counters[posState] == 0)
- UpdateTable(posState);
- }
-};
-
-}
-
-class CEncoder :
- public ICompressCoder,
- public ICompressSetOutStream,
- public ICompressSetCoderProperties,
- public ICompressWriteCoderProperties,
- public CBaseState,
- public CMyUnknownImp
-{
- COptimal _optimum[kNumOpts];
- CMyComPtr<IMatchFinder> _matchFinder; // test it
- NRangeCoder::CEncoder _rangeEncoder;
-
- CMyBitEncoder _isMatch[kNumStates][NLength::kNumPosStatesEncodingMax];
- CMyBitEncoder _isRep[kNumStates];
- CMyBitEncoder _isRepG0[kNumStates];
- CMyBitEncoder _isRepG1[kNumStates];
- CMyBitEncoder _isRepG2[kNumStates];
- CMyBitEncoder _isRep0Long[kNumStates][NLength::kNumPosStatesEncodingMax];
-
- NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> _posSlotEncoder[kNumLenToPosStates];
-
- CMyBitEncoder _posEncoders[kNumFullDistances - kEndPosModelIndex];
- NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumAlignBits> _posAlignEncoder;
-
- NLength::CPriceTableEncoder _lenEncoder;
- NLength::CPriceTableEncoder _repMatchLenEncoder;
-
- CLiteralEncoder _literalEncoder;
-
- UInt32 _matchDistances[kMatchMaxLen * 2 + 2 + 1];
-
- bool _fastMode;
- // bool _maxMode;
- UInt32 _numFastBytes;
- UInt32 _longestMatchLength;
- UInt32 _numDistancePairs;
-
- UInt32 _additionalOffset;
-
- UInt32 _optimumEndIndex;
- UInt32 _optimumCurrentIndex;
-
- bool _longestMatchWasFound;
-
- UInt32 _posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
-
- UInt32 _distancesPrices[kNumLenToPosStates][kNumFullDistances];
-
- UInt32 _alignPrices[kAlignTableSize];
- UInt32 _alignPriceCount;
-
- UInt32 _distTableSize;
-
- UInt32 _posStateBits;
- UInt32 _posStateMask;
- UInt32 _numLiteralPosStateBits;
- UInt32 _numLiteralContextBits;
-
- UInt32 _dictionarySize;
-
- UInt32 _dictionarySizePrev;
- UInt32 _numFastBytesPrev;
-
- UInt32 _matchPriceCount;
- UInt64 nowPos64;
- bool _finished;
- ISequentialInStream *_inStream;
-
- UInt32 _matchFinderCycles;
- int _matchFinderIndex;
- #ifdef COMPRESS_MF_MT
- bool _multiThread;
- #endif
-
- bool _writeEndMark;
-
- bool _needReleaseMFStream;
-
- IMatchFinderSetNumPasses *setMfPasses;
-
- void ReleaseMatchFinder()
- {
- setMfPasses = 0;
- _matchFinder.Release();
- }
-
- HRESULT ReadMatchDistances(UInt32 &len, UInt32 &numDistancePairs);
-
- HRESULT MovePos(UInt32 num);
- UInt32 GetRepLen1Price(CState state, UInt32 posState) const
- {
- return _isRepG0[state.Index].GetPrice0() +
- _isRep0Long[state.Index][posState].GetPrice0();
- }
-
- UInt32 GetPureRepPrice(UInt32 repIndex, CState state, UInt32 posState) const
- {
- UInt32 price;
- if(repIndex == 0)
- {
- price = _isRepG0[state.Index].GetPrice0();
- price += _isRep0Long[state.Index][posState].GetPrice1();
- }
- else
- {
- price = _isRepG0[state.Index].GetPrice1();
- if (repIndex == 1)
- price += _isRepG1[state.Index].GetPrice0();
- else
- {
- price += _isRepG1[state.Index].GetPrice1();
- price += _isRepG2[state.Index].GetPrice(repIndex - 2);
- }
- }
- return price;
- }
- UInt32 GetRepPrice(UInt32 repIndex, UInt32 len, CState state, UInt32 posState) const
- {
- return _repMatchLenEncoder.GetPrice(len - kMatchMinLen, posState) +
- GetPureRepPrice(repIndex, state, posState);
- }
- /*
- UInt32 GetPosLen2Price(UInt32 pos, UInt32 posState) const
- {
- if (pos >= kNumFullDistances)
- return kIfinityPrice;
- return _distancesPrices[0][pos] + _lenEncoder.GetPrice(0, posState);
- }
- UInt32 GetPosLen3Price(UInt32 pos, UInt32 len, UInt32 posState) const
- {
- UInt32 price;
- UInt32 lenToPosState = GetLenToPosState(len);
- if (pos < kNumFullDistances)
- price = _distancesPrices[lenToPosState][pos];
- else
- price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] +
- _alignPrices[pos & kAlignMask];
- return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
- }
- */
- UInt32 GetPosLenPrice(UInt32 pos, UInt32 len, UInt32 posState) const
- {
- UInt32 price;
- UInt32 lenToPosState = GetLenToPosState(len);
- if (pos < kNumFullDistances)
- price = _distancesPrices[lenToPosState][pos];
- else
- price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] +
- _alignPrices[pos & kAlignMask];
- return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
- }
-
- UInt32 Backward(UInt32 &backRes, UInt32 cur);
- HRESULT GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes);
- HRESULT GetOptimumFast(UInt32 &backRes, UInt32 &lenRes);
-
- void FillDistancesPrices();
- void FillAlignPrices();
-
- void ReleaseMFStream()
- {
- if (_matchFinder && _needReleaseMFStream)
- {
- _matchFinder->ReleaseStream();
- _needReleaseMFStream = false;
- }
- }
-
- void ReleaseStreams()
- {
- ReleaseMFStream();
- ReleaseOutStream();
- }
-
- HRESULT Flush(UInt32 nowPos);
- class CCoderReleaser
- {
- CEncoder *_coder;
- public:
- CCoderReleaser(CEncoder *coder): _coder(coder) {}
- ~CCoderReleaser()
- {
- _coder->ReleaseStreams();
- }
- };
- friend class CCoderReleaser;
-
- void WriteEndMarker(UInt32 posState);
-
-public:
- CEncoder();
- void SetWriteEndMarkerMode(bool writeEndMarker)
- { _writeEndMark= writeEndMarker; }
-
- HRESULT Create();
-
- MY_UNKNOWN_IMP3(
- ICompressSetOutStream,
- ICompressSetCoderProperties,
- ICompressWriteCoderProperties
- )
-
- HRESULT Init();
-
- // ICompressCoder interface
- HRESULT SetStreams(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 *inSize, const UInt64 *outSize);
- HRESULT CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished);
-
- HRESULT CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- // ICompressCoder interface
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- // ICompressSetCoderProperties2
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
- const PROPVARIANT *properties, UInt32 numProperties);
-
- // ICompressWriteCoderProperties
- STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
-
- STDMETHOD(SetOutStream)(ISequentialOutStream *outStream);
- STDMETHOD(ReleaseOutStream)();
-
- virtual ~CEncoder() {}
-};
-
-}}
-
-#endif
diff --git a/7zip/Compress/LZMA/makefile b/7zip/Compress/LZMA/makefile
deleted file mode 100755
index aae16966..00000000
--- a/7zip/Compress/LZMA/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-PROG = LZMA.dll
-DEF_FILE = ../Codec.def
-CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MF_MT -D_ST_MODE
-LIBS = $(LIBS) oleaut32.lib
-
-LZMA_OBJS = \
- $O\DllExports.obj \
-
-LZMA_OPT_OBJS = \
- $O\LZMADecoder.obj \
- $O\LZMAEncoder.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CRC.obj \
-
-WIN_OBJS = \
- $O\Synchronization.obj
-
-7ZIP_COMMON_OBJS = \
- $O\InBuffer.obj \
- $O\OutBuffer.obj \
- $O\StreamUtils.obj \
-
-LZ_OBJS = \
- $O\LZInWindow.obj \
- $O\LZOutWindow.obj \
-
-
-OBJS = \
- $O\StdAfx.obj \
- $(LZMA_OBJS) \
- $(LZMA_OPT_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(LZ_OBJS) \
- $O\MT.obj \
- $O\RangeCoderBit.obj \
- $O\resource.res
-
-!include "../../../Build.mak"
-
-$(LZMA_OBJS): $(*B).cpp
- $(COMPL)
-$(LZMA_OPT_OBJS): $(*B).cpp
- $(COMPL_O2)
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(LZ_OBJS): ../LZ/$(*B).cpp
- $(COMPL)
-$O\MT.obj: ../LZ/MT/$(*B).cpp
- $(COMPL_O2)
-$O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp
- $(COMPL)
diff --git a/7zip/Compress/LZMA_Alone/AloneLZMA.dsp b/7zip/Compress/LZMA_Alone/AloneLZMA.dsp
deleted file mode 100755
index dace1476..00000000
--- a/7zip/Compress/LZMA_Alone/AloneLZMA.dsp
+++ /dev/null
@@ -1,475 +0,0 @@
-# Microsoft Developer Studio Project File - Name="AloneLZMA" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=AloneLZMA - Win32 DebugU
-!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 "AloneLZMA.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 "AloneLZMA.mak" CFG="AloneLZMA - Win32 DebugU"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "AloneLZMA - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "AloneLZMA - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "AloneLZMA - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
-!MESSAGE "AloneLZMA - Win32 DebugU" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "AloneLZMA - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /c
-# 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 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 /subsystem:console /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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "AloneLZMA - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /GZ /c
-# 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 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 /subsystem:console /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "AloneLZMA - Win32 ReleaseU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ReleaseU"
-# PROP BASE Intermediate_Dir "ReleaseU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ReleaseU"
-# PROP Intermediate_Dir "ReleaseU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /c
-# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7za2.exe" /opt:NOWIN98
-# SUBTRACT BASE LINK32 /pdb:none
-# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "AloneLZMA - Win32 DebugU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "DebugU"
-# PROP BASE Intermediate_Dir "DebugU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "DebugU"
-# PROP Intermediate_Dir "DebugU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /GZ /c
-# 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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za2.exe" /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "AloneLZMA - Win32 Release"
-# Name "AloneLZMA - Win32 Debug"
-# Name "AloneLZMA - Win32 ReleaseU"
-# Name "AloneLZMA - Win32 DebugU"
-# Begin Group "Spec"
-
-# PROP Default_Filter ""
-# 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 "Compress"
-
-# PROP Default_Filter ""
-# Begin Group "LZMA"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\LZMA\LZMA.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZMA\LZMADecoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZMA\LZMADecoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZMA\LZMAEncoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZMA\LZMAEncoder.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 "LZ"
-
-# PROP Default_Filter ""
-# Begin Group "BT"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree3.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree3Z.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTree4.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\BinTree\BinTreeMain.h
-# End Source File
-# End Group
-# Begin Group "HC"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\LZ\HashChain\HC4.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\HashChain\HCMain.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\LZ\IMatchFinder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZInWindow.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZInWindow.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZOutWindow.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZ\LZOutWindow.h
-# End Source File
-# End Group
-# Begin Group "Branch"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Branch\BranchTypes.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Branch\BranchX86.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-# Begin Source File
-
-SOURCE=..\Branch\BranchX86.h
-# End Source File
-# End Group
-# Begin Group "LZMA_C"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\LZMA_C\LzmaDecode.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZMA_C\LzmaDecode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\LZMA_C\LzmaTypes.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Windows\FileIO.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\FileIO.h
-# End Source File
-# End Group
-# Begin Group "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CommandLineParser.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CommandLineParser.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Defs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Defs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyCom.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyWindows.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\String.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.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
-# Begin Source File
-
-SOURCE=..\..\..\Common\Types.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.h
-# End Source File
-# End Group
-# Begin Group "7zip Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.h
-# End Source File
-# 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 Source File
-
-SOURCE=..\..\ICoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaAlone.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaBench.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaBench.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaRam.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaRam.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaRamDecode.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaRamDecode.h
-# End Source File
-# End Target
-# End Project
diff --git a/7zip/Compress/LZMA_Alone/LzmaAlone.cpp b/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
deleted file mode 100755
index 16f80414..00000000
--- a/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
+++ /dev/null
@@ -1,526 +0,0 @@
-// LzmaAlone.cpp
-
-#include "StdAfx.h"
-
-#include "../../../Common/MyWindows.h"
-#include "../../../Common/MyInitGuid.h"
-
-#include <stdio.h>
-
-#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
-#include <fcntl.h>
-#include <io.h>
-#define MY_SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY)
-#else
-#define MY_SET_BINARY_MODE(file)
-#endif
-
-#include "../../../Common/CommandLineParser.h"
-#include "../../../Common/StringConvert.h"
-#include "../../../Common/StringToInt.h"
-
-#include "../../Common/FileStreams.h"
-#include "../../Common/StreamUtils.h"
-
-#include "../LZMA/LZMADecoder.h"
-#include "../LZMA/LZMAEncoder.h"
-
-#include "LzmaBench.h"
-#include "LzmaRam.h"
-
-extern "C"
-{
-#include "LzmaRamDecode.h"
-}
-
-using namespace NCommandLineParser;
-
-#ifdef _WIN32
-bool g_IsNT = false;
-static inline bool IsItWindowsNT()
-{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
-}
-#endif
-
-static const char *kCantAllocate = "Can not allocate memory";
-static const char *kReadError = "Read error";
-static const char *kWriteError = "Write error";
-
-namespace NKey {
-enum Enum
-{
- kHelp1 = 0,
- kHelp2,
- kMode,
- kDictionary,
- kFastBytes,
- kMatchFinderCycles,
- kLitContext,
- kLitPos,
- kPosBits,
- kMatchFinder,
- kEOS,
- kStdIn,
- kStdOut,
- kFilter86
-};
-}
-
-static const CSwitchForm kSwitchForms[] =
-{
- { L"?", NSwitchType::kSimple, false },
- { L"H", NSwitchType::kSimple, false },
- { L"A", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"D", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"FB", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"MC", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"LC", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"LP", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"PB", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"MF", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"EOS", NSwitchType::kSimple, false },
- { L"SI", NSwitchType::kSimple, false },
- { L"SO", NSwitchType::kSimple, false },
- { L"F86", NSwitchType::kSimple, false }
-};
-
-static const int kNumSwitches = sizeof(kSwitchForms) / sizeof(kSwitchForms[0]);
-
-static void PrintHelp()
-{
- fprintf(stderr, "\nUsage: LZMA <e|d> inputFile outputFile [<switches>...]\n"
- " e: encode file\n"
- " d: decode file\n"
- " b: Benchmark\n"
- "<Switches>\n"
- " -a{N}: set compression mode - [0, 1], default: 1 (max)\n"
- " -d{N}: set dictionary - [0,30], default: 23 (8MB)\n"
- " -fb{N}: set number of fast bytes - [5, 273], default: 128\n"
- " -mc{N}: set number of cycles for match finder\n"
- " -lc{N}: set number of literal context bits - [0, 8], default: 3\n"
- " -lp{N}: set number of literal pos bits - [0, 4], default: 0\n"
- " -pb{N}: set number of pos bits - [0, 4], default: 2\n"
- " -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, hc4], default: bt4\n"
- " -eos: write End Of Stream marker\n"
- " -si: read data from stdin\n"
- " -so: write data to stdout\n"
- );
-}
-
-static void PrintHelpAndExit(const char *s)
-{
- fprintf(stderr, "\nError: %s\n\n", s);
- PrintHelp();
- throw -1;
-}
-
-static void IncorrectCommand()
-{
- PrintHelpAndExit("Incorrect command");
-}
-
-static void WriteArgumentsToStringList(int numArguments, const char *arguments[],
- UStringVector &strings)
-{
- for(int i = 1; i < numArguments; i++)
- strings.Add(MultiByteToUnicodeString(arguments[i]));
-}
-
-static bool GetNumber(const wchar_t *s, UInt32 &value)
-{
- value = 0;
- if (MyStringLen(s) == 0)
- return false;
- const wchar_t *end;
- UInt64 res = ConvertStringToUInt64(s, &end);
- if (*end != L'\0')
- return false;
- if (res > 0xFFFFFFFF)
- return false;
- value = UInt32(res);
- return true;
-}
-
-int main2(int n, const char *args[])
-{
- #ifdef _WIN32
- g_IsNT = IsItWindowsNT();
- #endif
-
- fprintf(stderr, "\nLZMA 4.43 Copyright (c) 1999-2006 Igor Pavlov 2006-08-08\n");
-
- if (n == 1)
- {
- PrintHelp();
- return 0;
- }
-
- bool unsupportedTypes = (sizeof(Byte) != 1 || sizeof(UInt32) < 4 || sizeof(UInt64) < 4);
- if (unsupportedTypes)
- {
- fprintf(stderr, "Unsupported base types. Edit Common/Types.h and recompile");
- return 1;
- }
-
- UStringVector commandStrings;
- WriteArgumentsToStringList(n, args, commandStrings);
- CParser parser(kNumSwitches);
- try
- {
- parser.ParseStrings(kSwitchForms, commandStrings);
- }
- catch(...)
- {
- IncorrectCommand();
- }
-
- if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
- {
- PrintHelp();
- return 0;
- }
- const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
-
- int paramIndex = 0;
- if (paramIndex >= nonSwitchStrings.Size())
- IncorrectCommand();
- const UString &command = nonSwitchStrings[paramIndex++];
-
- bool dictionaryIsDefined = false;
- UInt32 dictionary = 1 << 21;
- if(parser[NKey::kDictionary].ThereIs)
- {
- UInt32 dicLog;
- if (!GetNumber(parser[NKey::kDictionary].PostStrings[0], dicLog))
- IncorrectCommand();
- dictionary = 1 << dicLog;
- dictionaryIsDefined = true;
- }
- UString mf = L"BT4";
- if (parser[NKey::kMatchFinder].ThereIs)
- mf = parser[NKey::kMatchFinder].PostStrings[0];
-
- if (command.CompareNoCase(L"b") == 0)
- {
- const UInt32 kNumDefaultItereations = 10;
- UInt32 numIterations = kNumDefaultItereations;
- {
- if (paramIndex < nonSwitchStrings.Size())
- if (!GetNumber(nonSwitchStrings[paramIndex++], numIterations))
- numIterations = kNumDefaultItereations;
- }
- return LzmaBenchmark(stderr, numIterations, dictionary);
- }
-
- bool encodeMode = false;
- if (command.CompareNoCase(L"e") == 0)
- encodeMode = true;
- else if (command.CompareNoCase(L"d") == 0)
- encodeMode = false;
- else
- IncorrectCommand();
-
- bool stdInMode = parser[NKey::kStdIn].ThereIs;
- bool stdOutMode = parser[NKey::kStdOut].ThereIs;
-
- CMyComPtr<ISequentialInStream> inStream;
- CInFileStream *inStreamSpec = 0;
- if (stdInMode)
- {
- inStream = new CStdInFileStream;
- MY_SET_BINARY_MODE(stdin);
- }
- else
- {
- if (paramIndex >= nonSwitchStrings.Size())
- IncorrectCommand();
- 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",
- (const char *)GetOemString(inputName));
- return 1;
- }
- }
-
- CMyComPtr<ISequentialOutStream> outStream;
- if (stdOutMode)
- {
- outStream = new CStdOutFileStream;
- MY_SET_BINARY_MODE(stdout);
- }
- else
- {
- if (paramIndex >= nonSwitchStrings.Size())
- IncorrectCommand();
- const UString &outputName = nonSwitchStrings[paramIndex++];
- COutFileStream *outStreamSpec = new COutFileStream;
- outStream = outStreamSpec;
- if (!outStreamSpec->Create(GetSystemString(outputName), true))
- {
- fprintf(stderr, "\nError: can not open output file %s\n",
- (const char *)GetOemString(outputName));
- return 1;
- }
- }
-
- if (parser[NKey::kFilter86].ThereIs)
- {
- // -f86 switch is for x86 filtered mode: BCJ + LZMA.
- if (parser[NKey::kEOS].ThereIs || stdInMode)
- throw "Can not use stdin in this mode";
- UInt64 fileSize;
- inStreamSpec->File.GetLength(fileSize);
- if (fileSize > 0xF0000000)
- throw "File is too big";
- UInt32 inSize = (UInt32)fileSize;
- Byte *inBuffer = 0;
- if (inSize != 0)
- {
- inBuffer = (Byte *)MyAlloc((size_t)inSize);
- if (inBuffer == 0)
- throw kCantAllocate;
- }
-
- UInt32 processedSize;
- if (ReadStream(inStream, inBuffer, (UInt32)inSize, &processedSize) != S_OK)
- throw "Can not read";
- if ((UInt32)inSize != processedSize)
- throw "Read size error";
-
- Byte *outBuffer = 0;
- size_t outSizeProcessed;
- if (encodeMode)
- {
- // we allocate 105% of original size for output buffer
- size_t outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
- if (outSize != 0)
- {
- outBuffer = (Byte *)MyAlloc((size_t)outSize);
- if (outBuffer == 0)
- throw kCantAllocate;
- }
- if (!dictionaryIsDefined)
- dictionary = 1 << 23;
- int res = LzmaRamEncode(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed,
- dictionary, SZ_FILTER_AUTO);
- if (res != 0)
- {
- fprintf(stderr, "\nEncoder error = %d\n", (int)res);
- return 1;
- }
- }
- else
- {
- size_t outSize;
- if (LzmaRamGetUncompressedSize(inBuffer, inSize, &outSize) != 0)
- throw "data error";
- if (outSize != 0)
- {
- outBuffer = (Byte *)MyAlloc(outSize);
- if (outBuffer == 0)
- throw kCantAllocate;
- }
- int res = LzmaRamDecompress(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed, malloc, free);
- if (res != 0)
- throw "LzmaDecoder error";
- }
- if (WriteStream(outStream, outBuffer, (UInt32)outSizeProcessed, &processedSize) != S_OK)
- throw kWriteError;
- MyFree(outBuffer);
- MyFree(inBuffer);
- return 0;
- }
-
-
- UInt64 fileSize;
- if (encodeMode)
- {
- NCompress::NLZMA::CEncoder *encoderSpec =
- new NCompress::NLZMA::CEncoder;
- CMyComPtr<ICompressCoder> encoder = encoderSpec;
-
- if (!dictionaryIsDefined)
- dictionary = 1 << 23;
-
- UInt32 posStateBits = 2;
- UInt32 litContextBits = 3; // for normal files
- // UInt32 litContextBits = 0; // for 32-bit data
- UInt32 litPosBits = 0;
- // UInt32 litPosBits = 2; // for 32-bit data
- UInt32 algorithm = 2;
- UInt32 numFastBytes = 128;
- UInt32 matchFinderCycles = 16 + numFastBytes / 2;
- bool matchFinderCyclesDefined = false;
-
- bool eos = parser[NKey::kEOS].ThereIs || stdInMode;
-
- if(parser[NKey::kMode].ThereIs)
- if (!GetNumber(parser[NKey::kMode].PostStrings[0], algorithm))
- IncorrectCommand();
-
- if(parser[NKey::kFastBytes].ThereIs)
- if (!GetNumber(parser[NKey::kFastBytes].PostStrings[0], numFastBytes))
- IncorrectCommand();
- matchFinderCyclesDefined = parser[NKey::kMatchFinderCycles].ThereIs;
- if (matchFinderCyclesDefined)
- if (!GetNumber(parser[NKey::kMatchFinderCycles].PostStrings[0], matchFinderCycles))
- IncorrectCommand();
- if(parser[NKey::kLitContext].ThereIs)
- if (!GetNumber(parser[NKey::kLitContext].PostStrings[0], litContextBits))
- IncorrectCommand();
- if(parser[NKey::kLitPos].ThereIs)
- if (!GetNumber(parser[NKey::kLitPos].PostStrings[0], litPosBits))
- IncorrectCommand();
- if(parser[NKey::kPosBits].ThereIs)
- if (!GetNumber(parser[NKey::kPosBits].PostStrings[0], posStateBits))
- IncorrectCommand();
-
- PROPID propIDs[] =
- {
- NCoderPropID::kDictionarySize,
- NCoderPropID::kPosStateBits,
- NCoderPropID::kLitContextBits,
- NCoderPropID::kLitPosBits,
- NCoderPropID::kAlgorithm,
- NCoderPropID::kNumFastBytes,
- NCoderPropID::kMatchFinder,
- NCoderPropID::kEndMarker,
- NCoderPropID::kMatchFinderCycles
- };
- const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]);
- /*
- NWindows::NCOM::CPropVariant properties[kNumProps];
- properties[0] = UInt32(dictionary);
- properties[1] = UInt32(posStateBits);
- properties[2] = UInt32(litContextBits);
-
- properties[3] = UInt32(litPosBits);
- properties[4] = UInt32(algorithm);
- properties[5] = UInt32(numFastBytes);
- properties[6] = mf;
- properties[7] = eos;
- */
- PROPVARIANT properties[kNumPropsMax];
- for (int p = 0; p < 6; p++)
- properties[p].vt = VT_UI4;
-
- properties[0].ulVal = UInt32(dictionary);
- properties[1].ulVal = UInt32(posStateBits);
- properties[2].ulVal = UInt32(litContextBits);
- properties[3].ulVal = UInt32(litPosBits);
- properties[4].ulVal = UInt32(algorithm);
- properties[5].ulVal = UInt32(numFastBytes);
-
- properties[8].vt = VT_UI4;
- properties[8].ulVal = UInt32(matchFinderCycles);
-
- properties[6].vt = VT_BSTR;
- properties[6].bstrVal = (BSTR)(const wchar_t *)mf;
-
- properties[7].vt = VT_BOOL;
- properties[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;
-
- int numProps = kNumPropsMax;
- if (!matchFinderCyclesDefined)
- numProps--;
-
- if (encoderSpec->SetCoderProperties(propIDs, properties, numProps) != S_OK)
- IncorrectCommand();
- encoderSpec->WriteCoderProperties(outStream);
-
- if (eos || stdInMode)
- fileSize = (UInt64)(Int64)-1;
- else
- inStreamSpec->File.GetLength(fileSize);
-
- for (int i = 0; i < 8; i++)
- {
- Byte b = Byte(fileSize >> (8 * i));
- if (outStream->Write(&b, 1, 0) != S_OK)
- {
- fprintf(stderr, kWriteError);
- return 1;
- }
- }
- HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
- if (result == E_OUTOFMEMORY)
- {
- 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
- {
- NCompress::NLZMA::CDecoder *decoderSpec =
- new NCompress::NLZMA::CDecoder;
- CMyComPtr<ICompressCoder> decoder = decoderSpec;
- const UInt32 kPropertiesSize = 5;
- Byte properties[kPropertiesSize];
- UInt32 processedSize;
- if (ReadStream(inStream, properties, kPropertiesSize, &processedSize) != S_OK)
- {
- fprintf(stderr, kReadError);
- return 1;
- }
- if (processedSize != kPropertiesSize)
- {
- fprintf(stderr, kReadError);
- return 1;
- }
- if (decoderSpec->SetDecoderProperties2(properties, kPropertiesSize) != S_OK)
- {
- fprintf(stderr, "SetDecoderProperties error");
- return 1;
- }
- fileSize = 0;
- for (int i = 0; i < 8; i++)
- {
- Byte b;
- if (inStream->Read(&b, 1, &processedSize) != S_OK)
- {
- fprintf(stderr, kReadError);
- return 1;
- }
- if (processedSize != 1)
- {
- fprintf(stderr, kReadError);
- return 1;
- }
- fileSize |= ((UInt64)b) << (8 * i);
- }
- if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
- {
- fprintf(stderr, "Decoder error");
- return 1;
- }
- }
- return 0;
-}
-
-int main(int n, const char *args[])
-{
- try { return main2(n, args); }
- catch(const char *s)
- {
- fprintf(stderr, "\nError: %s\n", s);
- return 1;
- }
- catch(...)
- {
- fprintf(stderr, "\nError\n");
- return 1;
- }
-}
diff --git a/7zip/Compress/LZMA_Alone/LzmaRam.cpp b/7zip/Compress/LZMA_Alone/LzmaRam.cpp
deleted file mode 100755
index eb66211a..00000000
--- a/7zip/Compress/LZMA_Alone/LzmaRam.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-// LzmaRam.cpp
-
-#include "StdAfx.h"
-#include "../../../Common/Types.h"
-#include "../LZMA/LZMADecoder.h"
-#include "../LZMA/LZMAEncoder.h"
-#include "LzmaRam.h"
-
-extern "C"
-{
-#include "../Branch/BranchX86.h"
-}
-
-class CInStreamRam:
- public ISequentialInStream,
- public CMyUnknownImp
-{
- const Byte *Data;
- size_t Size;
- size_t Pos;
-public:
- MY_UNKNOWN_IMP
- void Init(const Byte *data, size_t size)
- {
- Data = data;
- Size = size;
- Pos = 0;
- }
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
-};
-
-STDMETHODIMP CInStreamRam::Read(void *data, UInt32 size, UInt32 *processedSize)
-{
- if (size > (Size - Pos))
- size = (UInt32)(Size - Pos);
- for (UInt32 i = 0; i < size; i++)
- ((Byte *)data)[i] = Data[Pos + i];
- Pos += size;
- if(processedSize != NULL)
- *processedSize = size;
- return S_OK;
-}
-
-class COutStreamRam:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
- size_t Size;
-public:
- Byte *Data;
- size_t Pos;
- bool Overflow;
- void Init(Byte *data, size_t size)
- {
- Data = data;
- Size = size;
- Pos = 0;
- Overflow = false;
- }
- void SetPos(size_t pos)
- {
- Overflow = false;
- Pos = pos;
- }
- MY_UNKNOWN_IMP
- HRESULT WriteByte(Byte b)
- {
- if (Pos >= Size)
- {
- Overflow = true;
- return E_FAIL;
- }
- Data[Pos++] = b;
- return S_OK;
- }
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
-};
-
-STDMETHODIMP COutStreamRam::Write(const void *data, UInt32 size, UInt32 *processedSize)
-{
- UInt32 i;
- for (i = 0; i < size && Pos < Size; i++)
- Data[Pos++] = ((const Byte *)data)[i];
- if(processedSize != NULL)
- *processedSize = i;
- if (i != size)
- {
- Overflow = true;
- return E_FAIL;
- }
- return S_OK;
-}
-
-#define SZE_FAIL (1)
-#define SZE_OUTOFMEMORY (2)
-#define SZE_OUT_OVERFLOW (3)
-
-int LzmaRamEncode(
- const Byte *inBuffer, size_t inSize,
- Byte *outBuffer, size_t outSize, size_t *outSizeProcessed,
- UInt32 dictionarySize, ESzFilterMode filterMode)
-{
- #ifndef _NO_EXCEPTIONS
- try {
- #endif
-
- *outSizeProcessed = 0;
- const size_t kIdSize = 1;
- const size_t kLzmaPropsSize = 5;
- const size_t kMinDestSize = kIdSize + kLzmaPropsSize + 8;
- if (outSize < kMinDestSize)
- return SZE_OUT_OVERFLOW;
- NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
- CMyComPtr<ICompressCoder> encoder = encoderSpec;
-
- PROPID propIDs[] =
- {
- NCoderPropID::kAlgorithm,
- NCoderPropID::kDictionarySize,
- NCoderPropID::kNumFastBytes,
- };
- const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
- PROPVARIANT properties[kNumProps];
- properties[0].vt = VT_UI4;
- properties[1].vt = VT_UI4;
- properties[2].vt = VT_UI4;
- properties[0].ulVal = (UInt32)2;
- properties[1].ulVal = (UInt32)dictionarySize;
- properties[2].ulVal = (UInt32)64;
-
- if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
- return 1;
-
- COutStreamRam *outStreamSpec = new COutStreamRam;
- if (outStreamSpec == 0)
- return SZE_OUTOFMEMORY;
- CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
- CInStreamRam *inStreamSpec = new CInStreamRam;
- if (inStreamSpec == 0)
- return SZE_OUTOFMEMORY;
- CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
-
- outStreamSpec->Init(outBuffer, outSize);
- if (outStreamSpec->WriteByte(0) != S_OK)
- return SZE_OUT_OVERFLOW;
-
- if (encoderSpec->WriteCoderProperties(outStream) != S_OK)
- return SZE_OUT_OVERFLOW;
- if (outStreamSpec->Pos != kIdSize + kLzmaPropsSize)
- return 1;
-
- int i;
- for (i = 0; i < 8; i++)
- {
- UInt64 t = (UInt64)(inSize);
- if (outStreamSpec->WriteByte((Byte)((t) >> (8 * i))) != S_OK)
- return SZE_OUT_OVERFLOW;
- }
-
- Byte *filteredStream = 0;
-
- bool useFilter = (filterMode != SZ_FILTER_NO);
- if (useFilter)
- {
- if (inSize != 0)
- {
- filteredStream = (Byte *)MyAlloc(inSize);
- if (filteredStream == 0)
- return SZE_OUTOFMEMORY;
- memmove(filteredStream, inBuffer, inSize);
- }
- UInt32 _prevMask;
- UInt32 _prevPos;
- x86_Convert_Init(_prevMask, _prevPos);
- x86_Convert(filteredStream, (UInt32)inSize, 0, &_prevMask, &_prevPos, 1);
- }
-
- size_t minSize = 0;
- int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1;
- bool bestIsFiltered = false;
- int mainResult = 0;
- size_t startPos = outStreamSpec->Pos;
- for (i = 0; i < numPasses; i++)
- {
- if (numPasses > 1 && i == numPasses - 1 && !bestIsFiltered)
- break;
- outStreamSpec->SetPos(startPos);
- bool curModeIsFiltered = false;
- if (useFilter && i == 0)
- curModeIsFiltered = true;
- if (numPasses > 1 && i == numPasses - 1)
- curModeIsFiltered = true;
-
- inStreamSpec->Init(curModeIsFiltered ? filteredStream : inBuffer, inSize);
-
- HRESULT lzmaResult = encoder->Code(inStream, outStream, 0, 0, 0);
-
- mainResult = 0;
- if (lzmaResult == E_OUTOFMEMORY)
- {
- mainResult = SZE_OUTOFMEMORY;
- break;
- }
- if (i == 0 || outStreamSpec->Pos <= minSize)
- {
- minSize = outStreamSpec->Pos;
- bestIsFiltered = curModeIsFiltered;
- }
- if (outStreamSpec->Overflow)
- mainResult = SZE_OUT_OVERFLOW;
- else if (lzmaResult != S_OK)
- {
- mainResult = SZE_FAIL;
- break;
- }
- }
- *outSizeProcessed = outStreamSpec->Pos;
- if (bestIsFiltered)
- outBuffer[0] = 1;
- if (useFilter)
- MyFree(filteredStream);
- return mainResult;
-
- #ifndef _NO_EXCEPTIONS
- } catch(...) { return SZE_OUTOFMEMORY; }
- #endif
-}
diff --git a/7zip/Compress/LZMA_Alone/LzmaRamDecode.c b/7zip/Compress/LZMA_Alone/LzmaRamDecode.c
deleted file mode 100755
index ed1784d6..00000000
--- a/7zip/Compress/LZMA_Alone/LzmaRamDecode.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* LzmaRamDecode.c */
-
-#include "LzmaRamDecode.h"
-#ifdef _SZ_ONE_DIRECTORY
-#include "LzmaDecode.h"
-#include "BranchX86.h"
-#else
-#include "../LZMA_C/LzmaDecode.h"
-#include "../Branch/BranchX86.h"
-#endif
-
-#define LZMA_PROPS_SIZE 14
-#define LZMA_SIZE_OFFSET 6
-
-int LzmaRamGetUncompressedSize(
- const unsigned char *inBuffer,
- size_t inSize,
- size_t *outSize)
-{
- unsigned int i;
- if (inSize < LZMA_PROPS_SIZE)
- return 1;
- *outSize = 0;
- for(i = 0; i < sizeof(size_t); i++)
- *outSize += ((size_t)inBuffer[LZMA_SIZE_OFFSET + i]) << (8 * i);
- for(; i < 8; i++)
- if (inBuffer[LZMA_SIZE_OFFSET + i] != 0)
- return 1;
- return 0;
-}
-
-#define SZE_DATA_ERROR (1)
-#define SZE_OUTOFMEMORY (2)
-
-int LzmaRamDecompress(
- const unsigned char *inBuffer,
- size_t inSize,
- unsigned char *outBuffer,
- size_t outSize,
- size_t *outSizeProcessed,
- void * (*allocFunc)(size_t size),
- void (*freeFunc)(void *))
-{
- CLzmaDecoderState state; /* it's about 24 bytes structure, if int is 32-bit */
- int result;
- SizeT outSizeProcessedLoc;
- SizeT inProcessed;
- int useFilter;
-
- if (inSize < LZMA_PROPS_SIZE)
- return 1;
- useFilter = inBuffer[0];
-
- *outSizeProcessed = 0;
- if (useFilter > 1)
- return 1;
-
- if (LzmaDecodeProperties(&state.Properties, inBuffer + 1, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
- return 1;
- state.Probs = (CProb *)allocFunc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
- if (state.Probs == 0)
- return SZE_OUTOFMEMORY;
-
- result = LzmaDecode(&state,
- inBuffer + LZMA_PROPS_SIZE, (SizeT)inSize - LZMA_PROPS_SIZE, &inProcessed,
- outBuffer, (SizeT)outSize, &outSizeProcessedLoc);
- freeFunc(state.Probs);
- if (result != LZMA_RESULT_OK)
- return 1;
- *outSizeProcessed = (size_t)outSizeProcessedLoc;
- if (useFilter == 1)
- {
- UInt32 _prevMask;
- UInt32 _prevPos;
- x86_Convert_Init(_prevMask, _prevPos);
- x86_Convert(outBuffer, (UInt32)outSizeProcessedLoc, 0, &_prevMask, &_prevPos, 0);
- }
- return 0;
-}
diff --git a/7zip/Compress/LZMA_Alone/makefile b/7zip/Compress/LZMA_Alone/makefile
deleted file mode 100755
index 135c54b0..00000000
--- a/7zip/Compress/LZMA_Alone/makefile
+++ /dev/null
@@ -1,114 +0,0 @@
-PROG = lzma.exe
-CFLAGS = $(CFLAGS) -I ../../../
-LIBS = $(LIBS) oleaut32.lib user32.lib
-
-!IFDEF CPU
-LIBS = $(LIBS) bufferoverflowU.lib
-CFLAGS = $(CFLAGS) -GS- -Zc:forScope -W4 -Wp64 -DUNICODE -D_UNICODE
-!ENDIF
-
-!IFNDEF O
-!IFDEF CPU
-O=$(CPU)
-!ELSE
-O=O
-!ENDIF
-!ENDIF
-
-!IFDEF MY_STATIC_LINK
-!IFNDEF MY_SINGLE_THREAD
-CFLAGS = $(CFLAGS) -MT
-!ENDIF
-!ELSE
-CFLAGS = $(CFLAGS) -MD
-!ENDIF
-
-
-CFLAGS = $(CFLAGS) -nologo -EHsc -c -Fo$O/ -WX
-CFLAGS_O1 = $(CFLAGS) -O1
-CFLAGS_O2 = $(CFLAGS) -O2
-
-LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98
-
-PROGPATH = $O\$(PROG)
-
-COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
-COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
-COMPL = $(CPP) $(CFLAGS_O1) $**
-
-
-LZMA_OBJS = \
- $O\LzmaAlone.obj \
- $O\LzmaBench.obj \
- $O\LzmaRam.obj \
-
-LZMA_OPT_OBJS = \
- $O\LZMADecoder.obj \
- $O\LZMAEncoder.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CRC.obj \
- $O\CommandLineParser.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\Vector.obj
-
-7ZIP_COMMON_OBJS = \
- $O\InBuffer.obj \
- $O\OutBuffer.obj \
- $O\StreamUtils.obj \
-
-LZ_OBJS = \
- $O\LZInWindow.obj \
- $O\LZOutWindow.obj \
-
-
-OBJS = \
- $(LZMA_OBJS) \
- $(LZMA_OPT_OBJS) \
- $(COMMON_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(LZ_OBJS) \
- $O\LzmaRamDecode.obj \
- $O\LzmaDecode.obj \
- $O\FileStreams.obj \
- $O\FileIO.obj \
- $O\RangeCoderBit.obj \
- $O\BranchX86.obj \
-
-all: $(PROGPATH)
-
-clean:
- -del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch
-
-$O:
- if not exist "$O" mkdir "$O"
-
-$(PROGPATH): $O $(OBJS)
- link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)
-
-
-$(LZMA_OBJS): $(*B).cpp
- $(COMPL)
-$(LZMA_OPT_OBJS): ../LZMA/$(*B).cpp
- $(COMPL_O2)
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(LZ_OBJS): ../LZ/$(*B).cpp
- $(COMPL)
-$O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp
- $(COMPL)
-$O\LzmaRamDecode.obj: LzmaRamDecode.c
- $(COMPL_O1)
-$O\LzmaDecode.obj: ../LZMA_C/LzmaDecode.c
- $(COMPL_O2)
-$O\BranchX86.obj: ../Branch/BranchX86.c
- $(COMPL_O2)
-$O\FileStreams.obj: ../../Common/FileStreams.cpp
- $(COMPL)
-$O\FileIO.obj: ../../../Windows/FileIO.cpp
- $(COMPL)
diff --git a/7zip/Compress/LZMA_Alone/makefile.gcc b/7zip/Compress/LZMA_Alone/makefile.gcc
deleted file mode 100755
index 1e180742..00000000
--- a/7zip/Compress/LZMA_Alone/makefile.gcc
+++ /dev/null
@@ -1,113 +0,0 @@
-PROG = lzma
-CXX = g++ -O2 -Wall
-CXX_C = gcc -O2 -Wall
-LIB = -lm
-RM = rm -f
-CFLAGS = -c -I ../../../
-
-OBJS = \
- LzmaAlone.o \
- LzmaBench.o \
- LzmaRam.o \
- LzmaRamDecode.o \
- LzmaDecode.o \
- BranchX86.o \
- LZMADecoder.o \
- LZMAEncoder.o \
- LZInWindow.o \
- LZOutWindow.o \
- RangeCoderBit.o \
- InBuffer.o \
- OutBuffer.o \
- FileStreams.o \
- StreamUtils.o \
- Alloc.o \
- C_FileIO.o \
- CommandLineParser.o \
- CRC.o \
- String.o \
- StringConvert.o \
- StringToInt.o \
- Vector.o \
-
-
-all: $(PROG)
-
-$(PROG): $(OBJS)
- $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)
-
-LzmaAlone.o: LzmaAlone.cpp
- $(CXX) $(CFLAGS) LzmaAlone.cpp
-
-LzmaBench.o: LzmaBench.cpp
- $(CXX) $(CFLAGS) LzmaBench.cpp
-
-LzmaRam.o: LzmaRam.cpp
- $(CXX) $(CFLAGS) LzmaRam.cpp
-
-LzmaRamDecode.o: LzmaRamDecode.c
- $(CXX_C) $(CFLAGS) LzmaRamDecode.c
-
-LzmaDecode.o: ../LZMA_C/LzmaDecode.c
- $(CXX_C) $(CFLAGS) ../LZMA_C/LzmaDecode.c
-
-BranchX86.o: ../Branch/BranchX86.c
- $(CXX_C) $(CFLAGS) ../Branch/BranchX86.c
-
-LZMADecoder.o: ../LZMA/LZMADecoder.cpp
- $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
-
-LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
- $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
-
-LZInWindow.o: ../LZ/LZInWindow.cpp
- $(CXX) $(CFLAGS) ../LZ/LZInWindow.cpp
-
-LZOutWindow.o: ../LZ/LZOutWindow.cpp
- $(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
-
-RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp
- $(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp
-
-InBuffer.o: ../../Common/InBuffer.cpp
- $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
-
-OutBuffer.o: ../../Common/OutBuffer.cpp
- $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp
-
-FileStreams.o: ../../Common/FileStreams.cpp
- $(CXX) $(CFLAGS) ../../Common/FileStreams.cpp
-
-StreamUtils.o: ../../Common/StreamUtils.cpp
- $(CXX) $(CFLAGS) ../../Common/StreamUtils.cpp
-
-Alloc.o: ../../../Common/Alloc.cpp
- $(CXX) $(CFLAGS) ../../../Common/Alloc.cpp
-
-C_FileIO.o: ../../../Common/C_FileIO.cpp
- $(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp
-
-CommandLineParser.o: ../../../Common/CommandLineParser.cpp
- $(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp
-
-CRC.o: ../../../Common/CRC.cpp
- $(CXX) $(CFLAGS) ../../../Common/CRC.cpp
-
-MyWindows.o: ../../../Common/MyWindows.cpp
- $(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp
-
-String.o: ../../../Common/String.cpp
- $(CXX) $(CFLAGS) ../../../Common/String.cpp
-
-StringConvert.o: ../../../Common/StringConvert.cpp
- $(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp
-
-StringToInt.o: ../../../Common/StringToInt.cpp
- $(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp
-
-Vector.o: ../../../Common/Vector.cpp
- $(CXX) $(CFLAGS) ../../../Common/Vector.cpp
-
-clean:
- -$(RM) $(PROG) $(OBJS)
-
diff --git a/7zip/Compress/Lzh/LzhDecoder.cpp b/7zip/Compress/Lzh/LzhDecoder.cpp
deleted file mode 100755
index 846a4163..00000000
--- a/7zip/Compress/Lzh/LzhDecoder.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-// LzhDecoder.cpp
-
-#include "StdAfx.h"
-
-#include "LzhDecoder.h"
-
-#include "Windows/Defs.h"
-
-namespace NCompress{
-namespace NLzh {
-namespace NDecoder {
-
-static const UInt32 kHistorySize = (1 << 16);
-
-static const int kBlockSizeBits = 16;
-static const int kNumCBits = 9;
-static const int kNumLevelBits = 5; // smallest integer such that (1 << kNumLevelBits) > kNumLevelSymbols/
-
-UInt32 CCoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
-
-HRESULT CCoder::ReadLevelTable()
-{
- int n = ReadBits(kNumLevelBits);
- if (n == 0)
- {
- m_LevelHuffman.Symbol = ReadBits(kNumLevelBits);
- if (m_LevelHuffman.Symbol >= kNumLevelSymbols)
- return S_FALSE;
- }
- else
- {
- if (n > kNumLevelSymbols)
- return S_FALSE;
- m_LevelHuffman.Symbol = -1;
- Byte lens[kNumLevelSymbols];
- int i = 0;
- while (i < n)
- {
- int c = m_InBitStream.ReadBits(3);
- if (c == 7)
- while (ReadBits(1))
- if (c++ > kMaxHuffmanLen)
- return S_FALSE;
- lens[i++] = (Byte)c;
- if (i == kNumSpecLevelSymbols)
- {
- c = ReadBits(2);
- while (--c >= 0)
- lens[i++] = 0;
- }
- }
- while (i < kNumLevelSymbols)
- lens[i++] = 0;
- m_LevelHuffman.SetCodeLengths(lens);
- }
- return S_OK;
-}
-
-HRESULT CCoder::ReadPTable(int numBits)
-{
- int n = ReadBits(numBits);
- if (n == 0)
- {
- m_PHuffmanDecoder.Symbol = ReadBits(numBits);
- if (m_PHuffmanDecoder.Symbol >= kNumDistanceSymbols)
- return S_FALSE;
- }
- else
- {
- if (n > kNumDistanceSymbols)
- return S_FALSE;
- m_PHuffmanDecoder.Symbol = -1;
- Byte lens[kNumDistanceSymbols];
- int i = 0;
- while (i < n)
- {
- int c = m_InBitStream.ReadBits(3);
- if (c == 7)
- while (ReadBits(1))
- {
- if (c > kMaxHuffmanLen)
- return S_FALSE;
- c++;
- }
- lens[i++] = (Byte)c;
- }
- while (i < kNumDistanceSymbols)
- lens[i++] = 0;
- m_PHuffmanDecoder.SetCodeLengths(lens);
- }
- return S_OK;
-}
-
-HRESULT CCoder::ReadCTable()
-{
- int n = ReadBits(kNumCBits);
- if (n == 0)
- {
- m_CHuffmanDecoder.Symbol = ReadBits(kNumCBits);
- if (m_CHuffmanDecoder.Symbol >= kNumCSymbols)
- return S_FALSE;
- }
- else
- {
- if (n > kNumCSymbols)
- return S_FALSE;
- m_CHuffmanDecoder.Symbol = -1;
- Byte lens[kNumCSymbols];
- int i = 0;
- while (i < n)
- {
- int c = m_LevelHuffman.Decode(&m_InBitStream);
- if (c < kNumSpecLevelSymbols)
- {
- if (c == 0)
- c = 1;
- else if (c == 1)
- c = ReadBits(4) + 3;
- else
- c = ReadBits(kNumCBits) + 20;
- while (--c >= 0)
- {
- if (i > kNumCSymbols)
- return S_FALSE;
- lens[i++] = 0;
- }
- }
- else
- lens[i++] = (Byte)(c - 2);
- }
- while (i < kNumCSymbols)
- lens[i++] = 0;
- m_CHuffmanDecoder.SetCodeLengths(lens);
- }
- return S_OK;
-}
-
-STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- if (outSize == NULL)
- return E_INVALIDARG;
-
- if (!m_OutWindowStream.Create(kHistorySize))
- return E_OUTOFMEMORY;
- if (!m_InBitStream.Create(1 << 20))
- return E_OUTOFMEMORY;
-
- UInt64 pos = 0;
- m_OutWindowStream.SetStream(outStream);
- m_OutWindowStream.Init(false);
- m_InBitStream.SetStream(inStream);
- m_InBitStream.Init();
-
- CCoderReleaser coderReleaser(this);
-
- int pbit;
- if (m_NumDictBits <= 13)
- pbit = 4;
- else
- pbit = 5;
-
- UInt32 blockSize = 0;
-
- while(pos < *outSize)
- {
- // for (i = 0; i < dictSize; i++) dtext[i] = 0x20;
-
- if (blockSize == 0)
- {
- if (progress != NULL)
- {
- UInt64 packSize = m_InBitStream.GetProcessedSize();
- RINOK(progress->SetRatioInfo(&packSize, &pos));
- }
- blockSize = ReadBits(kBlockSizeBits);
- ReadLevelTable();
- ReadCTable();
- RINOK(ReadPTable(pbit));
- }
- blockSize--;
- UInt32 c = m_CHuffmanDecoder.Decode(&m_InBitStream);
- if (c < 256)
- {
- m_OutWindowStream.PutByte((Byte)c);
- pos++;
- }
- else
- {
- // offset = (interface->method == LARC_METHOD_NUM) ? 0x100 - 2 : 0x100 - 3;
- UInt32 len = c - 256 + kMinMatch;
- UInt32 distance = m_PHuffmanDecoder.Decode(&m_InBitStream);
- if (distance != 0)
- distance = (1 << (distance - 1)) + ReadBits(distance - 1);
- pos += len;
- if (distance >= pos)
- throw 1;
- m_OutWindowStream.CopyBlock(distance, len);
- }
- }
- coderReleaser.NeedFlush = false;
- return m_OutWindowStream.Flush();
-}
-
-STDMETHODIMP CCoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- try { return CodeReal(inStream, outStream, inSize, outSize, progress);}
- catch(const CInBufferException &e) { return e.ErrorCode; }
- catch(const CLZOutWindowException &e) { return e.ErrorCode; }
- catch(...) { return S_FALSE; }
-}
-
-}}}
diff --git a/7zip/Compress/PPMD/DllExports.cpp b/7zip/Compress/PPMD/DllExports.cpp
deleted file mode 100755
index c4a4fc61..00000000
--- a/7zip/Compress/PPMD/DllExports.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-#ifdef _WIN32
-#include "Common/Alloc.h"
-#endif
-
-#include "PPMDEncoder.h"
-#include "PPMDDecoder.h"
-
-// {23170F69-40C1-278B-0304-010000000000}
-DEFINE_GUID(CLSID_CCompressPPMDDecoder,
-0x23170F69, 0x40C1, 0x278B, 0x03, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-// {23170F69-40C1-278B-0304-010000000100}
-DEFINE_GUID(CLSID_CCompressPPMDEncoder,
-0x23170F69, 0x40C1, 0x278B, 0x03, 0x04, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD dwReason, LPVOID /*lpReserved*/)
-{
- #ifdef _WIN32
- if (dwReason == DLL_PROCESS_ATTACH)
- SetLargePageSize();
- #endif
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- int correctInterface = (*iid == IID_ICompressCoder);
- CMyComPtr<ICompressCoder> coder;
- if (*clsid == CLSID_CCompressPPMDDecoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NPPMD::CDecoder();
- }
- else if (*clsid == CLSID_CCompressPPMDEncoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NPPMD::CEncoder();
- }
- else
- return CLASS_E_CLASSNOTAVAILABLE;
- *outObject = coder.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[] = { 0x03, 0x04, 0x01 };
- if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(L"PPMD")) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCompressPPMDDecoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kEncoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCompressPPMDEncoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- return S_OK;
-}
diff --git a/7zip/Compress/PPMD/PPMDDecode.h b/7zip/Compress/PPMD/PPMDDecode.h
deleted file mode 100755
index 5eddcdf4..00000000
--- a/7zip/Compress/PPMD/PPMDDecode.h
+++ /dev/null
@@ -1,137 +0,0 @@
-// PPMDDecode.h
-// This code is based on Dmitry Shkarin's PPMdH code
-
-#ifndef __COMPRESS_PPMD_DECODE_H
-#define __COMPRESS_PPMD_DECODE_H
-
-#include "PPMDContext.h"
-
-namespace NCompress {
-namespace NPPMD {
-
-struct CDecodeInfo: public CInfo
-{
- void DecodeBinSymbol(NRangeCoder::CDecoder *rangeDecoder)
- {
- PPM_CONTEXT::STATE& rs = MinContext->oneState();
- UInt16& bs = GetBinSumm(rs, GetContextNoCheck(MinContext->Suffix)->NumStats);
- 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
- {
- bs = (UInt16)(bs - GET_MEAN(bs, PERIOD_BITS, 2));
- InitEsc = ExpEscape[bs >> 10];
- NumMasked = 1;
- CharMask[rs.Symbol] = EscCount;
- PrevSuccess = 0;
- FoundState = NULL;
- }
- }
-
- void DecodeSymbol1(NRangeCoder::CDecoder *rangeDecoder)
- {
- PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats);
- int i, count, hiCnt;
- 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);
- MinContext->SummFreq += 4;
- if (hiCnt > MAX_FREQ)
- rescale();
- return;
- }
- PrevSuccess = 0;
- i = MinContext->NumStats - 1;
- while ((hiCnt += (++p)->Freq) <= count)
- if (--i == 0)
- {
- HiBitsFlag = HB2Flag[FoundState->Symbol];
- rangeDecoder->Decode(hiCnt, MinContext->SummFreq - hiCnt); // , MinContext->SummFreq);
- CharMask[p->Symbol] = EscCount;
- i = (NumMasked = MinContext->NumStats)-1;
- FoundState = NULL;
- do { CharMask[(--p)->Symbol] = EscCount; } while ( --i );
- return;
- }
- rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , MinContext->SummFreq);
- update1(p);
- }
-
-
- void DecodeSymbol2(NRangeCoder::CDecoder *rangeDecoder)
- {
- int count, hiCnt, i = MinContext->NumStats - NumMasked;
- UInt32 freqSum;
- SEE2_CONTEXT* psee2c = makeEscFreq2(i, freqSum);
- PPM_CONTEXT::STATE* ps[256], ** pps = ps, * p = GetStateNoCheck(MinContext->Stats)-1;
- hiCnt = 0;
- do
- {
- do { p++; } while (CharMask[p->Symbol] == EscCount);
- hiCnt += p->Freq;
- *pps++ = p;
- }
- while ( --i );
-
- freqSum += hiCnt;
- count = rangeDecoder->GetThreshold(freqSum);
-
- p = *(pps = ps);
- if (count < hiCnt)
- {
- hiCnt = 0;
- while ((hiCnt += p->Freq) <= count)
- p=*++pps;
- rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , freqSum);
-
- psee2c->update();
- update2(p);
- }
- else
- {
- rangeDecoder->Decode(hiCnt, freqSum - hiCnt); // , freqSum);
-
- i = MinContext->NumStats - NumMasked;
- pps--;
- do { CharMask[(*++pps)->Symbol] = EscCount; } while ( --i );
- psee2c->Summ = (UInt16)(psee2c->Summ + freqSum);
- NumMasked = MinContext->NumStats;
- }
- }
-
- int DecodeSymbol(NRangeCoder::CDecoder *rangeDecoder)
- {
- if (MinContext->NumStats != 1)
- DecodeSymbol1(rangeDecoder);
- else
- DecodeBinSymbol(rangeDecoder);
- while ( !FoundState )
- {
- do
- {
- OrderFall++;
- MinContext = GetContext(MinContext->Suffix);
- if (MinContext == 0)
- return -1;
- }
- while (MinContext->NumStats == NumMasked);
- DecodeSymbol2(rangeDecoder);
- }
- Byte symbol = FoundState->Symbol;
- NextContext();
- return symbol;
- }
-};
-
-}}
-
-#endif
diff --git a/7zip/Compress/PPMD/PPMDDecoder.cpp b/7zip/Compress/PPMD/PPMDDecoder.cpp
deleted file mode 100755
index f5f9b06c..00000000
--- a/7zip/Compress/PPMD/PPMDDecoder.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-// PPMDDecoder.cpp
-
-#include "StdAfx.h"
-
-#include "Common/Defs.h"
-#include "Windows/Defs.h"
-
-#include "PPMDDecoder.h"
-
-namespace NCompress {
-namespace NPPMD {
-
-const int kLenIdFinished = -1;
-const int kLenIdNeedInit = -2;
-
-STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *properties, UInt32 size)
-{
- if (size < 5)
- return E_INVALIDARG;
- _order = properties[0];
- _usedMemorySize = 0;
- for (int i = 0; i < 4; i++)
- _usedMemorySize += ((UInt32)(properties[1 + i])) << (i * 8);
-
- if (_usedMemorySize > kMaxMemBlockSize)
- return E_NOTIMPL;
-
- if (!_rangeDecoder.Create(1 << 20))
- return E_OUTOFMEMORY;
- if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
- return E_OUTOFMEMORY;
-
- return S_OK;
-}
-
-class CDecoderFlusher
-{
- CDecoder *_coder;
-public:
- bool NeedFlush;
- CDecoderFlusher(CDecoder *coder): _coder(coder), NeedFlush(true) {}
- ~CDecoderFlusher()
- {
- if (NeedFlush)
- _coder->Flush();
- _coder->ReleaseStreams();
- }
-};
-
-HRESULT CDecoder::CodeSpec(UInt32 size, Byte *memStream)
-{
- const UInt32 startSize = size;
- if (_outSizeDefined)
- {
- const UInt64 rem = _outSize - _processedSize;
- if (size > rem)
- size = (UInt32)rem;
- }
-
- if (_remainLen == kLenIdFinished)
- return S_OK;
- if (_remainLen == kLenIdNeedInit)
- {
- _rangeDecoder.Init();
- _remainLen = 0;
- _info.MaxOrder = 0;
- _info.StartModelRare(_order);
- }
- while (size != 0)
- {
- int symbol = _info.DecodeSymbol(&_rangeDecoder);
- if (symbol < 0)
- {
- _remainLen = kLenIdFinished;
- break;
- }
- if (memStream != 0)
- *memStream++ = (Byte)symbol;
- else
- _outStream.WriteByte((Byte)symbol);
- size--;
- }
- _processedSize += startSize - size;
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- if (!_outStream.Create(1 << 20))
- return E_OUTOFMEMORY;
-
- SetInStream(inStream);
- _outStream.SetStream(outStream);
- SetOutStreamSize(outSize);
- CDecoderFlusher flusher(this);
-
- for (;;)
- {
- _processedSize = _outStream.GetProcessedSize();
- UInt32 curSize = (1 << 18);
- RINOK(CodeSpec(curSize, NULL));
- if (_remainLen == kLenIdFinished)
- break;
- if (progress != NULL)
- {
- UInt64 inSize = _rangeDecoder.GetProcessedSize();
- RINOK(progress->SetRatioInfo(&inSize, &_processedSize));
- }
- if (_outSizeDefined)
- if (_outStream.GetProcessedSize() >= _outSize)
- break;
- }
- flusher.NeedFlush = false;
- return Flush();
-}
-
-#ifdef _NO_EXCEPTIONS
-
-#define PPMD_TRY_BEGIN
-#define PPMD_TRY_END
-
-#else
-
-#define PPMD_TRY_BEGIN try {
-#define PPMD_TRY_END } \
- catch(const CInBufferException &e) { return e.ErrorCode; } \
- catch(const COutBufferException &e) { return e.ErrorCode; } \
- catch(...) { return S_FALSE; }
-
-#endif
-
-
-STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- PPMD_TRY_BEGIN
- return CodeReal(inStream, outStream, inSize, outSize, progress);
- PPMD_TRY_END
-}
-
-STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
-{
- _rangeDecoder.SetStream(inStream);
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::ReleaseInStream()
-{
- _rangeDecoder.ReleaseStream();
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
-{
- _outSizeDefined = (outSize != NULL);
- if (_outSizeDefined)
- _outSize = *outSize;
- _remainLen = kLenIdNeedInit;
- _outStream.Init();
- return S_OK;
-}
-
-#ifdef _ST_MODE
-
-STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
-{
- PPMD_TRY_BEGIN
- if (processedSize)
- *processedSize = 0;
- const UInt64 startPos = _processedSize;
- RINOK(CodeSpec(size, (Byte *)data));
- if (processedSize)
- *processedSize = (UInt32)(_processedSize - startPos);
- return Flush();
- PPMD_TRY_END
-}
-
-#endif
-
-}}
diff --git a/7zip/Compress/PPMD/PPMDDecoder.h b/7zip/Compress/PPMD/PPMDDecoder.h
deleted file mode 100755
index bbb68ac5..00000000
--- a/7zip/Compress/PPMD/PPMDDecoder.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Compress/PPM/PPMDDecoder.h
-
-#ifndef __COMPRESS_PPMD_DECODER_H
-#define __COMPRESS_PPMD_DECODER_H
-
-#include "../../../Common/MyCom.h"
-
-#include "../../ICoder.h"
-#include "../../Common/OutBuffer.h"
-#include "../RangeCoder/RangeCoder.h"
-
-#include "PPMDDecode.h"
-
-namespace NCompress {
-namespace NPPMD {
-
-class CDecoder :
- public ICompressCoder,
- public ICompressSetDecoderProperties2,
- #ifdef _ST_MODE
- public ICompressSetInStream,
- public ICompressSetOutStreamSize,
- public ISequentialInStream,
- #endif
- public CMyUnknownImp
-{
- NRangeCoder::CDecoder _rangeDecoder;
-
- COutBuffer _outStream;
-
- CDecodeInfo _info;
-
- Byte _order;
- UInt32 _usedMemorySize;
-
- int _remainLen;
- UInt64 _outSize;
- bool _outSizeDefined;
- UInt64 _processedSize;
-
- HRESULT CodeSpec(UInt32 num, Byte *memStream);
-public:
-
- #ifdef _ST_MODE
- MY_UNKNOWN_IMP4(
- ICompressSetDecoderProperties2,
- ICompressSetInStream,
- ICompressSetOutStreamSize,
- ISequentialInStream)
- #else
- MY_UNKNOWN_IMP1(
- ICompressSetDecoderProperties2)
- #endif
-
- void ReleaseStreams()
- {
- ReleaseInStream();
- _outStream.ReleaseStream();
- }
-
- HRESULT Flush() { return _outStream.Flush(); }
-
- STDMETHOD(CodeReal)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
-
- STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
-
- STDMETHOD(SetInStream)(ISequentialInStream *inStream);
- STDMETHOD(ReleaseInStream)();
- STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
-
- #ifdef _ST_MODE
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
- #endif
-
- CDecoder(): _outSizeDefined(false) {}
-
-};
-
-}}
-
-#endif
diff --git a/7zip/Compress/PPMD/PPMDSubAlloc.h b/7zip/Compress/PPMD/PPMDSubAlloc.h
deleted file mode 100755
index 9b13f933..00000000
--- a/7zip/Compress/PPMD/PPMDSubAlloc.h
+++ /dev/null
@@ -1,290 +0,0 @@
-// PPMDSubAlloc.h
-// This code is based on Dmitry Shkarin's PPMdH code
-
-#ifndef __PPMD_SUBALLOC_H
-#define __PPMD_SUBALLOC_H
-
-#include "PPMDType.h"
-
-#include "../../../Common/Alloc.h"
-
-const UINT N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
-const UINT UNIT_SIZE=12, N_INDEXES=N1+N2+N3+N4;
-
-// Extra 1 * UNIT_SIZE for NULL support
-// Extra 2 * UNIT_SIZE for s0 in GlueFreeBlocks()
-const UInt32 kExtraSize = (UNIT_SIZE * 3);
-const UInt32 kMaxMemBlockSize = 0xFFFFFFFF - kExtraSize;
-
-struct MEM_BLK
-{
- UInt16 Stamp, NU;
- UInt32 Next, Prev;
- 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)
- {
- ((MEM_BLK *)(Base + Prev))->Next = Next;
- ((MEM_BLK *)(Base + Next))->Prev = Prev;
- }
-};
-
-
-class CSubAllocator
-{
- UInt32 SubAllocatorSize;
- Byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;
- UInt32 FreeList[N_INDEXES];
-
- Byte *Base;
- Byte *HeapStart, *LoUnit, *HiUnit;
-public:
- Byte *pText, *UnitsStart;
- CSubAllocator():
- SubAllocatorSize(0),
- GlueCount(0),
- LoUnit(0),
- HiUnit(0),
- pText(0),
- UnitsStart(0)
- {
- memset(Indx2Units, 0, sizeof(Indx2Units));
- memset(FreeList, 0, sizeof(FreeList));
- }
- ~CSubAllocator()
- {
- StopSubAllocator();
- };
-
- void *GetPtr(UInt32 offset) const { return (offset == 0) ? 0 : (void *)(Base + offset); }
- void *GetPtrNoCheck(UInt32 offset) const { return (void *)(Base + offset); }
- UInt32 GetOffset(void *ptr) const { return (ptr == 0) ? 0 : (UInt32)((Byte *)ptr - Base); }
- UInt32 GetOffsetNoCheck(void *ptr) const { return (UInt32)((Byte *)ptr - Base); }
- 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)
- {
- *(UInt32 *)p = FreeList[indx];
- FreeList[indx] = GetOffsetNoCheck(p);
- }
-
- void* RemoveNode(int indx)
- {
- UInt32 offset = FreeList[indx];
- UInt32 *p = GetNode(offset);
- FreeList[indx] = *p;
- return (void *)p;
- }
-
- UINT U2B(int NU) const { return (UINT)(NU) * UNIT_SIZE; }
-
- void SplitBlock(void* pv, int oldIndx, int newIndx)
- {
- int i, UDiff = Indx2Units[oldIndx] - Indx2Units[newIndx];
- Byte* p = ((Byte*)pv) + U2B(Indx2Units[newIndx]);
- if (Indx2Units[i = Units2Indx[UDiff-1]] != UDiff)
- {
- InsertNode(p, --i);
- p += U2B(i = Indx2Units[i]);
- UDiff -= i;
- }
- InsertNode(p, Units2Indx[UDiff - 1]);
- }
-
- UInt32 GetUsedMemory() const
- {
- UInt32 RetVal = SubAllocatorSize - (UInt32)(HiUnit - LoUnit) - (UInt32)(UnitsStart - pText);
- 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);
- }
-
- void StopSubAllocator()
- {
- if (SubAllocatorSize != 0)
- {
- BigFree(Base);
- SubAllocatorSize = 0;
- Base = 0;
- }
- }
-
- bool StartSubAllocator(UInt32 size)
- {
- if (SubAllocatorSize == size)
- return true;
- StopSubAllocator();
- if (size == 0)
- Base = 0;
- else
- {
- if ((Base = (Byte *)::BigAlloc(size + kExtraSize)) == 0)
- return false;
- HeapStart = Base + UNIT_SIZE; // we need such code to support NULL;
- }
- SubAllocatorSize = size;
- return true;
- }
-
- void InitSubAllocator()
- {
- int i, k;
- memset(FreeList, 0, sizeof(FreeList));
- HiUnit = (pText = HeapStart) + SubAllocatorSize;
- UINT Diff = UNIT_SIZE * (SubAllocatorSize / 8 / UNIT_SIZE * 7);
- LoUnit = UnitsStart = HiUnit - Diff;
- for (i = 0, k=1; i < N1 ; i++, k += 1) Indx2Units[i] = (Byte)k;
- for (k++; i < N1 + N2 ;i++, k += 2) Indx2Units[i] = (Byte)k;
- 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++)
- {
- i += (Indx2Units[i] < k+1);
- Units2Indx[k] = (Byte)i;
- }
- }
-
- void GlueFreeBlocks()
- {
- UInt32 s0 = (UInt32)(HeapStart + SubAllocatorSize - Base);
-
- // We need add exta MEM_BLK with Stamp=0
- GetBlk(s0)->Stamp = 0;
- s0 += UNIT_SIZE;
- MEM_BLK *ps0 = GetBlk(s0);
-
- UInt32 p;
- int i;
- if (LoUnit != HiUnit)
- *LoUnit=0;
- ps0->Next = ps0->Prev = s0;
-
- for (i = 0; i < N_INDEXES; i++)
- while (FreeList[i] != 0)
- {
- MEM_BLK *pp = (MEM_BLK *)RemoveNode(i);
- pp->InsertAt(Base, s0);
- pp->Stamp = 0xFFFF;
- pp->NU = Indx2Units[i];
- }
- for (p = ps0->Next; p != s0; p = GetBlk(p)->Next)
- {
- for (;;)
- {
- MEM_BLK *pp = GetBlk(p);
- MEM_BLK *pp1 = GetBlk(p + pp->NU * UNIT_SIZE);
- if (pp1->Stamp != 0xFFFF || int(pp->NU) + pp1->NU >= 0x10000)
- break;
- pp1->Remove(Base);
- pp->NU = (UInt16)(pp->NU + pp1->NU);
- }
- }
- 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)
- {
- int k = sz - Indx2Units[--i];
- InsertNode(Base + p + (sz - k) * UNIT_SIZE, k - 1);
- }
- InsertNode(Base + p, i);
- }
- }
- void* AllocUnitsRare(int indx)
- {
- if ( !GlueCount )
- {
- GlueCount = 255;
- GlueFreeBlocks();
- if (FreeList[indx] != 0)
- return RemoveNode(indx);
- }
- int i = indx;
- do
- {
- if (++i == N_INDEXES)
- {
- GlueCount--;
- i = U2B(Indx2Units[indx]);
- return (UnitsStart - pText > i) ? (UnitsStart -= i) : (NULL);
- }
- } while (FreeList[i] == 0);
- void* RetVal = RemoveNode(i);
- SplitBlock(RetVal, i, indx);
- return RetVal;
- }
-
- void* AllocUnits(int NU)
- {
- int indx = Units2Indx[NU - 1];
- if (FreeList[indx] != 0)
- return RemoveNode(indx);
- void* RetVal = LoUnit;
- LoUnit += U2B(Indx2Units[indx]);
- if (LoUnit <= HiUnit)
- return RetVal;
- LoUnit -= U2B(Indx2Units[indx]);
- return AllocUnitsRare(indx);
- }
-
- void* AllocContext()
- {
- if (HiUnit != LoUnit)
- return (HiUnit -= UNIT_SIZE);
- if (FreeList[0] != 0)
- return RemoveNode(0);
- return AllocUnitsRare(0);
- }
-
- void* ExpandUnits(void* oldPtr, int oldNU)
- {
- int i0=Units2Indx[oldNU - 1], i1=Units2Indx[oldNU - 1 + 1];
- if (i0 == i1)
- return oldPtr;
- void* ptr = AllocUnits(oldNU + 1);
- if (ptr)
- {
- memcpy(ptr, oldPtr, U2B(oldNU));
- InsertNode(oldPtr, i0);
- }
- return ptr;
- }
-
- void* ShrinkUnits(void* oldPtr, int oldNU, int newNU)
- {
- int i0 = Units2Indx[oldNU - 1], i1 = Units2Indx[newNU - 1];
- if (i0 == i1)
- return oldPtr;
- if (FreeList[i1] != 0)
- {
- void* ptr = RemoveNode(i1);
- memcpy(ptr, oldPtr, U2B(newNU));
- InsertNode(oldPtr,i0);
- return ptr;
- }
- else
- {
- SplitBlock(oldPtr, i0, i1);
- return oldPtr;
- }
- }
-
- void FreeUnits(void* ptr, int oldNU)
- {
- InsertNode(ptr, Units2Indx[oldNU - 1]);
- }
-};
-
-#endif
diff --git a/7zip/Compress/Rar20/DllExports.cpp b/7zip/Compress/Rar20/DllExports.cpp
deleted file mode 100755
index 599d71c3..00000000
--- a/7zip/Compress/Rar20/DllExports.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-
-#include "Rar20Decoder.h"
-
-// {23170F69-40C1-278B-0403-020000000000}
-DEFINE_GUID(CLSID_CCompressRar20Decoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
-{
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- if (*clsid != CLSID_CCompressRar20Decoder)
- return CLASS_E_CLASSNOTAVAILABLE;
- if (*iid != IID_ICompressCoder)
- return E_NOINTERFACE;
- CMyComPtr<ICompressCoder> coder = (ICompressCoder *)new
- NCompress::NRar20::CDecoder;
- *outObject = coder.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[] = { 0x04, 0x03, 0x02 };
- if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(L"Rar20")) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCompressRar20Decoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- return S_OK;
-}
diff --git a/7zip/Compress/Rar20/Rar20Const.h b/7zip/Compress/Rar20/Rar20Const.h
deleted file mode 100755
index 6c5fecb6..00000000
--- a/7zip/Compress/Rar20/Rar20Const.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Rar20CoderConst.h
-// According to unRAR license,
-// this code may not be used to develop a
-// RAR (WinRAR) compatible archiver
-
-#ifndef __RAR20_CONST_H
-#define __RAR20_CONST_H
-
-#include "Rar20ExtConst.h"
-
-namespace NCompress {
-namespace NRar20 {
-
-const UInt32 kMainTableSize = 298;
-const UInt32 kLenTableSize = 28;
-
-const UInt32 kDistTableStart = kMainTableSize;
-const UInt32 kLenTableStart = kDistTableStart + kDistTableSize;
-
-const UInt32 kHeapTablesSizesSum = kMainTableSize + kDistTableSize + kLenTableSize;
-
-const UInt32 kLevelTableSize = 19;
-
-const UInt32 kMMTablesSizesSum = kMMTableSize * 4;
-
-const UInt32 kMaxTableSize = kMMTablesSizesSum;
-
-const UInt32 kTableDirectLevels = 16;
-const UInt32 kTableLevelRepNumber = kTableDirectLevels;
-const UInt32 kTableLevel0Number = kTableLevelRepNumber + 1;
-const UInt32 kTableLevel0Number2 = kTableLevel0Number + 1;
-
-const UInt32 kLevelMask = 0xF;
-
-
-const UInt32 kRepBothNumber = 256;
-const UInt32 kRepNumber = kRepBothNumber + 1;
-const UInt32 kLen2Number = kRepNumber + 4;
-
-const UInt32 kLen2NumNumbers = 8;
-const UInt32 kReadTableNumber = kLen2Number + kLen2NumNumbers;
-const UInt32 kMatchNumber = kReadTableNumber + 1;
-
-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};
-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};
-
-const UInt32 kDistStart[kDistTableSize] = {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,32768U,49152U,65536,98304,131072,196608,262144,327680,393216,458752,524288,589824,655360,720896,786432,851968,917504,983040};
-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};
-
-const Byte kLevelDirectBits[kLevelTableSize] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7};
-
-const Byte kLen2DistStarts[kLen2NumNumbers]={0,4,8,16,32,64,128,192};
-const Byte kLen2DistDirectBits[kLen2NumNumbers]={2,2,3, 4, 5, 6, 6, 6};
-
-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;
-
-}}
-
-#endif
diff --git a/7zip/Compress/Rar20/Rar20Decoder.cpp b/7zip/Compress/Rar20/Rar20Decoder.cpp
deleted file mode 100755
index f990811f..00000000
--- a/7zip/Compress/Rar20/Rar20Decoder.cpp
+++ /dev/null
@@ -1,322 +0,0 @@
-// Rar20Decoder.cpp
-// According to unRAR license,
-// this code may not be used to develop a
-// RAR (WinRAR) compatible archiver
-
-#include "StdAfx.h"
-
-#include "Rar20Decoder.h"
-#include "Rar20Const.h"
-
-namespace NCompress {
-namespace NRar20 {
-
-class CException
-{
-public:
- enum ECauseType
- {
- kData
- } Cause;
- CException(ECauseType cause): Cause(cause) {}
-};
-
-static const char *kNumberErrorMessage = "Number error";
-
-static const UInt32 kHistorySize = 1 << 20;
-
-static const int kNumStats = 11;
-
-static const UInt32 kWindowReservSize = (1 << 22) + 256;
-
-CDecoder::CDecoder():
- m_IsSolid(false)
-{
-}
-
-void CDecoder::InitStructures()
-{
- m_Predictor.Init();
- for(int i = 0; i < kNumRepDists; i++)
- m_RepDists[i] = 0;
- m_RepDistPtr = 0;
- m_LastLength = 0;
- memset(m_LastLevels, 0, kMaxTableSize);
-}
-
-#define RIF(x) { if (!(x)) return false; }
-
-bool CDecoder::ReadTables(void)
-{
- Byte levelLevels[kLevelTableSize];
- Byte newLevels[kMaxTableSize];
- m_AudioMode = (m_InBitStream.ReadBits(1) == 1);
-
- if (m_InBitStream.ReadBits(1) == 0)
- memset(m_LastLevels, 0, kMaxTableSize);
- int numLevels;
- if (m_AudioMode)
- {
- m_NumChannels = m_InBitStream.ReadBits(2) + 1;
- if (m_Predictor.CurrentChannel >= m_NumChannels)
- m_Predictor.CurrentChannel = 0;
- numLevels = m_NumChannels * kMMTableSize;
- }
- else
- numLevels = kHeapTablesSizesSum;
-
- int i;
- for (i = 0; i < kLevelTableSize; i++)
- levelLevels[i] = Byte(m_InBitStream.ReadBits(4));
- RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
- i = 0;
- while (i < numLevels)
- {
- UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
- if (number < kTableDirectLevels)
- {
- newLevels[i] = Byte((number + m_LastLevels[i]) & kLevelMask);
- i++;
- }
- else
- {
- if (number == kTableLevelRepNumber)
- {
- int t = m_InBitStream.ReadBits(2) + 3;
- for (int reps = t; reps > 0 && i < numLevels ; reps--, i++)
- newLevels[i] = newLevels[i - 1];
- }
- else
- {
- int num;
- if (number == kTableLevel0Number)
- num = m_InBitStream.ReadBits(3) + 3;
- else if (number == kTableLevel0Number2)
- num = m_InBitStream.ReadBits(7) + 11;
- else
- return false;
- for (;num > 0 && i < numLevels; num--)
- newLevels[i++] = 0;
- }
- }
- }
- if (m_AudioMode)
- for (i = 0; i < m_NumChannels; i++)
- {
- RIF(m_MMDecoders[i].SetCodeLengths(&newLevels[i * kMMTableSize]));
- }
- else
- {
- RIF(m_MainDecoder.SetCodeLengths(&newLevels[0]));
- RIF(m_DistDecoder.SetCodeLengths(&newLevels[kMainTableSize]));
- RIF(m_LenDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize]));
- }
- memcpy(m_LastLevels, newLevels, kMaxTableSize);
- return true;
-}
-
-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_AudioMode)
- {
- UInt32 symbol = m_MMDecoders[m_Predictor.CurrentChannel].DecodeSymbol(&m_InBitStream);
- if (symbol == 256)
- return ReadTables();
- if (symbol >= kMMTableSize)
- return false;
- }
- else
- {
- UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
- if (number == kReadTableNumber)
- return ReadTables();
- if (number >= kMainTableSize)
- return false;
- }
- return true;
-}
-
-class CCoderReleaser
-{
- CDecoder *m_Coder;
-public:
- CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
- ~CCoderReleaser()
- {
- m_Coder->ReleaseStreams();
- }
-};
-
-STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- if (inSize == NULL || outSize == NULL)
- return E_INVALIDARG;
-
- if (!m_OutWindowStream.Create(kHistorySize))
- return E_OUTOFMEMORY;
- if (!m_InBitStream.Create(1 << 20))
- return E_OUTOFMEMORY;
-
- m_PackSize = *inSize;
-
- UInt64 pos = 0, unPackSize = *outSize;
-
- m_OutWindowStream.SetStream(outStream);
- m_OutWindowStream.Init(m_IsSolid);
- m_InBitStream.SetStream(inStream);
- m_InBitStream.Init();
-
- CCoderReleaser coderReleaser(this);
- if (!m_IsSolid)
- {
- InitStructures();
- if (unPackSize == 0)
- {
- if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
- if (!ReadTables())
- return S_FALSE;
- return S_OK;
- }
- if (!ReadTables())
- return S_FALSE;
- }
-
- while(pos < unPackSize)
- {
- if (m_AudioMode)
- while(pos < unPackSize)
- {
- UInt32 symbol = m_MMDecoders[m_Predictor.CurrentChannel].DecodeSymbol(&m_InBitStream);
- if (symbol == 256)
- {
- if (progress != 0)
- {
- UInt64 packSize = m_InBitStream.GetProcessedSize();
- RINOK(progress->SetRatioInfo(&packSize, &pos));
- }
- if (!ReadTables())
- return S_FALSE;
- break;
- }
- if (symbol >= kMMTableSize)
- return S_FALSE;
- Byte byPredict = m_Predictor.Predict();
- Byte byReal = (Byte)(byPredict - (Byte)symbol);
- m_Predictor.Update(byReal, byPredict);
- m_OutWindowStream.PutByte(byReal);
- if (++m_Predictor.CurrentChannel == m_NumChannels)
- m_Predictor.CurrentChannel = 0;
- pos++;
- }
- else
- while(pos < unPackSize)
- {
- UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
- UInt32 length, distance;
- if (number < 256)
- {
- m_OutWindowStream.PutByte(Byte(number));
- pos++;
- continue;
- }
- else if (number >= kMatchNumber)
- {
- number -= kMatchNumber;
- length = kNormalMatchMinLen + UInt32(kLenStart[number]) +
- m_InBitStream.ReadBits(kLenDirectBits[number]);
- number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
- if (number >= kDistTableSize)
- return S_FALSE;
- distance = kDistStart[number] + m_InBitStream.ReadBits(kDistDirectBits[number]);
- if (distance >= kDistLimit3)
- {
- length += 2 - ((distance - kDistLimit4) >> 31);
- // length++;
- // if (distance >= kDistLimit4)
- // length++;
- }
- }
- else if (number == kRepBothNumber)
- {
- length = m_LastLength;
- distance = m_RepDists[(m_RepDistPtr + 4 - 1) & 3];
- }
- else if (number < kLen2Number)
- {
- distance = m_RepDists[(m_RepDistPtr - (number - kRepNumber + 1)) & 3];
- number = m_LenDecoder.DecodeSymbol(&m_InBitStream);
- if (number >= kLenTableSize)
- return S_FALSE;
- length = 2 + kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
- if (distance >= kDistLimit2)
- {
- length++;
- if (distance >= kDistLimit3)
- {
- length += 2 - ((distance - kDistLimit4) >> 31);
- // length++;
- // if (distance >= kDistLimit4)
- // length++;
- }
- }
- }
- else if (number < kReadTableNumber)
- {
- number -= kLen2Number;
- distance = kLen2DistStarts[number] +
- m_InBitStream.ReadBits(kLen2DistDirectBits[number]);
- length = 2;
- }
- else if (number == kReadTableNumber)
- {
- if (progress != 0)
- {
- UInt64 packSize = m_InBitStream.GetProcessedSize();
- RINOK(progress->SetRatioInfo(&packSize, &pos));
- }
- if (!ReadTables())
- return S_FALSE;
- break;
- }
- else
- return S_FALSE;
- m_RepDists[m_RepDistPtr++ & 3] = distance;
- m_LastLength = length;
- if (!m_OutWindowStream.CopyBlock(distance, length))
- return S_FALSE;
- pos += length;
- }
- }
- if (pos > unPackSize)
- throw CException(CException::kData);
-
- if (!ReadLastTables())
- return S_FALSE;
- return m_OutWindowStream.Flush();
-}
-
-STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
- catch(const CLZOutWindowException &e) { return e.ErrorCode; }
- catch(...) { return S_FALSE; }
-}
-
-STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
-{
- if (size < 1)
- return E_INVALIDARG;
- m_IsSolid = (data[0] != 0);
- return S_OK;
-}
-
-}}
diff --git a/7zip/Compress/Rar20/Rar20Decoder.h b/7zip/Compress/Rar20/Rar20Decoder.h
deleted file mode 100755
index f807594c..00000000
--- a/7zip/Compress/Rar20/Rar20Decoder.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// Rar20Decoder.h
-// According to unRAR license,
-// this code may not be used to develop a
-// RAR (WinRAR) compatible archiver
-
-#ifndef __RAR20_DECODER_H
-#define __RAR20_DECODER_H
-
-#include "../../../Common/MyCom.h"
-
-#include "../../ICoder.h"
-#include "../../Common/MSBFDecoder.h"
-#include "../../Common/InBuffer.h"
-
-#include "../LZ/LZOutWindow.h"
-#include "../Huffman/HuffmanDecoder.h"
-
-#include "Rar20Multimedia.h"
-#include "Rar20Const.h"
-
-namespace NCompress {
-namespace NRar20 {
-
-typedef NStream::NMSBF::CDecoder<CInBuffer> CBitDecoder;
-
-const int kNumHuffmanBits = 15;
-
-class CDecoder :
- public ICompressCoder,
- public ICompressSetDecoderProperties2,
- public CMyUnknownImp
-{
- CLZOutWindow m_OutWindowStream;
- CBitDecoder m_InBitStream;
- NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
- NHuffman::CDecoder<kNumHuffmanBits, kDistTableSize> m_DistDecoder;
- NHuffman::CDecoder<kNumHuffmanBits, kLenTableSize> m_LenDecoder;
- NHuffman::CDecoder<kNumHuffmanBits, kMMTableSize> m_MMDecoders[NMultimedia::kNumChanelsMax];
- NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
-
- bool m_AudioMode;
-
- NMultimedia::CPredictor m_Predictor;
- int m_NumChannels;
-
- UInt32 m_RepDists[kNumRepDists];
- UInt32 m_RepDistPtr;
-
- UInt32 m_LastLength;
-
- Byte m_LastLevels[kMaxTableSize];
-
- UInt64 m_PackSize;
- bool m_IsSolid;
-
- void InitStructures();
- bool ReadTables();
- bool ReadLastTables();
-
-public:
- CDecoder();
-
- MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
-
- void ReleaseStreams()
- {
- m_OutWindowStream.ReleaseStream();
- m_InBitStream.ReleaseStream();
- }
-
- STDMETHOD(CodeReal)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
-
-};
-
-}}
-
-#endif
diff --git a/7zip/Compress/Rar20/Rar20ExtConst.h b/7zip/Compress/Rar20/Rar20ExtConst.h
deleted file mode 100755
index b74bc0cf..00000000
--- a/7zip/Compress/Rar20/Rar20ExtConst.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Rar20ExtConst.h
-// According to unRAR license,
-// this code may not be used to develop a
-// RAR (WinRAR) compatible archiver
-
-#ifndef __RAR20_EXTCONST_H
-#define __RAR20_EXTCONST_H
-
-#include "../../../Common/Types.h"
-
-namespace NCompress {
-namespace NRar20 {
-
-const UInt32 kNumRepDists = 4;
-const UInt32 kDistTableSize = 48;
-
-const int kMMTableSize = 256 + 1;
-
-}}
-
-#endif
diff --git a/7zip/Compress/Rar20/Rar20Multimedia.cpp b/7zip/Compress/Rar20/Rar20Multimedia.cpp
deleted file mode 100755
index 3c0a13af..00000000
--- a/7zip/Compress/Rar20/Rar20Multimedia.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-// Rar20Multimedia.cpp
-// According to unRAR license,
-// this code may not be used to develop a
-// RAR (WinRAR) compatible archiver
-
-#include "StdAfx.h"
-
-#include "Rar20Multimedia.h"
-
-namespace NCompress {
-namespace NRar20 {
-namespace NMultimedia {
-
-void CAudioVariables::Init()
-{
- memset(this, 0, sizeof(CAudioVariables));
-}
-
-void CPredictor::Init()
-{
- for(int i = 0; i < kNumChanelsMax; i++)
- m_AudioVariablesArray[i].Init();
- m_ChannelDelta = 0;
- CurrentChannel = 0;
-}
-
-Byte CPredictor::Predict()
-{
- CAudioVariables *v = &m_AudioVariablesArray[CurrentChannel];
- v->ByteCount++;
- v->D4 = v->D3;
- v->D3 = v->D2;
- v->D2 = v->LastDelta-v->D1;
- v->D1 = v->LastDelta;
- int pCh = 8 * v->LastChar +
- v->K1 * v->D1 +
- v->K2 * v->D2 +
- v->K3 * v->D3 +
- v->K4 * v->D4 +
- v->K5*m_ChannelDelta;
- pCh = (pCh >> 3) & 0xFF;
- return Byte(pCh);
-}
-
-void CPredictor::Update(Byte realValue, int predictedValue)
-{
- struct CAudioVariables *v = &m_AudioVariablesArray[CurrentChannel];
-
- int delta = predictedValue - realValue;
- int i = ((signed char)delta) << 3;
-
- v->Dif[0] += abs(i);
- v->Dif[1] += abs(i - v->D1);
- v->Dif[2] += abs(i + v->D1);
- v->Dif[3] += abs(i - v->D2);
- v->Dif[4] += abs(i + v->D2);
- v->Dif[5] += abs(i - v->D3);
- v->Dif[6] += abs(i + v->D3);
- v->Dif[7] += abs(i - v->D4);
- v->Dif[8] += abs(i + v->D4);
- v->Dif[9] += abs(i - m_ChannelDelta);
- v->Dif[10] += abs(i + m_ChannelDelta);
-
- m_ChannelDelta = v->LastDelta = (signed char)(realValue - v->LastChar);
- v->LastChar = realValue;
-
- UInt32 numMinDif, minDif;
- if ((v->ByteCount & 0x1F)==0)
- {
- minDif = v->Dif[0];
- numMinDif = 0;
- v->Dif[0] = 0;
- for (i = 1; i < sizeof(v->Dif) / sizeof(v->Dif[0]); i++)
- {
- if (v->Dif[i] < minDif)
- {
- minDif = v->Dif[i];
- numMinDif = i;
- }
- v->Dif[i] = 0;
- }
- switch(numMinDif)
- {
- case 1:
- if (v->K1 >= -16)
- v->K1--;
- break;
- case 2:
- if (v->K1 < 16)
- v->K1++;
- break;
- case 3:
- if (v->K2 >= -16)
- v->K2--;
- break;
- case 4:
- if (v->K2 < 16)
- v->K2++;
- break;
- case 5:
- if (v->K3 >= -16)
- v->K3--;
- break;
- case 6:
- if (v->K3 < 16)
- v->K3++;
- break;
- case 7:
- if (v->K4 >= -16)
- v->K4--;
- break;
- case 8:
- if (v->K4 < 16)
- v->K4++;
- break;
- case 9:
- if (v->K5 >= -16)
- v->K5--;
- break;
- case 10:
- if (v->K5 < 16)
- v->K5++;
- break;
- }
- }
-}
-
-}}}
diff --git a/7zip/Compress/Rar20/Rar20Multimedia.h b/7zip/Compress/Rar20/Rar20Multimedia.h
deleted file mode 100755
index 7af86d07..00000000
--- a/7zip/Compress/Rar20/Rar20Multimedia.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Rar20Multimedia.h
-// According to unRAR license,
-// this code may not be used to develop a
-// RAR (WinRAR) compatible archiver
-
-#ifndef __RAR20_MULTIMEDIA_H
-#define __RAR20_MULTIMEDIA_H
-
-#include "../../../Common/Types.h"
-
-namespace NCompress {
-namespace NRar20 {
-namespace NMultimedia {
-
-struct CAudioVariables
-{
- int K1,K2,K3,K4,K5;
- int D1,D2,D3,D4;
- int LastDelta;
- UInt32 Dif[11];
- UInt32 ByteCount;
- int LastChar;
-
- void Init();
-};
-
-const int kNumChanelsMax = 4;
-
-class CPredictor
-{
- CAudioVariables m_AudioVariablesArray[kNumChanelsMax];
- int m_ChannelDelta;
-public:
- int CurrentChannel;
-
- void Init();
- Byte Predict();
- void Update(Byte realValue, int predictedValue);
-};
-
-}}}
-
-#endif
diff --git a/7zip/Compress/Rar29/DllExports.cpp b/7zip/Compress/Rar29/DllExports.cpp
deleted file mode 100755
index d0053055..00000000
--- a/7zip/Compress/Rar29/DllExports.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-
-#include "../Rar20/Rar20Decoder.h"
-#include "Rar29Decoder.h"
-
-// {23170F69-40C1-278B-0403-010000000000}
-DEFINE_GUID(CLSID_CCompressRar15Decoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-// {23170F69-40C1-278B-0403-020000000000}
-DEFINE_GUID(CLSID_CCompressRar20Decoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-// {23170F69-40C1-278B-0403-030000000000}
-DEFINE_GUID(CLSID_CCompressRar29Decoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
-{
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
-
- int correctInterface = (*iid == IID_ICompressCoder);
- CMyComPtr<ICompressCoder> coder;
- if (*clsid == CLSID_CCompressRar15Decoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NRar15::CDecoder;
- }
- else if (*clsid == CLSID_CCompressRar20Decoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NRar20::CDecoder;
- }
- else if (*clsid == CLSID_CCompressRar29Decoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- coder = (ICompressCoder *)new NCompress::NRar29::CDecoder;
- }
- else
- return CLASS_E_CLASSNOTAVAILABLE;
- *outObject = coder.Detach();
- COM_TRY_END
- return S_OK;
-}
-
-struct CRarMethodItem
-{
- char ID[3];
- const wchar_t *UserName;
- const GUID *Decoder;
-};
-
-static CRarMethodItem g_Methods[] =
-{
- { { 0x04, 0x03, 0x01 }, L"Rar15", &CLSID_CCompressRar15Decoder },
- { { 0x04, 0x03, 0x02 }, L"Rar20", &CLSID_CCompressRar20Decoder },
- { { 0x04, 0x03, 0x03 }, L"Rar29", &CLSID_CCompressRar29Decoder }
-};
-
-STDAPI GetNumberOfMethods(UINT32 *numMethods)
-{
- *numMethods = sizeof(g_Methods) / sizeof(g_Methods[1]);
- return S_OK;
-}
-
-STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
-{
- if (index > sizeof(g_Methods) / sizeof(g_Methods[1]))
- return E_INVALIDARG;
- VariantClear((tagVARIANT *)value);
- const CRarMethodItem &method = g_Methods[index];
- switch(propID)
- {
- case NMethodPropID::kID:
- if ((value->bstrVal = ::SysAllocStringByteLen(method.ID,
- sizeof(method.ID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(method.UserName)) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)method.Decoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- return S_OK;
-}
diff --git a/7zip/Compress/Rar29/Original/archive.hpp b/7zip/Compress/Rar29/Original/archive.hpp
deleted file mode 100755
index c076b5b7..00000000
--- a/7zip/Compress/Rar29/Original/archive.hpp
+++ /dev/null
@@ -1,128 +0,0 @@
-#ifndef _RAR_ARCHIVE_
-#define _RAR_ARCHIVE_
-
-class Pack;
-
-enum {EN_LOCK=1,EN_VOL=2,EN_FIRSTVOL=4};
-
-class Archive:public File
-{
- private:
- bool IsSignature(byte *D);
- void UpdateLatestTime(FileHeader *CurBlock);
- void Protect(int RecSectors);
- void ConvertNameCase(char *Name);
- void ConvertNameCase(wchar *Name);
- void ConvertUnknownHeader();
- bool AddArcComment(char *NameToShow);
- int ReadOldHeader();
- void PrepareExtraTime(FileHeader *hd,EXTTIME_MODE etm,EXTTIME_MODE etc,EXTTIME_MODE eta,EXTTIME_MODE etarc,Array<byte> &TimeData);
-
-#if !defined(SHELL_EXT) && !defined(NOCRYPT)
- CryptData HeadersCrypt;
- byte HeadersSalt[SALT_SIZE];
-#endif
-#ifndef SHELL_EXT
- ComprDataIO SubDataIO;
- byte SubDataSalt[SALT_SIZE];
-#endif
- RAROptions *Cmd,DummyCmd;
-
- MarkHeader MarkHead;
- OldMainHeader OldMhd;
-
- int RecoverySectors;
- Int64 RecoveryPos;
-
- RarTime LatestTime;
- int LastReadBlock;
- int CurHeaderType;
-
- bool SilentOpen;
- public:
- Archive(RAROptions *InitCmd=NULL);
- bool IsArchive(bool EnableBroken);
- int SearchBlock(int BlockType);
- int SearchSubBlock(const char *Type);
- int ReadBlock(int BlockType);
- void WriteBlock(int BlockType,BaseBlock *wb=NULL);
- int PrepareNamesToWrite(char *Name,wchar *NameW,char *DestName,byte *DestNameW);
- void SetLhdSize();
- int ReadHeader();
- void CheckArc(bool EnableBroken);
- void CheckOpen(char *Name,wchar *NameW=NULL);
- bool WCheckOpen(char *Name,wchar *NameW=NULL);
- bool TestLock(int Mode);
- void MakeTemp();
- void CopyMainHeader(Archive &Src,bool CopySFX=true,char *NameToDisplay=NULL);
- bool ProcessToFileHead(Archive &Src,bool LastBlockAdded,
- Pack *Pack=NULL,const char *SkipName=NULL);
- void TmpToArc(Archive &Src);
- void CloseNew(int AdjustRecovery,bool CloseVolume);
- void WriteEndBlock(bool CloseVolume);
- void CopyFileRecord(Archive &Src);
- void CopyArchiveData(Archive &Src);
- bool GetComment(Array<byte> &CmtData);
- void ViewComment();
- void ViewFileComment();
- void SetLatestTime(RarTime *NewTime);
- void SeekToNext();
- bool CheckAccess();
- bool IsArcDir();
- bool IsArcLabel();
- void ConvertAttributes();
- int GetRecoverySize(bool Required);
- void VolSubtractHeaderSize(int SubSize);
- void AddSubData(byte *SrcData,int DataSize,File *SrcFile,char *Name,bool AllowSplit);
- bool ReadSubData(Array<byte> *UnpData,File *DestFile);
- int GetHeaderType() {return(CurHeaderType);};
- int ReadCommentData(Array<byte> &CmtData);
- void WriteCommentData(byte *Data,int DataSize,bool FileComment);
- RAROptions* GetRAROptions() {return(Cmd);}
- void SetSilentOpen(bool Mode) {SilentOpen=Mode;}
-
- BaseBlock ShortBlock;
- MainHeader NewMhd;
- FileHeader NewLhd;
- EndArcHeader EndArcHead;
- SubBlockHeader SubBlockHead;
- FileHeader SubHead;
- CommentHeader CommHead;
- ProtectHeader ProtectHead;
- AVHeader AVHead;
- SignHeader SignHead;
- UnixOwnersHeader UOHead;
- MacFInfoHeader MACHead;
- EAHeader EAHead;
- StreamHeader StreamHead;
-
- Int64 CurBlockPos;
- Int64 NextBlockPos;
-
- bool OldFormat;
- bool Solid;
- bool Volume;
- bool MainComment;
- bool Locked;
- bool Signed;
- bool NotFirstVolume;
- bool Protected;
- bool Encrypted;
- uint SFXSize;
- bool BrokenFileHeader;
-
- bool Splitting;
-
- ushort HeaderCRC;
-
- Int64 VolWrite;
- Int64 AddingFilesSize;
- uint AddingHeadersSize;
-
- bool NewArchive;
-
- char FirstVolumeName[NM];
- wchar FirstVolumeNameW[NM];
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/array.hpp b/7zip/Compress/Rar29/Original/array.hpp
deleted file mode 100755
index 3afec70c..00000000
--- a/7zip/Compress/Rar29/Original/array.hpp
+++ /dev/null
@@ -1,121 +0,0 @@
-#ifndef _RAR_ARRAY_
-#define _RAR_ARRAY_
-
-extern ErrorHandler ErrHandler;
-
-template <class T> class Array
-{
- private:
- T *Buffer;
- int BufSize;
- int AllocSize;
- public:
- Array();
- Array(int Size);
- ~Array();
- inline void CleanData();
- inline T& operator [](int Item);
- inline int Size();
- void Add(int Items);
- void Alloc(int Items);
- void Reset();
- void operator = (Array<T> &Src);
- void Push(T Item);
-};
-
-template <class T> void Array<T>::CleanData()
-{
- Buffer=NULL;
- BufSize=0;
- AllocSize=0;
-}
-
-
-template <class T> Array<T>::Array()
-{
- CleanData();
-}
-
-
-template <class T> Array<T>::Array(int Size)
-{
- Buffer=(T *)rarmalloc(sizeof(T)*Size);
- if (Buffer==NULL && Size!=0)
- ErrHandler.MemoryError();
-
- AllocSize=BufSize=Size;
-}
-
-
-template <class T> Array<T>::~Array()
-{
- if (Buffer!=NULL)
- rarfree(Buffer);
-}
-
-
-template <class T> inline T& Array<T>::operator [](int Item)
-{
- return(Buffer[Item]);
-}
-
-
-template <class T> inline int Array<T>::Size()
-{
- return(BufSize);
-}
-
-
-template <class T> void Array<T>::Add(int Items)
-{
- BufSize+=Items;
- if (BufSize>AllocSize)
- {
- int Suggested=AllocSize+AllocSize/4+32;
- int NewSize=Max(BufSize,Suggested);
-
- Buffer=(T *)rarrealloc(Buffer,NewSize*sizeof(T));
- if (Buffer==NULL)
- ErrHandler.MemoryError();
- AllocSize=NewSize;
- }
-}
-
-
-template <class T> void Array<T>::Alloc(int Items)
-{
- if (Items>AllocSize)
- Add(Items-BufSize);
- else
- BufSize=Items;
-}
-
-
-template <class T> void Array<T>::Reset()
-{
- if (Buffer!=NULL)
- {
- rarfree(Buffer);
- Buffer=NULL;
- }
- BufSize=0;
- AllocSize=0;
-}
-
-
-template <class T> void Array<T>::operator =(Array<T> &Src)
-{
- Reset();
- Alloc(Src.BufSize);
- if (Src.BufSize!=0)
- memcpy((void *)Buffer,(void *)Src.Buffer,Src.BufSize*sizeof(T));
-}
-
-
-template <class T> void Array<T>::Push(T Item)
-{
- Add(1);
- (*this)[Size()-1]=Item;
-}
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/cmddata.hpp b/7zip/Compress/Rar29/Original/cmddata.hpp
deleted file mode 100755
index 08b92c11..00000000
--- a/7zip/Compress/Rar29/Original/cmddata.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef _RAR_CMDDATA_
-#define _RAR_CMDDATA_
-
-#define DefaultStoreList "ace;arj;bz2;cab;gz;jpeg;jpg;lha;lzh;mp3;rar;zip;taz;tgz;z"
-
-class CommandData:public RAROptions
-{
- private:
- void ProcessSwitchesString(char *Str);
- void ProcessSwitch(char *Switch);
- void BadSwitch(char *Switch);
- bool ExclCheckArgs(StringList *Args,char *CheckName,bool CheckFullPath,int MatchMode);
- uint GetExclAttr(char *Str);
-
- bool FileLists;
- bool NoMoreSwitches;
- bool TimeConverted;
- bool BareOutput;
- public:
- CommandData();
- ~CommandData();
- void Init();
- void Close();
- void ParseArg(char *Arg,wchar *ArgW);
- void ParseDone();
- void ParseEnvVar();
- void ReadConfig(int argc,char *argv[]);
- bool IsConfigEnabled(int argc,char *argv[]);
- void OutTitle();
- void OutHelp();
- bool IsSwitch(int Ch);
- bool ExclCheck(char *CheckName,bool CheckFullPath);
- bool StoreCheck(char *CheckName);
- bool TimeCheck(RarTime &ft);
- int IsProcessFile(FileHeader &NewLhd,bool *ExactMatch=NULL,int MatchType=MATCH_WILDSUBPATH);
- void ProcessCommand();
- void AddArcName(char *Name,wchar *NameW);
- bool GetArcName(char *Name,wchar *NameW,int MaxSize);
- bool CheckWinSize();
-
- int GetRecoverySize(char *Str,int DefSize);
-
- char Command[NM+16];
- wchar CommandW[NM+16];
-
- char ArcName[NM];
- wchar ArcNameW[NM];
-
- StringList *FileArgs;
- StringList *ExclArgs;
- StringList *InclArgs;
- StringList *ArcNames;
- StringList *StoreArgs;
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/coder.cpp b/7zip/Compress/Rar29/Original/coder.cpp
deleted file mode 100755
index cb6a8836..00000000
--- a/7zip/Compress/Rar29/Original/coder.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-inline unsigned int RangeCoder::GetChar()
-{
- return(UnpackRead->GetChar());
-}
-
-
-void RangeCoder::InitDecoder(Unpack *UnpackRead)
-{
- RangeCoder::UnpackRead=UnpackRead;
-
- low=code=0;
- range=uint(-1);
- for (int i=0;i < 4;i++)
- code=(code << 8) | GetChar();
-}
-
-
-#define ARI_DEC_NORMALIZE(code,low,range,read) \
-{ \
- while ((low^(low+range))<TOP || range<BOT && ((range=-low&(BOT-1)),1)) \
- { \
- code=(code << 8) | read->GetChar(); \
- range <<= 8; \
- low <<= 8; \
- } \
-}
-
-
-inline int RangeCoder::GetCurrentCount()
-{
- return (code-low)/(range /= SubRange.scale);
-}
-
-
-inline uint RangeCoder::GetCurrentShiftCount(uint SHIFT)
-{
- return (code-low)/(range >>= SHIFT);
-}
-
-
-inline void RangeCoder::Decode()
-{
- low += range*SubRange.LowCount;
- range *= SubRange.HighCount-SubRange.LowCount;
-}
diff --git a/7zip/Compress/Rar29/Original/coder.hpp b/7zip/Compress/Rar29/Original/coder.hpp
deleted file mode 100755
index f09f911c..00000000
--- a/7zip/Compress/Rar29/Original/coder.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/****************************************************************************
- * Contents: 'Carryless rangecoder' by Dmitry Subbotin *
- ****************************************************************************/
-
-const uint TOP=1 << 24, BOT=1 << 15;
-
-class RangeCoder
-{
- public:
- void InitDecoder(Unpack *UnpackRead);
- inline int GetCurrentCount();
- inline uint GetCurrentShiftCount(uint SHIFT);
- inline void Decode();
- inline void PutChar(unsigned int c);
- inline unsigned int GetChar();
-
- uint low, code, range;
- struct SUBRANGE
- {
- uint LowCount, HighCount, scale;
- } SubRange;
-
- Unpack *UnpackRead;
-};
diff --git a/7zip/Compress/Rar29/Original/compress.hpp b/7zip/Compress/Rar29/Original/compress.hpp
deleted file mode 100755
index 2ba7b23e..00000000
--- a/7zip/Compress/Rar29/Original/compress.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef _RAR_COMPRESS_
-#define _RAR_COMPRESS_
-
-class ComprDataIO;
-class PackingFileTable;
-
-#define CODEBUFSIZE 0x4000
-#define MAXWINSIZE 0x400000
-#define MAXWINMASK (MAXWINSIZE-1)
-
-#define LOW_DIST_REP_COUNT 16
-
-#define NC 299 /* alphabet = {0, 1, 2, ..., NC - 1} */
-#define DC 60
-#define LDC 17
-#define RC 28
-#define HUFF_TABLE_SIZE (NC+DC+RC+LDC)
-#define BC 20
-
-#define NC20 298 /* alphabet = {0, 1, 2, ..., NC - 1} */
-#define DC20 48
-#define RC20 28
-#define BC20 19
-#define MC20 257
-
-enum {CODE_HUFFMAN,CODE_LZ,CODE_LZ2,CODE_REPEATLZ,CODE_CACHELZ,
- CODE_STARTFILE,CODE_ENDFILE,CODE_VM,CODE_VMDATA};
-
-
-enum FilterType {
- FILTER_NONE, FILTER_PPM /*dummy*/, FILTER_E8, FILTER_E8E9,
- FILTER_UPCASETOLOW, FILTER_AUDIO, FILTER_RGB, FILTER_DELTA,
- FILTER_ITANIUM, FILTER_E8E9V2
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/consio.hpp b/7zip/Compress/Rar29/Original/consio.hpp
deleted file mode 100755
index 780ae7f3..00000000
--- a/7zip/Compress/Rar29/Original/consio.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef _RAR_CONSIO_
-#define _RAR_CONSIO_
-
-enum {ALARM_SOUND,ERROR_SOUND,QUESTION_SOUND};
-
-enum PASSWORD_TYPE {PASSWORD_GLOBAL,PASSWORD_FILE,PASSWORD_ARCHIVE};
-
-void InitConsoleOptions(MESSAGE_TYPE MsgStream,bool Sound);
-
-#ifndef SILENT
-void mprintf(const char *fmt,...);
-void eprintf(const char *fmt,...);
-void Alarm();
-void GetPasswordText(char *Str,int MaxLength);
-unsigned int GetKey();
-bool GetPassword(PASSWORD_TYPE Type,const char *FileName,char *Password,int MaxLength);
-int Ask(const char *AskStr);
-#endif
-
-int KbdAnsi(char *Addr,int Size);
-void OutComment(char *Comment,int Size);
-
-#ifdef SILENT
-#ifdef __GNUC__
- #define mprintf(args...)
- #define eprintf(args...)
-#else
- inline void mprintf(const char *fmt,const char *a=NULL,const char *b=NULL) {}
- inline void eprintf(const char *fmt,const char *a=NULL,const char *b=NULL) {}
- inline void mprintf(const char *fmt,int b) {}
- inline void eprintf(const char *fmt,int b) {}
- inline void mprintf(const char *fmt,const char *a,int b) {}
- inline void eprintf(const char *fmt,const char *a,int b) {}
-#endif
-inline void Alarm() {}
-inline void GetPasswordText(char *Str,int MaxLength) {}
-inline unsigned int GetKey() {return(0);}
-inline bool GetPassword(PASSWORD_TYPE Type,const char *FileName,char *Password,int MaxLength) {return(false);}
-inline int Ask(const char *AskStr) {return(0);}
-#endif
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/crc.cpp b/7zip/Compress/Rar29/Original/crc.cpp
deleted file mode 100755
index c19f8595..00000000
--- a/7zip/Compress/Rar29/Original/crc.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "rar.hpp"
-
-uint CRCTab[256];
-
-void InitCRC()
-{
- for (int I=0;I<256;I++)
- {
- uint C=I;
- for (int J=0;J<8;J++)
- C=(C & 1) ? (C>>1)^0xEDB88320L : (C>>1);
- CRCTab[I]=C;
- }
-}
-
-
-uint CRC(uint StartCRC,const void *Addr,uint Size)
-{
- if (CRCTab[1]==0)
- InitCRC();
- byte *Data=(byte *)Addr;
-#if defined(LITTLE_ENDIAN) && defined(PRESENT_INT32)
- while (Size>0 && ((long)Data & 7))
- {
- StartCRC=CRCTab[(byte)(StartCRC^Data[0])]^(StartCRC>>8);
- Size--;
- Data++;
- }
- while (Size>=8)
- {
- StartCRC^=*(uint32 *)Data;
- StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
- StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
- StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
- StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
- StartCRC^=*(uint32 *)(Data+4);
- StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
- StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
- StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
- StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
- Data+=8;
- Size-=8;
- }
-#endif
- for (int I=0;I<Size;I++)
- StartCRC=CRCTab[(byte)(StartCRC^Data[I])]^(StartCRC>>8);
- return(StartCRC);
-}
-
-#ifndef SFX_MODULE
-ushort OldCRC(ushort StartCRC,const void *Addr,uint Size)
-{
- byte *Data=(byte *)Addr;
- for (int I=0;I<Size;I++)
- {
- StartCRC=(StartCRC+Data[I])&0xffff;
- StartCRC=((StartCRC<<1)|(StartCRC>>15))&0xffff;
- }
- return(StartCRC);
-}
-#endif
diff --git a/7zip/Compress/Rar29/Original/crc.hpp b/7zip/Compress/Rar29/Original/crc.hpp
deleted file mode 100755
index 47ee7e23..00000000
--- a/7zip/Compress/Rar29/Original/crc.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _RAR_CRC_
-#define _RAR_CRC_
-
-extern uint CRCTab[256];
-
-void InitCRC();
-uint CRC(uint StartCRC,const void *Addr,uint Size);
-ushort OldCRC(ushort StartCRC,const void *Addr,uint Size);
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/crypt.hpp b/7zip/Compress/Rar29/Original/crypt.hpp
deleted file mode 100755
index 809d76a5..00000000
--- a/7zip/Compress/Rar29/Original/crypt.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef _RAR_CRYPT_
-#define _RAR_CRYPT_
-
-enum { OLD_DECODE=0,OLD_ENCODE=1,NEW_CRYPT=2 };
-
-struct CryptKeyCacheItem
-{
-#ifndef _SFX_RTL_
- CryptKeyCacheItem()
- {
- *Password=0;
- }
-
- ~CryptKeyCacheItem()
- {
- memset(AESKey,0,sizeof(AESKey));
- memset(AESInit,0,sizeof(AESInit));
- memset(Password,0,sizeof(Password));
- }
-#endif
- byte AESKey[16],AESInit[16];
- char Password[MAXPASSWORD];
- bool SaltPresent;
- byte Salt[SALT_SIZE];
-};
-
-class CryptData
-{
- private:
- void Encode13(byte *Data,uint Count);
- void Decode13(byte *Data,uint Count);
- void Crypt15(byte *Data,uint Count);
- void UpdKeys(byte *Buf);
- void Swap(byte *Ch1,byte *Ch2);
- void SetOldKeys(char *Password);
-
- Rijndael rin;
-
- byte SubstTable[256];
- uint Key[4];
- ushort OldKey[4];
- byte PN1,PN2,PN3;
-
- byte AESKey[16],AESInit[16];
-
- static CryptKeyCacheItem Cache[4];
- static int CachePos;
- public:
- void SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly=false);
- void SetAV15Encryption();
- void SetCmt13Encryption();
- void EncryptBlock20(byte *Buf);
- void DecryptBlock20(byte *Buf);
- void EncryptBlock(byte *Buf,int Size);
- void DecryptBlock(byte *Buf,int Size);
- void Crypt(byte *Data,uint Count,int Method);
- static void SetSalt(byte *Salt,int SaltSize);
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/encname.hpp b/7zip/Compress/Rar29/Original/encname.hpp
deleted file mode 100755
index 586f4216..00000000
--- a/7zip/Compress/Rar29/Original/encname.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _RAR_ENCNAME_
-#define _RAR_ENCNAME_
-
-class EncodeFileName
-{
- private:
- void AddFlags(int Value);
-
- byte *EncName;
- byte Flags;
- int FlagBits;
- int FlagsPos;
- int DestSize;
- public:
- EncodeFileName();
- int Encode(char *Name,wchar *NameW,byte *EncName);
- void Decode(char *Name,byte *EncName,int EncSize,wchar *NameW,int MaxDecSize);
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/errhnd.cpp b/7zip/Compress/Rar29/Original/errhnd.cpp
deleted file mode 100755
index 6e162217..00000000
--- a/7zip/Compress/Rar29/Original/errhnd.cpp
+++ /dev/null
@@ -1,356 +0,0 @@
-#include "rar.hpp"
-
-
-static bool UserBreak;
-
-ErrorHandler::ErrorHandler()
-{
- Clean();
-}
-
-
-void ErrorHandler::Clean()
-{
- ExitCode=SUCCESS;
- ErrCount=0;
- EnableBreak=true;
- Silent=false;
- DoShutdown=false;
-}
-
-
-void ErrorHandler::MemoryError()
-{
- MemoryErrorMsg();
- Throw(MEMORY_ERROR);
-}
-
-
-void ErrorHandler::OpenError(const char *FileName)
-{
-#ifndef SILENT
- OpenErrorMsg(FileName);
- Throw(OPEN_ERROR);
-#endif
-}
-
-
-void ErrorHandler::CloseError(const char *FileName)
-{
-#ifndef SILENT
- if (!UserBreak)
- {
- ErrMsg(NULL,St(MErrFClose),FileName);
- SysErrMsg();
- }
-#endif
-#if !defined(SILENT) || defined(RARDLL)
- Throw(FATAL_ERROR);
-#endif
-}
-
-
-void ErrorHandler::ReadError(const char *FileName)
-{
-#ifndef SILENT
- ReadErrorMsg(NULL,FileName);
-#endif
-#if !defined(SILENT) || defined(RARDLL)
- Throw(FATAL_ERROR);
-#endif
-}
-
-
-bool ErrorHandler::AskRepeatRead(const char *FileName)
-{
-#if !defined(SILENT) && !defined(SFX_MODULE) && !defined(_WIN_CE)
- if (!Silent)
- {
- mprintf("\n");
- Log(NULL,St(MErrRead),FileName);
- return(Ask(St(MRetryAbort))==1);
- }
-#endif
- return(false);
-}
-
-
-void ErrorHandler::WriteError(const char *ArcName,const char *FileName)
-{
-#ifndef SILENT
- WriteErrorMsg(ArcName,FileName);
-#endif
-#if !defined(SILENT) || defined(RARDLL)
- Throw(WRITE_ERROR);
-#endif
-}
-
-
-#ifdef _WIN_32
-void ErrorHandler::WriteErrorFAT(const char *FileName)
-{
-#if !defined(SILENT) && !defined(SFX_MODULE)
- SysErrMsg();
- ErrMsg(NULL,St(MNTFSRequired),FileName);
-#endif
-#if !defined(SILENT) && !defined(SFX_MODULE) || defined(RARDLL)
- Throw(WRITE_ERROR);
-#endif
-}
-#endif
-
-
-bool ErrorHandler::AskRepeatWrite(const char *FileName)
-{
-#if !defined(SILENT) && !defined(_WIN_CE)
- if (!Silent)
- {
- mprintf("\n");
- Log(NULL,St(MErrWrite),FileName);
- return(Ask(St(MRetryAbort))==1);
- }
-#endif
- return(false);
-}
-
-
-void ErrorHandler::SeekError(const char *FileName)
-{
-#ifndef SILENT
- if (!UserBreak)
- {
- ErrMsg(NULL,St(MErrSeek),FileName);
- SysErrMsg();
- }
-#endif
-#if !defined(SILENT) || defined(RARDLL)
- Throw(FATAL_ERROR);
-#endif
-}
-
-
-void ErrorHandler::MemoryErrorMsg()
-{
-#ifndef SILENT
- ErrMsg(NULL,St(MErrOutMem));
-#endif
-}
-
-
-void ErrorHandler::OpenErrorMsg(const char *FileName)
-{
- OpenErrorMsg(NULL,FileName);
-}
-
-
-void ErrorHandler::OpenErrorMsg(const char *ArcName,const char *FileName)
-{
-#ifndef SILENT
- Log(ArcName && *ArcName ? ArcName:NULL,St(MCannotOpen),FileName);
- Alarm();
- SysErrMsg();
-#endif
-}
-
-
-void ErrorHandler::CreateErrorMsg(const char *FileName)
-{
- CreateErrorMsg(NULL,FileName);
-}
-
-
-void ErrorHandler::CreateErrorMsg(const char *ArcName,const char *FileName)
-{
-#ifndef SILENT
- Log(ArcName && *ArcName ? ArcName:NULL,St(MCannotCreate),FileName);
- Alarm();
-#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE) && defined(MAXPATH)
- if (GetLastError()==ERROR_PATH_NOT_FOUND)
- {
- int NameLength=strlen(FileName);
- if (!IsFullPath(FileName))
- {
- char CurDir[NM];
- GetCurrentDirectory(sizeof(CurDir),CurDir);
- NameLength+=strlen(CurDir)+1;
- }
- if (NameLength>MAXPATH)
- {
- Log(ArcName && *ArcName ? ArcName:NULL,St(MMaxPathLimit),MAXPATH);
- }
- }
-#endif
- SysErrMsg();
-#endif
-}
-
-
-void ErrorHandler::ReadErrorMsg(const char *ArcName,const char *FileName)
-{
-#ifndef SILENT
- ErrMsg(ArcName,St(MErrRead),FileName);
- SysErrMsg();
-#endif
-}
-
-
-void ErrorHandler::WriteErrorMsg(const char *ArcName,const char *FileName)
-{
-#ifndef SILENT
- ErrMsg(ArcName,St(MErrWrite),FileName);
- SysErrMsg();
-#endif
-}
-
-
-void ErrorHandler::Exit(int ExitCode)
-{
-#ifndef SFX_MODULE
- Alarm();
-#endif
- Throw(ExitCode);
-}
-
-
-#ifndef GUI
-void ErrorHandler::ErrMsg(const char *ArcName,const char *fmt,...)
-{
- safebuf char Msg[NM+1024];
- va_list argptr;
- va_start(argptr,fmt);
- vsprintf(Msg,fmt,argptr);
- va_end(argptr);
-#ifdef _WIN_32
- if (UserBreak)
- Sleep(5000);
-#endif
- Alarm();
- if (*Msg)
- {
- Log(ArcName,"\n%s",Msg);
- mprintf("\n%s\n",St(MProgAborted));
- }
-}
-#endif
-
-
-void ErrorHandler::SetErrorCode(int Code)
-{
- switch(Code)
- {
- case WARNING:
- case USER_BREAK:
- if (ExitCode==SUCCESS)
- ExitCode=Code;
- break;
- case FATAL_ERROR:
- if (ExitCode==SUCCESS || ExitCode==WARNING)
- ExitCode=FATAL_ERROR;
- break;
- default:
- ExitCode=Code;
- break;
- }
- ErrCount++;
-}
-
-
-#if !defined(GUI) && !defined(_SFX_RTL_)
-#ifdef _WIN_32
-BOOL __stdcall ProcessSignal(DWORD SigType)
-#else
-#if defined(__sun)
-extern "C"
-#endif
-void _stdfunction ProcessSignal(int SigType)
-#endif
-{
-#ifdef _WIN_32
- if (SigType==CTRL_LOGOFF_EVENT)
- return(TRUE);
-#endif
- UserBreak=true;
- mprintf(St(MBreak));
- for (int I=0;
- // Igor Pavlov
- // !File::RemoveCreated() &&
- I<3;I++)
- {
-#ifdef _WIN_32
- Sleep(100);
-#endif
- }
-#if defined(USE_RC) && !defined(SFX_MODULE) && !defined(_WIN_CE)
- ExtRes.UnloadDLL();
-#endif
- exit(USER_BREAK);
-#ifdef _WIN_32
- return(TRUE);
-#endif
-}
-#endif
-
-
-void ErrorHandler::SetSignalHandlers(bool Enable)
-{
- EnableBreak=Enable;
-#if !defined(GUI) && !defined(_SFX_RTL_)
-#ifdef _WIN_32
- SetConsoleCtrlHandler(Enable ? ProcessSignal:NULL,TRUE);
-// signal(SIGBREAK,Enable ? ProcessSignal:SIG_IGN);
-#else
- signal(SIGINT,Enable ? ProcessSignal:SIG_IGN);
- signal(SIGTERM,Enable ? ProcessSignal:SIG_IGN);
-#endif
-#endif
-}
-
-
-void ErrorHandler::Throw(int Code)
-{
- if (Code==USER_BREAK && !EnableBreak)
- return;
- ErrHandler.SetErrorCode(Code);
-#ifdef ALLOW_EXCEPTIONS
- throw Code;
-#else
- // Igor Pavlov
- // File::RemoveCreated();
- exit(Code);
-#endif
-}
-
-
-void ErrorHandler::SysErrMsg()
-{
-#if defined(_WIN_32) && !defined(SFX_MODULE) && !defined(SILENT)
- #define STRCHR strchr
- #define ERRCHAR char
- ERRCHAR *lpMsgBuf=NULL;
- int ErrType=GetLastError();
- if (ErrType!=0 && FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,ErrType,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&lpMsgBuf,0,NULL))
- {
- ERRCHAR *CurMsg=lpMsgBuf;
- while (CurMsg!=NULL)
- {
- while (*CurMsg=='\r' || *CurMsg=='\n')
- CurMsg++;
- if (*CurMsg==0)
- break;
- ERRCHAR *EndMsg=STRCHR(CurMsg,'\r');
- if (EndMsg==NULL)
- EndMsg=STRCHR(CurMsg,'\n');
- if (EndMsg!=NULL)
- {
- *EndMsg=0;
- EndMsg++;
- }
- Log(NULL,"\n%s",CurMsg);
- CurMsg=EndMsg;
- }
- }
- LocalFree( lpMsgBuf );
-#endif
-}
diff --git a/7zip/Compress/Rar29/Original/errhnd.hpp b/7zip/Compress/Rar29/Original/errhnd.hpp
deleted file mode 100755
index 9e276222..00000000
--- a/7zip/Compress/Rar29/Original/errhnd.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef _RAR_ERRHANDLER_
-#define _RAR_ERRHANDLER_
-
-#if (defined(GUI) || !defined(_WIN_32)) && !defined(SFX_MODULE) && !defined(_WIN_CE) || defined(RARDLL)
-#define ALLOW_EXCEPTIONS
-#endif
-
-
-
-#define rarmalloc malloc
-#define rarcalloc calloc
-#define rarrealloc realloc
-#define rarfree free
-#define rarstrdup strdup
-
-
-
-enum { SUCCESS,WARNING,FATAL_ERROR,CRC_ERROR,LOCK_ERROR,WRITE_ERROR,
- OPEN_ERROR,USER_ERROR,MEMORY_ERROR,CREATE_ERROR,USER_BREAK=255};
-
-class ErrorHandler
-{
- private:
- void ErrMsg(const char *ArcName,const char *fmt,...);
-
- int ExitCode;
- int ErrCount;
- bool EnableBreak;
- bool Silent;
- bool DoShutdown;
- public:
- ErrorHandler();
- void Clean();
- void MemoryError();
- void OpenError(const char *FileName);
- void CloseError(const char *FileName);
- void ReadError(const char *FileName);
- bool AskRepeatRead(const char *FileName);
- void WriteError(const char *ArcName,const char *FileName);
- void WriteErrorFAT(const char *FileName);
- bool AskRepeatWrite(const char *FileName);
- void SeekError(const char *FileName);
- void MemoryErrorMsg();
- void OpenErrorMsg(const char *FileName);
- void OpenErrorMsg(const char *ArcName,const char *FileName);
- void CreateErrorMsg(const char *FileName);
- void CreateErrorMsg(const char *ArcName,const char *FileName);
- void ReadErrorMsg(const char *ArcName,const char *FileName);
- void WriteErrorMsg(const char *ArcName,const char *FileName);
- void Exit(int ExitCode);
- void SetErrorCode(int Code);
- int GetErrorCode() {return(ExitCode);}
- int GetErrorCount() {return(ErrCount);}
- void SetSignalHandlers(bool Enable);
- void Throw(int Code);
- void SetSilent(bool Mode) {Silent=Mode;};
- void SetShutdown(bool Mode) {DoShutdown=Mode;};
- void SysErrMsg();
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/extinfo.hpp b/7zip/Compress/Rar29/Original/extinfo.hpp
deleted file mode 100755
index db7cea53..00000000
--- a/7zip/Compress/Rar29/Original/extinfo.hpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _RAR_EXTINFO_
-#define _RAR_EXTINFO_
-
-
-void SetExtraInfo(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW);
-void SetExtraInfoNew(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW);
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/extract.hpp b/7zip/Compress/Rar29/Original/extract.hpp
deleted file mode 100755
index b78c988d..00000000
--- a/7zip/Compress/Rar29/Original/extract.hpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef _RAR_EXTRACT_
-#define _RAR_EXTRACT_
-
-enum EXTRACT_ARC_CODE {EXTRACT_ARC_NEXT,EXTRACT_ARC_REPEAT};
-
-class CmdExtract
-{
- private:
- ComprDataIO DataIO;
- Unpack *Unp;
- long TotalFileCount;
-
- long FileCount;
- long MatchedArgs;
- bool FirstFile;
- bool AllMatchesExact;
- bool ReconstructDone;
-
- char ArcName[NM];
- wchar ArcNameW[NM];
-
- char Password[MAXPASSWORD];
- bool PasswordAll;
- bool PrevExtracted;
- bool SignatureFound;
- char DestFileName[NM];
- wchar DestFileNameW[NM];
- bool PasswordCancelled;
- public:
- CmdExtract();
- ~CmdExtract();
- void DoExtract(CommandData *Cmd);
- void ExtractArchiveInit(CommandData *Cmd,Archive &Arc);
- EXTRACT_ARC_CODE ExtractArchive(CommandData *Cmd);
- bool ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize,
- bool &Repeat);
- static void UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize);
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/filcreat.hpp b/7zip/Compress/Rar29/Original/filcreat.hpp
deleted file mode 100755
index fa1fddd0..00000000
--- a/7zip/Compress/Rar29/Original/filcreat.hpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _RAR_FILECREATE_
-#define _RAR_FILECREATE_
-
-bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
- OVERWRITE_MODE Mode,bool *UserReject,Int64 FileSize=INT64ERR,
- uint FileTime=0);
-
-#if defined(_WIN_32) && !defined(_WIN_CE)
-bool UpdateExistingShortName(char *Name,wchar *NameW);
-#endif
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/file.hpp b/7zip/Compress/Rar29/Original/file.hpp
deleted file mode 100755
index afa9529c..00000000
--- a/7zip/Compress/Rar29/Original/file.hpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef _RAR_FILE_
-#define _RAR_FILE_
-
-#ifdef _WIN_32
-typedef HANDLE FileHandle;
-#define BAD_HANDLE INVALID_HANDLE_VALUE
-#else
-typedef FILE* FileHandle;
-#define BAD_HANDLE NULL
-#endif
-
-class RAROptions;
-
-enum FILE_HANDLETYPE {FILE_HANDLENORMAL,FILE_HANDLESTD,FILE_HANDLEERR};
-
-enum FILE_ERRORTYPE {FILE_SUCCESS,FILE_NOTFOUND,FILE_READERROR};
-
-struct FileStat
-{
- uint FileAttr;
- uint FileTime;
- Int64 FileSize;
- bool IsDir;
-};
-
-
-class File
-{
- private:
- void AddFileToList(FileHandle hFile);
-
- FileHandle hFile;
- bool LastWrite;
- FILE_HANDLETYPE HandleType;
- bool SkipClose;
- bool IgnoreReadErrors;
- bool NewFile;
- bool AllowDelete;
- bool AllowExceptions;
-#ifdef _WIN_32
- bool NoSequentialRead;
-#endif
- protected:
- bool OpenShared;
- public:
- char FileName[NM];
- wchar FileNameW[NM];
-
- FILE_ERRORTYPE ErrorType;
-
- uint CloseCount;
- public:
- File();
- virtual ~File();
- void operator = (File &SrcFile);
- bool Open(const char *Name,const wchar *NameW=NULL,bool OpenShared=false,bool Update=false);
- void TOpen(const char *Name,const wchar *NameW=NULL);
- bool WOpen(const char *Name,const wchar *NameW=NULL);
- bool Create(const char *Name,const wchar *NameW=NULL);
- void TCreate(const char *Name,const wchar *NameW=NULL);
- bool WCreate(const char *Name,const wchar *NameW=NULL);
- bool Close();
- void Flush();
- bool Delete();
- bool Rename(const char *NewName);
- void Write(const void *Data,int Size);
- int Read(void *Data,int Size);
- int DirectRead(void *Data,int Size);
- void Seek(Int64 Offset,int Method);
- bool RawSeek(Int64 Offset,int Method);
- Int64 Tell();
- void Prealloc(Int64 Size);
- byte GetByte();
- void PutByte(byte Byte);
- bool Truncate();
- void SetOpenFileTime(RarTime *ftm,RarTime *ftc=NULL,RarTime *fta=NULL);
- void SetCloseFileTime(RarTime *ftm,RarTime *fta=NULL);
- static void SetCloseFileTimeByName(const char *Name,RarTime *ftm,RarTime *fta);
- void SetOpenFileStat(RarTime *ftm,RarTime *ftc,RarTime *fta);
- void SetCloseFileStat(RarTime *ftm,RarTime *fta,uint FileAttr);
- void GetOpenFileTime(RarTime *ft);
- bool IsOpened() {return(hFile!=BAD_HANDLE);};
- Int64 FileLength();
- void SetHandleType(FILE_HANDLETYPE Type);
- FILE_HANDLETYPE GetHandleType() {return(HandleType);};
- bool IsDevice();
- void fprintf(const char *fmt,...);
- static bool RemoveCreated();
- FileHandle GetHandle() {return(hFile);};
- void SetIgnoreReadErrors(bool Mode) {IgnoreReadErrors=Mode;};
- char *GetName() {return(FileName);}
- long Copy(File &Dest,Int64 Length=INT64ERR);
- void SetAllowDelete(bool Allow) {AllowDelete=Allow;}
- void SetExceptions(bool Allow) {AllowExceptions=Allow;}
-#ifdef _WIN_32
- void RemoveSequentialFlag() {NoSequentialRead=true;}
-#endif
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/filefn.hpp b/7zip/Compress/Rar29/Original/filefn.hpp
deleted file mode 100755
index 3ad31b5e..00000000
--- a/7zip/Compress/Rar29/Original/filefn.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef _RAR_FILEFN_
-#define _RAR_FILEFN_
-
-enum MKDIR_CODE {MKDIR_SUCCESS,MKDIR_ERROR,MKDIR_BADPATH};
-
-MKDIR_CODE MakeDir(const char *Name,const wchar *NameW,uint Attr);
-void CreatePath(const char *Path,const wchar *PathW,bool SkipLastName);
-void SetDirTime(const char *Name,RarTime *ftm,RarTime *ftc,RarTime *fta);
-bool IsRemovable(const char *Name);
-Int64 GetFreeDisk(const char *Name);
-bool FileExist(const char *Name,const wchar *NameW=NULL);
-bool WildFileExist(const char *Name,const wchar *NameW=NULL);
-bool IsDir(uint Attr);
-bool IsUnreadable(uint Attr);
-bool IsLabel(uint Attr);
-bool IsLink(uint Attr);
-void SetSFXMode(const char *FileName);
-void EraseDiskContents(const char *FileName);
-bool IsDeleteAllowed(uint FileAttr);
-void PrepareToDelete(const char *Name,const wchar *NameW=NULL);
-uint GetFileAttr(const char *Name,const wchar *NameW=NULL);
-bool SetFileAttr(const char *Name,const wchar *NameW,uint Attr);
-void ConvertNameToFull(const char *Src,char *Dest);
-void ConvertNameToFull(const wchar *Src,wchar *Dest);
-char* MkTemp(char *Name);
-
-
-uint CalcFileCRC(File *SrcFile,Int64 Size=INT64ERR);
-bool RenameFile(const char *SrcName,const wchar *SrcNameW,const char *DestName,const wchar *DestNameW);
-bool DelFile(const char *Name);
-bool DelFile(const char *Name,const wchar *NameW);
-bool DelDir(const char *Name);
-bool DelDir(const char *Name,const wchar *NameW);
-
-#if defined(_WIN_32) && !defined(_WIN_CE)
-bool SetFileCompression(char *Name,wchar *NameW,bool State);
-#endif
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/filestr.hpp b/7zip/Compress/Rar29/Original/filestr.hpp
deleted file mode 100755
index b2bcbe0e..00000000
--- a/7zip/Compress/Rar29/Original/filestr.hpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _RAR_FILESTR_
-#define _RAR_FILESTR_
-
-bool ReadTextFile(char *Name,StringList *List,bool Config,
- bool AbortOnError=false,bool ConvertToAnsi=false,
- bool Unquote=false,bool SkipComments=false);
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/find.hpp b/7zip/Compress/Rar29/Original/find.hpp
deleted file mode 100755
index 81548199..00000000
--- a/7zip/Compress/Rar29/Original/find.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef _RAR_FINDDATA_
-#define _RAR_FINDDATA_
-
-struct FindData
-{
- char Name[NM];
- wchar NameW[NM];
- Int64 Size;
- uint FileAttr;
- uint FileTime;
- bool IsDir;
- RarTime mtime;
- RarTime ctime;
- RarTime atime;
-#ifdef _WIN_32
- char ShortName[NM];
- FILETIME ftCreationTime;
- FILETIME ftLastAccessTime;
- FILETIME ftLastWriteTime;
-#endif
- bool Error;
-};
-
-class FindFile
-{
- private:
-#ifdef _WIN_32
- static HANDLE Win32Find(HANDLE hFind,const char *Mask,const wchar *MaskW,struct FindData *fd);
-#endif
-
- char FindMask[NM];
- wchar FindMaskW[NM];
- int FirstCall;
-#ifdef _WIN_32
- HANDLE hFind;
-#else
- DIR *dirp;
-#endif
- public:
- FindFile();
- ~FindFile();
- void SetMask(const char *FindMask);
- void SetMaskW(const wchar *FindMaskW);
- bool Next(struct FindData *fd,bool GetSymLink=false);
- static bool FastFind(const char *FindMask,const wchar *FindMaskW,struct FindData *fd,bool GetSymLink=false);
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/getbits.cpp b/7zip/Compress/Rar29/Original/getbits.cpp
deleted file mode 100755
index 71ecfc87..00000000
--- a/7zip/Compress/Rar29/Original/getbits.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "rar.hpp"
-
-BitInput::BitInput()
-{
- InBuf=new byte[MAX_SIZE];
-}
-
-
-BitInput::~BitInput()
-{
- delete[] InBuf;
-}
-
-
-void BitInput::faddbits(int Bits)
-{
- addbits(Bits);
-}
-
-
-unsigned int BitInput::fgetbits()
-{
- return(getbits());
-}
diff --git a/7zip/Compress/Rar29/Original/getbits.hpp b/7zip/Compress/Rar29/Original/getbits.hpp
deleted file mode 100755
index 8819f53a..00000000
--- a/7zip/Compress/Rar29/Original/getbits.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _RAR_GETBITS_
-#define _RAR_GETBITS_
-
-class BitInput
-{
- public:
- enum BufferSize {MAX_SIZE=0x8000};
- protected:
- int InAddr,InBit;
- public:
- BitInput();
- ~BitInput();
-
- byte *InBuf;
-
- void InitBitInput()
- {
- InAddr=InBit=0;
- }
- void addbits(int Bits)
- {
- Bits+=InBit;
- InAddr+=Bits>>3;
- InBit=Bits&7;
- }
- unsigned int getbits()
- {
- unsigned int BitField=(uint)InBuf[InAddr] << 16;
- BitField|=(uint)InBuf[InAddr+1] << 8;
- BitField|=(uint)InBuf[InAddr+2];
- BitField >>= (8-InBit);
- return(BitField & 0xffff);
- }
- void faddbits(int Bits);
- unsigned int fgetbits();
-};
-#endif
diff --git a/7zip/Compress/Rar29/Original/global.hpp b/7zip/Compress/Rar29/Original/global.hpp
deleted file mode 100755
index 35c6cf91..00000000
--- a/7zip/Compress/Rar29/Original/global.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _RAR_GLOBAL_
-#define _RAR_GLOBAL_
-
-#ifdef INCLUDEGLOBAL
- #define EXTVAR
-#else
- #define EXTVAR extern
-#endif
-
-EXTVAR ErrorHandler ErrHandler;
-
-
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/headers.hpp b/7zip/Compress/Rar29/Original/headers.hpp
deleted file mode 100755
index f719a7ec..00000000
--- a/7zip/Compress/Rar29/Original/headers.hpp
+++ /dev/null
@@ -1,304 +0,0 @@
-#ifndef _RAR_HEADERS_
-#define _RAR_HEADERS_
-
-#define SIZEOF_MARKHEAD 7
-#define SIZEOF_OLDMHD 7
-#define SIZEOF_NEWMHD 13
-#define SIZEOF_OLDLHD 21
-#define SIZEOF_NEWLHD 32
-#define SIZEOF_SHORTBLOCKHEAD 7
-#define SIZEOF_LONGBLOCKHEAD 11
-#define SIZEOF_SUBBLOCKHEAD 14
-#define SIZEOF_COMMHEAD 13
-#define SIZEOF_PROTECTHEAD 26
-#define SIZEOF_AVHEAD 14
-#define SIZEOF_SIGNHEAD 15
-#define SIZEOF_UOHEAD 18
-#define SIZEOF_MACHEAD 22
-#define SIZEOF_EAHEAD 24
-#define SIZEOF_BEEAHEAD 24
-#define SIZEOF_STREAMHEAD 26
-
-#define PACK_VER 29
-#define PACK_CRYPT_VER 29
-#define UNP_VER 29
-#define CRYPT_VER 29
-#define AV_VER 20
-#define PROTECT_VER 20
-
-#define MHD_VOLUME 0x0001
-#define MHD_COMMENT 0x0002
-#define MHD_LOCK 0x0004
-#define MHD_SOLID 0x0008
-#define MHD_PACK_COMMENT 0x0010
-#define MHD_NEWNUMBERING 0x0010
-#define MHD_AV 0x0020
-#define MHD_PROTECT 0x0040
-#define MHD_PASSWORD 0x0080
-#define MHD_FIRSTVOLUME 0x0100
-
-#define LHD_SPLIT_BEFORE 0x0001
-#define LHD_SPLIT_AFTER 0x0002
-#define LHD_PASSWORD 0x0004
-#define LHD_COMMENT 0x0008
-#define LHD_SOLID 0x0010
-
-#define LHD_WINDOWMASK 0x00e0
-#define LHD_WINDOW64 0x0000
-#define LHD_WINDOW128 0x0020
-#define LHD_WINDOW256 0x0040
-#define LHD_WINDOW512 0x0060
-#define LHD_WINDOW1024 0x0080
-#define LHD_WINDOW2048 0x00a0
-#define LHD_WINDOW4096 0x00c0
-#define LHD_DIRECTORY 0x00e0
-
-#define LHD_LARGE 0x0100
-#define LHD_UNICODE 0x0200
-#define LHD_SALT 0x0400
-#define LHD_VERSION 0x0800
-#define LHD_EXTTIME 0x1000
-#define LHD_EXTFLAGS 0x2000
-
-#define SKIP_IF_UNKNOWN 0x4000
-#define LONG_BLOCK 0x8000
-
-#define EARC_NEXT_VOLUME 0x0001
-#define EARC_DATACRC 0x0002
-#define EARC_REVSPACE 0x0004
-#define EARC_VOLNUMBER 0x0008
-
-enum HEADER_TYPE {
- MARK_HEAD=0x72,MAIN_HEAD=0x73,FILE_HEAD=0x74,COMM_HEAD=0x75,AV_HEAD=0x76,
- SUB_HEAD=0x77,PROTECT_HEAD=0x78,SIGN_HEAD=0x79,NEWSUB_HEAD=0x7a,
- ENDARC_HEAD=0x7b
-};
-
-enum { EA_HEAD=0x100,UO_HEAD=0x101,MAC_HEAD=0x102,BEEA_HEAD=0x103,
- NTACL_HEAD=0x104,STREAM_HEAD=0x105 };
-
-enum HOST_SYSTEM {
- HOST_MSDOS=0,HOST_OS2=1,HOST_WIN32=2,HOST_UNIX=3,HOST_MACOS=4,
- HOST_BEOS=5,HOST_MAX
-};
-
-#define SUBHEAD_TYPE_CMT "CMT"
-#define SUBHEAD_TYPE_ACL "ACL"
-#define SUBHEAD_TYPE_STREAM "STM"
-#define SUBHEAD_TYPE_UOWNER "UOW"
-#define SUBHEAD_TYPE_AV "AV"
-#define SUBHEAD_TYPE_RR "RR"
-#define SUBHEAD_TYPE_OS2EA "EA2"
-#define SUBHEAD_TYPE_BEOSEA "EABE"
-
-/* new file inherits a subblock when updating a host file */
-#define SUBHEAD_FLAGS_INHERITED 0x80000000
-
-#define SUBHEAD_FLAGS_CMT_UNICODE 0x00000001
-
-struct OldMainHeader
-{
- byte Mark[4];
- ushort HeadSize;
- byte Flags;
-};
-
-
-struct OldFileHeader
-{
- uint PackSize;
- uint UnpSize;
- ushort FileCRC;
- ushort HeadSize;
- uint FileTime;
- byte FileAttr;
- byte Flags;
- byte UnpVer;
- byte NameSize;
- byte Method;
-};
-
-
-struct MarkHeader
-{
- byte Mark[7];
-};
-
-
-struct BaseBlock
-{
- ushort HeadCRC;
- HEADER_TYPE HeadType;//byte
- ushort Flags;
- ushort HeadSize;
-
- bool IsSubBlock()
- {
- if (HeadType==SUB_HEAD)
- return(true);
- if (HeadType==NEWSUB_HEAD && (Flags & LHD_SOLID)!=0)
- return(true);
- return(false);
- }
-};
-
-struct BlockHeader:BaseBlock
-{
- union {
- uint DataSize;
- uint PackSize;
- };
-};
-
-
-struct MainHeader:BlockHeader
-{
- ushort HighPosAV;
- uint PosAV;
-};
-
-
-#define SALT_SIZE 8
-
-struct FileHeader:BlockHeader
-{
- uint UnpSize;
- byte HostOS;
- uint FileCRC;
- uint FileTime;
- byte UnpVer;
- byte Method;
- ushort NameSize;
- union {
- uint FileAttr;
- uint SubFlags;
- };
-/* optional */
- uint HighPackSize;
- uint HighUnpSize;
-/* names */
- char FileName[NM];
- wchar FileNameW[NM];
-/* optional */
- Array<byte> SubData;
- byte Salt[SALT_SIZE];
-
- RarTime mtime;
- RarTime ctime;
- RarTime atime;
- RarTime arctime;
-/* dummy */
- Int64 FullPackSize;
- Int64 FullUnpSize;
-
- void Clear(int SubDataSize)
- {
- SubData.Alloc(SubDataSize);
- Flags=LONG_BLOCK;
- SubFlags=0;
- }
-
- bool CmpName(const char *Name)
- {
- return(strcmp(FileName,Name)==0);
- }
-
- FileHeader& operator = (FileHeader &hd)
- {
- SubData.Reset();
- memcpy(this,&hd,sizeof(*this));
- SubData.CleanData();
- SubData=hd.SubData;
- return(*this);
- }
-};
-
-
-struct EndArcHeader:BaseBlock
-{
- uint ArcDataCRC;
- ushort VolNumber;
-};
-
-
-struct SubBlockHeader:BlockHeader
-{
- ushort SubType;
- byte Level;
-};
-
-
-struct CommentHeader:BaseBlock
-{
- ushort UnpSize;
- byte UnpVer;
- byte Method;
- ushort CommCRC;
-};
-
-
-struct ProtectHeader:BlockHeader
-{
- byte Version;
- ushort RecSectors;
- uint TotalBlocks;
- byte Mark[8];
-};
-
-
-struct AVHeader:BaseBlock
-{
- byte UnpVer;
- byte Method;
- byte AVVer;
- uint AVInfoCRC;
-};
-
-
-struct SignHeader:BaseBlock
-{
- uint CreationTime;
- ushort ArcNameSize;
- ushort UserNameSize;
-};
-
-
-struct UnixOwnersHeader:SubBlockHeader
-{
- ushort OwnerNameSize;
- ushort GroupNameSize;
-/* dummy */
- char OwnerName[NM];
- char GroupName[NM];
-};
-
-
-struct EAHeader:SubBlockHeader
-{
- uint UnpSize;
- byte UnpVer;
- byte Method;
- uint EACRC;
-};
-
-
-struct StreamHeader:SubBlockHeader
-{
- uint UnpSize;
- byte UnpVer;
- byte Method;
- uint StreamCRC;
- ushort StreamNameSize;
-/* dummy */
- byte StreamName[NM];
-};
-
-
-struct MacFInfoHeader:SubBlockHeader
-{
- uint fileType;
- uint fileCreator;
-};
-
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/int64.cpp b/7zip/Compress/Rar29/Original/int64.cpp
deleted file mode 100755
index 996d0ea6..00000000
--- a/7zip/Compress/Rar29/Original/int64.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-#include "rar.hpp"
-
-#ifndef NATIVE_INT64
-
-Int64::Int64()
-{
-}
-
-
-Int64::Int64(uint n)
-{
- HighPart=0;
- LowPart=n;
-}
-
-
-Int64::Int64(uint HighPart,uint LowPart)
-{
- Int64::HighPart=HighPart;
- Int64::LowPart=LowPart;
-}
-
-
-/*
-Int64 Int64::operator = (Int64 n)
-{
- HighPart=n.HighPart;
- LowPart=n.LowPart;
- return(*this);
-}
-*/
-
-
-Int64 Int64::operator << (int n)
-{
- Int64 res=*this;
- while (n--)
- {
- res.HighPart<<=1;
- if (res.LowPart & 0x80000000)
- res.HighPart|=1;
- res.LowPart<<=1;
- }
- return(res);
-}
-
-
-Int64 Int64::operator >> (int n)
-{
- Int64 res=*this;
- while (n--)
- {
- res.LowPart>>=1;
- if (res.HighPart & 1)
- res.LowPart|=0x80000000;
- res.HighPart>>=1;
- }
- return(res);
-}
-
-
-Int64 operator / (Int64 n1,Int64 n2)
-{
- if (n1.HighPart==0 && n2.HighPart==0)
- return(Int64(0,n1.LowPart/n2.LowPart));
- int ShiftCount=0;
- while (n1>n2)
- {
- n2=n2<<1;
- if (++ShiftCount>64)
- return(0);
- }
- Int64 res=0;
- while (ShiftCount-- >= 0)
- {
- res=res<<1;
- if (n1>=n2)
- {
- n1-=n2;
- ++res;
- }
- n2=n2>>1;
- }
- return(res);
-}
-
-
-Int64 operator * (Int64 n1,Int64 n2)
-{
- if (n1<0x10000 && n2<0x10000)
- return(Int64(0,n1.LowPart*n2.LowPart));
- Int64 res=0;
- for (int I=0;I<64;I++)
- {
- if (n2.LowPart & 1)
- res+=n1;
- n1=n1<<1;
- n2=n2>>1;
- }
- return(res);
-}
-
-
-Int64 operator % (Int64 n1,Int64 n2)
-{
- if (n1.HighPart==0 && n2.HighPart==0)
- return(Int64(0,n1.LowPart%n2.LowPart));
- return(n1-n1/n2*n2);
-}
-
-
-Int64 operator + (Int64 n1,Int64 n2)
-{
- n1.LowPart+=n2.LowPart;
- if (n1.LowPart<n2.LowPart)
- n1.HighPart++;
- n1.HighPart+=n2.HighPart;
- return(n1);
-}
-
-
-Int64 operator - (Int64 n1,Int64 n2)
-{
- if (n1.LowPart<n2.LowPart)
- n1.HighPart--;
- n1.LowPart-=n2.LowPart;
- n1.HighPart-=n2.HighPart;
- return(n1);
-}
-
-
-Int64 operator += (Int64 &n1,Int64 n2)
-{
- n1=n1+n2;
- return(n1);
-}
-
-
-Int64 operator -= (Int64 &n1,Int64 n2)
-{
- n1=n1-n2;
- return(n1);
-}
-
-
-Int64 operator *= (Int64 &n1,Int64 n2)
-{
- n1=n1*n2;
- return(n1);
-}
-
-
-Int64 operator /= (Int64 &n1,Int64 n2)
-{
- n1=n1/n2;
- return(n1);
-}
-
-
-Int64 operator | (Int64 n1,Int64 n2)
-{
- n1.LowPart|=n2.LowPart;
- n1.HighPart|=n2.HighPart;
- return(n1);
-}
-
-
-Int64 operator & (Int64 n1,Int64 n2)
-{
- n1.LowPart&=n2.LowPart;
- n1.HighPart&=n2.HighPart;
- return(n1);
-}
-
-
-/*
-inline void operator -= (Int64 &n1,unsigned int n2)
-{
- if (n1.LowPart<n2)
- n1.HighPart--;
- n1.LowPart-=n2;
-}
-
-
-inline void operator ++ (Int64 &n)
-{
- if (++n.LowPart == 0)
- ++n.HighPart;
-}
-
-
-inline void operator -- (Int64 &n)
-{
- if (n.LowPart-- == 0)
- n.HighPart--;
-}
-*/
-
-bool operator == (Int64 n1,Int64 n2)
-{
- return(n1.LowPart==n2.LowPart && n1.HighPart==n2.HighPart);
-}
-
-
-bool operator > (Int64 n1,Int64 n2)
-{
- return((int)n1.HighPart>(int)n2.HighPart || n1.HighPart==n2.HighPart && n1.LowPart>n2.LowPart);
-}
-
-
-bool operator < (Int64 n1,Int64 n2)
-{
- return((int)n1.HighPart<(int)n2.HighPart || n1.HighPart==n2.HighPart && n1.LowPart<n2.LowPart);
-}
-
-
-bool operator != (Int64 n1,Int64 n2)
-{
- return(n1.LowPart!=n2.LowPart || n1.HighPart!=n2.HighPart);
-}
-
-
-bool operator >= (Int64 n1,Int64 n2)
-{
- return(n1>n2 || n1==n2);
-}
-
-
-bool operator <= (Int64 n1,Int64 n2)
-{
- return(n1<n2 || n1==n2);
-}
-
-
-void Int64::Set(uint HighPart,uint LowPart)
-{
- Int64::HighPart=HighPart;
- Int64::LowPart=LowPart;
-}
-#endif
-
-void itoa(Int64 n,char *Str)
-{
- if (n<=0xffffffff)
- {
- sprintf(Str,"%u",int64to32(n));
- return;
- }
-
- char NumStr[50];
- int Pos=0;
-
- do
- {
- NumStr[Pos++]=int64to32(n%10)+'0';
- n=n/10;
- } while (n!=0);
-
- for (int I=0;I<Pos;I++)
- Str[I]=NumStr[Pos-I-1];
- Str[Pos]=0;
-}
-
-
-Int64 atoil(char *Str)
-{
- Int64 n=0;
- while (*Str>='0' && *Str<='9')
- {
- n=n*10+*Str-'0';
- Str++;
- }
- return(n);
-}
diff --git a/7zip/Compress/Rar29/Original/int64.hpp b/7zip/Compress/Rar29/Original/int64.hpp
deleted file mode 100755
index a8057522..00000000
--- a/7zip/Compress/Rar29/Original/int64.hpp
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef _RAR_INT64_
-#define _RAR_INT64_
-
-#if defined(__BORLANDC__) || defined(_MSC_VER)
-#define NATIVE_INT64
-typedef __int64 Int64;
-#endif
-
-#if defined(__GNUC__) || defined(__HP_aCC)
-#define NATIVE_INT64
-typedef long long Int64;
-#endif
-
-#ifdef NATIVE_INT64
-
-#define int64to32(x) ((uint)(x))
-#define int32to64(high,low) ((((Int64)(high))<<32)+(low))
-#define is64plus(x) (x>=0)
-
-#else
-
-class Int64
-{
- public:
- Int64();
- Int64(uint n);
- Int64(uint HighPart,uint LowPart);
-
-// Int64 operator = (Int64 n);
- Int64 operator << (int n);
- Int64 operator >> (int n);
-
- friend Int64 operator / (Int64 n1,Int64 n2);
- friend Int64 operator * (Int64 n1,Int64 n2);
- friend Int64 operator % (Int64 n1,Int64 n2);
- friend Int64 operator + (Int64 n1,Int64 n2);
- friend Int64 operator - (Int64 n1,Int64 n2);
- friend Int64 operator += (Int64 &n1,Int64 n2);
- friend Int64 operator -= (Int64 &n1,Int64 n2);
- friend Int64 operator *= (Int64 &n1,Int64 n2);
- friend Int64 operator /= (Int64 &n1,Int64 n2);
- friend Int64 operator | (Int64 n1,Int64 n2);
- friend Int64 operator & (Int64 n1,Int64 n2);
- inline friend void operator -= (Int64 &n1,unsigned int n2)
- {
- if (n1.LowPart<n2)
- n1.HighPart--;
- n1.LowPart-=n2;
- }
- inline friend void operator ++ (Int64 &n)
- {
- if (++n.LowPart == 0)
- ++n.HighPart;
- }
- inline friend void operator -- (Int64 &n)
- {
- if (n.LowPart-- == 0)
- n.HighPart--;
- }
- friend bool operator == (Int64 n1,Int64 n2);
- friend bool operator > (Int64 n1,Int64 n2);
- friend bool operator < (Int64 n1,Int64 n2);
- friend bool operator != (Int64 n1,Int64 n2);
- friend bool operator >= (Int64 n1,Int64 n2);
- friend bool operator <= (Int64 n1,Int64 n2);
-
- void Set(uint HighPart,uint LowPart);
- uint GetLowPart() {return(LowPart);}
-
- uint LowPart;
- uint HighPart;
-};
-
-inline uint int64to32(Int64 n) {return(n.GetLowPart());}
-#define int32to64(high,low) (Int64((high),(low)))
-#define is64plus(x) ((int)(x).HighPart>=0)
-
-#endif
-
-#define INT64ERR int32to64(0x80000000,0)
-#define INT64MAX int32to64(0x7fffffff,0)
-
-void itoa(Int64 n,char *Str);
-Int64 atoil(char *Str);
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/isnt.hpp b/7zip/Compress/Rar29/Original/isnt.hpp
deleted file mode 100755
index 02652361..00000000
--- a/7zip/Compress/Rar29/Original/isnt.hpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _RAR_ISNT_
-#define _RAR_ISNT_
-
-int WinNT();
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/list.hpp b/7zip/Compress/Rar29/Original/list.hpp
deleted file mode 100755
index 7721ae52..00000000
--- a/7zip/Compress/Rar29/Original/list.hpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _RAR_LIST_
-#define _RAR_LIST_
-
-void ListArchive(CommandData *Cmd);
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/loclang.hpp b/7zip/Compress/Rar29/Original/loclang.hpp
deleted file mode 100755
index 05eefdde..00000000
--- a/7zip/Compress/Rar29/Original/loclang.hpp
+++ /dev/null
@@ -1,340 +0,0 @@
-#define MYesNo "_Yes_No"
-#define MYesNoAll "_Yes_No_All"
-#define MYesNoAllRenQ "_Yes_No_All_nEver_Rename_Quit"
-#define MContinueQuit "_Continue_Quit"
-#define MRetryAbort "_Retry_Abort"
-#define MCopyright "\nRAR %s Copyright (c) 1993-%d Alexander Roshal %d %s %d"
-#define MRegTo "\nRegistered to %s\n"
-#define MShare "\nShareware version Type RAR -? for help\n"
-#define MUCopyright "\nUNRAR %s freeware Copyright (c) 1993-%d Alexander Roshal\n"
-#define MBeta "beta"
-#define MMonthJan "Jan"
-#define MMonthFeb "Feb"
-#define MMonthMar "Mar"
-#define MMonthApr "Apr"
-#define MMonthMay "May"
-#define MMonthJun "Jun"
-#define MMonthJul "Jul"
-#define MMonthAug "Aug"
-#define MMonthSep "Sep"
-#define MMonthOct "Oct"
-#define MMonthNov "Nov"
-#define MMonthDec "Dec"
-#define MRARTitle1 "\nUsage: rar <command> -<switch 1> -<switch N> <archive> <files...>"
-#define MUNRARTitle1 "\nUsage: unrar <command> -<switch 1> -<switch N> <archive> <files...>"
-#define MRARTitle2 "\n <@listfiles...> <path_to_extract\\>"
-#define MCHelpCmd "\n\n<Commands>"
-#define MCHelpCmdA "\n a Add files to archive"
-#define MCHelpCmdC "\n c Add archive comment"
-#define MCHelpCmdCF "\n cf Add files comment"
-#define MCHelpCmdCW "\n cw Write archive comment to file"
-#define MCHelpCmdD "\n d Delete files from archive"
-#define MCHelpCmdE "\n e Extract files to current directory"
-#define MCHelpCmdF "\n f Freshen files in archive"
-#define MCHelpCmdI "\n i[par]=<str> Find string in archives"
-#define MCHelpCmdK "\n k Lock archive"
-#define MCHelpCmdL "\n l[t,b] List archive [technical, bare]"
-#define MCHelpCmdM "\n m[f] Move to archive [files only]"
-#define MCHelpCmdP "\n p Print file to stdout"
-#define MCHelpCmdR "\n r Repair archive"
-#define MCHelpCmdRC "\n rc Reconstruct missing volumes"
-#define MCHelpCmdRN "\n rn Rename archived files"
-#define MCHelpCmdRR "\n rr[N] Add data recovery record"
-#define MCHelpCmdRV "\n rv[N] Create recovery volumes"
-#define MCHelpCmdS "\n s[name|-] Convert archive to or from SFX"
-#define MCHelpCmdT "\n t Test archive files"
-#define MCHelpCmdU "\n u Update files in archive"
-#define MCHelpCmdV "\n v[t,b] Verbosely list archive [technical,bare]"
-#define MCHelpCmdX "\n x Extract files with full path"
-#define MCHelpSw "\n\n<Switches>"
-#define MCHelpSwm "\n - Stop switches scanning"
-#define MCHelpSwAC "\n ac Clear Archive attribute after compression or extraction"
-#define MCHelpSwAD "\n ad Append archive name to destination path"
-#define MCHelpSwAG "\n ag[format] Generate archive name using the current date"
-#define MCHelpSwAO "\n ao Add files with Archive attribute set"
-#define MCHelpSwAP "\n ap<path> Set path inside archive"
-#define MCHelpSwAS "\n as Synchronize archive contents"
-#define MCHelpSwAV "\n av Put authenticity verification (registered versions only)"
-#define MCHelpSwAVm "\n av- Disable authenticity verification check"
-#define MCHelpSwCm "\n c- Disable comments show"
-#define MCHelpSwCFGm "\n cfg- Disable read configuration"
-#define MCHelpSwCL "\n cl Convert names to lower case"
-#define MCHelpSwCU "\n cu Convert names to upper case"
-#define MCHelpSwDF "\n df Delete files after archiving"
-#define MCHelpSwDH "\n dh Open shared files"
-#define MCHelpSwDS "\n ds Disable name sort for solid archive"
-#define MCHelpSwEa "\n e[+]<attr> Set file exclude and include attributes"
-#define MCHelpSwED "\n ed Do not add empty directories"
-#define MCHelpSwEE "\n ee Do not save and extract extended attributes"
-#define MCHelpSwEN "\n en Do not put 'end of archive' block"
-#define MCHelpSwEP "\n ep Exclude paths from names"
-#define MCHelpSwEP1 "\n ep1 Exclude base directory from names"
-#define MCHelpSwEP2 "\n ep2 Expand paths to full"
-#define MCHelpSwEP3 "\n ep3 Expand paths to full including the drive letter"
-#define MCHelpSwF "\n f Freshen files"
-#define MCHelpSwHP "\n hp[password] Encrypt both file data and headers"
-#define MCHelpSwIDP "\n id[c,d,p,q] Disable messages"
-#define MCHelpSwIEML "\n ieml[addr] Send archive by email"
-#define MCHelpSwIERR "\n ierr Send all messages to stderr"
-#define MCHelpSwILOG "\n ilog[name] Log errors to file (registered versions only)"
-#define MCHelpSwINUL "\n inul Disable all messages"
-#define MCHelpSwIOFF "\n ioff Turn PC off after completing an operation"
-#define MCHelpSwISND "\n isnd Enable sound"
-#define MCHelpSwK "\n k Lock archive"
-#define MCHelpSwKB "\n kb Keep broken extracted files"
-#define MCHelpSwMn "\n m<0..5> Set compression level (0-store...3-default...5-maximal)"
-#define MCHelpSwMC "\n mc<par> Set advanced compression parameters"
-#define MCHelpSwMD "\n md<size> Dictionary size in KB (64,128,256,512,1024,2048,4096 or A-G)"
-#define MCHelpSwMS "\n ms[ext;ext] Specify file types to store"
-#define MCHelpSwN "\n n<file> Include only specified file"
-#define MCHelpSwNa "\n n@ Read file names to include from stdin"
-#define MCHelpSwNal "\n n@<list> Include files in specified list file"
-#define MCHelpSwOp "\n o+ Overwrite existing files"
-#define MCHelpSwOm "\n o- Do not overwrite existing files"
-#define MCHelpSwOC "\n oc Set NTFS Compressed attribute"
-#define MCHelpSwOL "\n ol Save symbolic links as the link instead of the file"
-#define MCHelpSwOS "\n os Save NTFS streams"
-#define MCHelpSwOW "\n ow Save or restore file owner and group"
-#define MCHelpSwP "\n p[password] Set password"
-#define MCHelpSwPm "\n p- Do not query password"
-#define MCHelpSwR "\n r Recurse subdirectories"
-#define MCHelpSwR0 "\n r0 Recurse subdirectories for wildcard names only"
-#define MCHelpSwRI "\n ri<P>[:<S>] Set priority (0-default,1-min..15-max) and sleep time in ms"
-#define MCHelpSwRR "\n rr[N] Add data recovery record"
-#define MCHelpSwRV "\n rv[N] Create recovery volumes"
-#define MCHelpSwS "\n s[<N>,v[-],e] Create solid archive"
-#define MCHelpSwSm "\n s- Disable solid archiving"
-#define MCHelpSwSFX "\n sfx[name] Create SFX archive"
-#define MCHelpSwSI "\n si[name] Read data from standard input (stdin)"
-#define MCHelpSwT "\n t Test files after archiving"
-#define MCHelpSwTK "\n tk Keep original archive time"
-#define MCHelpSwTL "\n tl Set archive time to latest file"
-#define MCHelpSwTN "\n tn<time> Process files newer than <time>"
-#define MCHelpSwTO "\n to<time> Process files older than <time>"
-#define MCHelpSwTA "\n ta<date> Process files modified after <date> in YYYYMMDDHHMMSS format"
-#define MCHelpSwTB "\n tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format"
-#define MCHelpSwTS "\n ts<m,c,a>[N] Save or restore file time (modification, creation, access)"
-#define MCHelpSwU "\n u Update files"
-#define MCHelpSwV "\n v Create volumes with size autodetection or list all volumes"
-#define MCHelpSwVUnr "\n v List all volumes"
-#define MCHelpSwVn "\n v<size>[k,b] Create volumes with size=<size>*1000 [*1024, *1]"
-#define MCHelpSwVD "\n vd Erase disk contents before creating volume"
-#define MCHelpSwVER "\n ver[n] File version control"
-#define MCHelpSwVN "\n vn Use the old style volume naming scheme"
-#define MCHelpSwVP "\n vp Pause before each volume"
-#define MCHelpSwW "\n w<path> Assign work directory"
-#define MCHelpSwX "\n x<file> Exclude specified file"
-#define MCHelpSwXa "\n x@ Read file names to exclude from stdin"
-#define MCHelpSwXal "\n x@<list> Exclude files in specified list file"
-#define MCHelpSwY "\n y Assume Yes on all queries"
-#define MCHelpSwZ "\n z<file> Read archive comment from file"
-#define MBadArc "\nERROR: Bad archive %s\n"
-#define MAskPsw "Enter password (will not be echoed)"
-#define MAskPswEcho "Enter password"
-#define MReAskPsw "\nReenter password: "
-#define MFor " for "
-#define MNotMatchPsw "\nERROR: Passwords do not match\n"
-#define MErrWrite "Write error in the file %s"
-#define MErrRead "Read error in the file %s"
-#define MErrSeek "Seek error in the file %s"
-#define MErrFClose "Cannot close the file %s"
-#define MErrOutMem "Not enough memory"
-#define MErrBrokenArc "Corrupt archive - use 'Repair' command"
-#define MProgAborted "Program aborted"
-#define MErrRename "\nCannot rename %s to %s"
-#define MAbsNextVol "\nCannot find volume %s"
-#define MBreak "\nUser break\n"
-#define MAskCreatVol "\nCreate next volume ?"
-#define MAskNextDisk "\nDisk full. Insert next"
-#define MCreatVol "\n\nCreating %sarchive %s\n"
-#define MAskNextVol "\nInsert disk with %s"
-#define MTestVol "\n\nTesting archive %s\n"
-#define MExtrVol "\n\nExtracting from %s\n"
-#define MConverting "\nConverting %s"
-#define MCvtToSFX "\nConvert archives to SFX"
-#define MCvtFromSFX "\nRemoving SFX module"
-#define MNotSFX "\n%s is not SFX archive"
-#define MNotRAR "\n%s is not RAR archive"
-#define MNotFirstVol "\n%s is not the first volume"
-#define MCvtOldFormat "\n%s - cannot convert to SFX archive with old format"
-#define MCannotCreate "\nCannot create %s"
-#define MCannotOpen "\nCannot open %s"
-#define MUnknownMeth "\nUnknown method in %s"
-#define MVerRequired "\nYou need RAR %d.%d to unpack it"
-#define MOk " OK"
-#define MDone "\nDone"
-#define MLockingArc "\nLocking archive"
-#define MNotMdfOld "\n\nERROR: Cannot modify old format archive"
-#define MNotMdfLock "\n\nERROR: Locked archive"
-#define MNotMdfVol "\n\nERROR: Cannot modify volume"
-#define MVerifyAV "\nVerifying authenticity information ... "
-#define MFailedAV " Failed\n"
-#define MStrAV1 "\n\nArchive %s"
-#define MStrAV2 "\ncreated at %s"
-#define MStrAV3 "\nby %s\n"
-#define MLogFailedAV "Invalid authenticity information"
-#define MAddingAV "\nAdding authenticity verification "
-#define MAVOldStyle "\n\nOld style authenticity information"
-#define MPackAskReg "\nEvaluation copy. Please register.\n"
-#define MCreateArchive "\nCreating %sarchive %s\n"
-#define MUpdateArchive "\nUpdating %sarchive %s\n"
-#define MAddSolid "solid "
-#define MAddFile "\nAdding %-58s "
-#define MUpdFile "\nUpdating %-58s "
-#define MAddPoints "\n... %-58s "
-#define MCannotUpdPswSolid "\nERROR: Cannot update solid archives with password\n"
-#define MMoveDelFiles "\n\nDeleting files %s..."
-#define MMoveDelDirs "and directories"
-#define MMoveDelFile "\nDeleting %-30s"
-#define MMoveDeleted " deleted"
-#define MMoveNotDeleted " NOT DELETED"
-#define MClearAttrib "\n\nClearing attributes..."
-#define MMoveDelDir "\nDeleting directory %-30s"
-#define MWarErrFOpen "\nWARNING: Cannot open %d %s"
-#define MErrOpenFiles "files"
-#define MErrOpenFile "file"
-#define MAddNoFiles "\nWARNING: No files"
-#define MMdfEncrSol "\n%s: encrypted"
-#define MCannotMdfEncrSol "\nCannot modify solid archive containing encrypted files"
-#define MAddAnalyze "\nAnalyzing archived files: "
-#define MRepacking "\nRepacking archived files: "
-#define MCRCFailed "\n%-20s - CRC failed"
-#define MExtrTest "\n\nTesting archive %s\n"
-#define MExtracting "\n\nExtracting from %s\n"
-#define MUseCurPsw "\n%s - use current password ?"
-#define MCreatDir "\nCreating %-56s"
-#define MExtrSkipFile "\nSkipping %-56s"
-#define MExtrTestFile "\nTesting %-56s"
-#define MExtrFile "\nExtracting %-56s"
-#define MExtrPoints "\n... %-56s"
-#define MExtrErrMkDir "\nCannot create directory %s"
-#define MExtrPrinting "\n------ Printing %s\n\n"
-#define MEncrBadCRC "\nEncrypted file: CRC failed in %s (password incorrect ?)"
-#define MExtrNoFiles "\nNo files to extract"
-#define MExtrAllOk "\nAll OK"
-#define MExtrTotalErr "\nTotal errors: %ld"
-#define MFileExists "\n\n%s already exists. Overwrite it ?"
-#define MAskOverwrite "\nOverwrite %s ?"
-#define MAskNewName "\nEnter new name: "
-#define MLogMainHead "\nThe archive header is corrupt"
-#define MLogFileHead "\n%s - the file header is corrupt"
-#define MLogCommHead "\nThe comment header is corrupt\n"
-#define MLogProtectHead "The data recovery header is corrupt"
-#define MReadStdinCmt "\nReading comment from stdin\n"
-#define MReadCommFrom "\nReading comment from %s"
-#define MDelComment "\nDeleting comment from %s"
-#define MAddComment "\nAdding comment to %s"
-#define MFCommAdd "\nAdding file comments"
-#define MAskFComm "\n\nReading comment for %s : %s from stdin\n"
-#define MLogCommBrk "\nThe archive comment is corrupt"
-#define MCommAskCont "\nPress 'Enter' to continue or 'Q' to quit:"
-#define MLogBrokFCmt "\nThe file comment is corrupt"
-#define MAbsDestName "\nDestination file name required"
-#define MWriteCommTo "\nWrite comment to %s"
-#define MCommNotPres "\nComment is not present"
-#define MDelFrom "\nDeleting from %s"
-#define MDeleting "\nDeleting %s"
-#define MEraseArc "\nErasing empty archive %s"
-#define MNoDelFiles "\nNo files to delete"
-#define MLogTitle "\n\n-------- %2d %s %d, archive %s\n"
-#define MPathTooLong "\nERROR: Path too long\n"
-#define MListSolid "Solid "
-#define MListSFX "SFX "
-#define MListVol1 "volume"
-#define MListVol2 "Volume"
-#define MListArc1 "archive"
-#define MListArc2 "Archive"
-#define MListRecRec "\nRecovery record is present\n"
-#define MListLock "\nLock is present\n"
-#define MListPathComm "\nPathname/Comment\n "
-#define MListName "\n Name "
-#define MListTitle " Size Packed Ratio Date Time Attr CRC Meth Ver\n"
-#define MListTechTitle " Host OS Solid Old\n"
-#define MListEAHead "\n OS/2 extended attributes"
-#define MListUOHead "\n Unix Owner/Group data: %-14s %-14s"
-#define MListBeEAHead "\n BeOS extended attributes"
-#define MListNTACLHead "\n NTFS security data"
-#define MListStrmHead "\n NTFS stream: %s"
-#define MListUnkHead "\n Unknown subheader type: 0x%04x"
-#define MFileComment "\nComment: "
-#define MYes "Yes"
-#define MNo "No"
-#define MListNoFiles " 0 files\n"
-#define MRprReconstr "\nReconstructing %s"
-#define MRprBuild "\nBuilding %s"
-#define MRprOldFormat "\nCannot repair archive with old format"
-#define MRprFind "\nFound %s"
-#define MRprAskIsSol "\nThe archive header is corrupt. Mark archive as solid ?"
-#define MRprNoFiles "\nNo files found"
-#define MRprSuspEntry "\n\nSuspicious entry %s"
-#define MRprDir "\nDirectory"
-#define MRprSuspSize "\nSize %ld Packed %ld"
-#define MRprSuspAdd "\nAdd it to archive ?"
-#define MLogUnexpEOF "\nUnexpected end of archive"
-#define MRepAskReconst "\nReconstruct archive structure ?"
-#define MRecScanning "\nScanning..."
-#define MRecRNotFound "\nData recovery record not found"
-#define MRecRFound "\nData recovery record found"
-#define MRecSecDamage "\nSector %ld (offsets %lX...%lX) damaged"
-#define MRecCorrected " - data recovered"
-#define MRecFailed " - cannot recover data"
-#define MAddRecRec "\nAdding data recovery record"
-#define MEraseForVolume "\n\nErasing contents of drive %c:\n"
-#define MGetOwnersError "\nWARNING: Cannot get %s owner and group\n"
-#define MErrGetOwnerID "\nWARNING: Cannot get owner %s ID\n"
-#define MErrGetGroupID "\nWARNING: Cannot get group %s ID\n"
-#define MOwnersBroken "\nERROR: %s group and owner data are corrupt\n"
-#define MSetOwnersError "\nWARNING: Cannot set %s owner and group\n"
-#define MErrLnkRead "\nWARNING: Cannot read symbolic link %s"
-#define MErrCreateLnk "\nWARNING: Cannot create link %s"
-#define MSymLinkExists "\nWARNING: Symbolic link %s already exists"
-#define MAskRetryCreate "\nCannot create %s. Retry ?"
-#define MListMACHead1 "\n MacOS file type: %c%c%c%c ; "
-#define MListMACHead2 "file creator: %c%c%c%c\n"
-#define MDataBadCRC "\n%-20s : packed data CRC failed in volume %s"
-#define MFileRO "\n%s is read-only"
-#define MACLGetError "\nWARNING: Cannot get %s security data\n"
-#define MACLSetError "\nWARNING: Cannot set %s security data\n"
-#define MACLBroken "\nERROR: %s security data are corrupt\n"
-#define MACLUnknown "\nWARNING: Unknown format of %s security data\n"
-#define MStreamBroken "\nERROR: %s stream data are corrupt\n"
-#define MStreamUnknown "\nWARNING: Unknown format of %s stream data\n"
-#define MInvalidName "\nERROR: Invalid file name %s"
-#define MEABroken "\nERROR: %s extended attributes are corrupt\n"
-#define MEAUnknHeader "\nWARNING: %s - unknown format of extended attributes\n"
-#define MCannotSetEA "\nWARNING: cannot set extended attributes to %s\n"
-#define MCannotGetEA "\nERROR: Cannot get extended attributes of %s\n"
-#define MShowEA " (+EA)"
-#define MSkipEA "\n...skipping extended attributes"
-#define MProcessArc "\n\nProcessing archive %s"
-#define MSyncScanError "\nFile search errors, cannot synchronize archive"
-#define MCorrectingName "\nWARNING: Attempting to correct the invalid file name"
-#define MUnpCannotMerge "\nWARNING: You need to start extraction from a previous volume to unpack %s"
-#define MUnknownOption "\nERROR: Unknown option: %s"
-#define MSubHeadCorrupt "\nERROR: Corrupt data header found, ignored"
-#define MSubHeadUnknown "\nWARNING: Unknown data header format, ignored"
-#define MSubHeadDataCRC "\nERROR: Corrupt %s data block"
-#define MSubHeadType "\nData header type: %s"
-#define MScanError "\nCannot read contents of %s"
-#define MNotVolume "\n%s is not volume"
-#define MRecVolDiffSets "\nERROR: %s and %s belong to different sets"
-#define MRecVolMissing "\n%d volumes missing"
-#define MRecVolFound "\n%d recovery volumes found"
-#define MRecVolAllExist "\nNothing to reconstruct"
-#define MRecVolCannotFix "\nReconstruction impossible"
-#define MReconstructing "\nReconstructing..."
-#define MCreating "\nCreating %s"
-#define MRenaming "\nRenaming %s to %s"
-#define MNTFSRequired "\nWrite error: only NTFS file system supports files larger than 4 GB"
-#define MErrChangeAttr "\nWARNING: Cannot change attributes of %s"
-#define MWrongSFXVer "\nERROR: default SFX module does not support RAR %d.%d archives"
-#define MCannotEncName "\nCannot encrypt archive already contained encrypted files"
-#define MCannotEmail "\nCannot email the file %s"
-#define MCopyrightS "\nRAR SFX archive"
-#define MSHelpCmd "\n\n<Commands>"
-#define MSHelpCmdE "\n -x Extract from archive (default)"
-#define MSHelpCmdT "\n -t Test archive files"
-#define MSHelpCmdV "\n -v Verbosely list contents of archive"
-#define MMaxPathLimit "\nTotal path and file name length must not exceed %d characters"
-#define MRecVolLimit "\nTotal number of usual and recovery volumes must not exceed 255"
-#define MVolumeNumber "volume %d"
diff --git a/7zip/Compress/Rar29/Original/log.hpp b/7zip/Compress/Rar29/Original/log.hpp
deleted file mode 100755
index 52d6b8d5..00000000
--- a/7zip/Compress/Rar29/Original/log.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _RAR_LOG_
-#define _RAR_LOG_
-
-void InitLogOptions(char *LogName);
-
-#ifndef SILENT
-void Log(const char *ArcName,const char *Format,...);
-#endif
-
-#ifdef SILENT
-#ifdef __GNUC__
-#define Log(args...)
-#else
-inline void Log(const char *a,const char *b,const char *c=NULL,const char *d=NULL) {}
-#endif
-#endif
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/match.hpp b/7zip/Compress/Rar29/Original/match.hpp
deleted file mode 100755
index a7367772..00000000
--- a/7zip/Compress/Rar29/Original/match.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _RAR_MATCH_
-#define _RAR_MATCH_
-
-enum {MATCH_NAMES,MATCH_PATH,MATCH_EXACTPATH,MATCH_SUBPATH,MATCH_WILDSUBPATH};
-
-#define MATCH_MODEMASK 0x0000ffff
-
-bool CmpName(char *Wildcard,char *Name,int CmpPath);
-bool CmpName(wchar *Wildcard,wchar *Name,int CmpPath);
-
-int stricompc(const char *Str1,const char *Str2);
-int stricompcw(const wchar *Str1,const wchar *Str2);
-int strnicompc(const char *Str1,const char *Str2,int N);
-int strnicompcw(const wchar *Str1,const wchar *Str2,int N);
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/model.cpp b/7zip/Compress/Rar29/Original/model.cpp
deleted file mode 100755
index e708feb2..00000000
--- a/7zip/Compress/Rar29/Original/model.cpp
+++ /dev/null
@@ -1,600 +0,0 @@
-/****************************************************************************
- * This file is part of PPMd project *
- * Written and distributed to public domain by Dmitry Shkarin 1997, *
- * 1999-2000 *
- * Contents: model description and encoding/decoding routines *
- ****************************************************************************/
-
-inline PPM_CONTEXT* PPM_CONTEXT::createChild(ModelPPM *Model,STATE* pStats,
- STATE& FirstState)
-{
- PPM_CONTEXT* pc = (PPM_CONTEXT*) Model->SubAlloc.AllocContext();
- if ( pc )
- {
- pc->NumStats=1;
- pc->OneState=FirstState;
- pc->Suffix=this;
- pStats->Successor=pc;
- }
- return pc;
-}
-
-
-ModelPPM::ModelPPM()
-{
- MinContext=NULL;
- MaxContext=NULL;
- MedContext=NULL;
-}
-
-
-void ModelPPM::RestartModelRare()
-{
- int i, k, m;
- memset(CharMask,0,sizeof(CharMask));
- SubAlloc.InitSubAllocator();
- InitRL=-(MaxOrder < 12 ? MaxOrder:12)-1;
- MinContext = MaxContext = (PPM_CONTEXT*) SubAlloc.AllocContext();
- MinContext->Suffix=NULL;
- OrderFall=MaxOrder;
- MinContext->U.SummFreq=(MinContext->NumStats=256)+1;
- FoundState=MinContext->U.Stats=(STATE*)SubAlloc.AllocUnits(256/2);
- for (RunLength=InitRL, PrevSuccess=i=0;i < 256;i++)
- {
- MinContext->U.Stats[i].Symbol=i;
- MinContext->U.Stats[i].Freq=1;
- MinContext->U.Stats[i].Successor=NULL;
- }
-
- static const ushort InitBinEsc[]={
- 0x3CDD,0x1F3F,0x59BF,0x48F3,0x64A1,0x5ABC,0x6632,0x6051
- };
-
- for (i=0;i < 128;i++)
- for (k=0;k < 8;k++)
- for (m=0;m < 64;m += 8)
- BinSumm[i][k+m]=BIN_SCALE-InitBinEsc[k]/(i+2);
- for (i=0;i < 25;i++)
- for (k=0;k < 16;k++)
- SEE2Cont[i][k].init(5*i+10);
-}
-
-
-void ModelPPM::StartModelRare(int MaxOrder)
-{
- int i, k, m ,Step;
- EscCount=1;
-/*
- if (MaxOrder < 2)
- {
- memset(CharMask,0,sizeof(CharMask));
- OrderFall=ModelPPM::MaxOrder;
- MinContext=MaxContext;
- while (MinContext->Suffix != NULL)
- {
- MinContext=MinContext->Suffix;
- OrderFall--;
- }
- FoundState=MinContext->U.Stats;
- MinContext=MaxContext;
- }
- else
-*/
- {
- ModelPPM::MaxOrder=MaxOrder;
- RestartModelRare();
- NS2BSIndx[0]=2*0;
- NS2BSIndx[1]=2*1;
- memset(NS2BSIndx+2,2*2,9);
- memset(NS2BSIndx+11,2*3,256-11);
- for (i=0;i < 3;i++)
- NS2Indx[i]=i;
- for (m=i, k=Step=1;i < 256;i++)
- {
- NS2Indx[i]=m;
- if ( !--k )
- {
- k = ++Step;
- m++;
- }
- }
- memset(HB2Flag,0,0x40);
- memset(HB2Flag+0x40,0x08,0x100-0x40);
- DummySEE2Cont.Shift=PERIOD_BITS;
- }
-}
-
-
-void PPM_CONTEXT::rescale(ModelPPM *Model)
-{
- int OldNS=NumStats, i=NumStats-1, Adder, EscFreq;
- STATE* p1, * p;
- for (p=Model->FoundState;p != U.Stats;p--)
- _PPMD_SWAP(p[0],p[-1]);
- U.Stats->Freq += 4;
- U.SummFreq += 4;
- EscFreq=U.SummFreq-p->Freq;
- Adder=(Model->OrderFall != 0);
- U.SummFreq = (p->Freq=(p->Freq+Adder) >> 1);
- do
- {
- EscFreq -= (++p)->Freq;
- U.SummFreq += (p->Freq=(p->Freq+Adder) >> 1);
- if (p[0].Freq > p[-1].Freq)
- {
- STATE tmp=*(p1=p);
- do
- {
- p1[0]=p1[-1];
- } while (--p1 != U.Stats && tmp.Freq > p1[-1].Freq);
- *p1=tmp;
- }
- } while ( --i );
- if (p->Freq == 0)
- {
- do
- {
- i++;
- } while ((--p)->Freq == 0);
- EscFreq += i;
- if ((NumStats -= i) == 1)
- {
- STATE tmp=*U.Stats;
- do
- {
- tmp.Freq-=(tmp.Freq >> 1);
- EscFreq>>=1;
- } while (EscFreq > 1);
- Model->SubAlloc.FreeUnits(U.Stats,(OldNS+1) >> 1);
- *(Model->FoundState=&OneState)=tmp; return;
- }
- }
- U.SummFreq += (EscFreq -= (EscFreq >> 1));
- int n0=(OldNS+1) >> 1, n1=(NumStats+1) >> 1;
- if (n0 != n1)
- U.Stats = (STATE*) Model->SubAlloc.ShrinkUnits(U.Stats,n0,n1);
- Model->FoundState=U.Stats;
-}
-
-
-inline PPM_CONTEXT* ModelPPM::CreateSuccessors(bool Skip,STATE* p1)
-{
-#ifdef __ICL
- static
-#endif
- STATE UpState;
- PPM_CONTEXT* pc=MinContext, * UpBranch=FoundState->Successor;
- STATE * p, * ps[MAX_O], ** pps=ps;
- if ( !Skip )
- {
- *pps++ = FoundState;
- if ( !pc->Suffix )
- goto NO_LOOP;
- }
- if ( p1 )
- {
- p=p1;
- pc=pc->Suffix;
- goto LOOP_ENTRY;
- }
- do
- {
- pc=pc->Suffix;
- if (pc->NumStats != 1)
- {
- if ((p=pc->U.Stats)->Symbol != FoundState->Symbol)
- do
- {
- p++;
- } while (p->Symbol != FoundState->Symbol);
- }
- else
- p=&(pc->OneState);
-LOOP_ENTRY:
- if (p->Successor != UpBranch)
- {
- pc=p->Successor;
- break;
- }
- *pps++ = p;
- } while ( pc->Suffix );
-NO_LOOP:
- if (pps == ps)
- return pc;
- UpState.Symbol=*(byte*) UpBranch;
- UpState.Successor=(PPM_CONTEXT*) (((byte*) UpBranch)+1);
- if (pc->NumStats != 1)
- {
- if ((byte*) pc <= SubAlloc.pText)
- return(NULL);
- if ((p=pc->U.Stats)->Symbol != UpState.Symbol)
- do
- {
- p++;
- } while (p->Symbol != UpState.Symbol);
- uint cf=p->Freq-1;
- uint s0=pc->U.SummFreq-pc->NumStats-cf;
- UpState.Freq=1+((2*cf <= s0)?(5*cf > s0):((2*cf+3*s0-1)/(2*s0)));
- }
- else
- UpState.Freq=pc->OneState.Freq;
- do
- {
- pc = pc->createChild(this,*--pps,UpState);
- if ( !pc )
- return NULL;
- } while (pps != ps);
- return pc;
-}
-
-
-inline void ModelPPM::UpdateModel()
-{
- STATE fs = *FoundState, *p = NULL;
- PPM_CONTEXT *pc, *Successor;
- uint ns1, ns, cf, sf, s0;
- if (fs.Freq < MAX_FREQ/4 && (pc=MinContext->Suffix) != NULL)
- {
- if (pc->NumStats != 1)
- {
- if ((p=pc->U.Stats)->Symbol != fs.Symbol)
- {
- do
- {
- p++;
- } while (p->Symbol != fs.Symbol);
- if (p[0].Freq >= p[-1].Freq)
- {
- _PPMD_SWAP(p[0],p[-1]);
- p--;
- }
- }
- if (p->Freq < MAX_FREQ-9)
- {
- p->Freq += 2;
- pc->U.SummFreq += 2;
- }
- }
- else
- {
- p=&(pc->OneState);
- p->Freq += (p->Freq < 32);
- }
- }
- if ( !OrderFall )
- {
- MinContext=MaxContext=FoundState->Successor=CreateSuccessors(TRUE,p);
- if ( !MinContext )
- goto RESTART_MODEL;
- return;
- }
- *SubAlloc.pText++ = fs.Symbol;
- Successor = (PPM_CONTEXT*) SubAlloc.pText;
- if (SubAlloc.pText >= SubAlloc.FakeUnitsStart)
- goto RESTART_MODEL;
- if ( fs.Successor )
- {
- if ((byte*) fs.Successor <= SubAlloc.pText &&
- (fs.Successor=CreateSuccessors(FALSE,p)) == NULL)
- goto RESTART_MODEL;
- if ( !--OrderFall )
- {
- Successor=fs.Successor;
- SubAlloc.pText -= (MaxContext != MinContext);
- }
- }
- else
- {
- FoundState->Successor=Successor;
- fs.Successor=MinContext;
- }
- s0=MinContext->U.SummFreq-(ns=MinContext->NumStats)-(fs.Freq-1);
- for (pc=MaxContext;pc != MinContext;pc=pc->Suffix)
- {
- if ((ns1=pc->NumStats) != 1)
- {
- if ((ns1 & 1) == 0)
- {
- pc->U.Stats=(STATE*) SubAlloc.ExpandUnits(pc->U.Stats,ns1 >> 1);
- if ( !pc->U.Stats )
- goto RESTART_MODEL;
- }
- pc->U.SummFreq += (2*ns1 < ns)+2*((4*ns1 <= ns) & (pc->U.SummFreq <= 8*ns1));
- }
- else
- {
- p=(STATE*) SubAlloc.AllocUnits(1);
- if ( !p )
- goto RESTART_MODEL;
- *p=pc->OneState;
- pc->U.Stats=p;
- if (p->Freq < MAX_FREQ/4-1)
- p->Freq += p->Freq;
- else
- p->Freq = MAX_FREQ-4;
- pc->U.SummFreq=p->Freq+InitEsc+(ns > 3);
- }
- cf=2*fs.Freq*(pc->U.SummFreq+6);
- sf=s0+pc->U.SummFreq;
- if (cf < 6*sf)
- {
- cf=1+(cf > sf)+(cf >= 4*sf);
- pc->U.SummFreq += 3;
- }
- else
- {
- cf=4+(cf >= 9*sf)+(cf >= 12*sf)+(cf >= 15*sf);
- pc->U.SummFreq += cf;
- }
- p=pc->U.Stats+ns1;
- p->Successor=Successor;
- p->Symbol = fs.Symbol;
- p->Freq = cf;
- pc->NumStats=++ns1;
- }
- MaxContext=MinContext=fs.Successor;
- return;
-RESTART_MODEL:
- RestartModelRare();
- EscCount=0;
-}
-
-
-// Tabulated escapes for exponential symbol distribution
-static const byte ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
-#define GET_MEAN(SUMM,SHIFT,ROUND) ((SUMM+(1 << (SHIFT-ROUND))) >> (SHIFT))
-
-
-
-inline void PPM_CONTEXT::decodeBinSymbol(ModelPPM *Model)
-{
- STATE& rs=OneState;
- Model->HiBitsFlag=Model->HB2Flag[Model->FoundState->Symbol];
- ushort& bs=Model->BinSumm[rs.Freq-1][Model->PrevSuccess+
- Model->NS2BSIndx[Suffix->NumStats-1]+
- Model->HiBitsFlag+2*Model->HB2Flag[rs.Symbol]+
- ((Model->RunLength >> 26) & 0x20)];
- if (Model->Coder.GetCurrentShiftCount(TOT_BITS) < bs)
- {
- Model->FoundState=&rs;
- rs.Freq += (rs.Freq < 128);
- Model->Coder.SubRange.LowCount=0;
- Model->Coder.SubRange.HighCount=bs;
- bs = SHORT16(bs+INTERVAL-GET_MEAN(bs,PERIOD_BITS,2));
- Model->PrevSuccess=1;
- Model->RunLength++;
- }
- else
- {
- Model->Coder.SubRange.LowCount=bs;
- bs = SHORT16(bs-GET_MEAN(bs,PERIOD_BITS,2));
- Model->Coder.SubRange.HighCount=BIN_SCALE;
- Model->InitEsc=ExpEscape[bs >> 10];
- Model->NumMasked=1;
- Model->CharMask[rs.Symbol]=Model->EscCount;
- Model->PrevSuccess=0;
- Model->FoundState=NULL;
- }
-}
-
-
-inline void PPM_CONTEXT::update1(ModelPPM *Model,STATE* p)
-{
- (Model->FoundState=p)->Freq += 4;
- U.SummFreq += 4;
- if (p[0].Freq > p[-1].Freq)
- {
- _PPMD_SWAP(p[0],p[-1]);
- Model->FoundState=--p;
- if (p->Freq > MAX_FREQ)
- rescale(Model);
- }
-}
-
-
-
-
-inline bool PPM_CONTEXT::decodeSymbol1(ModelPPM *Model)
-{
- Model->Coder.SubRange.scale=U.SummFreq;
- STATE* p=U.Stats;
- int i, HiCnt;
- int count=Model->Coder.GetCurrentCount();
- if (count>=Model->Coder.SubRange.scale)
- return(false);
- if (count < (HiCnt=p->Freq))
- {
- Model->PrevSuccess=(2*(Model->Coder.SubRange.HighCount=HiCnt) > Model->Coder.SubRange.scale);
- Model->RunLength += Model->PrevSuccess;
- (Model->FoundState=p)->Freq=(HiCnt += 4);
- U.SummFreq += 4;
- if (HiCnt > MAX_FREQ)
- rescale(Model);
- Model->Coder.SubRange.LowCount=0;
- return(true);
- }
- else
- if (Model->FoundState==NULL)
- return(false);
- Model->PrevSuccess=0;
- i=NumStats-1;
- while ((HiCnt += (++p)->Freq) <= count)
- if (--i == 0)
- {
- Model->HiBitsFlag=Model->HB2Flag[Model->FoundState->Symbol];
- Model->Coder.SubRange.LowCount=HiCnt;
- Model->CharMask[p->Symbol]=Model->EscCount;
- i=(Model->NumMasked=NumStats)-1;
- Model->FoundState=NULL;
- do
- {
- Model->CharMask[(--p)->Symbol]=Model->EscCount;
- } while ( --i );
- Model->Coder.SubRange.HighCount=Model->Coder.SubRange.scale;
- return(true);
- }
- Model->Coder.SubRange.LowCount=(Model->Coder.SubRange.HighCount=HiCnt)-p->Freq;
- update1(Model,p);
- return(true);
-}
-
-
-inline void PPM_CONTEXT::update2(ModelPPM *Model,STATE* p)
-{
- (Model->FoundState=p)->Freq += 4;
- U.SummFreq += 4;
- if (p->Freq > MAX_FREQ)
- rescale(Model);
- Model->EscCount++;
- Model->RunLength=Model->InitRL;
-}
-
-
-inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2(ModelPPM *Model,int Diff)
-{
- SEE2_CONTEXT* psee2c;
- if (NumStats != 256)
- {
- psee2c=Model->SEE2Cont[Model->NS2Indx[Diff-1]]+
- (Diff < Suffix->NumStats-NumStats)+
- 2*(U.SummFreq < 11*NumStats)+4*(Model->NumMasked > Diff)+
- Model->HiBitsFlag;
- Model->Coder.SubRange.scale=psee2c->getMean();
- }
- else
- {
- psee2c=&Model->DummySEE2Cont;
- Model->Coder.SubRange.scale=1;
- }
- return psee2c;
-}
-
-
-
-
-inline bool PPM_CONTEXT::decodeSymbol2(ModelPPM *Model)
-{
- int count, HiCnt, i=NumStats-Model->NumMasked;
- SEE2_CONTEXT* psee2c=makeEscFreq2(Model,i);
- STATE* ps[256], ** pps=ps, * p=U.Stats-1;
- HiCnt=0;
- do
- {
- do
- {
- p++;
- } while (Model->CharMask[p->Symbol] == Model->EscCount);
- HiCnt += p->Freq;
- *pps++ = p;
- } while ( --i );
- Model->Coder.SubRange.scale += HiCnt;
- count=Model->Coder.GetCurrentCount();
- if (count>=Model->Coder.SubRange.scale)
- return(false);
- p=*(pps=ps);
- if (count < HiCnt)
- {
- HiCnt=0;
- while ((HiCnt += p->Freq) <= count)
- p=*++pps;
- Model->Coder.SubRange.LowCount = (Model->Coder.SubRange.HighCount=HiCnt)-p->Freq;
- psee2c->update();
- update2(Model,p);
- }
- else
- {
- Model->Coder.SubRange.LowCount=HiCnt;
- Model->Coder.SubRange.HighCount=Model->Coder.SubRange.scale;
- i=NumStats-Model->NumMasked;
- pps--;
- do
- {
- Model->CharMask[(*++pps)->Symbol]=Model->EscCount;
- } while ( --i );
- psee2c->Summ += Model->Coder.SubRange.scale;
- Model->NumMasked = NumStats;
- }
- return(true);
-}
-
-
-inline void ModelPPM::ClearMask()
-{
- EscCount=1;
- memset(CharMask,0,sizeof(CharMask));
-}
-
-
-
-
-bool ModelPPM::DecodeInit(Unpack *UnpackRead,int &EscChar)
-{
- int MaxOrder=UnpackRead->GetChar();
-
- // Igor Pavlov
- bool Reset = ((MaxOrder & 0x20) != 0);
-
- int MaxMB;
- if (Reset)
- MaxMB=UnpackRead->GetChar();
- else
- if (SubAlloc.GetAllocatedMemory()==0)
- return(false);
- if (MaxOrder & 0x40)
- EscChar=UnpackRead->GetChar();
- Coder.InitDecoder(UnpackRead);
- if (Reset)
- {
- MaxOrder=(MaxOrder & 0x1f)+1;
- if (MaxOrder>16)
- MaxOrder=16+(MaxOrder-16)*3;
- if (MaxOrder==1)
- {
- SubAlloc.StopSubAllocator();
- return(false);
- }
- SubAlloc.StartSubAllocator(MaxMB+1);
- StartModelRare(MaxOrder);
- }
- return(MinContext!=NULL);
-}
-
-
-int ModelPPM::DecodeChar()
-{
- if ((byte*)MinContext <= SubAlloc.pText || (byte*)MinContext>SubAlloc.HeapEnd)
- return(-1);
- if (MinContext->NumStats != 1)
- {
- if (!MinContext->decodeSymbol1(this))
- return(-1);
- }
- else
- MinContext->decodeBinSymbol(this);
- Coder.Decode();
- while ( !FoundState )
- {
- ARI_DEC_NORMALIZE(Coder.code,Coder.low,Coder.range,Coder.UnpackRead);
- do
- {
- OrderFall++;
- MinContext=MinContext->Suffix;
- if ((byte*)MinContext <= SubAlloc.pText || (byte*)MinContext>SubAlloc.HeapEnd)
- return(-1);
- } while (MinContext->NumStats == NumMasked);
- if (!MinContext->decodeSymbol2(this))
- return(-1);
- Coder.Decode();
- }
- int Symbol=FoundState->Symbol;
- if (!OrderFall && (byte*) FoundState->Successor > SubAlloc.pText)
- MinContext=MaxContext=FoundState->Successor;
- else
- {
- UpdateModel();
- if (EscCount == 0)
- ClearMask();
- }
- ARI_DEC_NORMALIZE(Coder.code,Coder.low,Coder.range,Coder.UnpackRead);
- return(Symbol);
-}
diff --git a/7zip/Compress/Rar29/Original/model.hpp b/7zip/Compress/Rar29/Original/model.hpp
deleted file mode 100755
index 1c3742b9..00000000
--- a/7zip/Compress/Rar29/Original/model.hpp
+++ /dev/null
@@ -1,126 +0,0 @@
-#ifndef _RAR_PPMMODEL_
-#define _RAR_PPMMODEL_
-
-#include "coder.hpp"
-#include "suballoc.hpp"
-
-const int MAX_O=64; /* maximum allowed model order */
-
-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;
-
-#pragma pack(1)
-
-struct SEE2_CONTEXT
-{ // SEE-contexts for PPM-contexts with masked symbols
- ushort Summ;
- byte Shift, Count;
- void init(int InitVal)
- {
- Summ=InitVal << (Shift=PERIOD_BITS-4);
- Count=4;
- }
- uint getMean()
- {
- uint RetVal=SHORT16(Summ) >> Shift;
- Summ -= RetVal;
- return RetVal+(RetVal == 0);
- }
- void update()
- {
- if (Shift < PERIOD_BITS && --Count == 0)
- {
- Summ += Summ;
- Count=3 << Shift++;
- }
- }
-};
-
-
-class ModelPPM;
-struct PPM_CONTEXT;
-
-struct STATE
-{
- byte Symbol;
- byte Freq;
- PPM_CONTEXT* Successor;
-};
-
-struct FreqData
-{
- ushort SummFreq;
- STATE _PACK_ATTR * Stats;
-};
-
-struct PPM_CONTEXT
-{
- ushort NumStats;
- union
- {
- FreqData U;
- STATE OneState;
- };
-
- PPM_CONTEXT* Suffix;
- inline void encodeBinSymbol(ModelPPM *Model,int symbol); // MaxOrder:
- inline void encodeSymbol1(ModelPPM *Model,int symbol); // ABCD context
- inline void encodeSymbol2(ModelPPM *Model,int symbol); // BCD suffix
- inline void decodeBinSymbol(ModelPPM *Model); // BCDE successor
- inline bool decodeSymbol1(ModelPPM *Model); // other orders:
- inline bool decodeSymbol2(ModelPPM *Model); // BCD context
- inline void update1(ModelPPM *Model,STATE* p); // CD suffix
- inline void update2(ModelPPM *Model,STATE* p); // BCDE successor
- void rescale(ModelPPM *Model);
- inline PPM_CONTEXT* createChild(ModelPPM *Model,STATE* pStats,STATE& FirstState);
- inline SEE2_CONTEXT* makeEscFreq2(ModelPPM *Model,int Diff);
-};
-#ifdef _AIX
-#pragma pack(pop)
-#else
-#pragma pack()
-#endif
-
-const uint UNIT_SIZE=sizeof(PPM_CONTEXT);
-const uint FIXED_UNIT_SIZE=12;
-
-/*
-inline PPM_CONTEXT::PPM_CONTEXT(STATE* pStats,PPM_CONTEXT* ShorterContext):
- NumStats(1), Suffix(ShorterContext) { pStats->Successor=this; }
-inline PPM_CONTEXT::PPM_CONTEXT(): NumStats(0) {}
-*/
-
-template <class T>
-inline void _PPMD_SWAP(T& t1,T& t2) { T tmp=t1; t1=t2; t2=tmp; }
-
-
-class ModelPPM
-{
- private:
- friend struct PPM_CONTEXT;
-
- _PACK_ATTR SEE2_CONTEXT SEE2Cont[25][16], DummySEE2Cont;
-
- struct PPM_CONTEXT *MinContext, *MedContext, *MaxContext;
- STATE* FoundState; // found next state transition
- int NumMasked, InitEsc, OrderFall, MaxOrder, RunLength, InitRL;
- byte CharMask[256], NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
- byte EscCount, PrevSuccess, HiBitsFlag;
- ushort BinSumm[128][64]; // binary SEE-contexts
-
- RangeCoder Coder;
- SubAllocator SubAlloc;
-
- void RestartModelRare();
- void StartModelRare(int MaxOrder);
- inline PPM_CONTEXT* CreateSuccessors(bool Skip,STATE* p1);
-
- inline void UpdateModel();
- inline void ClearMask();
- public:
- ModelPPM();
- bool DecodeInit(Unpack *UnpackRead,int &EscChar);
- int DecodeChar();
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/options.hpp b/7zip/Compress/Rar29/Original/options.hpp
deleted file mode 100755
index b43739f6..00000000
--- a/7zip/Compress/Rar29/Original/options.hpp
+++ /dev/null
@@ -1,129 +0,0 @@
-#ifndef _RAR_OPTIONS_
-#define _RAR_OPTIONS_
-
-#define DEFAULT_RECOVERY -1
-
-#define DEFAULT_RECVOLUMES -10
-
-enum PathExclMode {
- EXCL_NONE,EXCL_BASEPATH,EXCL_SKIPWHOLEPATH,EXCL_SAVEFULLPATH,
- EXCL_SKIPABSPATH,EXCL_ABSPATH
-};
-enum {SOLID_NONE=0,SOLID_NORMAL=1,SOLID_COUNT=2,SOLID_FILEEXT=4,
- SOLID_VOLUME_DEPENDENT=8,SOLID_VOLUME_INDEPENDENT=16};
-enum {ARCTIME_NONE,ARCTIME_KEEP,ARCTIME_LATEST};
-enum EXTTIME_MODE {
- EXTTIME_NONE,EXTTIME_1S,EXTTIME_HIGH1,EXTTIME_HIGH2,EXTTIME_HIGH3
-};
-enum {NAMES_ORIGINALCASE,NAMES_UPPERCASE,NAMES_LOWERCASE};
-enum MESSAGE_TYPE {MSG_STDOUT,MSG_STDERR,MSG_ERRONLY,MSG_NULL};
-enum OVERWRITE_MODE { OVERWRITE_ASK,OVERWRITE_ALL,OVERWRITE_NONE};
-
-#define MAX_FILTERS 16
-enum FilterState {FILTER_DEFAULT=0,FILTER_AUTO,FILTER_FORCE,FILTER_DISABLE};
-
-
-struct FilterMode
-{
- FilterState State;
- int Param1;
- int Param2;
-};
-
-
-class RAROptions
-{
- public:
- RAROptions();
- ~RAROptions();
- void Init();
-
- uint ExclFileAttr;
- uint InclFileAttr;
- bool InclAttrSet;
- uint WinSize;
- char TempPath[NM];
- char SFXModule[NM];
- char ExtrPath[NM];
- wchar ExtrPathW[NM];
- char CommentFile[NM];
- char ArcPath[NM];
- char Password[MAXPASSWORD];
- bool EncryptHeaders;
- char LogName[NM];
- MESSAGE_TYPE MsgStream;
- bool Sound;
- OVERWRITE_MODE Overwrite;
- int Method;
- int Recovery;
- int RecVolNumber;
- bool DisablePercentage;
- bool DisableCopyright;
- bool DisableDone;
- int Solid;
- int SolidCount;
- bool ClearArc;
- bool AddArcOnly;
- bool AV;
- bool DisableComment;
- bool FreshFiles;
- bool UpdateFiles;
- PathExclMode ExclPath;
- int Recurse;
- Int64 VolSize;
- Array<Int64> NextVolSizes;
- int CurVolNum;
- bool AllYes;
- bool DisableViewAV;
- bool DisableSortSolid;
- int ArcTime;
- int ConvertNames;
- bool ProcessOwners;
- bool SaveLinks;
- int Priority;
- int SleepTime;
- bool KeepBroken;
- bool EraseDisk;
- bool OpenShared;
- bool ExclEmptyDir;
- bool DeleteFiles;
- bool SyncFiles;
- bool GenerateArcName;
- char GenerateMask[80];
- bool ProcessEA;
- bool SaveStreams;
- bool SetCompressedAttr;
- uint FileTimeOlder;
- uint FileTimeNewer;
- RarTime FileTimeBefore;
- RarTime FileTimeAfter;
- bool OldNumbering;
- bool Lock;
- bool Test;
- bool VolumePause;
- FilterMode FilterModes[MAX_FILTERS];
- char EmailTo[NM];
- int VersionControl;
- bool NoEndBlock;
- bool AppendArcNameToPath;
- bool Shutdown;
- EXTTIME_MODE xmtime;
- EXTTIME_MODE xctime;
- EXTTIME_MODE xatime;
- EXTTIME_MODE xarctime;
- char CompressStdin[NM];
-
-
-
-#ifdef RARDLL
- char DllDestName[NM];
- wchar DllDestNameW[NM];
- int DllOpMode;
- int DllError;
- LONG UserData;
- UNRARCALLBACK Callback;
- CHANGEVOLPROC ChangeVolProc;
- PROCESSDATAPROC ProcessDataProc;
-#endif
-};
-#endif
diff --git a/7zip/Compress/Rar29/Original/os.hpp b/7zip/Compress/Rar29/Original/os.hpp
deleted file mode 100755
index 29da46a1..00000000
--- a/7zip/Compress/Rar29/Original/os.hpp
+++ /dev/null
@@ -1,235 +0,0 @@
-#ifndef _RAR_OS_
-#define _RAR_OS_
-
-#define FALSE 0
-#define TRUE 1
-
-#ifdef __EMX__
- #define INCL_BASE
-#endif
-
-#if defined(_WIN_32) || defined(_EMX)
-#define ENABLE_BAD_ALLOC
-#endif
-
-
-#if defined(_WIN_32) || defined(_EMX)
-
-#define LITTLE_ENDIAN
-#define NM 1024
-
-#ifdef _WIN_32
-
-// Igor Pavlov
-#ifndef STRICT
-#define STRICT
-#endif
-
-#undef WINVER
-#undef _WIN32_WINNT
-#define WINVER 0x0400
-#define _WIN32_WINNT 0x0300
-
-#define WIN32_LEAN_AND_MEAN
-
-#include <windows.h>
-#include <prsht.h>
-
-#ifndef _WIN_CE
-#include <winioctl.h>
-#endif
-
-#endif
-
-#ifndef _WIN_CE
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dos.h>
-#endif
-
-#if !defined(_EMX) && !defined(_MSC_VER) && !defined(_WIN_CE)
- #define ENABLE_MKTEMP
- #include <dir.h>
-#endif
-#ifdef _MSC_VER
- #define for if (0) ; else for
-#ifndef _WIN_CE
- #include <direct.h>
-#endif
-#else
- #include <dirent.h>
-#endif
-
-#ifndef _WIN_CE
-#include <share.h>
-#endif
-
-#if defined(ENABLE_BAD_ALLOC) && !defined(_WIN_CE)
- #include <new.h>
-#endif
-
-#ifdef _EMX
- #include <unistd.h>
- #include <pwd.h>
- #include <grp.h>
- #include <errno.h>
- #ifdef _DJGPP
- #include <utime.h>
- #else
- #include <os2.h>
- #include <sys/utime.h>
- #include <emx/syscalls.h>
- #endif
-#else
- #if defined(_MSC_VER) || defined(__MINGW32__)
- #include <exception>
- #else
- #include <except.h>
- #endif
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#ifndef _WIN_CE
- #include <fcntl.h>
- #include <dos.h>
- #include <io.h>
- #include <time.h>
- #include <signal.h>
-#endif
-
-/*
-#ifdef _WIN_32
-#pragma hdrstop
-#endif
-*/
-
-#define ENABLE_ACCESS
-
-#define DefConfigName "rar.ini"
-#define DefLogName "rar.log"
-
-
-#define PATHDIVIDER "\\"
-#define PATHDIVIDERW L"\\"
-#define CPATHDIVIDER '\\'
-#define MASKALL "*"
-#define MASKALLW L"*"
-
-#define READBINARY "rb"
-#define READTEXT "rt"
-#define UPDATEBINARY "r+b"
-#define CREATEBINARY "w+b"
-#define APPENDTEXT "at"
-
-#if defined(_WIN_32)
- #ifdef _MSC_VER
- #define _stdfunction __cdecl
- #else
- #define _stdfunction _USERENTRY
- #endif
-#else
- #define _stdfunction
-#endif
-
-#endif
-
-#ifdef _UNIX
-
-#define NM 1024
-
-#ifdef _BEOS
-#include <be/kernel/fs_info.h>
-#include <be/kernel/fs_attr.h>
-#endif
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#if defined(__QNXNTO__)
- #include <sys/param.h>
-#endif
-#if defined(__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined(__APPLE__)
- #include <sys/param.h>
- #include <sys/mount.h>
-#else
-#endif
-#include <pwd.h>
-#include <grp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <dirent.h>
-#include <time.h>
-#include <signal.h>
-#include <utime.h>
-#include <locale.h>
-
-#ifdef S_IFLNK
-#define SAVE_LINKS
-#endif
-
-#define ENABLE_ACCESS
-
-#define DefConfigName ".rarrc"
-#define DefLogName ".rarlog"
-
-
-#define PATHDIVIDER "/"
-#define PATHDIVIDERW L"/"
-#define CPATHDIVIDER '/'
-#define MASKALL "*"
-#define MASKALLW L"*"
-
-#define READBINARY "r"
-#define READTEXT "r"
-#define UPDATEBINARY "r+"
-#define CREATEBINARY "w+"
-#define APPENDTEXT "a"
-
-#define _stdfunction
-
-#ifdef _APPLE
- #ifndef BIG_ENDIAN
- #define BIG_ENDIAN
- #endif
- #ifdef LITTLE_ENDIAN
- #undef LITTLE_ENDIAN
- #endif
-#endif
-
-#if defined(__sparc) || defined(sparc) || defined(__hpux)
- #ifndef BIG_ENDIAN
- #define BIG_ENDIAN
- #endif
-#endif
-
-#endif
-
-typedef const char* MSGID;
-
-#define safebuf static
-
-#if defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
- #if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
- #undef LITTLE_ENDIAN
- #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
- #undef BIG_ENDIAN
- #else
- #error "Both LITTLE_ENDIAN and BIG_ENDIAN are defined. Undef something one"
- #endif
-#endif
-
-#if !defined(BIG_ENDIAN) && !defined(_WIN_CE) && defined(_WIN_32)
-#define ALLOW_NOT_ALIGNED_INT
-#endif
-
-#endif // _RAR_OS_
diff --git a/7zip/Compress/Rar29/Original/pathfn.hpp b/7zip/Compress/Rar29/Original/pathfn.hpp
deleted file mode 100755
index c6d2d9b9..00000000
--- a/7zip/Compress/Rar29/Original/pathfn.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef _RAR_PATHFN_
-#define _RAR_PATHFN_
-
-char* PointToName(const char *Path);
-wchar* PointToName(const wchar *Path);
-char* PointToLastChar(const char *Path);
-char* ConvertPath(const char *SrcPath,char *DestPath);
-wchar* ConvertPath(const wchar *SrcPath,wchar *DestPath);
-void SetExt(char *Name,const char *NewExt);
-void SetExt(wchar *Name,const wchar *NewExt);
-void SetSFXExt(char *SFXName);
-void SetSFXExt(wchar *SFXName);
-char *GetExt(const char *Name);
-wchar *GetExt(const wchar *Name);
-bool CmpExt(const char *Name,const char *Ext);
-bool IsWildcard(const char *Str,const wchar *StrW=NULL);
-bool IsPathDiv(int Ch);
-bool IsDriveDiv(int Ch);
-int GetPathDisk(const char *Path);
-void AddEndSlash(char *Path);
-void AddEndSlash(wchar *Path);
-void GetFilePath(const char *FullName,char *Path);
-void GetFilePath(const wchar *FullName,wchar *Path);
-void RemoveNameFromPath(char *Path);
-void RemoveNameFromPath(wchar *Path);
-bool EnumConfigPaths(char *Path,int Number);
-void GetConfigName(const char *Name,char *FullName,bool CheckExist);
-char* GetVolNumPart(char *ArcName);
-void NextVolumeName(char *ArcName,bool OldNumbering);
-bool IsNameUsable(const char *Name);
-void MakeNameUsable(char *Name,bool Extended);
-char* UnixSlashToDos(char *SrcName,char *DestName=NULL,uint MaxLength=NM);
-char* DosSlashToUnix(char *SrcName,char *DestName=NULL,uint MaxLength=NM);
-bool IsFullPath(const char *Path);
-bool IsDiskLetter(const char *Path);
-void GetPathRoot(const char *Path,char *Root);
-int ParseVersionFileName(char *Name,wchar *NameW,bool Truncate);
-char* VolNameToFirstName(const char *VolName,char *FirstName,bool NewNumbering);
-wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW);
-
-
-inline char* GetOutputName(const char *Name) {return((char *)Name);};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/rar.hpp b/7zip/Compress/Rar29/Original/rar.hpp
deleted file mode 100755
index 70b6826b..00000000
--- a/7zip/Compress/Rar29/Original/rar.hpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef _RAR_RARCOMMON_
-#define _RAR_RARCOMMON_
-
-#include "raros.hpp"
-#include "os.hpp"
-
-
-#ifdef RARDLL
-#include "dll.hpp"
-#endif
-
-#ifndef _WIN_CE
-#include "version.hpp"
-#endif
-#include "rartypes.hpp"
-#include "rardefs.hpp"
-#include "rarlang.hpp"
-#include "int64.hpp"
-#include "unicode.hpp"
-#include "errhnd.hpp"
-#include "array.hpp"
-#include "timefn.hpp"
-#include "headers.hpp"
-#include "rarfn.hpp"
-#include "pathfn.hpp"
-#include "strfn.hpp"
-#include "strlist.hpp"
-#include "file.hpp"
-#include "sha1.hpp"
-#include "crc.hpp"
-#include "rijndael.hpp"
-#include "crypt.hpp"
-#include "filefn.hpp"
-#include "filestr.hpp"
-#include "find.hpp"
-#include "scantree.hpp"
-#include "savepos.hpp"
-#include "getbits.hpp"
-#include "rdwrfn.hpp"
-#include "options.hpp"
-#include "archive.hpp"
-#include "match.hpp"
-#include "cmddata.hpp"
-#include "filcreat.hpp"
-#include "consio.hpp"
-#include "system.hpp"
-#include "isnt.hpp"
-#include "log.hpp"
-#include "rawread.hpp"
-#include "encname.hpp"
-#include "resource.hpp"
-#include "compress.hpp"
-
-
-#include "rarvm.hpp"
-#include "model.hpp"
-
-
-#include "unpack.hpp"
-
-
-#include "extinfo.hpp"
-#include "extract.hpp"
-
-
-
-#include "list.hpp"
-
-
-
-#include "rs.hpp"
-#include "recvol.hpp"
-#include "volume.hpp"
-#include "smallfn.hpp"
-#include "ulinks.hpp"
-
-#include "global.hpp"
-
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/rardefs.hpp b/7zip/Compress/Rar29/Original/rardefs.hpp
deleted file mode 100755
index 51661658..00000000
--- a/7zip/Compress/Rar29/Original/rardefs.hpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef _RAR_DEFS_
-#define _RAR_DEFS_
-
-#define Min(x,y) (((x)<(y)) ? (x):(y))
-#define Max(x,y) (((x)>(y)) ? (x):(y))
-
-#define MAXPASSWORD 128
-
-#define DefSFXName "default.sfx"
-#define DefSortListName "rarfiles.lst"
-
-#ifndef FA_RDONLY
- #define FA_RDONLY 0x01
- #define FA_HIDDEN 0x02
- #define FA_SYSTEM 0x04
- #define FA_LABEL 0x08
- #define FA_DIREC 0x10
- #define FA_ARCH 0x20
-#endif
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/rarfn.hpp b/7zip/Compress/Rar29/Original/rarfn.hpp
deleted file mode 100755
index 05ffdbcf..00000000
--- a/7zip/Compress/Rar29/Original/rarfn.hpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _RAR_FN_
-#define _RAR_FN_
-
-void RARInitData();
-
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/rarlang.hpp b/7zip/Compress/Rar29/Original/rarlang.hpp
deleted file mode 100755
index 6151d15a..00000000
--- a/7zip/Compress/Rar29/Original/rarlang.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _RAR_LANG_
-#define _RAR_LANG_
-
- #ifdef USE_RC
- #include "rarres.hpp"
- #else
- #include "loclang.hpp"
- #endif
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/raros.hpp b/7zip/Compress/Rar29/Original/raros.hpp
deleted file mode 100755
index e6867981..00000000
--- a/7zip/Compress/Rar29/Original/raros.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef _RAR_RAROS_
-#define _RAR_RAROS_
-
-#ifdef __EMX__
- #define _EMX
-#endif
-
-#ifdef __DJGPP__
- #define _DJGPP
- #define _EMX
-#endif
-
-#if defined(__WIN32__) || defined(_WIN32)
- #define _WIN_32
-#endif
-
-#ifdef _WIN32_WCE
- #define _WIN_32
- #define _WIN_CE
- #ifdef WM_FILECHANGEINFO
- #define PC2002
- #else
- #undef PC2002
- #endif
-#endif
-
-#ifdef __BEOS__
- #define _UNIX
- #define _BEOS
-#endif
-
-#ifdef __APPLE__
- #define _UNIX
- #define _APPLE
-#endif
-
-#if !defined(_EMX) && !defined(_WIN_32) && !defined(_BEOS) && !defined(_APPLE)
- #define _UNIX
-#endif
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/rartypes.hpp b/7zip/Compress/Rar29/Original/rartypes.hpp
deleted file mode 100755
index 9e4f640f..00000000
--- a/7zip/Compress/Rar29/Original/rartypes.hpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef _RAR_TYPES_
-#define _RAR_TYPES_
-
-typedef unsigned char byte; //8 bits
-typedef unsigned short ushort; //preferably 16 bits, but can be more
-typedef unsigned int uint; //32 bits or more
-
-typedef unsigned int uint32; //32 bits exactly
-typedef int sint32; //signed 32 bits exactly
-#define PRESENT_INT32
-
-#if defined(_WIN_32) || defined(__GNUC__) || defined(__sgi) || defined(_AIX) || defined(__sun) || defined(__hpux)
-typedef wchar_t wchar;
-#else
-typedef ushort wchar;
-#endif
-
-#define SHORT16(x) (sizeof(ushort)==2 ? (ushort)(x):((x)&0xffff))
-#define UINT32(x) (sizeof(uint32)==4 ? (uint32)(x):((x)&0xffffffff))
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/rarvm.cpp b/7zip/Compress/Rar29/Original/rarvm.cpp
deleted file mode 100755
index 09585f5a..00000000
--- a/7zip/Compress/Rar29/Original/rarvm.cpp
+++ /dev/null
@@ -1,1050 +0,0 @@
-#include "rar.hpp"
-
-#include "rarvmtbl.cpp"
-
-RarVM::RarVM()
-{
- Mem=NULL;
-}
-
-
-RarVM::~RarVM()
-{
- delete[] Mem;
-}
-
-
-void RarVM::Init()
-{
- if (Mem==NULL)
- Mem=new byte[VM_MEMSIZE+4];
-}
-
-
-inline uint RarVM::GetValue(bool ByteMode,uint *Addr)
-{
- if (ByteMode)
- return(*(byte *)Addr);
- else
- {
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT)
- byte *B=(byte *)Addr;
- return UINT32((uint)B[0]|((uint)B[1]<<8)|((uint)B[2]<<16)|((uint)B[3]<<24));
-#else
- return UINT32(*Addr);
-#endif
- }
-}
-
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT)
- #define GET_VALUE(ByteMode,Addr) GetValue(ByteMode,(uint *)Addr)
-#else
- #define GET_VALUE(ByteMode,Addr) ((ByteMode) ? (*(byte *)(Addr)):UINT32(*(uint *)(Addr)))
-#endif
-
-
-inline void RarVM::SetValue(bool ByteMode,uint *Addr,uint Value)
-{
- if (ByteMode)
- *(byte *)Addr=Value;
- else
- {
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT) || !defined(PRESENT_INT32)
- ((byte *)Addr)[0]=(byte)Value;
- ((byte *)Addr)[1]=(byte)(Value>>8);
- ((byte *)Addr)[2]=(byte)(Value>>16);
- ((byte *)Addr)[3]=(byte)(Value>>24);
-#else
- *(uint32 *)Addr=Value;
-#endif
- }
-}
-
-#if defined(BIG_ENDIAN) || !defined(ALLOW_NOT_ALIGNED_INT) || !defined(PRESENT_INT32)
- #define SET_VALUE(ByteMode,Addr,Value) SetValue(ByteMode,(uint *)Addr,Value)
-#else
- #define SET_VALUE(ByteMode,Addr,Value) ((ByteMode) ? (*(byte *)(Addr)=(Value)):(*(uint32 *)(Addr)=((uint32)(Value))))
-#endif
-
-
-void RarVM::SetValue(uint *Addr,uint Value)
-{
- SetValue(false,Addr,Value);
-}
-
-
-inline uint* RarVM::GetOperand(VM_PreparedOperand *CmdOp)
-{
- if (CmdOp->Type==VM_OPREGMEM)
- return((uint *)&Mem[(*CmdOp->Addr+CmdOp->Base)&VM_MEMMASK]);
- else
- return(CmdOp->Addr);
-}
-
-
-void RarVM::Execute(VM_PreparedProgram *Prg)
-{
- memcpy(R,Prg->InitR,sizeof(Prg->InitR));
- unsigned int GlobalSize=Min(Prg->GlobalData.Size(),VM_GLOBALMEMSIZE);
- if (GlobalSize)
- memcpy(Mem+VM_GLOBALMEMADDR,&Prg->GlobalData[0],GlobalSize);
- unsigned int StaticSize=Min(Prg->StaticData.Size(),VM_GLOBALMEMSIZE-GlobalSize);
- if (StaticSize)
- memcpy(Mem+VM_GLOBALMEMADDR+GlobalSize,&Prg->StaticData[0],StaticSize);
-
- R[7]=VM_MEMSIZE;
- Flags=0;
-
- VM_PreparedCommand *PreparedCode=Prg->AltCmd ? Prg->AltCmd:&Prg->Cmd[0];
- if (!ExecuteCode(PreparedCode,Prg->CmdCount))
- PreparedCode[0].OpCode=VM_RET;
- uint NewBlockPos=GET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x20])&VM_MEMMASK;
- uint NewBlockSize=GET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x1c])&VM_MEMMASK;
- if (NewBlockPos+NewBlockSize>=VM_MEMSIZE)
- NewBlockPos=NewBlockSize=0;
- Prg->FilteredData=Mem+NewBlockPos;
- Prg->FilteredDataSize=NewBlockSize;
-
- Prg->GlobalData.Reset();
- uint DataSize=Min(GET_VALUE(false,(uint*)&Mem[VM_GLOBALMEMADDR+0x30]),VM_GLOBALMEMSIZE);
- if (DataSize!=0)
- {
- Prg->GlobalData.Add(DataSize+VM_FIXEDGLOBALSIZE);
- memcpy(&Prg->GlobalData[0],&Mem[VM_GLOBALMEMADDR],DataSize+VM_FIXEDGLOBALSIZE);
- }
-}
-
-
-#define SET_IP(IP) \
- if ((IP)>=CodeSize) \
- return(true); \
- if (--MaxOpCount<=0) \
- return(false); \
- Cmd=PreparedCode+(IP);
-
-bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
-{
- int MaxOpCount=25000000;
- VM_PreparedCommand *Cmd=PreparedCode;
- while (1)
- {
- uint *Op1=GetOperand(&Cmd->Op1);
- uint *Op2=GetOperand(&Cmd->Op2);
- switch(Cmd->OpCode)
- {
-#ifndef NORARVM
- case VM_MOV:
- SET_VALUE(Cmd->ByteMode,Op1,GET_VALUE(Cmd->ByteMode,Op2));
- break;
-#ifdef VM_OPTIMIZE
- case VM_MOVB:
- SET_VALUE(true,Op1,GET_VALUE(true,Op2));
- break;
- case VM_MOVD:
- SET_VALUE(false,Op1,GET_VALUE(false,Op2));
- break;
-#endif
- case VM_CMP:
- {
- uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
- uint Result=UINT32(Value1-GET_VALUE(Cmd->ByteMode,Op2));
- Flags=Result==0 ? VM_FZ:(Result>Value1)|(Result&VM_FS);
- }
- break;
-#ifdef VM_OPTIMIZE
- case VM_CMPB:
- {
- uint Value1=GET_VALUE(true,Op1);
- uint Result=UINT32(Value1-GET_VALUE(true,Op2));
- Flags=Result==0 ? VM_FZ:(Result>Value1)|(Result&VM_FS);
- }
- break;
- case VM_CMPD:
- {
- uint Value1=GET_VALUE(false,Op1);
- uint Result=UINT32(Value1-GET_VALUE(false,Op2));
- Flags=Result==0 ? VM_FZ:(Result>Value1)|(Result&VM_FS);
- }
- break;
-#endif
- case VM_ADD:
- {
- uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
- uint Result=UINT32(Value1+GET_VALUE(Cmd->ByteMode,Op2));
- Flags=Result==0 ? VM_FZ:(Result<Value1)|(Result&VM_FS);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
-#ifdef VM_OPTIMIZE
- case VM_ADDB:
- SET_VALUE(true,Op1,GET_VALUE(true,Op1)+GET_VALUE(true,Op2));
- break;
- case VM_ADDD:
- SET_VALUE(false,Op1,GET_VALUE(false,Op1)+GET_VALUE(false,Op2));
- break;
-#endif
- case VM_SUB:
- {
- uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
- uint Result=UINT32(Value1-GET_VALUE(Cmd->ByteMode,Op2));
- Flags=Result==0 ? VM_FZ:(Result>Value1)|(Result&VM_FS);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
-#ifdef VM_OPTIMIZE
- case VM_SUBB:
- SET_VALUE(true,Op1,GET_VALUE(true,Op1)-GET_VALUE(true,Op2));
- break;
- case VM_SUBD:
- SET_VALUE(false,Op1,GET_VALUE(false,Op1)-GET_VALUE(false,Op2));
- break;
-#endif
- case VM_JZ:
- if ((Flags & VM_FZ)!=0)
- {
- SET_IP(GET_VALUE(false,Op1));
- continue;
- }
- break;
- case VM_JNZ:
- if ((Flags & VM_FZ)==0)
- {
- SET_IP(GET_VALUE(false,Op1));
- continue;
- }
- break;
- case VM_INC:
- {
- uint Result=UINT32(GET_VALUE(Cmd->ByteMode,Op1)+1);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- Flags=Result==0 ? VM_FZ:Result&VM_FS;
- }
- break;
-#ifdef VM_OPTIMIZE
- case VM_INCB:
- SET_VALUE(true,Op1,GET_VALUE(true,Op1)+1);
- break;
- case VM_INCD:
- SET_VALUE(false,Op1,GET_VALUE(false,Op1)+1);
- break;
-#endif
- case VM_DEC:
- {
- uint Result=UINT32(GET_VALUE(Cmd->ByteMode,Op1)-1);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- Flags=Result==0 ? VM_FZ:Result&VM_FS;
- }
- break;
-#ifdef VM_OPTIMIZE
- case VM_DECB:
- SET_VALUE(true,Op1,GET_VALUE(true,Op1)-1);
- break;
- case VM_DECD:
- SET_VALUE(false,Op1,GET_VALUE(false,Op1)-1);
- break;
-#endif
- case VM_JMP:
- SET_IP(GET_VALUE(false,Op1));
- continue;
- case VM_XOR:
- {
- uint Result=UINT32(GET_VALUE(Cmd->ByteMode,Op1)^GET_VALUE(Cmd->ByteMode,Op2));
- Flags=Result==0 ? VM_FZ:Result&VM_FS;
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
- case VM_AND:
- {
- uint Result=UINT32(GET_VALUE(Cmd->ByteMode,Op1)&GET_VALUE(Cmd->ByteMode,Op2));
- Flags=Result==0 ? VM_FZ:Result&VM_FS;
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
- case VM_OR:
- {
- uint Result=UINT32(GET_VALUE(Cmd->ByteMode,Op1)|GET_VALUE(Cmd->ByteMode,Op2));
- Flags=Result==0 ? VM_FZ:Result&VM_FS;
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
- case VM_TEST:
- {
- uint Result=UINT32(GET_VALUE(Cmd->ByteMode,Op1)&GET_VALUE(Cmd->ByteMode,Op2));
- Flags=Result==0 ? VM_FZ:Result&VM_FS;
- }
- break;
- case VM_JS:
- if ((Flags & VM_FS)!=0)
- {
- SET_IP(GET_VALUE(false,Op1));
- continue;
- }
- break;
- case VM_JNS:
- if ((Flags & VM_FS)==0)
- {
- SET_IP(GET_VALUE(false,Op1));
- continue;
- }
- break;
- case VM_JB:
- if ((Flags & VM_FC)!=0)
- {
- SET_IP(GET_VALUE(false,Op1));
- continue;
- }
- break;
- case VM_JBE:
- if ((Flags & (VM_FC|VM_FZ))!=0)
- {
- SET_IP(GET_VALUE(false,Op1));
- continue;
- }
- break;
- case VM_JA:
- if ((Flags & (VM_FC|VM_FZ))==0)
- {
- SET_IP(GET_VALUE(false,Op1));
- continue;
- }
- break;
- case VM_JAE:
- if ((Flags & VM_FC)==0)
- {
- SET_IP(GET_VALUE(false,Op1));
- continue;
- }
- break;
- case VM_PUSH:
- R[7]-=4;
- SET_VALUE(false,(uint *)&Mem[R[7]&VM_MEMMASK],GET_VALUE(false,Op1));
- break;
- case VM_POP:
- SET_VALUE(false,Op1,GET_VALUE(false,(uint *)&Mem[R[7] & VM_MEMMASK]));
- R[7]+=4;
- break;
- case VM_CALL:
- R[7]-=4;
- SET_VALUE(false,(uint *)&Mem[R[7]&VM_MEMMASK],Cmd-PreparedCode+1);
- SET_IP(GET_VALUE(false,Op1));
- continue;
- case VM_NOT:
- SET_VALUE(Cmd->ByteMode,Op1,~GET_VALUE(Cmd->ByteMode,Op1));
- break;
- case VM_SHL:
- {
- uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
- uint Value2=GET_VALUE(Cmd->ByteMode,Op2);
- uint Result=UINT32(Value1<<Value2);
- Flags=(Result==0 ? VM_FZ:(Result&VM_FS))|((Value1<<(Value2-1))&0x80000000 ? VM_FC:0);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
- case VM_SHR:
- {
- uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
- uint Value2=GET_VALUE(Cmd->ByteMode,Op2);
- uint Result=UINT32(Value1>>Value2);
- Flags=(Result==0 ? VM_FZ:(Result&VM_FS))|((Value1>>(Value2-1))&VM_FC);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
- case VM_SAR:
- {
- uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
- uint Value2=GET_VALUE(Cmd->ByteMode,Op2);
- uint Result=UINT32(((int)Value1)>>Value2);
- Flags=(Result==0 ? VM_FZ:(Result&VM_FS))|((Value1>>(Value2-1))&VM_FC);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
- case VM_NEG:
- {
- uint Result=UINT32(-GET_VALUE(Cmd->ByteMode,Op1));
- Flags=Result==0 ? VM_FZ:VM_FC|(Result&VM_FS);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
-#ifdef VM_OPTIMIZE
- case VM_NEGB:
- SET_VALUE(true,Op1,-GET_VALUE(true,Op1));
- break;
- case VM_NEGD:
- SET_VALUE(false,Op1,-GET_VALUE(false,Op1));
- break;
-#endif
- case VM_PUSHA:
- {
- const int RegCount=sizeof(R)/sizeof(R[0]);
- for (int I=0,SP=R[7]-4;I<RegCount;I++,SP-=4)
- SET_VALUE(false,(uint *)&Mem[SP & VM_MEMMASK],R[I]);
- R[7]-=RegCount*4;
- }
- break;
- case VM_POPA:
- {
- const int RegCount=sizeof(R)/sizeof(R[0]);
- for (uint I=0,SP=R[7];I<RegCount;I++,SP+=4)
- R[7-I]=GET_VALUE(false,(uint *)&Mem[SP & VM_MEMMASK]);
- }
- break;
- case VM_PUSHF:
- R[7]-=4;
- SET_VALUE(false,(uint *)&Mem[R[7]&VM_MEMMASK],Flags);
- break;
- case VM_POPF:
- Flags=GET_VALUE(false,(uint *)&Mem[R[7] & VM_MEMMASK]);
- R[7]+=4;
- break;
- case VM_MOVZX:
- SET_VALUE(false,Op1,GET_VALUE(true,Op2));
- break;
- case VM_MOVSX:
- SET_VALUE(false,Op1,(signed char)GET_VALUE(true,Op2));
- break;
- case VM_XCHG:
- {
- uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
- SET_VALUE(Cmd->ByteMode,Op1,GET_VALUE(Cmd->ByteMode,Op2));
- SET_VALUE(Cmd->ByteMode,Op2,Value1);
- }
- break;
- case VM_MUL:
- {
- uint Result=GET_VALUE(Cmd->ByteMode,Op1)*GET_VALUE(Cmd->ByteMode,Op2);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
- case VM_DIV:
- {
- uint Divider=GET_VALUE(Cmd->ByteMode,Op2);
- if (Divider!=0)
- {
- uint Result=GET_VALUE(Cmd->ByteMode,Op1)/Divider;
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- }
- break;
- case VM_ADC:
- {
- uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
- uint FC=(Flags&VM_FC);
- uint Result=UINT32(Value1+GET_VALUE(Cmd->ByteMode,Op2)+FC);
- Flags=Result==0 ? VM_FZ:(Result<Value1 || Result==Value1 && FC)|(Result&VM_FS);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
- case VM_SBB:
- {
- uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
- uint FC=(Flags&VM_FC);
- uint Result=UINT32(Value1-GET_VALUE(Cmd->ByteMode,Op2)-FC);
- Flags=Result==0 ? VM_FZ:(Result>Value1 || Result==Value1 && FC)|(Result&VM_FS);
- SET_VALUE(Cmd->ByteMode,Op1,Result);
- }
- break;
-#endif
- case VM_RET:
- if (R[7]>=VM_MEMSIZE)
- return(true);
- SET_IP(GET_VALUE(false,(uint *)&Mem[R[7] & VM_MEMMASK]));
- R[7]+=4;
- continue;
-#ifdef VM_STANDARDFILTERS
- case VM_STANDARD:
- ExecuteStandardFilter((VM_StandardFilters)Cmd->Op1.Data);
- break;
-#endif
- case VM_PRINT:
-#ifdef DEBUG
- PrintState(Cmd-PreparedCode);
-#endif
- break;
- }
- Cmd++;
- --MaxOpCount;
- }
-}
-
-
-void RarVM::PrintState(uint IP)
-{
-#if defined(DEBUG) && !defined(GUI) && !defined(SILENT)
- mprintf("\n");
- for (int I=0;I<sizeof(R)/sizeof(R[0]);I++)
- mprintf("R%d=%08X\t%s",I,R[I],I==3 ? "\n":"");
- mprintf("\nIP=%08X\tFlags: C=%d S=%d",IP,(Flags & VM_FC)!=0,(Flags & VM_FS)!=0);
- mprintf("\n");
-#endif
-}
-
-
-void RarVM::Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg)
-{
- InitBitInput();
- memcpy(InBuf,Code,Min(CodeSize,BitInput::MAX_SIZE));
-
- byte XorSum=0;
- for (int I=1;I<CodeSize;I++)
- XorSum^=Code[I];
-
- faddbits(8);
-
- Prg->CmdCount=0;
- if (XorSum==Code[0])
- {
-#ifdef VM_STANDARDFILTERS
- VM_StandardFilters FilterType=IsStandardFilter(Code,CodeSize);
- if (FilterType!=VMSF_NONE)
- {
- Prg->Cmd.Add(1);
- VM_PreparedCommand *CurCmd=&Prg->Cmd[Prg->CmdCount++];
- CurCmd->OpCode=VM_STANDARD;
- CurCmd->Op1.Data=FilterType;
- CurCmd->Op1.Addr=&CurCmd->Op1.Data;
- CurCmd->Op2.Addr=&CurCmd->Op2.Data;
- CurCmd->Op1.Type=CurCmd->Op2.Type=VM_OPNONE;
- CodeSize=0;
- }
-#endif
- uint DataFlag=fgetbits();
- faddbits(1);
- if (DataFlag&0x8000)
- {
- int DataSize=ReadData(*this)+1;
- for (int I=0;InAddr<CodeSize && I<DataSize;I++)
- {
- Prg->StaticData.Add(1);
- Prg->StaticData[I]=fgetbits()>>8;
- faddbits(8);
- }
- }
- while (InAddr<CodeSize)
- {
- Prg->Cmd.Add(1);
- VM_PreparedCommand *CurCmd=&Prg->Cmd[Prg->CmdCount];
- uint Data=fgetbits();
- if ((Data&0x8000)==0)
- {
- CurCmd->OpCode=(VM_Commands)(Data>>12);
- faddbits(4);
- }
- else
- {
- CurCmd->OpCode=(VM_Commands)((Data>>10)-24);
- faddbits(6);
- }
- if (VM_CmdFlags[CurCmd->OpCode] & VMCF_BYTEMODE)
- {
- // Igor Pavlov
- CurCmd->ByteMode = ((fgetbits() >> 15) != 0);
-
- faddbits(1);
- }
- else
- CurCmd->ByteMode=0;
- CurCmd->Op1.Type=CurCmd->Op2.Type=VM_OPNONE;
- int OpNum=(VM_CmdFlags[CurCmd->OpCode] & VMCF_OPMASK);
- CurCmd->Op1.Addr=CurCmd->Op2.Addr=NULL;
- if (OpNum>0)
- {
- DecodeArg(CurCmd->Op1,CurCmd->ByteMode);
- if (OpNum==2)
- DecodeArg(CurCmd->Op2,CurCmd->ByteMode);
- else
- {
- if (CurCmd->Op1.Type==VM_OPINT && (VM_CmdFlags[CurCmd->OpCode]&(VMCF_JUMP|VMCF_PROC)))
- {
- int Distance=CurCmd->Op1.Data;
- if (Distance>=256)
- Distance-=256;
- else
- {
- if (Distance>=136)
- Distance-=264;
- else
- if (Distance>=16)
- Distance-=8;
- else
- if (Distance>=8)
- Distance-=16;
- Distance+=Prg->CmdCount;
- }
- CurCmd->Op1.Data=Distance;
- }
- }
- }
- Prg->CmdCount++;
- }
- }
- Prg->Cmd.Add(1);
- VM_PreparedCommand *CurCmd=&Prg->Cmd[Prg->CmdCount++];
- CurCmd->OpCode=VM_RET;
- CurCmd->Op1.Addr=&CurCmd->Op1.Data;
- CurCmd->Op2.Addr=&CurCmd->Op2.Data;
- CurCmd->Op1.Type=CurCmd->Op2.Type=VM_OPNONE;
-
- for (int I=0;I<Prg->CmdCount;I++)
- {
- VM_PreparedCommand *Cmd=&Prg->Cmd[I];
- if (Cmd->Op1.Addr==NULL)
- Cmd->Op1.Addr=&Cmd->Op1.Data;
- if (Cmd->Op2.Addr==NULL)
- Cmd->Op2.Addr=&Cmd->Op2.Data;
- }
-
-#ifdef VM_OPTIMIZE
- if (CodeSize!=0)
- Optimize(Prg);
-#endif
-}
-
-
-void RarVM::DecodeArg(VM_PreparedOperand &Op,bool ByteMode)
-{
- uint Data=fgetbits();
- if (Data & 0x8000)
- {
- Op.Type=VM_OPREG;
- Op.Data=(Data>>12)&7;
- Op.Addr=&R[Op.Data];
- faddbits(4);
- }
- else
- if ((Data & 0xc000)==0)
- {
- Op.Type=VM_OPINT;
- if (ByteMode)
- {
- Op.Data=(Data>>6) & 0xff;
- faddbits(10);
- }
- else
- {
- faddbits(2);
- Op.Data=ReadData(*this);
- }
- }
- else
- {
- Op.Type=VM_OPREGMEM;
- if ((Data & 0x2000)==0)
- {
- Op.Data=(Data>>10)&7;
- Op.Addr=&R[Op.Data];
- Op.Base=0;
- faddbits(6);
- }
- else
- {
- if ((Data & 0x1000)==0)
- {
- Op.Data=(Data>>9)&7;
- Op.Addr=&R[Op.Data];
- faddbits(7);
- }
- else
- {
- Op.Data=0;
- faddbits(4);
- }
- Op.Base=ReadData(*this);
- }
- }
-}
-
-
-uint RarVM::ReadData(BitInput &Inp)
-{
- uint Data=Inp.fgetbits();
- switch(Data&0xc000)
- {
- case 0:
- Inp.faddbits(6);
- return((Data>>10)&0xf);
- case 0x4000:
- if ((Data&0x3c00)==0)
- {
- Data=0xffffff00|((Data>>2)&0xff);
- Inp.faddbits(14);
- }
- else
- {
- Data=(Data>>6)&0xff;
- Inp.faddbits(10);
- }
- return(Data);
- case 0x8000:
- Inp.faddbits(2);
- Data=Inp.fgetbits();
- Inp.faddbits(16);
- return(Data);
- default:
- Inp.faddbits(2);
- Data=(Inp.fgetbits()<<16);
- Inp.faddbits(16);
- Data|=Inp.fgetbits();
- Inp.faddbits(16);
- return(Data);
- }
-}
-
-
-void RarVM::SetMemory(unsigned int Pos,byte *Data,unsigned int DataSize)
-{
- if (Pos<VM_MEMSIZE && Data!=Mem+Pos)
- memmove(Mem+Pos,Data,Min(DataSize,VM_MEMSIZE-Pos));
-}
-
-
-#ifdef VM_OPTIMIZE
-void RarVM::Optimize(VM_PreparedProgram *Prg)
-{
- VM_PreparedCommand *Code=&Prg->Cmd[0];
- int CodeSize=Prg->CmdCount;
-
- for (int I=0;I<CodeSize;I++)
- {
- VM_PreparedCommand *Cmd=Code+I;
- switch(Cmd->OpCode)
- {
- case VM_MOV:
- Cmd->OpCode=Cmd->ByteMode ? VM_MOVB:VM_MOVD;
- continue;
- case VM_CMP:
- Cmd->OpCode=Cmd->ByteMode ? VM_CMPB:VM_CMPD;
- continue;
- }
- if ((VM_CmdFlags[Cmd->OpCode] & VMCF_CHFLAGS)==0)
- continue;
- bool FlagsRequired=false;
- for (int J=I+1;J<CodeSize;J++)
- {
- int Flags=VM_CmdFlags[Code[J].OpCode];
- if (Flags & (VMCF_JUMP|VMCF_PROC|VMCF_USEFLAGS))
- {
- FlagsRequired=true;
- break;
- }
- if (Flags & VMCF_CHFLAGS)
- break;
- }
- if (FlagsRequired)
- continue;
- switch(Cmd->OpCode)
- {
- case VM_ADD:
- Cmd->OpCode=Cmd->ByteMode ? VM_ADDB:VM_ADDD;
- continue;
- case VM_SUB:
- Cmd->OpCode=Cmd->ByteMode ? VM_SUBB:VM_SUBD;
- continue;
- case VM_INC:
- Cmd->OpCode=Cmd->ByteMode ? VM_INCB:VM_INCD;
- continue;
- case VM_DEC:
- Cmd->OpCode=Cmd->ByteMode ? VM_DECB:VM_DECD;
- continue;
- case VM_NEG:
- Cmd->OpCode=Cmd->ByteMode ? VM_NEGB:VM_NEGD;
- continue;
- }
- }
-}
-#endif
-
-
-#ifdef VM_STANDARDFILTERS
-VM_StandardFilters RarVM::IsStandardFilter(byte *Code,int CodeSize)
-{
- struct StandardFilterSignature
- {
- int Length;
- uint CRC;
- VM_StandardFilters Type;
- } StdList[]={
- 53, 0xad576887, VMSF_E8,
- 57, 0x3cd7e57e, VMSF_E8E9,
- 120, 0x3769893f, VMSF_ITANIUM,
- 29, 0x0e06077d, VMSF_DELTA,
- 149, 0x1c2c5dc8, VMSF_RGB,
- 216, 0xbc85e701, VMSF_AUDIO,
- 40, 0x46b9c560, VMSF_UPCASE
- };
- uint CodeCRC=CRC(0xffffffff,Code,CodeSize)^0xffffffff;
- for (int I=0;I<sizeof(StdList)/sizeof(StdList[0]);I++)
- if (StdList[I].CRC==CodeCRC && StdList[I].Length==CodeSize)
- return(StdList[I].Type);
- return(VMSF_NONE);
-}
-
-
-void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
-{
- switch(FilterType)
- {
- case VMSF_E8:
- case VMSF_E8E9:
- {
- byte *Data=Mem;
- int DataSize=R[4];
- uint FileOffset=R[6];
-
- if (DataSize>=VM_GLOBALMEMADDR)
- break;
-
- const int FileSize=0x1000000;
- byte CmpByte2=FilterType==VMSF_E8E9 ? 0xe9:0xe8;
- for (uint CurPos=0;CurPos<DataSize-4;)
- {
- byte CurByte=*(Data++);
- CurPos++;
- if (CurByte==0xe8 || CurByte==CmpByte2)
- {
-#ifdef PRESENT_INT32
- sint32 Offset=CurPos+FileOffset;
- sint32 Addr=GET_VALUE(false,Data);
- if (Addr<0)
- {
- if (Addr+Offset>=0)
- SET_VALUE(false,Data,Addr+FileSize);
- }
- else
- if (Addr<FileSize)
- SET_VALUE(false,Data,Addr-Offset);
-#else
- long Offset=CurPos+FileOffset;
- long Addr=GET_VALUE(false,Data);
- if ((Addr & 0x80000000)!=0)
- {
- if (((Addr+Offset) & 0x80000000)==0)
- SET_VALUE(false,Data,Addr+FileSize);
- }
- else
- if (((Addr-FileSize) & 0x80000000)!=0)
- SET_VALUE(false,Data,Addr-Offset);
-#endif
- Data+=4;
- CurPos+=4;
- }
- }
- }
- break;
- case VMSF_ITANIUM:
- {
- byte *Data=Mem;
- int DataSize=R[4];
- uint FileOffset=R[6];
-
- if (DataSize>=VM_GLOBALMEMADDR)
- break;
-
- uint CurPos=0;
-
- FileOffset>>=4;
-
- while (CurPos<DataSize-21)
- {
- int Byte=(Data[0]&0x1f)-0x10;
- if (Byte>=0)
- {
- static byte Masks[16]={4,4,6,6,0,0,7,7,4,4,0,0,4,4,0,0};
- byte CmdMask=Masks[Byte];
- if (CmdMask!=0)
- for (int I=0;I<=2;I++)
- if (CmdMask & (1<<I))
- {
- int StartPos=I*41+5;
- int OpType=FilterItanium_GetBits(Data,StartPos+37,4);
- if (OpType==5)
- {
- int Offset=FilterItanium_GetBits(Data,StartPos+13,20);
- FilterItanium_SetBits(Data,(Offset-FileOffset)&0xfffff,StartPos+13,20);
- }
- }
- }
- Data+=16;
- CurPos+=16;
- FileOffset++;
- }
- }
- break;
- case VMSF_DELTA:
- {
- int DataSize=R[4],Channels=R[0],SrcPos=0,Border=DataSize*2;
- SET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x20],DataSize);
- if (DataSize>=VM_GLOBALMEMADDR/2)
- break;
- for (int CurChannel=0;CurChannel<Channels;CurChannel++)
- {
- byte PrevByte=0;
- for (int DestPos=DataSize+CurChannel;DestPos<Border;DestPos+=Channels)
- Mem[DestPos]=(PrevByte-=Mem[SrcPos++]);
- }
- }
- break;
- case VMSF_RGB:
- {
- int DataSize=R[4],Width=R[0]-3,PosR=R[1];
- byte *SrcData=Mem,*DestData=SrcData+DataSize;
- const int Channels=3;
- SET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x20],DataSize);
- if (DataSize>=VM_GLOBALMEMADDR/2)
- break;
- for (int CurChannel=0;CurChannel<Channels;CurChannel++)
- {
- unsigned int PrevByte=0;
-
- for (int I=CurChannel;I<DataSize;I+=Channels)
- {
- unsigned int Predicted;
- int UpperPos=I-Width;
- if (UpperPos>=3)
- {
- byte *UpperData=DestData+UpperPos;
- unsigned int UpperByte=*UpperData;
- unsigned int UpperLeftByte=*(UpperData-3);
- Predicted=PrevByte+UpperByte-UpperLeftByte;
- int pa=abs((int)(Predicted-PrevByte));
- int pb=abs((int)(Predicted-UpperByte));
- int pc=abs((int)(Predicted-UpperLeftByte));
- if (pa<=pb && pa<=pc)
- Predicted=PrevByte;
- else
- if (pb<=pc)
- Predicted=UpperByte;
- else
- Predicted=UpperLeftByte;
- }
- else
- Predicted=PrevByte;
- DestData[I]=PrevByte=(byte)(Predicted-*(SrcData++));
- }
- }
- for (int I=PosR,Border=DataSize-2;I<Border;I+=3)
- {
- byte G=DestData[I+1];
- DestData[I]+=G;
- DestData[I+2]+=G;
- }
- }
- break;
- case VMSF_AUDIO:
- {
- int DataSize=R[4],Channels=R[0];
- byte *SrcData=Mem,*DestData=SrcData+DataSize;
- SET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x20],DataSize);
- if (DataSize>=VM_GLOBALMEMADDR/2)
- break;
- for (int CurChannel=0;CurChannel<Channels;CurChannel++)
- {
- unsigned int PrevByte=0,PrevDelta=0,Dif[7];
- int D1=0,D2=0,D3;
- int K1=0,K2=0,K3=0;
- memset(Dif,0,sizeof(Dif));
-
- for (int I=CurChannel,ByteCount=0;I<DataSize;I+=Channels,ByteCount++)
- {
- D3=D2;
- D2=PrevDelta-D1;
- D1=PrevDelta;
-
- unsigned int Predicted=8*PrevByte+K1*D1+K2*D2+K3*D3;
- Predicted=(Predicted>>3) & 0xff;
-
- unsigned int CurByte=*(SrcData++);
-
- Predicted-=CurByte;
- DestData[I]=Predicted;
- PrevDelta=(signed char)(Predicted-PrevByte);
- PrevByte=Predicted;
-
- int D=((signed char)CurByte)<<3;
-
- Dif[0]+=abs(D);
- Dif[1]+=abs(D-D1);
- Dif[2]+=abs(D+D1);
- Dif[3]+=abs(D-D2);
- Dif[4]+=abs(D+D2);
- Dif[5]+=abs(D-D3);
- Dif[6]+=abs(D+D3);
-
- if ((ByteCount & 0x1f)==0)
- {
- unsigned int MinDif=Dif[0],NumMinDif=0;
- Dif[0]=0;
- for (int J=1;J<sizeof(Dif)/sizeof(Dif[0]);J++)
- {
- if (Dif[J]<MinDif)
- {
- MinDif=Dif[J];
- NumMinDif=J;
- }
- Dif[J]=0;
- }
- switch(NumMinDif)
- {
- 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 5: if (K3>=-16) K3--; break;
- case 6: if (K3 < 16) K3++; break;
- }
- }
- }
- }
- }
- break;
- case VMSF_UPCASE:
- {
- int DataSize=R[4],SrcPos=0,DestPos=DataSize;
- if (DataSize>=VM_GLOBALMEMADDR/2)
- break;
- while (SrcPos<DataSize)
- {
- byte CurByte=Mem[SrcPos++];
- if (CurByte==2 && (CurByte=Mem[SrcPos++])!=2)
- CurByte-=32;
- Mem[DestPos++]=CurByte;
- }
- SET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x1c],DestPos-DataSize);
- SET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x20],DataSize);
- }
- break;
- }
-}
-
-
-unsigned int RarVM::FilterItanium_GetBits(byte *Data,int BitPos,int BitCount)
-{
- int InAddr=BitPos/8;
- int InBit=BitPos&7;
- unsigned int BitField=(uint)Data[InAddr++];
- BitField|=(uint)Data[InAddr++] << 8;
- BitField|=(uint)Data[InAddr++] << 16;
- BitField|=(uint)Data[InAddr] << 24;
- BitField >>= InBit;
- return(BitField & (0xffffffff>>(32-BitCount)));
-}
-
-
-void RarVM::FilterItanium_SetBits(byte *Data,unsigned int BitField,int BitPos,
- int BitCount)
-{
- int InAddr=BitPos/8;
- int InBit=BitPos&7;
- unsigned int AndMask=0xffffffff>>(32-BitCount);
- AndMask=~(AndMask<<InBit);
-
- BitField<<=InBit;
-
- for (int I=0;I<4;I++)
- {
- Data[InAddr+I]&=AndMask;
- Data[InAddr+I]|=BitField;
- AndMask=(AndMask>>8)|0xff000000;
- BitField>>=8;
- }
-}
-#endif
diff --git a/7zip/Compress/Rar29/Original/rarvm.hpp b/7zip/Compress/Rar29/Original/rarvm.hpp
deleted file mode 100755
index f330390b..00000000
--- a/7zip/Compress/Rar29/Original/rarvm.hpp
+++ /dev/null
@@ -1,110 +0,0 @@
-#ifndef _RAR_VM_
-#define _RAR_VM_
-
-#define VM_STANDARDFILTERS
-
-#ifndef SFX_MODULE
-#define VM_OPTIMIZE
-#endif
-
-
-#define VM_MEMSIZE 0x40000
-#define VM_MEMMASK (VM_MEMSIZE-1)
-#define VM_GLOBALMEMADDR 0x3C000
-#define VM_GLOBALMEMSIZE 0x2000
-#define VM_FIXEDGLOBALSIZE 64
-
-enum VM_Commands
-{
- VM_MOV, VM_CMP, VM_ADD, VM_SUB, VM_JZ, VM_JNZ, VM_INC, VM_DEC,
- VM_JMP, VM_XOR, VM_AND, VM_OR, VM_TEST, VM_JS, VM_JNS, VM_JB,
- VM_JBE, VM_JA, VM_JAE, VM_PUSH, VM_POP, VM_CALL, VM_RET, VM_NOT,
- VM_SHL, VM_SHR, VM_SAR, VM_NEG, VM_PUSHA,VM_POPA, VM_PUSHF,VM_POPF,
- VM_MOVZX,VM_MOVSX,VM_XCHG, VM_MUL, VM_DIV, VM_ADC, VM_SBB, VM_PRINT,
-
-#ifdef VM_OPTIMIZE
- VM_MOVB, VM_MOVD, VM_CMPB, VM_CMPD,
-
- VM_ADDB, VM_ADDD, VM_SUBB, VM_SUBD, VM_INCB, VM_INCD, VM_DECB, VM_DECD,
- VM_NEGB, VM_NEGD,
-#endif
-
- VM_STANDARD
-};
-
-enum VM_StandardFilters {
- VMSF_NONE, VMSF_E8, VMSF_E8E9, VMSF_ITANIUM, VMSF_RGB, VMSF_AUDIO,
- VMSF_DELTA, VMSF_UPCASE
-};
-
-enum VM_Flags {VM_FC=1,VM_FZ=2,VM_FS=0x80000000};
-
-enum VM_OpType {VM_OPREG,VM_OPINT,VM_OPREGMEM,VM_OPNONE};
-
-struct VM_PreparedOperand
-{
- VM_OpType Type;
- uint Data;
- uint Base;
- uint *Addr;
-};
-
-struct VM_PreparedCommand
-{
- VM_Commands OpCode;
- bool ByteMode;
- VM_PreparedOperand Op1,Op2;
-};
-
-
-struct VM_PreparedProgram
-{
- VM_PreparedProgram() {AltCmd=NULL;}
-
- Array<VM_PreparedCommand> Cmd;
- VM_PreparedCommand *AltCmd;
- int CmdCount;
-
- Array<byte> GlobalData;
- Array<byte> StaticData;
- uint InitR[7];
-
- byte *FilteredData;
- unsigned int FilteredDataSize;
-};
-
-class RarVM:private BitInput
-{
- private:
- inline uint GetValue(bool ByteMode,uint *Addr);
- inline void SetValue(bool ByteMode,uint *Addr,uint Value);
- inline uint* GetOperand(VM_PreparedOperand *CmdOp);
- void PrintState(uint IP);
- void DecodeArg(VM_PreparedOperand &Op,bool ByteMode);
-#ifdef VM_OPTIMIZE
- void Optimize(VM_PreparedProgram *Prg);
-#endif
- bool ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize);
-#ifdef VM_STANDARDFILTERS
- VM_StandardFilters IsStandardFilter(byte *Code,int CodeSize);
- void ExecuteStandardFilter(VM_StandardFilters FilterType);
- unsigned int FilterItanium_GetBits(byte *Data,int BitPos,int BitCount);
- void FilterItanium_SetBits(byte *Data,unsigned int BitField,int BitPos,
- int BitCount);
-#endif
-
- byte *Mem;
- uint R[8];
- uint Flags;
- public:
- RarVM();
- ~RarVM();
- void Init();
- void Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg);
- void Execute(VM_PreparedProgram *Prg);
- void SetValue(uint *Addr,uint Value);
- void SetMemory(unsigned int Pos,byte *Data,unsigned int DataSize);
- static uint ReadData(BitInput &Inp);
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/rarvmtbl.cpp b/7zip/Compress/Rar29/Original/rarvmtbl.cpp
deleted file mode 100755
index b5e6c720..00000000
--- a/7zip/Compress/Rar29/Original/rarvmtbl.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#define VMCF_OP0 0
-#define VMCF_OP1 1
-#define VMCF_OP2 2
-#define VMCF_OPMASK 3
-#define VMCF_BYTEMODE 4
-#define VMCF_JUMP 8
-#define VMCF_PROC 16
-#define VMCF_USEFLAGS 32
-#define VMCF_CHFLAGS 64
-
-static byte VM_CmdFlags[]=
-{
- /* VM_MOV */ VMCF_OP2 | VMCF_BYTEMODE ,
- /* VM_CMP */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_ADD */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_SUB */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_JZ */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
- /* VM_JNZ */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
- /* VM_INC */ VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_DEC */ VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_JMP */ VMCF_OP1 | VMCF_JUMP ,
- /* VM_XOR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_AND */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_OR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_TEST */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_JS */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
- /* VM_JNS */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
- /* VM_JB */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
- /* VM_JBE */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
- /* VM_JA */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
- /* VM_JAE */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
- /* VM_PUSH */ VMCF_OP1 ,
- /* VM_POP */ VMCF_OP1 ,
- /* VM_CALL */ VMCF_OP1 | VMCF_PROC ,
- /* VM_RET */ VMCF_OP0 | VMCF_PROC ,
- /* VM_NOT */ VMCF_OP1 | VMCF_BYTEMODE ,
- /* VM_SHL */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_SHR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_SAR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_NEG */ VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
- /* VM_PUSHA */ VMCF_OP0 ,
- /* VM_POPA */ VMCF_OP0 ,
- /* VM_PUSHF */ VMCF_OP0 | VMCF_USEFLAGS ,
- /* VM_POPF */ VMCF_OP0 | VMCF_CHFLAGS ,
- /* VM_MOVZX */ VMCF_OP2 ,
- /* VM_MOVSX */ VMCF_OP2 ,
- /* VM_XCHG */ VMCF_OP2 | VMCF_BYTEMODE ,
- /* VM_MUL */ VMCF_OP2 | VMCF_BYTEMODE ,
- /* VM_DIV */ VMCF_OP2 | VMCF_BYTEMODE ,
- /* VM_ADC */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS ,
- /* VM_SBB */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS ,
- /* VM_PRINT */ VMCF_OP0
-};
diff --git a/7zip/Compress/Rar29/Original/rawread.hpp b/7zip/Compress/Rar29/Original/rawread.hpp
deleted file mode 100755
index 47c2bbcb..00000000
--- a/7zip/Compress/Rar29/Original/rawread.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _RAR_RAWREAD_
-#define _RAR_RAWREAD_
-
-class RawRead
-{
- private:
- Array<byte> Data;
- File *SrcFile;
- int DataSize;
- int ReadPos;
-#ifndef SHELL_EXT
- CryptData *Crypt;
-#endif
- public:
- RawRead(File *SrcFile);
- void Read(int Size);
- void Read(byte *SrcData,int Size);
- void Get(byte &Field);
- void Get(ushort &Field);
- void Get(uint &Field);
- void Get8(Int64 &Field);
- void Get(byte *Field,int Size);
- void Get(wchar *Field,int Size);
- uint GetCRC(bool ProcessedOnly);
- int Size() {return DataSize;}
- int PaddedSize() {return Data.Size()-DataSize;}
-#ifndef SHELL_EXT
- void SetCrypt(CryptData *Crypt) {RawRead::Crypt=Crypt;}
-#endif
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/rdwrfn.cpp b/7zip/Compress/Rar29/Original/rdwrfn.cpp
deleted file mode 100755
index 7340ea67..00000000
--- a/7zip/Compress/Rar29/Original/rdwrfn.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-#include "rar.hpp"
-
-// Igor Pavlov
-#include "../../../Common/StreamUtils.h"
-
-ComprDataIO::ComprDataIO()
-{
- Init();
-}
-
-
-void ComprDataIO::Init()
-{
- UnpackFromMemory=false;
- UnpackToMemory=false;
- UnpPackedSize=0;
- ShowProgress=true;
- TestMode=false;
- SkipUnpCRC=false;
- PackVolume=false;
- UnpVolume=false;
- NextVolumeMissing=false;
- SrcFile=NULL;
- DestFile=NULL;
- UnpWrSize=0;
- Command=NULL;
- Encryption=0;
- Decryption=0;
- TotalPackRead=0;
- CurPackRead=CurPackWrite=CurUnpRead=CurUnpWrite=0;
- PackFileCRC=UnpFileCRC=PackedCRC=0xffffffff;
- LastPercent=-1;
- // Igor Pavlov
- /*
- SubHead=NULL;
- SubHeadPos=NULL;
- */
- CurrentCommand=0;
- ProcessedArcSize=TotalArcSize=0;
-}
-
-
-
-
-int ComprDataIO::UnpRead(byte *Addr,uint Count)
-{
- int RetCode=0,TotalRead=0;
- byte *ReadAddr;
- ReadAddr=Addr;
- while (Count > 0)
- {
- Archive *SrcArc=(Archive *)SrcFile;
-
- uint ReadSize=(Count>UnpPackedSize) ? int64to32(UnpPackedSize):Count;
- if (UnpackFromMemory)
- {
- memcpy(Addr,UnpackFromMemoryAddr,UnpackFromMemorySize);
- RetCode=UnpackFromMemorySize;
- UnpackFromMemorySize=0;
- }
- else
- {
- // Igor Pavlov
- if (!SrcFile)
- // if (!SrcFile->IsOpened())
- return(-1);
-
- // Igor Pavlov
- UInt32 processedSize;
- HRESULT result = ReadStream(SrcFile, ReadAddr, ReadSize, &processedSize);
- RetCode = processedSize;
-
- // Igor Pavlov
- /*
- FileHeader *hd=SubHead!=NULL ? SubHead:&SrcArc->NewLhd;
- if (hd->Flags & LHD_SPLIT_AFTER)
- PackedCRC=CRC(PackedCRC,ReadAddr,ReadSize);
- */
- }
- CurUnpRead+=RetCode;
- ReadAddr+=RetCode;
- TotalRead+=RetCode;
- Count-=RetCode;
- UnpPackedSize-=RetCode;
- if (UnpPackedSize == 0 && UnpVolume)
- {
-#ifndef NOVOLUME
- if (!MergeArchive(*SrcArc,this,true,CurrentCommand))
-#endif
- {
- NextVolumeMissing=true;
- return(-1);
- }
- }
- else
- break;
- }
- // Igor Pavlov
- /*
- Archive *SrcArc=(Archive *)SrcFile;
- if (SrcArc!=NULL)
- ShowUnpRead(SrcArc->CurBlockPos+CurUnpRead,UnpArcSize);
- */
- if (RetCode!=-1)
- {
- RetCode=TotalRead;
-#ifndef NOCRYPT
- if (Decryption)
-#ifndef SFX_MODULE
- if (Decryption<20)
- Decrypt.Crypt(Addr,RetCode,(Decryption==15) ? NEW_CRYPT : OLD_DECODE);
- else
- if (Decryption==20)
- for (uint I=0;I<RetCode;I+=16)
- Decrypt.DecryptBlock20(&Addr[I]);
- else
-#endif
- {
- int CryptSize=(RetCode & 0xf)==0 ? RetCode:((RetCode & ~0xf)+16);
- Decrypt.DecryptBlock(Addr,CryptSize);
- }
-#endif
- }
- Wait();
- return(RetCode);
-}
-
-
-void ComprDataIO::UnpWrite(byte *Addr,uint Count)
-{
-#ifdef RARDLL
- RAROptions *Cmd=((Archive *)SrcFile)->GetRAROptions();
- if (Cmd->DllOpMode!=RAR_SKIP)
- {
- if (Cmd->Callback!=NULL &&
- Cmd->Callback(UCM_PROCESSDATA,Cmd->UserData,(LONG)Addr,Count)==-1)
- ErrHandler.Exit(USER_BREAK);
- if (Cmd->ProcessDataProc!=NULL)
- {
-#ifdef _WIN_32
- _EBX=_ESP;
-#endif
- int RetCode=Cmd->ProcessDataProc(Addr,Count);
-#ifdef _WIN_32
- _ESP=_EBX;
-#endif
- if (RetCode==0)
- ErrHandler.Exit(USER_BREAK);
- }
- }
-#endif
- UnpWrAddr=Addr;
- UnpWrSize=Count;
- if (UnpackToMemory)
- {
- if (Count <= UnpackToMemorySize)
- {
- memcpy(UnpackToMemoryAddr,Addr,Count);
- UnpackToMemoryAddr+=Count;
- UnpackToMemorySize-=Count;
- }
- }
- else
- if (!TestMode)
- {
- // Igor Pavlov
- // DestFile->Write(Addr,Count);
- WriteStream(DestFile, Addr,Count, 0);
- }
- CurUnpWrite+=Count;
- // Igor Pavlov
- /*
- if (!SkipUnpCRC)
-#ifndef SFX_MODULE
- if (((Archive *)SrcFile)->OldFormat)
- UnpFileCRC=OldCRC((ushort)UnpFileCRC,Addr,Count);
- else
-#endif
- UnpFileCRC=CRC(UnpFileCRC,Addr,Count);
- */
- ShowUnpWrite();
- Wait();
-}
-
-
-
-
-
-
-void ComprDataIO::ShowUnpRead(Int64 ArcPos,Int64 ArcSize)
-{
- if (ShowProgress && SrcFile!=NULL)
- {
- Archive *SrcArc=(Archive *)SrcFile;
- RAROptions *Cmd=SrcArc->GetRAROptions();
- if (TotalArcSize!=0)
- ArcSize=TotalArcSize;
- ArcPos+=ProcessedArcSize;
- if (!SrcArc->Volume)
- {
- int CurPercent=ToPercent(ArcPos,ArcSize);
- if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
- {
- mprintf("\b\b\b\b%3d%%",CurPercent);
- LastPercent=CurPercent;
- }
- }
- }
-}
-
-
-void ComprDataIO::ShowUnpWrite()
-{
- // Igor Pavlov
- if (Progress)
- {
- UInt64 unPackSize = CurUnpWrite;
- HRESULT result = Progress->SetRatioInfo(NULL, &unPackSize);
- if (result != S_OK)
- throw CExitCode(result);
- }
-}
-
-
-
-
-
-
-
-// Igor Pavlov
-/*
-void ComprDataIO::SetFiles(File *SrcFile,File *DestFile)
-{
- if (SrcFile!=NULL)
- ComprDataIO::SrcFile=SrcFile;
- if (DestFile!=NULL)
- ComprDataIO::DestFile=DestFile;
- LastPercent=-1;
-}
-*/
-
-void ComprDataIO::GetUnpackedData(byte **Data,uint *Size)
-{
- *Data=UnpWrAddr;
- *Size=UnpWrSize;
-}
-
-// Igor Pavlov
-/*
-void ComprDataIO::SetEncryption(int Method,char *Password,byte *Salt,bool Encrypt)
-{
- if (Encrypt)
- {
- Encryption=*Password ? Method:0;
-#ifndef NOCRYPT
- Crypt.SetCryptKeys(Password,Salt,Encrypt);
-#endif
- }
- else
- {
- Decryption=*Password ? Method:0;
-#ifndef NOCRYPT
- Decrypt.SetCryptKeys(Password,Salt,Encrypt,Method<29);
-#endif
- }
-}
-
-
-#ifndef SFX_MODULE
-void ComprDataIO::SetAV15Encryption()
-{
- Decryption=15;
- Decrypt.SetAV15Encryption();
-}
-#endif
-
-
-#ifndef SFX_MODULE
-void ComprDataIO::SetCmt13Encryption()
-{
- Decryption=13;
- Decrypt.SetCmt13Encryption();
-}
-#endif
-
-*/
-
-
-
-void ComprDataIO::SetUnpackToMemory(byte *Addr,uint Size)
-{
- UnpackToMemory=true;
- UnpackToMemoryAddr=Addr;
- UnpackToMemorySize=Size;
-}
-
-// Igor Pavlov
-void ComprDataIO::SetFiles(ISequentialInStream *srcFile,
- ISequentialOutStream *destFile, ICompressProgressInfo *progress)
-{
- SrcFile = srcFile;
- DestFile = destFile;
- Progress = progress;
- LastPercent = -1;
-}
-
diff --git a/7zip/Compress/Rar29/Original/rdwrfn.hpp b/7zip/Compress/Rar29/Original/rdwrfn.hpp
deleted file mode 100755
index d2feb842..00000000
--- a/7zip/Compress/Rar29/Original/rdwrfn.hpp
+++ /dev/null
@@ -1,104 +0,0 @@
-#ifndef _RAR_DATAIO_
-#define _RAR_DATAIO_
-
-// Igor Pavlov
-#include "../../../ICoder.h"
-
-class CmdAdd;
-class Unpack;
-
-// Igor Pavlov
-struct CExitCode
-{
- HRESULT Result;
- CExitCode(HRESULT result): Result(result) {};
-};
-
-class ComprDataIO
-{
- private:
- void ShowUnpRead(Int64 ArcPos,Int64 ArcSize);
- void ShowUnpWrite();
-
-
- bool UnpackFromMemory;
- uint UnpackFromMemorySize;
- byte *UnpackFromMemoryAddr;
-
- bool UnpackToMemory;
- uint UnpackToMemorySize;
- byte *UnpackToMemoryAddr;
-
- uint UnpWrSize;
- byte *UnpWrAddr;
-
- Int64 UnpPackedSize;
-
- bool ShowProgress;
- bool TestMode;
- bool SkipUnpCRC;
-
- // Igor Pavlov
- // File *SrcFile;
- // File *DestFile;
- ISequentialInStream *SrcFile;
- ISequentialOutStream *DestFile;
- ICompressProgressInfo *Progress;
-
- CmdAdd *Command;
-
- // Igor Pavlov
- /*
- FileHeader *SubHead;
- Int64 *SubHeadPos;
- */
-
-#ifndef NOCRYPT
- CryptData Crypt;
- CryptData Decrypt;
-#endif
-
-
- int LastPercent;
-
- char CurrentCommand;
-
- public:
- ComprDataIO();
- void Init();
- int UnpRead(byte *Addr,uint Count);
- void UnpWrite(byte *Addr,uint Count);
- void EnableShowProgress(bool Show) {ShowProgress=Show;}
- void GetUnpackedData(byte **Data,uint *Size);
- void SetPackedSizeToRead(Int64 Size) {UnpPackedSize=Size;}
- void SetTestMode(bool Mode) {TestMode=Mode;}
- void SetSkipUnpCRC(bool Skip) {SkipUnpCRC=Skip;}
- // Igor Pavlov
- // void SetFiles(File *SrcFile,File *DestFile);
- void SetFiles(ISequentialInStream *srcFile,
- ISequentialOutStream *destFile, ICompressProgressInfo *progress);
-
- void SetCommand(CmdAdd *Cmd) {Command=Cmd;}
- // Igor Pavlov
- // void SetSubHeader(FileHeader *hd,Int64 *Pos) {SubHead=hd;SubHeadPos=Pos;}
- // void SetEncryption(int Method,char *Password,byte *Salt,bool Encrypt);
- // void SetAV15Encryption();
- // void SetCmt13Encryption();
- void SetUnpackToMemory(byte *Addr,uint Size);
- void SetCurrentCommand(char Cmd) {CurrentCommand=Cmd;}
-
- bool PackVolume;
- bool UnpVolume;
- bool NextVolumeMissing;
- Int64 TotalPackRead;
- Int64 UnpArcSize;
- Int64 CurPackRead,CurPackWrite,CurUnpRead,CurUnpWrite;
- Int64 ProcessedArcSize,TotalArcSize;
-
- uint PackFileCRC,UnpFileCRC,PackedCRC;
-
- int Encryption;
- int Decryption;
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/recvol.hpp b/7zip/Compress/Rar29/Original/recvol.hpp
deleted file mode 100755
index 5a0abe58..00000000
--- a/7zip/Compress/Rar29/Original/recvol.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _RAR_RECVOL_
-#define _RAR_RECVOL_
-
-class RecVolumes
-{
- private:
- File *SrcFile[256];
- Array<byte> Buf;
- public:
- RecVolumes();
- ~RecVolumes();
- void Make(RAROptions *Cmd,char *ArcName,wchar *ArcNameW);
- bool Restore(RAROptions *Cmd,const char *Name,const wchar *NameW,bool Silent);
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/resource.cpp b/7zip/Compress/Rar29/Original/resource.cpp
deleted file mode 100755
index f2a46573..00000000
--- a/7zip/Compress/Rar29/Original/resource.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "rar.hpp"
-
-
-
-#if !defined(SILENT) || !defined(RARDLL)
-const char *St(MSGID StringId)
-{
- return(StringId);
-}
-#endif
-
-
diff --git a/7zip/Compress/Rar29/Original/resource.hpp b/7zip/Compress/Rar29/Original/resource.hpp
deleted file mode 100755
index 581b34b4..00000000
--- a/7zip/Compress/Rar29/Original/resource.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _RAR_RESOURCE_
-#define _RAR_RESOURCE_
-
-#if defined(SILENT) && defined(RARDLL)
-#define St(x) ("")
-#else
-const char *St(MSGID StringId);
-#endif
-
-
-inline const char *StT(MSGID StringId) {return(St(StringId));}
-
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/rijndael.hpp b/7zip/Compress/Rar29/Original/rijndael.hpp
deleted file mode 100755
index 6a8eddeb..00000000
--- a/7zip/Compress/Rar29/Original/rijndael.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _RIJNDAEL_H_
-#define _RIJNDAEL_H_
-
-/**************************************************************************
- * This code is based on Szymon Stefanek AES implementation: *
- * http://www.esat.kuleuven.ac.be/~rijmen/rijndael/rijndael-cpplib.tar.gz *
- * *
- * Dynamic tables generation is based on the Brian Gladman's work: *
- * http://fp.gladman.plus.com/cryptography_technology/rijndael *
- **************************************************************************/
-
-#define _MAX_KEY_COLUMNS (256/32)
-#define _MAX_ROUNDS 14
-#define MAX_IV_SIZE 16
-
-class Rijndael
-{
- public:
- enum Direction { Encrypt , Decrypt };
- private:
- void keySched(byte key[_MAX_KEY_COLUMNS][4]);
- void keyEncToDec();
- void encrypt(const byte a[16], byte b[16]);
- void decrypt(const byte a[16], byte b[16]);
- void GenerateTables();
-
- Direction m_direction;
- byte m_initVector[MAX_IV_SIZE];
- byte m_expandedKey[_MAX_ROUNDS+1][4][4];
- public:
- Rijndael();
- void init(Direction dir,const byte *key,byte *initVector);
- int blockEncrypt(const byte *input, int inputLen, byte *outBuffer);
- int blockDecrypt(const byte *input, int inputLen, byte *outBuffer);
-};
-
-#endif // _RIJNDAEL_H_
diff --git a/7zip/Compress/Rar29/Original/rs.hpp b/7zip/Compress/Rar29/Original/rs.hpp
deleted file mode 100755
index 2f099f00..00000000
--- a/7zip/Compress/Rar29/Original/rs.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _RAR_RS_
-#define _RAR_RS_
-
-#define MAXPAR 255
-#define MAXPOL 512
-
-class RSCoder
-{
- private:
- void gfInit();
- int gfMult(int a,int b);
- void pnInit();
- void pnMult(int *p1,int *p2,int *r);
-
- int gfExp[MAXPOL];
- int gfLog[MAXPAR+1];
-
- int GXPol[MAXPOL*2];
-
- int ErrorLocs[MAXPAR+1],ErrCount;
- int Dn[MAXPAR+1];
-
- int ParSize;
- int PolB[MAXPOL];
- bool FirstBlockDone;
- public:
- RSCoder(int ParSize);
- void Encode(byte *Data,int DataSize,byte *DestData);
- bool Decode(byte *Data,int DataSize,int *EraLoc,int EraSize);
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/savepos.hpp b/7zip/Compress/Rar29/Original/savepos.hpp
deleted file mode 100755
index 303550a0..00000000
--- a/7zip/Compress/Rar29/Original/savepos.hpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _RAR_SAVEPOS_
-#define _RAR_SAVEPOS_
-
-class SaveFilePos
-{
- private:
- File *SaveFile;
- Int64 SavePos;
- uint CloseCount;
- public:
- SaveFilePos(File &SaveFile);
- ~SaveFilePos();
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/scantree.hpp b/7zip/Compress/Rar29/Original/scantree.hpp
deleted file mode 100755
index 2f206ba1..00000000
--- a/7zip/Compress/Rar29/Original/scantree.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef _RAR_SCANTREE_
-#define _RAR_SCANTREE_
-
-enum { RECURSE_NONE=0,RECURSE_ALWAYS,RECURSE_WILDCARDS };
-enum { SCAN_SKIPDIRS=0,SCAN_GETDIRS,SCAN_GETDIRSTWICE,SCAN_GETCURDIRS };
-enum { SCAN_SUCCESS,SCAN_DONE,SCAN_ERROR,SCAN_NEXT };
-
-#define MAXSCANDEPTH (NM/2)
-
-class CommandData;
-
-class ScanTree
-{
- private:
- bool PrepareMasks();
- int FindProc(FindData *FindData);
-
- FindFile *FindStack[MAXSCANDEPTH];
- int Depth;
-
- int SetAllMaskDepth;
-
- StringList *FileMasks;
- int Recurse;
- bool GetLinks;
- int GetDirs;
- int Errors;
-
- char CurMask[NM];
- wchar CurMaskW[NM];
- char OrigCurMask[NM];
- wchar OrigCurMaskW[NM];
- bool SearchAllInRoot;
- bool FastFindFile;
- int SpecPathLength;
- int SpecPathLengthW;
-
- char ErrArcName[NM];
-
- CommandData *Cmd;
- public:
- ScanTree(StringList *FileMasks,int Recurse,bool GetLinks,int GetDirs);
- ~ScanTree();
- int GetNext(FindData *FindData);
- int GetSpecPathLength() {return(SpecPathLength);};
- int GetSpecPathLengthW() {return(SpecPathLengthW);};
- int GetErrors() {return(Errors);};
- void SetErrArcName(const char *Name) {strcpy(ErrArcName,Name);}
- void SetCommandData(CommandData *Cmd) {ScanTree::Cmd=Cmd;}
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/sha1.hpp b/7zip/Compress/Rar29/Original/sha1.hpp
deleted file mode 100755
index 96cef44e..00000000
--- a/7zip/Compress/Rar29/Original/sha1.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _RAR_SHA1_
-#define _RAR_SHA1_
-
-#define HW 5
-
-typedef struct {
- uint32 state[5];
- uint32 count[2];
- unsigned char buffer[64];
-} hash_context;
-
-void hash_initial( hash_context * c );
-void hash_process( hash_context * c, unsigned char * data, unsigned len );
-void hash_final( hash_context * c, uint32[HW] );
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/smallfn.cpp b/7zip/Compress/Rar29/Original/smallfn.cpp
deleted file mode 100755
index 094691f0..00000000
--- a/7zip/Compress/Rar29/Original/smallfn.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "rar.hpp"
-
-int ToPercent(Int64 N1,Int64 N2)
-{
- if (N2==0)
- return(0);
- if (N2<N1)
- return(100);
- return(int64to32(N1*100/N2));
-}
-
-
-void RARInitData()
-{
- InitCRC();
- ErrHandler.Clean();
-}
diff --git a/7zip/Compress/Rar29/Original/smallfn.hpp b/7zip/Compress/Rar29/Original/smallfn.hpp
deleted file mode 100755
index 096ffef1..00000000
--- a/7zip/Compress/Rar29/Original/smallfn.hpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _RAR_SMALLFN_
-#define _RAR_SMALLFN_
-
-int ToPercent(Int64 N1,Int64 N2);
-void RARInitData();
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/strfn.hpp b/7zip/Compress/Rar29/Original/strfn.hpp
deleted file mode 100755
index 57813e52..00000000
--- a/7zip/Compress/Rar29/Original/strfn.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _RAR_STRFN_
-#define _RAR_STRFN_
-
-const char *NullToEmpty(const char *Str);
-const wchar *NullToEmpty(const wchar *Str);
-char *IntNameToExt(const char *Name);
-void ExtToInt(const char *Src,char *Dest);
-void IntToExt(const char *Src,char *Dest);
-char* strlower(char *Str);
-char* strupper(char *Str);
-int stricomp(const char *Str1,const char *Str2);
-int strnicomp(const char *Str1,const char *Str2,int N);
-char* RemoveEOL(char *Str);
-char* RemoveLF(char *Str);
-unsigned int loctolower(byte ch);
-unsigned int loctoupper(byte ch);
-
-
-
-bool LowAscii(const char *Str);
-bool LowAscii(const wchar *Str);
-
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/strlist.hpp b/7zip/Compress/Rar29/Original/strlist.hpp
deleted file mode 100755
index c4d3b017..00000000
--- a/7zip/Compress/Rar29/Original/strlist.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef _RAR_STRLIST_
-#define _RAR_STRLIST_
-
-class StringList
-{
- private:
- Array<char> StringData;
- unsigned int CurPos;
-
- Array<wchar> StringDataW;
- unsigned int CurPosW;
-
- Array<int> PosDataW;
- uint PosDataItem;
-
- uint StringsCount;
-
- uint SaveCurPos[16],SaveCurPosW[16],SavePosDataItem[16],SavePosNumber;
- public:
- StringList();
- ~StringList();
- void Reset();
- unsigned int AddString(const char *Str);
- unsigned int AddString(const char *Str,const wchar *StrW);
- bool GetString(char *Str,int MaxLength);
- bool GetString(char *Str,wchar *StrW,int MaxLength);
- bool GetString(char *Str,wchar *StrW,int MaxLength,int StringNum);
- char* GetString();
- bool GetString(char **Str,wchar **StrW);
- char* GetString(unsigned int StringPos);
- void Rewind();
- unsigned int ItemsCount() {return(StringsCount);};
- int GetBufferSize();
- bool Search(char *Str,wchar *StrW,bool CaseSensitive);
- void SavePosition();
- void RestorePosition();
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/suballoc.cpp b/7zip/Compress/Rar29/Original/suballoc.cpp
deleted file mode 100755
index bffc7632..00000000
--- a/7zip/Compress/Rar29/Original/suballoc.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-/****************************************************************************
- * This file is part of PPMd project *
- * Written and distributed to public domain by Dmitry Shkarin 1997, *
- * 1999-2000 *
- * Contents: memory allocation routines *
- ****************************************************************************/
-
-SubAllocator::SubAllocator()
-{
- Clean();
-}
-
-
-void SubAllocator::Clean()
-{
- SubAllocatorSize=0;
-}
-
-
-inline void SubAllocator::InsertNode(void* p,int indx)
-{
- ((RAR_NODE*) p)->next=FreeList[indx].next;
- FreeList[indx].next=(RAR_NODE*) p;
-}
-
-
-inline void* SubAllocator::RemoveNode(int indx)
-{
- RAR_NODE* RetVal=FreeList[indx].next;
- FreeList[indx].next=RetVal->next;
- return RetVal;
-}
-
-
-inline uint SubAllocator::U2B(int NU)
-{
- return /*8*NU+4*NU*/UNIT_SIZE*NU;
-}
-
-
-inline void SubAllocator::SplitBlock(void* pv,int OldIndx,int NewIndx)
-{
- int i, UDiff=Indx2Units[OldIndx]-Indx2Units[NewIndx];
- byte* p=((byte*) pv)+U2B(Indx2Units[NewIndx]);
- if (Indx2Units[i=Units2Indx[UDiff-1]] != UDiff)
- {
- InsertNode(p,--i);
- p += U2B(i=Indx2Units[i]);
- UDiff -= i;
- }
- InsertNode(p,Units2Indx[UDiff-1]);
-}
-
-
-
-
-void SubAllocator::StopSubAllocator()
-{
- if ( SubAllocatorSize )
- {
- SubAllocatorSize=0;
- rarfree(HeapStart);
- }
-}
-
-
-bool SubAllocator::StartSubAllocator(int SASize)
-{
- uint t=SASize << 20;
- if (SubAllocatorSize == t)
- return TRUE;
- StopSubAllocator();
- uint AllocSize=t/FIXED_UNIT_SIZE*UNIT_SIZE+UNIT_SIZE;
- if ((HeapStart=(byte *)rarmalloc(AllocSize)) == NULL)
- {
- ErrHandler.MemoryError();
- return FALSE;
- }
- HeapEnd=HeapStart+AllocSize-UNIT_SIZE;
- SubAllocatorSize=t;
- return TRUE;
-}
-
-
-void SubAllocator::InitSubAllocator()
-{
- int i, k;
- memset(FreeList,0,sizeof(FreeList));
- pText=HeapStart;
- uint Size2=FIXED_UNIT_SIZE*(SubAllocatorSize/8/FIXED_UNIT_SIZE*7);
- uint RealSize2=Size2/FIXED_UNIT_SIZE*UNIT_SIZE;
- uint Size1=SubAllocatorSize-Size2;
- uint RealSize1=Size1/FIXED_UNIT_SIZE*UNIT_SIZE+Size1%FIXED_UNIT_SIZE;
- HiUnit=HeapStart+SubAllocatorSize;
- LoUnit=UnitsStart=HeapStart+RealSize1;
- FakeUnitsStart=HeapStart+Size1;
- HiUnit=LoUnit+RealSize2;
- for (i=0,k=1;i < N1 ;i++,k += 1)
- Indx2Units[i]=k;
- for (k++;i < N1+N2 ;i++,k += 2)
- Indx2Units[i]=k;
- for (k++;i < N1+N2+N3 ;i++,k += 3)
- Indx2Units[i]=k;
- for (k++;i < N1+N2+N3+N4;i++,k += 4)
- Indx2Units[i]=k;
- for (GlueCount=k=i=0;k < 128;k++)
- {
- i += (Indx2Units[i] < k+1);
- Units2Indx[k]=i;
- }
-}
-
-
-inline void SubAllocator::GlueFreeBlocks()
-{
- RAR_MEM_BLK s0, * p, * p1;
- int i, k, sz;
- if (LoUnit != HiUnit)
- *LoUnit=0;
- for (i=0, s0.next=s0.prev=&s0;i < N_INDEXES;i++)
- while ( FreeList[i].next )
- {
- p=(RAR_MEM_BLK*)RemoveNode(i);
- p->insertAt(&s0);
- p->Stamp=0xFFFF;
- p->NU=Indx2Units[i];
- }
- for (p=s0.next;p != &s0;p=p->next)
- while ((p1=p+p->NU)->Stamp == 0xFFFF && int(p->NU)+p1->NU < 0x10000)
- {
- p1->remove();
- p->NU += p1->NU;
- }
- while ((p=s0.next) != &s0)
- {
- for (p->remove(), sz=p->NU;sz > 128;sz -= 128, p += 128)
- InsertNode(p,N_INDEXES-1);
- if (Indx2Units[i=Units2Indx[sz-1]] != sz)
- {
- k=sz-Indx2Units[--i];
- InsertNode(p+(sz-k),k-1);
- }
- InsertNode(p,i);
- }
-}
-
-void* SubAllocator::AllocUnitsRare(int indx)
-{
- if ( !GlueCount )
- {
- GlueCount = 255;
- GlueFreeBlocks();
- if ( FreeList[indx].next )
- return RemoveNode(indx);
- }
- int i=indx;
- do
- {
- if (++i == N_INDEXES)
- {
- GlueCount--;
- i=U2B(Indx2Units[indx]);
- int j=12*Indx2Units[indx];
- if (FakeUnitsStart-pText > j)
- {
- FakeUnitsStart-=j;
- UnitsStart -= i;
- return(UnitsStart);
- }
- return(NULL);
- }
- } while ( !FreeList[i].next );
- void* RetVal=RemoveNode(i);
- SplitBlock(RetVal,i,indx);
- return RetVal;
-}
-
-
-inline void* SubAllocator::AllocUnits(int NU)
-{
- int indx=Units2Indx[NU-1];
- if ( FreeList[indx].next )
- return RemoveNode(indx);
- void* RetVal=LoUnit;
- LoUnit += U2B(Indx2Units[indx]);
- if (LoUnit <= HiUnit)
- return RetVal;
- LoUnit -= U2B(Indx2Units[indx]);
- return AllocUnitsRare(indx);
-}
-
-
-void* SubAllocator::AllocContext()
-{
- if (HiUnit != LoUnit)
- return (HiUnit -= UNIT_SIZE);
- if ( FreeList->next )
- return RemoveNode(0);
- return AllocUnitsRare(0);
-}
-
-
-void* SubAllocator::ExpandUnits(void* OldPtr,int OldNU)
-{
- int i0=Units2Indx[OldNU-1], i1=Units2Indx[OldNU-1+1];
- if (i0 == i1)
- return OldPtr;
- void* ptr=AllocUnits(OldNU+1);
- if ( ptr )
- {
- memcpy(ptr,OldPtr,U2B(OldNU));
- InsertNode(OldPtr,i0);
- }
- return ptr;
-}
-
-
-void* SubAllocator::ShrinkUnits(void* OldPtr,int OldNU,int NewNU)
-{
- int i0=Units2Indx[OldNU-1], i1=Units2Indx[NewNU-1];
- if (i0 == i1)
- return OldPtr;
- if ( FreeList[i1].next )
- {
- void* ptr=RemoveNode(i1);
- memcpy(ptr,OldPtr,U2B(NewNU));
- InsertNode(OldPtr,i0);
- return ptr;
- }
- else
- {
- SplitBlock(OldPtr,i0,i1);
- return OldPtr;
- }
-}
-
-
-void SubAllocator::FreeUnits(void* ptr,int OldNU)
-{
- InsertNode(ptr,Units2Indx[OldNU-1]);
-}
diff --git a/7zip/Compress/Rar29/Original/suballoc.hpp b/7zip/Compress/Rar29/Original/suballoc.hpp
deleted file mode 100755
index 08174eea..00000000
--- a/7zip/Compress/Rar29/Original/suballoc.hpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
- * This file is part of PPMd project *
- * Written and distributed to public domain by Dmitry Shkarin 1997, *
- * 1999-2000 *
- * Contents: interface to memory allocation routines *
- ****************************************************************************/
-#if !defined(_SUBALLOC_H_)
-#define _SUBALLOC_H_
-
-const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
-const int N_INDEXES=N1+N2+N3+N4;
-
-#if defined(__GNUC__)
-#define _PACK_ATTR __attribute__ ((packed))
-#else
-#define _PACK_ATTR
-#endif /* defined(__GNUC__) */
-
-#pragma pack(1)
-struct RAR_MEM_BLK
-{
- ushort Stamp, NU;
- RAR_MEM_BLK* next, * prev;
- void insertAt(RAR_MEM_BLK* p)
- {
- next=(prev=p)->next;
- p->next=next->prev=this;
- }
- void remove()
- {
- prev->next=next;
- next->prev=prev;
- }
-} _PACK_ATTR;
-
-#ifdef _AIX
-#pragma pack(pop)
-#else
-#pragma pack()
-#endif
-
-
-struct RAR_NODE
-{
- RAR_NODE* next;
-};
-
-class SubAllocator
-{
- private:
- inline void InsertNode(void* p,int indx);
- inline void* RemoveNode(int indx);
- inline uint U2B(int NU);
- inline void SplitBlock(void* pv,int OldIndx,int NewIndx);
- uint GetUsedMemory();
- inline void GlueFreeBlocks();
- void* AllocUnitsRare(int indx);
-
- long SubAllocatorSize;
- byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;
- byte *HeapStart,*LoUnit, *HiUnit;
- struct RAR_NODE FreeList[N_INDEXES];
- public:
- SubAllocator();
- ~SubAllocator() {StopSubAllocator();}
- void Clean();
- bool StartSubAllocator(int SASize);
- void StopSubAllocator();
- void InitSubAllocator();
- inline void* AllocContext();
- inline void* AllocUnits(int NU);
- inline void* ExpandUnits(void* ptr,int OldNU);
- inline void* ShrinkUnits(void* ptr,int OldNU,int NewNU);
- inline void FreeUnits(void* ptr,int OldNU);
- long GetAllocatedMemory() {return(SubAllocatorSize);};
-
- byte *pText, *UnitsStart,*HeapEnd,*FakeUnitsStart;
-};
-
-
-#endif /* !defined(_SUBALLOC_H_) */
diff --git a/7zip/Compress/Rar29/Original/system.cpp b/7zip/Compress/Rar29/Original/system.cpp
deleted file mode 100755
index 1d3cdafe..00000000
--- a/7zip/Compress/Rar29/Original/system.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "rar.hpp"
-
-#ifndef _WIN_CE
-static int SleepTime=0;
-
-void InitSystemOptions(int SleepTime)
-{
- ::SleepTime=SleepTime;
-}
-#endif
-
-
-#if !defined(SFX_MODULE) && !defined(_WIN_CE)
-
-#if defined(_WIN_32) && !defined(BELOW_NORMAL_PRIORITY_CLASS)
-#define BELOW_NORMAL_PRIORITY_CLASS 0x00004000
-#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
-#endif
-
-void SetPriority(int Priority)
-{
-#ifdef _WIN_32
- uint PriorityClass;
- int PriorityLevel;
- if (Priority<1 || Priority>15)
- return;
-
- if (Priority==1)
- {
- PriorityClass=IDLE_PRIORITY_CLASS;
- PriorityLevel=THREAD_PRIORITY_IDLE;
- }
- else
- if (Priority<7)
- {
- PriorityClass=IDLE_PRIORITY_CLASS;
- PriorityLevel=Priority-4;
- }
- else
- if (Priority==7)
- {
- PriorityClass=BELOW_NORMAL_PRIORITY_CLASS;
- PriorityLevel=THREAD_PRIORITY_ABOVE_NORMAL;
- }
- else
- if (Priority<10)
- {
- PriorityClass=NORMAL_PRIORITY_CLASS;
- PriorityLevel=Priority-7;
- }
- else
- if (Priority==10)
- {
- PriorityClass=ABOVE_NORMAL_PRIORITY_CLASS;
- PriorityLevel=THREAD_PRIORITY_NORMAL;
- }
- else
- {
- PriorityClass=HIGH_PRIORITY_CLASS;
- PriorityLevel=Priority-13;
- }
- SetPriorityClass(GetCurrentProcess(),PriorityClass);
- SetThreadPriority(GetCurrentThread(),PriorityLevel);
-#endif
-}
-#endif
-
-
-void Wait()
-{
-#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE)
- if (SleepTime!=0)
- Sleep(SleepTime);
-#endif
-}
-
-
-
-
diff --git a/7zip/Compress/Rar29/Original/system.hpp b/7zip/Compress/Rar29/Original/system.hpp
deleted file mode 100755
index 89582ece..00000000
--- a/7zip/Compress/Rar29/Original/system.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _RAR_SYSTEM_
-#define _RAR_SYSTEM_
-
-void InitSystemOptions(int SleepTime);
-void SetPriority(int Priority);
-void Wait();
-bool EmailFile(char *FileName,char *MailTo);
-void Shutdown();
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/timefn.hpp b/7zip/Compress/Rar29/Original/timefn.hpp
deleted file mode 100755
index 9ab5032f..00000000
--- a/7zip/Compress/Rar29/Original/timefn.hpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef _RAR_TIMEFN_
-#define _RAR_TIMEFN_
-
-struct RarLocalTime
-{
- uint Year;
- uint Month;
- uint Day;
- uint Hour;
- uint Minute;
- uint Second;
- uint Reminder;
- uint wDay;
- uint yDay;
-};
-
-
-class RarTime
-{
- private:
- Int64 GetRaw();
- void SetRaw(Int64 RawTime);
-
- RarLocalTime rlt;
-
- Int64 Time;
- public:
- RarTime();
-#ifdef _WIN_32
- RarTime& operator =(FILETIME &ft);
- void GetWin32(FILETIME *ft);
-#endif
-#if defined(_UNIX) || defined(_EMX)
- RarTime& operator =(time_t ut);
- time_t GetUnix();
-#endif
- bool operator == (RarTime &rt);
- bool operator < (RarTime &rt);
- bool operator <= (RarTime &rt);
- bool operator > (RarTime &rt);
- bool operator >= (RarTime &rt);
- void GetLocal(RarLocalTime *lt) {*lt=rlt;}
- void SetLocal(RarLocalTime *lt) {rlt=*lt;}
- uint GetDos();
- void SetDos(uint DosTime);
- void GetText(char *DateStr,bool FullYear);
- void SetIsoText(char *TimeText);
- void SetAgeText(char *TimeText);
- void SetCurrentTime();
- void Reset() {rlt.Year=0;}
- bool IsSet() {return(rlt.Year!=0);}
-};
-
-const char *GetMonthName(int Month);
-bool IsLeapYear(int Year);
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/ulinks.hpp b/7zip/Compress/Rar29/Original/ulinks.hpp
deleted file mode 100755
index 69b0e9f8..00000000
--- a/7zip/Compress/Rar29/Original/ulinks.hpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _RAR_ULINKS_
-#define _RAR_ULINKS_
-
-void SaveLinkData(ComprDataIO &DataIO,Archive &TempArc,FileHeader &hd,
- char *Name);
-int ExtractLink(ComprDataIO &DataIO,Archive &Arc,char *DestName,
- uint &LinkCRC,bool Create);
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/unicode.hpp b/7zip/Compress/Rar29/Original/unicode.hpp
deleted file mode 100755
index a1bdbbe1..00000000
--- a/7zip/Compress/Rar29/Original/unicode.hpp
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef _RAR_UNICODE_
-#define _RAR_UNICODE_
-
-#ifndef _EMX
-#define MBFUNCTIONS
-#endif
-
-#if defined(MBFUNCTIONS) || defined(_WIN_32) || defined(_EMX) && !defined(_DJGPP)
-#define UNICODE_SUPPORTED
-#endif
-
-#ifdef _WIN_32
-#define DBCS_SUPPORTED
-#endif
-
-#ifdef _EMX
-int uni_init(int codepage);
-int uni_done();
-#endif
-
-bool WideToChar(const wchar *Src,char *Dest,int DestSize=0x10000000);
-bool CharToWide(const char *Src,wchar *Dest,int DestSize=0x10000000);
-byte* WideToRaw(const wchar *Src,byte *Dest,int DestSize=0x10000000);
-wchar* RawToWide(const byte *Src,wchar *Dest,int DestSize=0x10000000);
-void WideToUtf(const wchar *Src,char *Dest,int DestSize);
-void UtfToWide(const char *Src,wchar *Dest,int DestSize);
-bool UnicodeEnabled();
-
-int strlenw(const wchar *str);
-wchar* strcpyw(wchar *dest,const wchar *src);
-wchar* strncpyw(wchar *dest,const wchar *src,int n);
-wchar* strcatw(wchar *dest,const wchar *src);
-wchar* strncatw(wchar *dest,const wchar *src,int n);
-int strcmpw(const wchar *s1,const wchar *s2);
-int strncmpw(const wchar *s1,const wchar *s2,int n);
-int stricmpw(const wchar *s1,const wchar *s2);
-int strnicmpw(const wchar *s1,const wchar *s2,int n);
-wchar *strchrw(const wchar *s,int c);
-wchar* strrchrw(const wchar *s,int c);
-wchar* strpbrkw(const wchar *s1,const wchar *s2);
-wchar* strlowerw(wchar *Str);
-wchar* strupperw(wchar *Str);
-int toupperw(int ch);
-int atoiw(const wchar *s);
-
-#ifdef DBCS_SUPPORTED
-class SupportDBCS
-{
- public:
- SupportDBCS();
- void Init();
-
- char* charnext(const char *s);
- uint strlend(const char *s);
- char *strchrd(const char *s, int c);
- char *strrchrd(const char *s, int c);
- void copychrd(char *dest,const char *src);
-
- bool IsLeadByte[256];
- bool DBCSMode;
-};
-
-extern SupportDBCS gdbcs;
-
-inline char* charnext(const char *s) {return (char *)(gdbcs.DBCSMode ? gdbcs.charnext(s):s+1);}
-inline uint strlend(const char *s) {return (uint)(gdbcs.DBCSMode ? gdbcs.strlend(s):strlen(s));}
-inline char* strchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strchrd(s,c):strchr(s,c));}
-inline char* strrchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strrchrd(s,c):strrchr(s,c));}
-inline void copychrd(char *dest,const char *src) {if (gdbcs.DBCSMode) gdbcs.copychrd(dest,src); else *dest=*src;}
-inline bool IsDBCSMode() {return(gdbcs.DBCSMode);}
-inline void InitDBCS() {gdbcs.Init();}
-
-#else
-#define charnext(s) ((s)+1)
-#define strlend strlen
-#define strchrd strchr
-#define strrchrd strrchr
-#define IsDBCSMode() (true)
-inline void copychrd(char *dest,const char *src) {*dest=*src;}
-#endif
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/unpack.cpp b/7zip/Compress/Rar29/Original/unpack.cpp
deleted file mode 100755
index e72d83cf..00000000
--- a/7zip/Compress/Rar29/Original/unpack.cpp
+++ /dev/null
@@ -1,939 +0,0 @@
-#include "rar.hpp"
-
-#include "coder.cpp"
-#include "suballoc.cpp"
-#include "model.cpp"
-#ifndef SFX_MODULE
-#include "unpack15.cpp"
-// Igor Pavlov
-// #include "unpack20.cpp"
-#endif
-
-Unpack::Unpack(ComprDataIO *DataIO)
-{
- UnpIO=DataIO;
- Window=NULL;
- ExternalWindow=false;
- Suspended=false;
- UnpAllBuf=false;
- UnpSomeRead=false;
-}
-
-
-Unpack::~Unpack()
-{
- if (Window!=NULL && !ExternalWindow)
- delete[] Window;
- InitFilters();
-}
-
-
-void Unpack::Init(byte *Window)
-{
- if (Window==NULL)
- {
- Unpack::Window=new byte[MAXWINSIZE];
-#ifndef ALLOW_EXCEPTIONS
- if (Unpack::Window==NULL)
- ErrHandler.MemoryError();
-#endif
- }
- else
- {
- Unpack::Window=Window;
- ExternalWindow=true;
- }
- UnpInitData(false);
-}
-
-
-void Unpack::DoUnpack(int Method,bool Solid)
-{
- switch(Method)
- {
-#ifndef SFX_MODULE
- case 15:
- Unpack15(Solid);
- break;
- // Igor Pavlov
- /*
- case 20:
- case 26:
- Unpack20(Solid);
- break;
- */
-#endif
- case 29:
- Unpack29(Solid);
- break;
- }
-}
-
-
-inline void Unpack::InsertOldDist(unsigned int Distance)
-{
- OldDist[3]=OldDist[2];
- OldDist[2]=OldDist[1];
- OldDist[1]=OldDist[0];
- OldDist[0]=Distance;
-}
-
-
-inline void Unpack::InsertLastMatch(unsigned int Length,unsigned int Distance)
-{
- LastDist=Distance;
- LastLength=Length;
-}
-
-
-void Unpack::CopyString(unsigned int Length,unsigned int Distance)
-{
- unsigned int DestPtr=UnpPtr-Distance;
- if (DestPtr<MAXWINSIZE-260 && UnpPtr<MAXWINSIZE-260)
- {
- Window[UnpPtr++]=Window[DestPtr++];
- while (--Length>0)
- Window[UnpPtr++]=Window[DestPtr++];
- }
- else
- while (Length--)
- {
- Window[UnpPtr]=Window[DestPtr++ & MAXWINMASK];
- UnpPtr=(UnpPtr+1) & MAXWINMASK;
- }
-}
-
-
-int Unpack::DecodeNumber(struct Decode *Dec)
-{
- unsigned int Bits;
- unsigned int BitField=getbits() & 0xfffe;
- if (BitField<Dec->DecodeLen[8])
- if (BitField<Dec->DecodeLen[4])
- if (BitField<Dec->DecodeLen[2])
- if (BitField<Dec->DecodeLen[1])
- Bits=1;
- else
- Bits=2;
- else
- if (BitField<Dec->DecodeLen[3])
- Bits=3;
- else
- Bits=4;
- else
- if (BitField<Dec->DecodeLen[6])
- if (BitField<Dec->DecodeLen[5])
- Bits=5;
- else
- Bits=6;
- else
- if (BitField<Dec->DecodeLen[7])
- Bits=7;
- else
- Bits=8;
- else
- if (BitField<Dec->DecodeLen[12])
- if (BitField<Dec->DecodeLen[10])
- if (BitField<Dec->DecodeLen[9])
- Bits=9;
- else
- Bits=10;
- else
- if (BitField<Dec->DecodeLen[11])
- Bits=11;
- else
- Bits=12;
- else
- if (BitField<Dec->DecodeLen[14])
- if (BitField<Dec->DecodeLen[13])
- Bits=13;
- else
- Bits=14;
- else
- Bits=15;
-
- addbits(Bits);
- unsigned int N=Dec->DecodePos[Bits]+((BitField-Dec->DecodeLen[Bits-1])>>(16-Bits));
- if (N>=Dec->MaxNum)
- N=0;
- return(Dec->DecodeNum[N]);
-}
-
-
-void Unpack::Unpack29(bool Solid)
-{
- static unsigned char LDecode[]={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 unsigned char LBits[]= {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 int DDecode[DC];
- static byte DBits[DC];
- static int DBitLengthCounts[]= {4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,14,0,12};
- static unsigned char SDDecode[]={0,4,8,16,32,64,128,192};
- static unsigned char SDBits[]= {2,2,3, 4, 5, 6, 6, 6};
- unsigned int Bits;
-
- if (DDecode[1]==0)
- {
- int Dist=0,BitLength=0,Slot=0;
- for (int I=0;I<sizeof(DBitLengthCounts)/sizeof(DBitLengthCounts[0]);I++,BitLength++)
- for (int J=0;J<DBitLengthCounts[I];J++,Slot++,Dist+=(1<<BitLength))
- {
- DDecode[Slot]=Dist;
- DBits[Slot]=BitLength;
- }
- }
-
- FileExtracted=true;
-
- if (!Suspended)
- {
- UnpInitData(Solid);
- if (!UnpReadBuf())
- return;
- if ((!Solid || !TablesRead) && !ReadTables())
- return;
- }
-
- if (PPMError)
- return;
-
- while (true)
- {
- UnpPtr&=MAXWINMASK;
-
- if (InAddr>ReadBorder)
- {
- if (!UnpReadBuf())
- break;
- }
- if (((WrPtr-UnpPtr) & MAXWINMASK)<260 && WrPtr!=UnpPtr)
- {
- UnpWriteBuf();
- if (WrittenFileSize>DestUnpSize)
- return;
- if (Suspended)
- {
- FileExtracted=false;
- return;
- }
- }
- if (UnpBlockType==BLOCK_PPM)
- {
- int Ch=PPM.DecodeChar();
- if (Ch==-1)
- {
- PPMError=true;
- break;
- }
- if (Ch==PPMEscChar)
- {
- int NextCh=PPM.DecodeChar();
- if (NextCh==0)
- {
- if (!ReadTables())
- break;
- continue;
- }
- if (NextCh==2 || NextCh==-1)
- break;
- if (NextCh==3)
- {
- if (!ReadVMCodePPM())
- break;
- continue;
- }
- if (NextCh==4)
- {
- unsigned int Distance=0,Length;
- bool Failed=false;
- for (int I=0;I<4 && !Failed;I++)
- {
- int Ch=PPM.DecodeChar();
- if (Ch==-1)
- Failed=true;
- else
- if (I==3)
- Length=(byte)Ch;
- else
- Distance=(Distance<<8)+(byte)Ch;
- }
- if (Failed)
- break;
- CopyString(Length+32,Distance+2);
- continue;
- }
- if (NextCh==5)
- {
- int Length=PPM.DecodeChar();
- if (Length==-1)
- break;
- CopyString(Length+4,1);
- continue;
- }
- }
- Window[UnpPtr++]=Ch;
- continue;
- }
-
- int Number=DecodeNumber((struct Decode *)&LD);
- if (Number<256)
- {
- Window[UnpPtr++]=(byte)Number;
- continue;
- }
- if (Number>=271)
- {
- int Length=LDecode[Number-=271]+3;
- if ((Bits=LBits[Number])>0)
- {
- Length+=getbits()>>(16-Bits);
- addbits(Bits);
- }
-
- int DistNumber=DecodeNumber((struct Decode *)&DD);
- unsigned int Distance=DDecode[DistNumber]+1;
- if ((Bits=DBits[DistNumber])>0)
- {
- if (DistNumber>9)
- {
- if (Bits>4)
- {
- Distance+=((getbits()>>(20-Bits))<<4);
- addbits(Bits-4);
- }
- if (LowDistRepCount>0)
- {
- LowDistRepCount--;
- Distance+=PrevLowDist;
- }
- else
- {
- int LowDist=DecodeNumber((struct Decode *)&LDD);
- if (LowDist==16)
- {
- LowDistRepCount=LOW_DIST_REP_COUNT-1;
- Distance+=PrevLowDist;
- }
- else
- {
- Distance+=LowDist;
- PrevLowDist=LowDist;
- }
- }
- }
- else
- {
- Distance+=getbits()>>(16-Bits);
- addbits(Bits);
- }
- }
-
- if (Distance>=0x2000)
- {
- Length++;
- if (Distance>=0x40000L)
- Length++;
- }
-
- InsertOldDist(Distance);
- InsertLastMatch(Length,Distance);
- CopyString(Length,Distance);
- continue;
- }
- if (Number==256)
- {
- if (!ReadEndOfBlock())
- break;
- continue;
- }
- if (Number==257)
- {
- if (!ReadVMCode())
- break;
- continue;
- }
- if (Number==258)
- {
- if (LastLength!=0)
- CopyString(LastLength,LastDist);
- continue;
- }
- if (Number<263)
- {
- int DistNum=Number-259;
- unsigned int Distance=OldDist[DistNum];
- for (int I=DistNum;I>0;I--)
- OldDist[I]=OldDist[I-1];
- OldDist[0]=Distance;
-
- int LengthNumber=DecodeNumber((struct Decode *)&RD);
- int Length=LDecode[LengthNumber]+2;
- if ((Bits=LBits[LengthNumber])>0)
- {
- Length+=getbits()>>(16-Bits);
- addbits(Bits);
- }
- InsertLastMatch(Length,Distance);
- CopyString(Length,Distance);
- continue;
- }
- if (Number<272)
- {
- unsigned int Distance=SDDecode[Number-=263]+1;
- if ((Bits=SDBits[Number])>0)
- {
- Distance+=getbits()>>(16-Bits);
- addbits(Bits);
- }
- InsertOldDist(Distance);
- InsertLastMatch(2,Distance);
- CopyString(2,Distance);
- continue;
- }
- }
- UnpWriteBuf();
-}
-
-
-bool Unpack::ReadEndOfBlock()
-{
- unsigned int BitField=getbits();
- bool NewTable,NewFile=false;
- if (BitField & 0x8000)
- {
- NewTable=true;
- addbits(1);
- }
- else
- {
- NewFile=true;
-
- // Igor Pavlov
- NewTable = ((BitField & 0x4000) != 0);
-
- addbits(2);
- }
- TablesRead=!NewTable;
- return !(NewFile || NewTable && !ReadTables());
-}
-
-
-bool Unpack::ReadVMCode()
-{
- unsigned int FirstByte=getbits()>>8;
- addbits(8);
- int Length=(FirstByte & 7)+1;
- if (Length==7)
- {
- Length=(getbits()>>8)+7;
- addbits(8);
- }
- else
- if (Length==8)
- {
- Length=getbits();
- addbits(16);
- }
- Array<byte> VMCode(Length);
- for (int I=0;I<Length;I++)
- {
- if (InAddr>=ReadTop-1 && !UnpReadBuf() && I<Length-1)
- return(false);
- VMCode[I]=getbits()>>8;
- addbits(8);
- }
- return(AddVMCode(FirstByte,&VMCode[0],Length));
-}
-
-
-bool Unpack::ReadVMCodePPM()
-{
- unsigned int FirstByte=PPM.DecodeChar();
- if ((int)FirstByte==-1)
- return(false);
- int Length=(FirstByte & 7)+1;
- if (Length==7)
- {
- int B1=PPM.DecodeChar();
- if (B1==-1)
- return(false);
- Length=B1+7;
- }
- else
- if (Length==8)
- {
- int B1=PPM.DecodeChar();
- if (B1==-1)
- return(false);
- int B2=PPM.DecodeChar();
- if (B2==-1)
- return(false);
- Length=B1*256+B2;
- }
- Array<byte> VMCode(Length);
- for (int I=0;I<Length;I++)
- {
- int Ch=PPM.DecodeChar();
- if (Ch==-1)
- return(false);
- VMCode[I]=Ch;
- }
- return(AddVMCode(FirstByte,&VMCode[0],Length));
-}
-
-
-bool Unpack::AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize)
-{
- BitInput Inp;
- Inp.InitBitInput();
- memcpy(Inp.InBuf,Code,Min(BitInput::MAX_SIZE,CodeSize));
- VM.Init();
-
- uint FiltPos;
- if (FirstByte & 0x80)
- {
- FiltPos=RarVM::ReadData(Inp);
- if (FiltPos==0)
- InitFilters();
- else
- FiltPos--;
- }
- else
- FiltPos=LastFilter;
- if (FiltPos>Filters.Size() || FiltPos>OldFilterLengths.Size())
- return(false);
- LastFilter=FiltPos;
- bool NewFilter=(FiltPos==Filters.Size());
-
- UnpackFilter *Filter;
- if (NewFilter)
- {
- Filters.Add(1);
- Filters[Filters.Size()-1]=Filter=new UnpackFilter;
- OldFilterLengths.Add(1);
- Filter->ExecCount=0;
- }
- else
- {
- Filter=Filters[FiltPos];
- Filter->ExecCount++;
- }
-
- UnpackFilter *StackFilter=new UnpackFilter;
-
- int EmptyCount=0;
- for (int I=0;I<PrgStack.Size();I++)
- {
- PrgStack[I-EmptyCount]=PrgStack[I];
- if (PrgStack[I]==NULL)
- EmptyCount++;
- if (EmptyCount>0)
- PrgStack[I]=NULL;
- }
- if (EmptyCount==0)
- {
- PrgStack.Add(1);
- EmptyCount=1;
- }
- int StackPos=PrgStack.Size()-EmptyCount;
- PrgStack[StackPos]=StackFilter;
- StackFilter->ExecCount=Filter->ExecCount;
-
- uint BlockStart=RarVM::ReadData(Inp);
- if (FirstByte & 0x40)
- BlockStart+=258;
- StackFilter->BlockStart=(BlockStart+UnpPtr)&MAXWINMASK;
- if (FirstByte & 0x20)
- StackFilter->BlockLength=RarVM::ReadData(Inp);
- else
- StackFilter->BlockLength=FiltPos<OldFilterLengths.Size() ? OldFilterLengths[FiltPos]:0;
- StackFilter->NextWindow=WrPtr!=UnpPtr && ((WrPtr-UnpPtr)&MAXWINMASK)<=BlockStart;
-
-// DebugLog("\nNextWindow: UnpPtr=%08x WrPtr=%08x BlockStart=%08x",UnpPtr,WrPtr,BlockStart);
-
- OldFilterLengths[FiltPos]=StackFilter->BlockLength;
-
- memset(StackFilter->Prg.InitR,0,sizeof(StackFilter->Prg.InitR));
- StackFilter->Prg.InitR[3]=VM_GLOBALMEMADDR;
- StackFilter->Prg.InitR[4]=StackFilter->BlockLength;
- StackFilter->Prg.InitR[5]=StackFilter->ExecCount;
- if (FirstByte & 0x10)
- {
- unsigned int InitMask=Inp.fgetbits()>>9;
- Inp.faddbits(7);
- for (int I=0;I<7;I++)
- if (InitMask & (1<<I))
- StackFilter->Prg.InitR[I]=RarVM::ReadData(Inp);
- }
- if (NewFilter)
- {
- uint VMCodeSize=RarVM::ReadData(Inp);
- if (VMCodeSize>=0x10000 || VMCodeSize==0)
- return(false);
- Array<byte> VMCode(VMCodeSize);
- for (int I=0;I<VMCodeSize;I++)
- {
- VMCode[I]=Inp.fgetbits()>>8;
- Inp.faddbits(8);
- }
- VM.Prepare(&VMCode[0],VMCodeSize,&Filter->Prg);
- }
- StackFilter->Prg.AltCmd=&Filter->Prg.Cmd[0];
- StackFilter->Prg.CmdCount=Filter->Prg.CmdCount;
-
- int StaticDataSize=Filter->Prg.StaticData.Size();
- if (StaticDataSize>0 && StaticDataSize<VM_GLOBALMEMSIZE)
- {
- StackFilter->Prg.StaticData.Add(StaticDataSize);
- memcpy(&StackFilter->Prg.StaticData[0],&Filter->Prg.StaticData[0],StaticDataSize);
- }
-
- if (StackFilter->Prg.GlobalData.Size()<VM_FIXEDGLOBALSIZE)
- {
- StackFilter->Prg.GlobalData.Reset();
- StackFilter->Prg.GlobalData.Add(VM_FIXEDGLOBALSIZE);
- }
- byte *GlobalData=&StackFilter->Prg.GlobalData[0];
- for (int I=0;I<7;I++)
- VM.SetValue((uint *)&GlobalData[I*4],StackFilter->Prg.InitR[I]);
- VM.SetValue((uint *)&GlobalData[0x1c],StackFilter->BlockLength);
- VM.SetValue((uint *)&GlobalData[0x20],0);
- VM.SetValue((uint *)&GlobalData[0x2c],StackFilter->ExecCount);
- memset(&GlobalData[0x30],0,16);
-
- if (FirstByte & 8)
- {
- uint DataSize=RarVM::ReadData(Inp);
- if (DataSize>=0x10000)
- return(false);
- unsigned int CurSize=StackFilter->Prg.GlobalData.Size();
- if (CurSize<DataSize+VM_FIXEDGLOBALSIZE)
- StackFilter->Prg.GlobalData.Add(DataSize+VM_FIXEDGLOBALSIZE-CurSize);
- byte *GlobalData=&StackFilter->Prg.GlobalData[VM_FIXEDGLOBALSIZE];
- for (int I=0;I<DataSize;I++)
- {
- GlobalData[I]=Inp.fgetbits()>>8;
- Inp.faddbits(8);
- }
- }
- return(true);
-}
-
-
-bool Unpack::UnpReadBuf()
-{
- int DataSize=ReadTop-InAddr;
- if (DataSize<0)
- return(false);
- if (InAddr>BitInput::MAX_SIZE/2)
- {
- if (DataSize>0)
- memmove(InBuf,InBuf+InAddr,DataSize);
- InAddr=0;
- ReadTop=DataSize;
- }
- else
- DataSize=ReadTop;
- int ReadCode=UnpIO->UnpRead(InBuf+DataSize,(BitInput::MAX_SIZE-DataSize)&~0xf);
- if (ReadCode>0)
- ReadTop+=ReadCode;
- ReadBorder=ReadTop-30;
- return(ReadCode!=-1);
-}
-
-
-void Unpack::UnpWriteBuf()
-{
- unsigned int WrittenBorder=WrPtr;
- unsigned int WriteSize=(UnpPtr-WrittenBorder)&MAXWINMASK;
- for (int I=0;I<PrgStack.Size();I++)
- {
- UnpackFilter *flt=PrgStack[I];
- if (flt==NULL)
- continue;
- if (flt->NextWindow)
- {
- flt->NextWindow=false;
- continue;
- }
- unsigned int BlockStart=flt->BlockStart;
- unsigned int BlockLength=flt->BlockLength;
- if (((BlockStart-WrittenBorder)&MAXWINMASK)<WriteSize)
- {
- if (WrittenBorder!=BlockStart)
- {
- UnpWriteArea(WrittenBorder,BlockStart);
- WrittenBorder=BlockStart;
- WriteSize=(UnpPtr-WrittenBorder)&MAXWINMASK;
- }
- if (BlockLength<=WriteSize)
- {
- unsigned int BlockEnd=(BlockStart+BlockLength)&MAXWINMASK;
- if (BlockStart<BlockEnd || BlockEnd==0)
- VM.SetMemory(0,Window+BlockStart,BlockLength);
- else
- {
- unsigned int FirstPartLength=MAXWINSIZE-BlockStart;
- VM.SetMemory(0,Window+BlockStart,FirstPartLength);
- VM.SetMemory(FirstPartLength,Window,BlockEnd);
- }
- VM_PreparedProgram *Prg=&flt->Prg;
- ExecuteCode(Prg);
-
- byte *FilteredData=Prg->FilteredData;
- unsigned int FilteredDataSize=Prg->FilteredDataSize;
-
- delete PrgStack[I];
- PrgStack[I]=NULL;
- while (I+1<PrgStack.Size())
- {
- UnpackFilter *NextFilter=PrgStack[I+1];
- if (NextFilter==NULL || NextFilter->BlockStart!=BlockStart ||
- NextFilter->BlockLength!=FilteredDataSize || NextFilter->NextWindow)
- break;
- VM.SetMemory(0,FilteredData,FilteredDataSize);
- VM_PreparedProgram *NextPrg=&PrgStack[I+1]->Prg;
- ExecuteCode(NextPrg);
- FilteredData=NextPrg->FilteredData;
- FilteredDataSize=NextPrg->FilteredDataSize;
- I++;
- delete PrgStack[I];
- PrgStack[I]=NULL;
- }
- UnpIO->UnpWrite(FilteredData,FilteredDataSize);
- UnpSomeRead=true;
- WrittenFileSize+=FilteredDataSize;
- WrittenBorder=BlockEnd;
- WriteSize=(UnpPtr-WrittenBorder)&MAXWINMASK;
- }
- else
- {
- for (int J=I;J<PrgStack.Size();J++)
- {
- UnpackFilter *flt=PrgStack[J];
- if (flt!=NULL && flt->NextWindow)
- flt->NextWindow=false;
- }
- WrPtr=WrittenBorder;
- return;
- }
- }
- }
-
- UnpWriteArea(WrittenBorder,UnpPtr);
- WrPtr=UnpPtr;
-}
-
-
-void Unpack::ExecuteCode(VM_PreparedProgram *Prg)
-{
- if (Prg->GlobalData.Size()>0)
- {
- Prg->InitR[6]=int64to32(WrittenFileSize);
- VM.SetValue((uint *)&Prg->GlobalData[0x24],int64to32(WrittenFileSize));
- VM.SetValue((uint *)&Prg->GlobalData[0x28],int64to32(WrittenFileSize>>32));
- VM.Execute(Prg);
- }
-}
-
-
-void Unpack::UnpWriteArea(unsigned int StartPtr,unsigned int EndPtr)
-{
- if (EndPtr!=StartPtr)
- UnpSomeRead=true;
- if (EndPtr<StartPtr)
- {
- UnpWriteData(&Window[StartPtr],-StartPtr & MAXWINMASK);
- UnpWriteData(Window,EndPtr);
- UnpAllBuf=true;
- }
- else
- UnpWriteData(&Window[StartPtr],EndPtr-StartPtr);
-}
-
-
-void Unpack::UnpWriteData(byte *Data,int Size)
-{
- if (WrittenFileSize>=DestUnpSize)
- return;
- int WriteSize=Size;
- Int64 LeftToWrite=DestUnpSize-WrittenFileSize;
- if (WriteSize>LeftToWrite)
- WriteSize=int64to32(LeftToWrite);
- UnpIO->UnpWrite(Data,WriteSize);
- WrittenFileSize+=Size;
-}
-
-
-bool Unpack::ReadTables()
-{
- byte BitLength[BC];
- unsigned char Table[HUFF_TABLE_SIZE];
- if (InAddr>ReadTop-25)
- if (!UnpReadBuf())
- return(false);
- faddbits((8-InBit)&7);
- unsigned int BitField=fgetbits();
- if (BitField & 0x8000)
- {
- UnpBlockType=BLOCK_PPM;
- return(PPM.DecodeInit(this,PPMEscChar));
- }
- UnpBlockType=BLOCK_LZ;
-
- PrevLowDist=0;
- LowDistRepCount=0;
-
- if (!(BitField & 0x4000))
- memset(UnpOldTable,0,sizeof(UnpOldTable));
- faddbits(2);
-
- for (int I=0;I<BC;I++)
- {
- int Length=(byte)(fgetbits() >> 12);
- faddbits(4);
- if (Length==15)
- {
- int ZeroCount=(byte)(fgetbits() >> 12);
- faddbits(4);
- if (ZeroCount==0)
- BitLength[I]=15;
- else
- {
- ZeroCount+=2;
- while (ZeroCount-- > 0 && I<sizeof(BitLength)/sizeof(BitLength[0]))
- BitLength[I++]=0;
- I--;
- }
- }
- else
- BitLength[I]=Length;
- }
- MakeDecodeTables(BitLength,(struct Decode *)&BD,BC);
-
- const int TableSize=HUFF_TABLE_SIZE;
- for (int I=0;I<TableSize;)
- {
- if (InAddr>ReadTop-5)
- if (!UnpReadBuf())
- return(false);
- int Number=DecodeNumber((struct Decode *)&BD);
- if (Number<16)
- {
- Table[I]=(Number+UnpOldTable[I]) & 0xf;
- I++;
- }
- else
- if (Number<18)
- {
- int N;
- if (Number==16)
- {
- N=(fgetbits() >> 13)+3;
- faddbits(3);
- }
- else
- {
- N=(fgetbits() >> 9)+11;
- faddbits(7);
- }
- while (N-- > 0 && I<TableSize)
- {
- Table[I]=Table[I-1];
- I++;
- }
- }
- else
- {
- int N;
- if (Number==18)
- {
- N=(fgetbits() >> 13)+3;
- faddbits(3);
- }
- else
- {
- N=(fgetbits() >> 9)+11;
- faddbits(7);
- }
- while (N-- > 0 && I<TableSize)
- Table[I++]=0;
- }
- }
- TablesRead=true;
- if (InAddr>ReadTop)
- return(false);
- MakeDecodeTables(&Table[0],(struct Decode *)&LD,NC);
- MakeDecodeTables(&Table[NC],(struct Decode *)&DD,DC);
- MakeDecodeTables(&Table[NC+DC],(struct Decode *)&LDD,LDC);
- MakeDecodeTables(&Table[NC+DC+LDC],(struct Decode *)&RD,RC);
- memcpy(UnpOldTable,Table,sizeof(UnpOldTable));
- return(true);
-}
-
-
-void Unpack::UnpInitData(int Solid)
-{
- if (!Solid)
- {
- TablesRead=false;
- memset(OldDist,0,sizeof(OldDist));
- OldDistPtr=0;
- LastDist=LastLength=0;
-// memset(Window,0,MAXWINSIZE);
- memset(UnpOldTable,0,sizeof(UnpOldTable));
- UnpPtr=WrPtr=0;
- PPMEscChar=2;
-
- InitFilters();
- }
- InitBitInput();
- PPMError=false;
- WrittenFileSize=0;
- ReadTop=0;
- ReadBorder=0;
-#ifndef SFX_MODULE
- // Igor Pavlov
- // UnpInitData20(Solid);
-#endif
-}
-
-
-void Unpack::InitFilters()
-{
- OldFilterLengths.Reset();
- LastFilter=0;
-
- for (int I=0;I<Filters.Size();I++)
- delete Filters[I];
- Filters.Reset();
- for (int I=0;I<PrgStack.Size();I++)
- delete PrgStack[I];
- PrgStack.Reset();
-}
-
-
-void Unpack::MakeDecodeTables(unsigned char *LenTab,struct Decode *Dec,int Size)
-{
- int LenCount[16],TmpPos[16],I;
- long M,N;
- memset(LenCount,0,sizeof(LenCount));
- memset(Dec->DecodeNum,0,Size*sizeof(*Dec->DecodeNum));
- for (I=0;I<Size;I++)
- LenCount[LenTab[I] & 0xF]++;
-
- LenCount[0]=0;
- for (TmpPos[0]=Dec->DecodePos[0]=Dec->DecodeLen[0]=0,N=0,I=1;I<16;I++)
- {
- N=2*(N+LenCount[I]);
- M=N<<(15-I);
- if (M>0xFFFF)
- M=0xFFFF;
- Dec->DecodeLen[I]=(unsigned int)M;
- TmpPos[I]=Dec->DecodePos[I]=Dec->DecodePos[I-1]+LenCount[I-1];
- }
-
- for (I=0;I<Size;I++)
- if (LenTab[I]!=0)
- Dec->DecodeNum[TmpPos[LenTab[I] & 0xF]++]=I;
- Dec->MaxNum=Size;
-}
diff --git a/7zip/Compress/Rar29/Original/unpack.hpp b/7zip/Compress/Rar29/Original/unpack.hpp
deleted file mode 100755
index 83fb0f02..00000000
--- a/7zip/Compress/Rar29/Original/unpack.hpp
+++ /dev/null
@@ -1,205 +0,0 @@
-#ifndef _RAR_UNPACK_
-#define _RAR_UNPACK_
-
-enum BLOCK_TYPES {BLOCK_LZ,BLOCK_PPM};
-
-struct Decode
-{
- unsigned int MaxNum;
- unsigned int DecodeLen[16];
- unsigned int DecodePos[16];
- unsigned int DecodeNum[2];
-};
-
-struct LitDecode
-{
- unsigned int MaxNum;
- unsigned int DecodeLen[16];
- unsigned int DecodePos[16];
- unsigned int DecodeNum[NC];
-};
-
-struct DistDecode
-{
- unsigned int MaxNum;
- unsigned int DecodeLen[16];
- unsigned int DecodePos[16];
- unsigned int DecodeNum[DC];
-};
-
-struct LowDistDecode
-{
- unsigned int MaxNum;
- unsigned int DecodeLen[16];
- unsigned int DecodePos[16];
- unsigned int DecodeNum[LDC];
-};
-
-struct RepDecode
-{
- unsigned int MaxNum;
- unsigned int DecodeLen[16];
- unsigned int DecodePos[16];
- unsigned int DecodeNum[RC];
-};
-
-struct BitDecode
-{
- unsigned int MaxNum;
- unsigned int DecodeLen[16];
- unsigned int DecodePos[16];
- unsigned int DecodeNum[BC];
-};
-
-struct UnpackFilter
-{
- unsigned int BlockStart;
- unsigned int BlockLength;
- unsigned int ExecCount;
- bool NextWindow;
- VM_PreparedProgram Prg;
-};
-
-/***************************** Unpack v 2.0 *********************************/
-struct MultDecode
-{
- unsigned int MaxNum;
- unsigned int DecodeLen[16];
- unsigned int DecodePos[16];
- unsigned int DecodeNum[MC20];
-};
-
-struct AudioVariables
-{
- int K1,K2,K3,K4,K5;
- int D1,D2,D3,D4;
- int LastDelta;
- unsigned int Dif[11];
- unsigned int ByteCount;
- int LastChar;
-};
-/***************************** Unpack v 2.0 *********************************/
-
-
-class Unpack:private BitInput
-{
- private:
- friend class Pack;
-
- void Unpack29(bool Solid);
- bool UnpReadBuf();
- void UnpWriteBuf();
- void ExecuteCode(VM_PreparedProgram *Prg);
- void UnpWriteArea(unsigned int StartPtr,unsigned int EndPtr);
- void UnpWriteData(byte *Data,int Size);
- bool ReadTables();
- void MakeDecodeTables(unsigned char *LenTab,struct Decode *Dec,int Size);
- int DecodeNumber(struct Decode *Dec);
- void CopyString();
- inline void InsertOldDist(unsigned int Distance);
- inline void InsertLastMatch(unsigned int Length,unsigned int Distance);
- void UnpInitData(int Solid);
- void CopyString(unsigned int Length,unsigned int Distance);
- bool ReadEndOfBlock();
- bool ReadVMCode();
- bool ReadVMCodePPM();
- bool AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize);
- void InitFilters();
-
- ComprDataIO *UnpIO;
- ModelPPM PPM;
- int PPMEscChar;
-
- RarVM VM;
- Array<UnpackFilter*> Filters;
- Array<UnpackFilter*> PrgStack;
- Array<int> OldFilterLengths;
- int LastFilter;
-
- bool TablesRead;
- struct LitDecode LD;
- struct DistDecode DD;
- struct LowDistDecode LDD;
- struct RepDecode RD;
- struct BitDecode BD;
-
- unsigned int OldDist[4],OldDistPtr;
- unsigned int LastDist,LastLength;
-
- unsigned int UnpPtr,WrPtr;
-
- int ReadTop;
- int ReadBorder;
-
- unsigned char UnpOldTable[HUFF_TABLE_SIZE];
-
- int UnpBlockType;
-
- byte *Window;
- bool ExternalWindow;
-
-
- Int64 DestUnpSize;
-
- bool Suspended;
- bool UnpAllBuf;
- bool UnpSomeRead;
- Int64 WrittenFileSize;
- bool FileExtracted;
- bool PPMError;
-
- int PrevLowDist,LowDistRepCount;
-
-/***************************** Unpack v 1.5 *********************************/
- void Unpack15(bool Solid);
- void ShortLZ();
- void LongLZ();
- void HuffDecode();
- void GetFlagsBuf();
- void OldUnpInitData(int Solid);
- void InitHuff();
- void CorrHuff(unsigned int *CharSet,unsigned int *NumToPlace);
- void OldCopyString(unsigned int Distance,unsigned int Length);
- unsigned int DecodeNum(int Num,unsigned int StartPos,
- unsigned int *DecTab,unsigned int *PosTab);
- void OldUnpWriteBuf();
-
- unsigned int ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
- unsigned int Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
- unsigned int NToPl[256],NToPlB[256],NToPlC[256];
- unsigned int FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
- int Buf60,NumHuf,StMode,LCount,FlagsCnt;
- unsigned int Nhfb,Nlzb,MaxDist3;
-/***************************** Unpack v 1.5 *********************************/
-
-/***************************** Unpack v 2.0 *********************************/
- void Unpack20(bool Solid);
- struct MultDecode MD[4];
- unsigned char UnpOldTable20[MC20*4];
- int UnpAudioBlock,UnpChannels,UnpCurChannel,UnpChannelDelta;
- void CopyString20(unsigned int Length,unsigned int Distance);
- bool ReadTables20();
- void UnpInitData20(int Solid);
- void ReadLastTables();
- byte DecodeAudio(int Delta);
- struct AudioVariables AudV[4];
-/***************************** Unpack v 2.0 *********************************/
-
- public:
- Unpack(ComprDataIO *DataIO);
- ~Unpack();
- void Init(byte *Window=NULL);
- void DoUnpack(int Method,bool Solid);
- bool IsFileExtracted() {return(FileExtracted);}
- void SetDestSize(Int64 DestSize) {DestUnpSize=DestSize;FileExtracted=false;}
- void SetSuspended(bool Suspended) {Unpack::Suspended=Suspended;}
-
- unsigned int GetChar()
- {
- if (InAddr>BitInput::MAX_SIZE-30)
- UnpReadBuf();
- return(InBuf[InAddr++]);
- }
-};
-
-#endif
diff --git a/7zip/Compress/Rar29/Original/unpack15.cpp b/7zip/Compress/Rar29/Original/unpack15.cpp
deleted file mode 100755
index a0fa897f..00000000
--- a/7zip/Compress/Rar29/Original/unpack15.cpp
+++ /dev/null
@@ -1,507 +0,0 @@
-#define STARTL1 2
-static unsigned int DecL1[]={0x8000,0xa000,0xc000,0xd000,0xe000,0xea00,
- 0xee00,0xf000,0xf200,0xf200,0xffff};
-static unsigned int PosL1[]={0,0,0,2,3,5,7,11,16,20,24,32,32};
-
-#define STARTL2 3
-static unsigned int DecL2[]={0xa000,0xc000,0xd000,0xe000,0xea00,0xee00,
- 0xf000,0xf200,0xf240,0xffff};
-static unsigned int PosL2[]={0,0,0,0,5,7,9,13,18,22,26,34,36};
-
-#define STARTHF0 4
-static unsigned int DecHf0[]={0x8000,0xc000,0xe000,0xf200,0xf200,0xf200,
- 0xf200,0xf200,0xffff};
-static unsigned int PosHf0[]={0,0,0,0,0,8,16,24,33,33,33,33,33};
-
-
-#define STARTHF1 5
-static unsigned int DecHf1[]={0x2000,0xc000,0xe000,0xf000,0xf200,0xf200,
- 0xf7e0,0xffff};
-static unsigned int PosHf1[]={0,0,0,0,0,0,4,44,60,76,80,80,127};
-
-
-#define STARTHF2 5
-static unsigned int DecHf2[]={0x1000,0x2400,0x8000,0xc000,0xfa00,0xffff,
- 0xffff,0xffff};
-static unsigned int PosHf2[]={0,0,0,0,0,0,2,7,53,117,233,0,0};
-
-
-#define STARTHF3 6
-static unsigned int DecHf3[]={0x800,0x2400,0xee00,0xfe80,0xffff,0xffff,
- 0xffff};
-static unsigned int PosHf3[]={0,0,0,0,0,0,0,2,16,218,251,0,0};
-
-
-#define STARTHF4 8
-static unsigned int DecHf4[]={0xff00,0xffff,0xffff,0xffff,0xffff,0xffff};
-static unsigned int PosHf4[]={0,0,0,0,0,0,0,0,0,255,0,0,0};
-
-
-void Unpack::Unpack15(bool Solid)
-{
- if (Suspended)
- UnpPtr=WrPtr;
- else
- {
- UnpInitData(Solid);
- OldUnpInitData(Solid);
- UnpReadBuf();
- if (!Solid)
- {
- InitHuff();
- UnpPtr=0;
- }
- else
- UnpPtr=WrPtr;
- --DestUnpSize;
- }
- if (DestUnpSize>=0)
- {
- GetFlagsBuf();
- FlagsCnt=8;
- }
-
- while (DestUnpSize>=0)
- {
- UnpPtr&=MAXWINMASK;
-
- if (InAddr>ReadTop-30 && !UnpReadBuf())
- break;
- if (((WrPtr-UnpPtr) & MAXWINMASK)<270 && WrPtr!=UnpPtr)
- {
- OldUnpWriteBuf();
- if (Suspended)
- return;
- }
- if (StMode)
- {
- HuffDecode();
- continue;
- }
-
- if (--FlagsCnt < 0)
- {
- GetFlagsBuf();
- FlagsCnt=7;
- }
-
- if (FlagBuf & 0x80)
- {
- FlagBuf<<=1;
- if (Nlzb > Nhfb)
- LongLZ();
- else
- HuffDecode();
- }
- else
- {
- FlagBuf<<=1;
- if (--FlagsCnt < 0)
- {
- GetFlagsBuf();
- FlagsCnt=7;
- }
- if (FlagBuf & 0x80)
- {
- FlagBuf<<=1;
- if (Nlzb > Nhfb)
- HuffDecode();
- else
- LongLZ();
- }
- else
- {
- FlagBuf<<=1;
- ShortLZ();
- }
- }
- }
- OldUnpWriteBuf();
-}
-
-
-void Unpack::OldUnpWriteBuf()
-{
- if (UnpPtr!=WrPtr)
- UnpSomeRead=true;
- if (UnpPtr<WrPtr)
- {
- UnpIO->UnpWrite(&Window[WrPtr],-WrPtr & MAXWINMASK);
- UnpIO->UnpWrite(Window,UnpPtr);
- UnpAllBuf=true;
- }
- else
- UnpIO->UnpWrite(&Window[WrPtr],UnpPtr-WrPtr);
- WrPtr=UnpPtr;
-}
-
-
-void Unpack::ShortLZ()
-{
- static unsigned int ShortLen1[]={1,3,4,4,5,6,7,8,8,4,4,5,6,6,4,0};
- static unsigned int ShortXor1[]={0,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xfe,
- 0xff,0xc0,0x80,0x90,0x98,0x9c,0xb0};
- static unsigned int ShortLen2[]={2,3,3,3,4,4,5,6,6,4,4,5,6,6,4,0};
- static unsigned int ShortXor2[]={0,0x40,0x60,0xa0,0xd0,0xe0,0xf0,0xf8,
- 0xfc,0xc0,0x80,0x90,0x98,0x9c,0xb0};
-
-
- unsigned int Length,SaveLength;
- unsigned int LastDistance;
- unsigned int Distance;
- int DistancePlace;
- NumHuf=0;
-
- unsigned int BitField=fgetbits();
- if (LCount==2)
- {
- faddbits(1);
- if (BitField >= 0x8000)
- {
- OldCopyString((unsigned int)LastDist,LastLength);
- return;
- }
- BitField <<= 1;
- LCount=0;
- }
-
- BitField>>=8;
-
- ShortLen1[1]=ShortLen2[3]=Buf60+3;
-
- if (AvrLn1<37)
- {
- for (Length=0;;Length++)
- if (((BitField^ShortXor1[Length]) & (~(0xff>>ShortLen1[Length])))==0)
- break;
- faddbits(ShortLen1[Length]);
- }
- else
- {
- for (Length=0;;Length++)
- if (((BitField^ShortXor2[Length]) & (~(0xff>>ShortLen2[Length])))==0)
- break;
- faddbits(ShortLen2[Length]);
- }
-
- if (Length >= 9)
- {
- if (Length == 9)
- {
- LCount++;
- OldCopyString((unsigned int)LastDist,LastLength);
- return;
- }
- if (Length == 14)
- {
- LCount=0;
- Length=DecodeNum(fgetbits(),STARTL2,DecL2,PosL2)+5;
- Distance=(fgetbits()>>1) | 0x8000;
- faddbits(15);
- LastLength=Length;
- LastDist=Distance;
- OldCopyString(Distance,Length);
- return;
- }
-
- LCount=0;
- SaveLength=Length;
- Distance=OldDist[(OldDistPtr-(Length-9)) & 3];
- Length=DecodeNum(fgetbits(),STARTL1,DecL1,PosL1)+2;
- if (Length==0x101 && SaveLength==10)
- {
- Buf60 ^= 1;
- return;
- }
- if (Distance > 256)
- Length++;
- if (Distance >= MaxDist3)
- Length++;
-
- OldDist[OldDistPtr++]=Distance;
- OldDistPtr = OldDistPtr & 3;
- LastLength=Length;
- LastDist=Distance;
- OldCopyString(Distance,Length);
- return;
- }
-
- LCount=0;
- AvrLn1 += Length;
- AvrLn1 -= AvrLn1 >> 4;
-
- DistancePlace=DecodeNum(fgetbits(),STARTHF2,DecHf2,PosHf2) & 0xff;
- Distance=ChSetA[DistancePlace];
- if (--DistancePlace != -1)
- {
- PlaceA[Distance]--;
- LastDistance=ChSetA[DistancePlace];
- PlaceA[LastDistance]++;
- ChSetA[DistancePlace+1]=LastDistance;
- ChSetA[DistancePlace]=Distance;
- }
- Length+=2;
- OldDist[OldDistPtr++] = ++Distance;
- OldDistPtr = OldDistPtr & 3;
- LastLength=Length;
- LastDist=Distance;
- OldCopyString(Distance,Length);
-}
-
-
-void Unpack::LongLZ()
-{
- unsigned int Length;
- unsigned int Distance;
- unsigned int DistancePlace,NewDistancePlace;
- unsigned int OldAvr2,OldAvr3;
-
- NumHuf=0;
- Nlzb+=16;
- if (Nlzb > 0xff)
- {
- Nlzb=0x90;
- Nhfb >>= 1;
- }
- OldAvr2=AvrLn2;
-
- unsigned int BitField=fgetbits();
- if (AvrLn2 >= 122)
- Length=DecodeNum(BitField,STARTL2,DecL2,PosL2);
- else
- if (AvrLn2 >= 64)
- Length=DecodeNum(BitField,STARTL1,DecL1,PosL1);
- else
- if (BitField < 0x100)
- {
- Length=BitField;
- faddbits(16);
- }
- else
- {
- for (Length=0;((BitField<<Length)&0x8000)==0;Length++)
- ;
- faddbits(Length+1);
- }
-
- AvrLn2 += Length;
- AvrLn2 -= AvrLn2 >> 5;
-
- BitField=fgetbits();
- if (AvrPlcB > 0x28ff)
- DistancePlace=DecodeNum(BitField,STARTHF2,DecHf2,PosHf2);
- else
- if (AvrPlcB > 0x6ff)
- DistancePlace=DecodeNum(BitField,STARTHF1,DecHf1,PosHf1);
- else
- DistancePlace=DecodeNum(BitField,STARTHF0,DecHf0,PosHf0);
-
- AvrPlcB += DistancePlace;
- AvrPlcB -= AvrPlcB >> 8;
- while (1)
- {
- Distance = ChSetB[DistancePlace & 0xff];
- NewDistancePlace = NToPlB[Distance++ & 0xff]++;
- if (!(Distance & 0xff))
- CorrHuff(ChSetB,NToPlB);
- else
- break;
- }
-
- ChSetB[DistancePlace]=ChSetB[NewDistancePlace];
- ChSetB[NewDistancePlace]=Distance;
-
- Distance=((Distance & 0xff00) | (fgetbits() >> 8)) >> 1;
- faddbits(7);
-
- OldAvr3=AvrLn3;
- if (Length!=1 && Length!=4)
- if (Length==0 && Distance <= MaxDist3)
- {
- AvrLn3++;
- AvrLn3 -= AvrLn3 >> 8;
- }
- else
- if (AvrLn3 > 0)
- AvrLn3--;
- Length+=3;
- if (Distance >= MaxDist3)
- Length++;
- if (Distance <= 256)
- Length+=8;
- if (OldAvr3 > 0xb0 || AvrPlc >= 0x2a00 && OldAvr2 < 0x40)
- MaxDist3=0x7f00;
- else
- MaxDist3=0x2001;
- OldDist[OldDistPtr++]=Distance;
- OldDistPtr = OldDistPtr & 3;
- LastLength=Length;
- LastDist=Distance;
- OldCopyString(Distance,Length);
-}
-
-
-void Unpack::HuffDecode()
-{
- unsigned int CurByte,NewBytePlace;
- unsigned int Length;
- unsigned int Distance;
- int BytePlace;
-
- unsigned int BitField=fgetbits();
-
- if (AvrPlc > 0x75ff)
- BytePlace=DecodeNum(BitField,STARTHF4,DecHf4,PosHf4);
- else
- if (AvrPlc > 0x5dff)
- BytePlace=DecodeNum(BitField,STARTHF3,DecHf3,PosHf3);
- else
- if (AvrPlc > 0x35ff)
- BytePlace=DecodeNum(BitField,STARTHF2,DecHf2,PosHf2);
- else
- if (AvrPlc > 0x0dff)
- BytePlace=DecodeNum(BitField,STARTHF1,DecHf1,PosHf1);
- else
- BytePlace=DecodeNum(BitField,STARTHF0,DecHf0,PosHf0);
- BytePlace&=0xff;
- if (StMode)
- {
- if (BytePlace==0 && BitField > 0xfff)
- BytePlace=0x100;
- if (--BytePlace==-1)
- {
- BitField=fgetbits();
- faddbits(1);
- if (BitField & 0x8000)
- {
- NumHuf=StMode=0;
- return;
- }
- else
- {
- Length = (BitField & 0x4000) ? 4 : 3;
- faddbits(1);
- Distance=DecodeNum(fgetbits(),STARTHF2,DecHf2,PosHf2);
- Distance = (Distance << 5) | (fgetbits() >> 11);
- faddbits(5);
- OldCopyString(Distance,Length);
- return;
- }
- }
- }
- else
- if (NumHuf++ >= 16 && FlagsCnt==0)
- StMode=1;
- AvrPlc += BytePlace;
- AvrPlc -= AvrPlc >> 8;
- Nhfb+=16;
- if (Nhfb > 0xff)
- {
- Nhfb=0x90;
- Nlzb >>= 1;
- }
-
- Window[UnpPtr++]=(byte)(ChSet[BytePlace]>>8);
- --DestUnpSize;
-
- while (1)
- {
- CurByte=ChSet[BytePlace];
- NewBytePlace=NToPl[CurByte++ & 0xff]++;
- if ((CurByte & 0xff) > 0xa1)
- CorrHuff(ChSet,NToPl);
- else
- break;
- }
-
- ChSet[BytePlace]=ChSet[NewBytePlace];
- ChSet[NewBytePlace]=CurByte;
-}
-
-
-void Unpack::GetFlagsBuf()
-{
- unsigned int Flags,NewFlagsPlace;
- unsigned int FlagsPlace=DecodeNum(fgetbits(),STARTHF2,DecHf2,PosHf2);
-
- while (1)
- {
- Flags=ChSetC[FlagsPlace];
- FlagBuf=Flags>>8;
- NewFlagsPlace=NToPlC[Flags++ & 0xff]++;
- if ((Flags & 0xff) != 0)
- break;
- CorrHuff(ChSetC,NToPlC);
- }
-
- ChSetC[FlagsPlace]=ChSetC[NewFlagsPlace];
- ChSetC[NewFlagsPlace]=Flags;
-}
-
-
-void Unpack::OldUnpInitData(int Solid)
-{
- if (!Solid)
- {
- AvrPlcB=AvrLn1=AvrLn2=AvrLn3=NumHuf=Buf60=0;
- AvrPlc=0x3500;
- MaxDist3=0x2001;
- Nhfb=Nlzb=0x80;
- }
- FlagsCnt=0;
- FlagBuf=0;
- StMode=0;
- LCount=0;
- ReadTop=0;
-}
-
-
-void Unpack::InitHuff()
-{
- for (unsigned int I=0;I<256;I++)
- {
- Place[I]=PlaceA[I]=PlaceB[I]=I;
- PlaceC[I]=(~I+1) & 0xff;
- ChSet[I]=ChSetB[I]=I<<8;
- ChSetA[I]=I;
- ChSetC[I]=((~I+1) & 0xff)<<8;
- }
- memset(NToPl,0,sizeof(NToPl));
- memset(NToPlB,0,sizeof(NToPlB));
- memset(NToPlC,0,sizeof(NToPlC));
- CorrHuff(ChSetB,NToPlB);
-}
-
-
-void Unpack::CorrHuff(unsigned int *CharSet,unsigned int *NumToPlace)
-{
- int I,J;
- for (I=7;I>=0;I--)
- for (J=0;J<32;J++,CharSet++)
- *CharSet=(*CharSet & ~0xff) | I;
- memset(NumToPlace,0,sizeof(NToPl));
- for (I=6;I>=0;I--)
- NumToPlace[I]=(7-I)*32;
-}
-
-
-void Unpack::OldCopyString(unsigned int Distance,unsigned int Length)
-{
- DestUnpSize-=Length;
- while (Length--)
- {
- Window[UnpPtr]=Window[(UnpPtr-Distance) & MAXWINMASK];
- UnpPtr=(UnpPtr+1) & MAXWINMASK;
- }
-}
-
-
-unsigned int Unpack::DecodeNum(int Num,unsigned int StartPos,
- unsigned int *DecTab,unsigned int *PosTab)
-{
- int I;
- for (Num&=0xfff0,I=0;DecTab[I]<=Num;I++)
- StartPos++;
- faddbits(StartPos);
- return(((Num-(I ? DecTab[I-1]:0))>>(16-StartPos))+PosTab[StartPos]);
-}
diff --git a/7zip/Compress/Rar29/Original/version.hpp b/7zip/Compress/Rar29/Original/version.hpp
deleted file mode 100755
index 6a5c653d..00000000
--- a/7zip/Compress/Rar29/Original/version.hpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#define RARVER_MAJOR 3
-#define RARVER_MINOR 50
-#define RARVER_BETA 0
-#define RARVER_DAY 3
-#define RARVER_MONTH 8
-#define RARVER_YEAR 2005
diff --git a/7zip/Compress/Rar29/Original/volume.hpp b/7zip/Compress/Rar29/Original/volume.hpp
deleted file mode 100755
index 64653405..00000000
--- a/7zip/Compress/Rar29/Original/volume.hpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _RAR_VOLUME_
-#define _RAR_VOLUME_
-
-void SplitArchive(Archive &Arc,FileHeader *fh,Int64 *HeaderPos,
- ComprDataIO *DataIO);
-bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,
- char Command);
-void SetVolWrite(Archive &Dest,Int64 VolSize);
-bool AskNextVol(char *ArcName);
-
-#endif
diff --git a/7zip/Compress/Rar29/Rar29.dsp b/7zip/Compress/Rar29/Rar29.dsp
deleted file mode 100755
index 7c3f3ba2..00000000
--- a/7zip/Compress/Rar29/Rar29.dsp
+++ /dev/null
@@ -1,415 +0,0 @@
-# Microsoft Developer Studio Project File - Name="Rar29" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=Rar29 - 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 "RAR29.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 "RAR29.mak" CFG="Rar29 - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Rar29 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "Rar29 - 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)" == "Rar29 - 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 "RAR29_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAR29_EXPORTS" /D "SILENT" /D "NOCRYPT" /D "NOVOLUME" /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\Rar29.dll" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "Rar29 - 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 "RAR29_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 "RAR29_EXPORTS" /D "SILENT" /D "NOCRYPT" /D "NOVOLUME" /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\Rar29.dll" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "Rar29 - Win32 Release"
-# Name "Rar29 - Win32 Debug"
-# Begin Group "Spec"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Codec.def
-# 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 "7zip 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\MSBFDecoder.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 "UnRar Sources"
-
-# PROP Default_Filter ""
-# Begin Group "hpp"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Original\int64.hpp
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=Original\crc.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=Original\errhnd.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=Original\getbits.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=Original\rar.hpp
-# End Source File
-# Begin Source File
-
-SOURCE=Original\rarvm.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=Original\rdwrfn.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=Original\rdwrfn.hpp
-# End Source File
-# Begin Source File
-
-SOURCE=Original\resource.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=Original\smallfn.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=Original\system.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=Original\unpack.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=Original\unpack.hpp
-# End Source File
-# End Group
-# Begin Group "Rar20"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Rar20\Rar20Const.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Rar20\Rar20Decoder.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\Rar20\Rar20Decoder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Rar20\Rar20ExtConst.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Rar20\Rar20Multimedia.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\Rar20\Rar20Multimedia.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 "Huffman"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Huffman\HuffmanDecoder.h
-# End Source File
-# End Group
-# Begin Group "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\Rar29Decoder.cpp
-
-!IF "$(CFG)" == "Rar29 - Win32 Release"
-
-# ADD CPP /O2
-# SUBTRACT CPP /YX /Yc /Yu
-
-!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\Rar29Decoder.h
-# End Source File
-# End Target
-# End Project
diff --git a/7zip/Compress/Rar29/Rar29.dsw b/7zip/Compress/Rar29/Rar29.dsw
deleted file mode 100755
index 61cbfecb..00000000
--- a/7zip/Compress/Rar29/Rar29.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "RAR29"=.\RAR29.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/7zip/Compress/Rar29/Rar29Decoder.cpp b/7zip/Compress/Rar29/Rar29Decoder.cpp
deleted file mode 100755
index 35daea87..00000000
--- a/7zip/Compress/Rar29/Rar29Decoder.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-// Rar29Decoder.cpp
-// According to unRAR license,
-// this code may not be used to develop a
-// RAR (WinRAR) compatible archiver
-
-#include "StdAfx.h"
-
-#include "Rar29Decoder.h"
-
-#include "Windows/Defs.h"
-
-// #include "Original/unpack15.cpp"
-
-ErrorHandler ErrHandler;
-
-namespace NCompress {
-namespace NRar29 {
-
-CDecoder::CDecoder():
- m_IsSolid(false),
- // DataIO(NULL)
- DataIO()
-{
- Unp = new Unpack(&DataIO);
- Unp->Init(NULL);
-}
-
-CDecoder::~CDecoder()
-{
- delete Unp;
-}
-
-STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- // CCoderReleaser coderReleaser(this);
-
- DataIO.CurUnpRead=0;
- DataIO.CurUnpWrite=0;
- DataIO.UnpFileCRC=0xffffffff;
- DataIO.PackedCRC=0xffffffff;
- /*
- DataIO.SetEncryption(
- 0,0,
- NULL,false);
- */
-
- DataIO.SetPackedSizeToRead(*inSize);
- DataIO.SetFiles(inStream, outStream, progress);
- DataIO.SetTestMode(false);
- // DataIO.SetSkipUnpCRC(SkipSolid);
- /*
- if (!TestMode && Arc.NewLhd.FullUnpSize>0x1000)
- CurFile.Prealloc(Arc.NewLhd.FullUnpSize);
-
- CurFile.SetAllowDelete(!Cmd->KeepBroken);
- */
-
- Unp->SetDestSize(*outSize);
-
- Unp->DoUnpack(29, m_IsSolid);
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
- catch(const CExitCode &exitCode) { return exitCode.Result; }
- catch(...) { return S_FALSE; }
-}
-
-STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
-{
- if (size < 1)
- return E_INVALIDARG;
- m_IsSolid = (data[0] != 0);
- return S_OK;
-}
-
-}
-
-
-namespace NRar15 {
-
-CDecoder::CDecoder():
- m_IsSolid(false),
- DataIO()
-{
- Unp=new Unpack(&DataIO);
- Unp->Init(NULL);
-}
-
-CDecoder::~CDecoder()
-{
- delete Unp;
-}
-
-
-STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- // CCoderReleaser coderReleaser(this);
-
- DataIO.CurUnpRead=0;
- DataIO.CurUnpWrite=0;
- DataIO.UnpFileCRC=0xffffffff;
- DataIO.PackedCRC=0xffffffff;
- /*
- DataIO.SetEncryption(
- 0,0,
- NULL,false);
- */
-
- DataIO.SetPackedSizeToRead(*inSize);
- DataIO.SetFiles(inStream, outStream, progress);
- DataIO.SetTestMode(false);
- // DataIO.SetSkipUnpCRC(SkipSolid);
- /*
- if (!TestMode && Arc.NewLhd.FullUnpSize>0x1000)
- CurFile.Prealloc(Arc.NewLhd.FullUnpSize);
-
- CurFile.SetAllowDelete(!Cmd->KeepBroken);
- */
- Unp->SetDestSize(*outSize);
- Unp->DoUnpack(15, m_IsSolid);
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize,
- const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
- catch(const CExitCode &exitCode) { return exitCode.Result; }
- catch(...) { return S_FALSE;}
-}
-
-STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
-{
- if (size < 1)
- return E_INVALIDARG;
- m_IsSolid = (data[0] != 0);
- return S_OK;
-}
-
-}
-
-}
diff --git a/7zip/Compress/Rar29/Rar29Decoder.h b/7zip/Compress/Rar29/Rar29Decoder.h
deleted file mode 100755
index de0044fd..00000000
--- a/7zip/Compress/Rar29/Rar29Decoder.h
+++ /dev/null
@@ -1,97 +0,0 @@
-// Rar29Decoder.h
-// According to unRAR license,
-// this code may not be used to develop a
-// RAR (WinRAR) compatible archiver
-
-#ifndef __RAR_DECODER_H
-#define __RAR_DECODER_H
-
-#include "Common/MyCom.h"
-
-#include "../../ICoder.h"
-
-#include "Original/rar.hpp"
-
-namespace NCompress {
-
-namespace NRar29 {
-
-class CDecoder :
- public ICompressCoder,
- public ICompressSetDecoderProperties2,
- public CMyUnknownImp
-{
- Unpack *Unp;
- bool m_IsSolid;
-public:
- ComprDataIO DataIO;
- CDecoder();
- ~CDecoder();
- /*
- class CCoderReleaser
- {
- CCoder *m_Coder;
- public:
- CCoderReleaser(CCoder *aCoder): m_Coder(aCoder) {}
- ~CCoderReleaser()
- {
- m_Coder->DataIO.ReleaseStreams();
- }
- };
- */
- MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
-
- // void ReleaseStreams();
- STDMETHOD(CodeReal)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
- STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
-};
-
-}
-
-namespace NRar15{
-
-class CDecoder :
- public ICompressCoder,
- public ICompressSetDecoderProperties2,
- public CMyUnknownImp
-{
- Unpack *Unp;
- bool m_IsSolid;
-public:
- ComprDataIO DataIO;
- CDecoder();
- ~CDecoder();
- /*
- class CCoderReleaser
- {
- CDecoder *m_Coder;
- public:
- CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
- ~CCoderReleaser()
- {
- m_Coder->DataIO.ReleaseStreams();
- }
- };
- */
- MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
-
- // void ReleaseStreams();
- STDMETHOD(CodeReal)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
- STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
-};
-
-}
-
-}
-
-#endif
diff --git a/7zip/Compress/Rar29/makefile b/7zip/Compress/Rar29/makefile
deleted file mode 100755
index 0a0f45f8..00000000
--- a/7zip/Compress/Rar29/makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-PROG = Rar29.dll
-DEF_FILE = ../Codec.def
-CFLAGS = $(CFLAGS) -I ../../../ -DSILENT -DNOCRYPT -DNOVOLUME
-LIBS = $(LIBS) oleaut32.lib
-
-RAR29_OBJS = \
- $O\DllExports.obj \
- $O\Rar29Decoder.obj \
-
-RAR29_OPT_OBJS = \
- $O\crc.obj \
- $O\errhnd.obj \
- $O\getbits.obj \
- $O\rarvm.obj \
- $O\rdwrfn.obj \
- $O\resource.obj \
- $O\smallfn.obj \
- $O\system.obj \
- $O\unpack.obj \
-
-RAR20_OPT_OBJS = \
- $O\Rar20Decoder.obj \
- $O\Rar20Multimedia.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
-
-7ZIP_COMMON_OBJS = \
- $O\InBuffer.obj \
- $O\OutBuffer.obj \
- $O\StreamUtils.obj \
-
-LZ_OBJS = \
- $O\LZOutWindow.obj \
-
-
-OBJS = \
- $O\StdAfx.obj \
- $(RAR29_OBJS) \
- $(RAR29_OPT_OBJS) \
- $(RAR20_OPT_OBJS) \
- $(COMMON_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(LZ_OBJS) \
- $O\resource.res
-
-!include "../../../Build.mak"
-
-COMPL_SPEC = $(CPP) $(CFLAGS_O2_W3) -w $**
-
-$(RAR29_OBJS): $(*B).cpp
- $(COMPL_SPEC)
-$(RAR29_OPT_OBJS): Original/$(*B).cpp
- $(COMPL_SPEC)
-$(RAR20_OPT_OBJS): ../Rar20/$(*B).cpp
- $(COMPL_O2)
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(LZ_OBJS): ../LZ/$(*B).cpp
- $(COMPL)
diff --git a/7zip/Compress/Shrink/DllExports.cpp b/7zip/Compress/Shrink/DllExports.cpp
deleted file mode 100755
index 25329f97..00000000
--- a/7zip/Compress/Shrink/DllExports.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-#include "ShrinkDecoder.h"
-
-// {23170F69-40C1-278B-0401-010000000000}
-DEFINE_GUID(CLSID_CCompressShrinkDecoder,
-0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
-{
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- if (*clsid != CLSID_CCompressShrinkDecoder)
- return CLASS_E_CLASSNOTAVAILABLE;
- if (*iid != IID_ICompressCoder)
- return E_NOINTERFACE;
- CMyComPtr<ICompressCoder> coder = (ICompressCoder *)new NCompress::NShrink::CDecoder;
- *outObject = coder.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[] = { 0x04, 0x01, 0x01 };
- if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(L"Shrink")) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCompressShrinkDecoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- return S_OK;
-}
diff --git a/7zip/Compress/Z/ZDecoder.cpp b/7zip/Compress/Z/ZDecoder.cpp
deleted file mode 100755
index f63fbbf6..00000000
--- a/7zip/Compress/Z/ZDecoder.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-// ZDecoder.cpp
-
-#include "StdAfx.h"
-
-#include "ZDecoder.h"
-
-#include "../../../Common/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;
-
-void CDecoder::Free()
-{
- 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();
-}
-
-STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
- ICompressProgressInfo *progress)
-{
- NStream::NLSBF::CBaseDecoder<CInBuffer> inBuffer;
- COutBuffer outBuffer;
-
- if (!inBuffer.Create(kBufferSize))
- return E_OUTOFMEMORY;
- inBuffer.SetStream(inStream);
- inBuffer.Init();
-
- if (!outBuffer.Create(kBufferSize))
- return E_OUTOFMEMORY;
- outBuffer.SetStream(outStream);
- outBuffer.Init();
-
- int maxbits = _properties & kNumBitsMask;
- if (maxbits < kNumMinBits || maxbits > kNumMaxBits)
- 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;
- _numMaxBits = maxbits;
- }
-
- UInt64 prevPos = 0;
- int numBits = kNumMinBits;
- UInt32 head = blockMode ? 257 : 256;
-
- bool needPrev = false;
-
- int keepBits = 0;
-
- _parents[256] = 0; // virus protection
- _suffixes[256] = 0;
-
- for (;;)
- {
- if (keepBits < numBits)
- keepBits = numBits * 8;
- UInt32 symbol = inBuffer.ReadBits(numBits);
- if (inBuffer.ExtraBitsWereRead())
- break;
- keepBits -= numBits;
- if (symbol >= head)
- return S_FALSE;
- if (blockMode && symbol == 256)
- {
- for (;keepBits > 0; keepBits--)
- inBuffer.ReadBits(1);
- numBits = kNumMinBits;
- head = 257;
- needPrev = false;
- continue;
- }
- UInt32 cur = symbol;
- int i = 0;
- while (cur >= 256)
- {
- _stack[i++] = _suffixes[cur];
- cur = _parents[cur];
- }
- _stack[i++] = (Byte)cur;
- if (needPrev)
- {
- _suffixes[head - 1] = (Byte)cur;
- if (symbol == head - 1)
- _stack[0] = (Byte)cur;
- }
- while (i > 0)
- outBuffer.WriteByte((_stack[--i]));
- if (head < numItems)
- {
- needPrev = true;
- _parents[head++] = (UInt16)symbol;
- if (head > ((UInt32)1 << numBits))
- {
- if (numBits < maxbits)
- {
- 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();
-}
-
-STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
- catch(const CInBufferException &e) { return e.ErrorCode; }
- catch(const COutBufferException &e) { return e.ErrorCode; }
- catch(...) { return S_FALSE; }
-}
-
-STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
-{
- if (size < 1)
- return E_INVALIDARG;
- _properties = data[0];
- return S_OK;
-}
-
-}}
diff --git a/7zip/Compress/Z/ZDecoder.h b/7zip/Compress/Z/ZDecoder.h
deleted file mode 100755
index 8b7f0b6d..00000000
--- a/7zip/Compress/Z/ZDecoder.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// ZDecoder.h
-
-#ifndef __COMPRESS_ZDECODER_H
-#define __COMPRESS_ZDECODER_H
-
-#include "../../../Common/MyCom.h"
-#include "../../ICoder.h"
-
-namespace NCompress {
-namespace NZ {
-
-class CDecoder :
- public ICompressCoder,
- public ICompressSetDecoderProperties2,
- public CMyUnknownImp
-{
- BYTE _properties;
- int _numMaxBits;
- UInt16 *_parents;
- Byte *_suffixes;
- Byte *_stack;
-
-public:
- CDecoder(): _properties(0), _numMaxBits(0), _parents(0), _suffixes(0), _stack(0) {};
- ~CDecoder();
- void Free();
- bool Alloc(size_t numItems);
-
- MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
-
- STDMETHOD(CodeReal)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
-};
-
-}}
-
-#endif
diff --git a/7zip/Compress/makefile b/7zip/Compress/makefile
deleted file mode 100755
index 68a8502c..00000000
--- a/7zip/Compress/makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-DIRS = \
- Branch\~ \
- ByteSwap\~ \
- BZip2\~ \
- Copy\~ \
- Deflate\~ \
- LZMA\~ \
- PPMD\~ \
- Rar29\~ \
-
-all: $(DIRS)
-
-$(DIRS):
-!include "../SubBuild.mak"
diff --git a/7zip/Crypto/Zip/StdAfx.h b/7zip/Crypto/Zip/StdAfx.h
deleted file mode 100755
index e7fb6986..00000000
--- a/7zip/Crypto/Zip/StdAfx.h
+++ /dev/null
@@ -1,8 +0,0 @@
-// StdAfx.h
-
-#ifndef __STDAFX_H
-#define __STDAFX_H
-
-#include "../../../Common/MyWindows.h"
-
-#endif
diff --git a/7zip/FileManager/App.cpp b/7zip/FileManager/App.cpp
deleted file mode 100755
index 25842849..00000000
--- a/7zip/FileManager/App.cpp
+++ /dev/null
@@ -1,751 +0,0 @@
-// App.cpp
-
-#include "StdAfx.h"
-
-#include "resource.h"
-
-#include "Common/StringConvert.h"
-#include "Windows/FileDir.h"
-#include "Windows/Error.h"
-#include "Windows/COM.h"
-#include "Windows/Thread.h"
-#include "IFolder.h"
-
-#include "App.h"
-
-#include "Resource/CopyDialog/CopyDialog.h"
-
-#include "ExtractCallback.h"
-#include "ViewSettings.h"
-#include "RegistryUtils.h"
-
-using namespace NWindows;
-using namespace NFile;
-using namespace NFind;
-
-extern DWORD g_ComCtl32Version;
-extern HINSTANCE g_hInstance;
-
-static LPCWSTR kTempDirPrefix = L"7zE";
-
-void CPanelCallbackImp::OnTab()
-{
- if (g_App.NumPanels != 1)
- _app->Panels[1 - _index].SetFocusToList();
-}
-
-void CPanelCallbackImp::SetFocusToPath(int index)
-{
- int newPanelIndex = index;
- if (g_App.NumPanels == 1)
- newPanelIndex = g_App.LastFocusedPanel;
- _app->Panels[newPanelIndex]._headerComboBox.SetFocus();
-}
-
-
-void CPanelCallbackImp::OnCopy(bool move, bool copyToSame)
- { _app->OnCopy(move, copyToSame, _index); }
-
-void CPanelCallbackImp::OnSetSameFolder()
- { _app->OnSetSameFolder(_index); }
-
-void CPanelCallbackImp::OnSetSubFolder()
- { _app->OnSetSubFolder(_index); }
-
-void CPanelCallbackImp::PanelWasFocused()
- { _app->SetFocusedPanel(_index); }
-
-void CPanelCallbackImp::DragBegin()
- { _app->DragBegin(_index); }
-
-void CPanelCallbackImp::DragEnd()
- { _app->DragEnd(); }
-
-void CApp::SetListSettings()
-{
- bool showDots = ReadShowDots();
- bool showRealFileIcons = ReadShowRealFileIcons();
-
- DWORD extendedStyle = LVS_EX_HEADERDRAGDROP;
- if (ReadFullRow())
- extendedStyle |= LVS_EX_FULLROWSELECT;
- if (ReadShowGrid())
- extendedStyle |= LVS_EX_GRIDLINES;
- bool mySelectionMode = ReadAlternativeSelection();
-
- /*
- if (ReadSingleClick())
- {
- extendedStyle |= LVS_EX_ONECLICKACTIVATE
- | LVS_EX_TRACKSELECT;
- if (ReadUnderline())
- extendedStyle |= LVS_EX_UNDERLINEHOT;
- }
- */
-
- for (int i = 0; i < kNumPanelsMax; i++)
- {
- CPanel &panel = Panels[i];
- panel._mySelectMode = mySelectionMode;
- panel._showDots = showDots;
- panel._showRealFileIcons = showRealFileIcons;
- panel._exStyle = extendedStyle;
-
- DWORD style = (DWORD)panel._listView.GetStyle();
- if (mySelectionMode)
- style |= LVS_SINGLESEL;
- else
- style &= ~LVS_SINGLESEL;
- panel._listView.SetStyle(style);
- panel.SetExtendedStyle();
- }
-}
-
-void CApp::SetShowSystemMenu()
-{
- ShowSystemMenu = ReadShowSystemMenu();
-}
-
-void CApp::CreateOnePanel(int panelIndex, const UString &mainPath)
-{
- if (PanelsCreated[panelIndex])
- return;
- m_PanelCallbackImp[panelIndex].Init(this, panelIndex);
- UString path;
- if (mainPath.IsEmpty())
- {
- if (!::ReadPanelPath(panelIndex, path))
- path.Empty();
- }
- else
- path = mainPath;
- int id = 1000 + 100 * panelIndex;
- Panels[panelIndex].Create(_window, _window,
- id, path, &m_PanelCallbackImp[panelIndex], &AppState);
- PanelsCreated[panelIndex] = true;
-}
-
-static void CreateToolbar(
- HWND parent,
- NWindows::NControl::CImageList &imageList,
- NWindows::NControl::CToolBar &toolBar,
- bool LargeButtons)
-{
- toolBar.Attach(::CreateWindowEx(0,
- TOOLBARCLASSNAME,
- NULL, 0
- | WS_VISIBLE
- | TBSTYLE_FLAT
- | TBSTYLE_TOOLTIPS
- | WS_CHILD
- | CCS_NOPARENTALIGN
- | CCS_NORESIZE
- | CCS_NODIVIDER
- // | TBSTYLE_AUTOSIZE
- // | CCS_ADJUSTABLE
- ,0,0,0,0, parent, NULL, g_hInstance, NULL));
-
- // TB_BUTTONSTRUCTSIZE message, which is required for
- // backward compatibility.
- toolBar.ButtonStructSize();
-
- imageList.Create(
- LargeButtons ? 48: 24,
- LargeButtons ? 36: 24,
- ILC_MASK, 0, 0);
- toolBar.SetImageList(0, imageList);
-}
-
-struct CButtonInfo
-{
- UINT commandID;
- UINT BitmapResID;
- UINT Bitmap2ResID;
- UINT StringResID;
- UINT32 LangID;
- UString GetText()const { return LangString(StringResID, LangID); };
-};
-
-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}
-};
-
-static CButtonInfo g_ArchiveButtons[] =
-{
- { kAddCommand, IDB_ADD, IDB_ADD2, IDS_ADD, 0x03020400},
- { kExtractCommand, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT, 0x03020401},
- { kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402}
-};
-
-bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, UString &s)
-{
- for (int i = 0; i < numButtons; i++)
- {
- const CButtonInfo &b = buttons[i];
- if (b.commandID == commandID)
- {
- s = b.GetText();
- return true;
- }
- }
- return false;
-}
-
-void SetButtonText(UINT32 commandID, UString &s)
-{
- if (SetButtonText(commandID, g_StandardButtons,
- sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s))
- return;
- SetButtonText(commandID, g_ArchiveButtons,
- sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s);
-}
-
-static void AddButton(
- NControl::CImageList &imageList,
- NControl::CToolBar &toolBar,
- CButtonInfo &butInfo,
- bool showText,
- bool large)
-{
- TBBUTTON but;
- but.iBitmap = 0;
- but.idCommand = butInfo.commandID;
- but.fsState = TBSTATE_ENABLED;
- but.fsStyle = BTNS_BUTTON
- // | BTNS_AUTOSIZE
- ;
- but.dwData = 0;
-
- UString s = butInfo.GetText();
- but.iString = 0;
- if (showText)
- but.iString = (INT_PTR)(LPCWSTR)s;
-
- but.iBitmap = imageList.GetImageCount();
- HBITMAP b = ::LoadBitmap(g_hInstance,
- large ?
- MAKEINTRESOURCE(butInfo.BitmapResID):
- MAKEINTRESOURCE(butInfo.Bitmap2ResID));
- if (b != 0)
- {
- imageList.AddMasked(b, RGB(255, 0, 255));
- ::DeleteObject(b);
- }
- #ifdef _UNICODE
- toolBar.AddButton(1, &but);
- #else
- toolBar.AddButtonW(1, &but);
- #endif
-}
-
-static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar)
-{
- SIZE size;
- toolBar.GetMaxSize(&size);
-
- RECT rect;
- toolBar.GetWindowRect(&rect);
-
- REBARBANDINFO rbBand;
- rbBand.cbSize = sizeof(REBARBANDINFO); // Required
- rbBand.fMask = RBBIM_STYLE
- | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
- rbBand.fStyle = RBBS_CHILDEDGE; // RBBS_NOGRIPPER;
- rbBand.cxMinChild = size.cx; // rect.right - rect.left;
- rbBand.cyMinChild = size.cy; // rect.bottom - rect.top;
- rbBand.cyChild = rbBand.cyMinChild;
- rbBand.cx = rbBand.cxMinChild;
- rbBand.cxIdeal = rbBand.cxMinChild;
- rbBand.hwndChild = toolBar;
- reBar.InsertBand(-1, &rbBand);
-}
-
-void CApp::ReloadToolbars()
-{
- if (!_rebar)
- return;
- HWND parent = _rebar;
-
- while(_rebar.GetBandCount() > 0)
- _rebar.DeleteBand(0);
-
- _archiveToolBar.Destroy();
- _archiveButtonsImageList.Destroy();
-
- _standardButtonsImageList.Destroy();
- _standardToolBar.Destroy();
-
- if (ShowArchiveToolbar)
- {
- CreateToolbar(parent, _archiveButtonsImageList, _archiveToolBar, LargeButtons);
- for (int i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++)
- AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i],
- ShowButtonsLables, LargeButtons);
- AddBand(_rebar, _archiveToolBar);
- }
-
- if (ShowStandardToolbar)
- {
- CreateToolbar(parent, _standardButtonsImageList, _standardToolBar, LargeButtons);
- for (int i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++)
- AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i],
- ShowButtonsLables, LargeButtons);
- AddBand(_rebar, _standardToolBar);
- }
-}
-
-void CApp::ReloadRebar(HWND hwnd)
-{
- _rebar.Destroy();
- if (!ShowArchiveToolbar && !ShowStandardToolbar)
- return;
- if (g_ComCtl32Version >= MAKELONG(71, 4))
- {
- INITCOMMONCONTROLSEX icex;
- icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
- icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
- InitCommonControlsEx(&icex);
-
- _rebar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
- REBARCLASSNAME,
- 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_BANDBORDERS
- // | RBS_AUTOSIZE
- ,0,0,0,0, hwnd, NULL, g_hInstance, NULL));
- }
- if (_rebar == 0)
- return;
- REBARINFO rbi;
- rbi.cbSize = sizeof(REBARINFO); // Required when using this struct.
- rbi.fMask = 0;
- rbi.himl = (HIMAGELIST)NULL;
- _rebar.SetBarInfo(&rbi);
- ReloadToolbars();
-}
-
-void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2])
-{
- ReadToolbar();
- ReloadRebar(hwnd);
-
- int i;
- for (i = 0; i < kNumPanelsMax; i++)
- PanelsCreated[i] = false;
-
- _window.Attach(hwnd);
- AppState.Read();
- SetListSettings();
- SetShowSystemMenu();
- UString mainPathSpec = mainPath;
- if (LastFocusedPanel >= kNumPanelsMax)
- LastFocusedPanel = 0;
-
- CListMode listMode;
- ReadListMode(listMode);
- for (i = 0; i < kNumPanelsMax; i++)
- {
- Panels[i]._ListViewMode = listMode.Panels[i];
- Panels[i]._xSize = xSizes[i];
- }
- for (i = 0; i < kNumPanelsMax; i++)
- if (NumPanels > 1 || i == LastFocusedPanel)
- {
- if (NumPanels == 1)
- Panels[i]._xSize = xSizes[0] + xSizes[1];
- CreateOnePanel(i, (i == LastFocusedPanel) ? mainPath : L"");
- }
- SetFocusedPanel(LastFocusedPanel);
- Panels[LastFocusedPanel].SetFocusToList();
-}
-
-extern void MoveSubWindows(HWND hWnd);
-
-void CApp::SwitchOnOffOnePanel()
-{
- if (NumPanels == 1)
- {
- NumPanels++;
- CreateOnePanel(1 - LastFocusedPanel, UString());
- Panels[1 - LastFocusedPanel].Enable(true);
- Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
- }
- else
- {
- NumPanels--;
- Panels[1 - LastFocusedPanel].Enable(false);
- Panels[1 - LastFocusedPanel].Show(SW_HIDE);
- }
- MoveSubWindows(_window);
-}
-
-void CApp::Save()
-{
- AppState.Save();
- CListMode listMode;
- for (int i = 0; i < kNumPanelsMax; i++)
- {
- const CPanel &panel = Panels[i];
- UString path;
- if (panel._parentFolders.IsEmpty())
- path = panel._currentFolderPrefix;
- else
- path = GetFolderPath(panel._parentFolders[0].ParentFolder);
- SavePanelPath(i, path);
- listMode.Panels[i] = panel.GetListViewMode();
- }
- SaveListMode(listMode);
-}
-
-void CApp::Release()
-{
- // 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))
- return false;
- return fileInfo.IsDirectory();
-}
-
-// reduces path to part that exists on disk
-static void ReducePathToRealFileSystemPath(UString &path)
-{
- while(!path.IsEmpty())
- {
- if (IsThereFolderOfPath(path))
- {
- NName::NormalizeDirPathPrefix(path);
- break;
- }
- int pos = path.ReverseFind('\\');
- if (pos < 0)
- path.Empty();
- else
- {
- path = path.Left(pos + 1);
- if (path.Length() == 3 && path[1] == L':')
- break;
- path = path.Left(pos);
- }
- }
-}
-
-// return true for dir\, if dir exist
-static bool CheckFolderPath(const UString &path)
-{
- UString pathReduced = path;
- ReducePathToRealFileSystemPath(pathReduced);
- return (pathReduced == path);
-}
-
-static bool IsPathAbsolute(const UString &path)
-{
- if ((path.Length() >= 1 && path[0] == L'\\') ||
- (path.Length() >= 3 && path[1] == L':' && path[2] == L'\\'))
- return true;
- return false;
-}
-
-void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
-{
- int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
- CPanel &srcPanel = Panels[srcPanelIndex];
- CPanel &destPanel = Panels[destPanelIndex];
-
- CPanel::CDisableTimerProcessing disableTimerProcessing1(destPanel);
- CPanel::CDisableTimerProcessing disableTimerProcessing2(srcPanel);
-
- if (!srcPanel.DoesItSupportOperations())
- {
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
-
- CRecordVector<UInt32> indices;
- UString destPath;
- bool useDestPanel = false;
-
- {
- if (copyToSame)
- {
- int focusedItem = srcPanel._listView.GetFocusedItem();
- if (focusedItem < 0)
- return;
- int realIndex = srcPanel.GetRealItemIndex(focusedItem);
- if (realIndex == kParentIndex)
- return;
- indices.Add(realIndex);
- destPath = srcPanel.GetItemName(realIndex);
- }
- else
- {
- srcPanel.GetOperatedItemIndices(indices);
- if (indices.Size() == 0)
- return;
- destPath = destPanel._currentFolderPrefix;
- if (NumPanels == 1)
- ReducePathToRealFileSystemPath(destPath);
- }
-
- CCopyDialog copyDialog;
- UStringVector copyFolders;
- ReadCopyHistory(copyFolders);
-
- copyDialog.Strings = copyFolders;
- copyDialog.Value = destPath;
-
- copyDialog.Title = move ?
- LangString(IDS_MOVE, 0x03020202):
- LangString(IDS_COPY, 0x03020201);
- copyDialog.Static = move ?
- LangString(IDS_MOVE_TO, 0x03020204):
- LangString(IDS_COPY_TO, 0x03020203);
-
- if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
- return;
-
- destPath = copyDialog.Value;
-
- if (!IsPathAbsolute(destPath))
- {
- if (!srcPanel.IsFSFolder())
- {
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
- destPath = srcPanel._currentFolderPrefix + destPath;
- }
-
- if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) ||
- IsThereFolderOfPath(destPath))
- {
- NDirectory::CreateComplexDirectory(destPath);
- NName::NormalizeDirPathPrefix(destPath);
- if (!CheckFolderPath(destPath))
- {
- if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
- {
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
- useDestPanel = true;
- }
- }
- else
- {
- int pos = destPath.ReverseFind('\\');
- if (pos >= 0)
- {
- UString prefix = destPath.Left(pos + 1);
- NDirectory::CreateComplexDirectory(prefix);
- if (!CheckFolderPath(prefix))
- {
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
- }
- }
-
- AddUniqueStringToHeadOfList(copyFolders, destPath);
- while (copyFolders.Size() > 20)
- copyFolders.DeleteBack();
- SaveCopyHistory(copyFolders);
- }
-
- bool useSrcPanel = (!useDestPanel || !srcPanel.IsFSFolder() || destPanel.IsFSFolder());
- bool useTemp = useSrcPanel && useDestPanel;
- NFile::NDirectory::CTempDirectoryW tempDirectory;
- UString tempDirPrefix;
- if (useTemp)
- {
- tempDirectory.Create(kTempDirPrefix);
- tempDirPrefix = tempDirectory.GetPath();
- NFile::NName::NormalizeDirPathPrefix(tempDirPrefix);
- }
-
- CSelectedState srcSelState;
- CSelectedState destSelState;
- srcPanel.SaveSelectedState(srcSelState);
- destPanel.SaveSelectedState(destSelState);
-
- HRESULT result;
- if (useSrcPanel)
- {
- UString folder = useTemp ? tempDirPrefix : destPath;
- result = srcPanel.CopyTo(indices, folder, move, true, 0);
- if (result != S_OK)
- {
- disableTimerProcessing1.Restore();
- disableTimerProcessing2.Restore();
- // For Password:
- srcPanel.SetFocusToList();
- if (result != E_ABORT)
- srcPanel.MessageBoxError(result, L"Error");
- return;
- }
- }
-
- if (useDestPanel)
- {
- UStringVector filePaths;
- UString folderPrefix;
- if (useTemp)
- folderPrefix = tempDirPrefix;
- else
- folderPrefix = srcPanel._currentFolderPrefix;
- filePaths.Reserve(indices.Size());
- for(int i = 0; i < indices.Size(); i++)
- filePaths.Add(srcPanel.GetItemRelPath(indices[i]));
-
- result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0);
-
- if (result != S_OK)
- {
- disableTimerProcessing1.Restore();
- disableTimerProcessing2.Restore();
- // For Password:
- srcPanel.SetFocusToList();
- if (result != E_ABORT)
- srcPanel.MessageBoxError(result, L"Error");
- return;
- }
- }
-
- if (copyToSame || move)
- {
- srcPanel.RefreshListCtrl(srcSelState);
- }
- if (!copyToSame)
- {
- destPanel.RefreshListCtrl(destSelState);
- srcPanel.KillSelection();
- }
- disableTimerProcessing1.Restore();
- disableTimerProcessing2.Restore();
- srcPanel.SetFocusToList();
-}
-
-void CApp::OnSetSameFolder(int srcPanelIndex)
-{
- if (NumPanels <= 1)
- return;
- const CPanel &srcPanel = Panels[srcPanelIndex];
- CPanel &destPanel = Panels[1 - srcPanelIndex];
- destPanel.BindToPathAndRefresh(srcPanel._currentFolderPrefix);
-}
-
-void CApp::OnSetSubFolder(int srcPanelIndex)
-{
- if (NumPanels <= 1)
- return;
- const CPanel &srcPanel = Panels[srcPanelIndex];
- CPanel &destPanel = Panels[1 - srcPanelIndex];
-
- int focusedItem = srcPanel._listView.GetFocusedItem();
- if (focusedItem < 0)
- return;
- int realIndex = srcPanel.GetRealItemIndex(focusedItem);
- if (!srcPanel.IsItemFolder(realIndex))
- return;
-
-
- /*
- UString string = srcPanel._currentFolderPrefix +
- srcPanel.GetItemName(realIndex) + L'\\';
- destPanel.BindToFolder(string);
- */
- CMyComPtr<IFolderFolder> newFolder;
- if (realIndex == kParentIndex)
- {
- if (srcPanel._folder->BindToParentFolder(&newFolder) != S_OK)
- return;
- }
- else
- {
- if (srcPanel._folder->BindToFolder(realIndex, &newFolder) != S_OK)
- return;
- }
- destPanel.CloseOpenFolders();
- destPanel._folder = newFolder;
- destPanel.RefreshListCtrl();
-}
-
-/*
-int CApp::GetFocusedPanelIndex() const
-{
- return LastFocusedPanel;
- HWND hwnd = ::GetFocus();
- for (;;)
- {
- if (hwnd == 0)
- return 0;
- for (int i = 0; i < kNumPanelsMax; i++)
- {
- if (PanelsCreated[i] &&
- ((HWND)Panels[i] == hwnd || Panels[i]._listView == hwnd))
- return i;
- }
- hwnd = GetParent(hwnd);
- }
-}
- */
-
-static UString g_ToolTipBuffer;
-static CSysString g_ToolTipBufferSys;
-
-void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
-{
- if (pnmh->hwndFrom == _rebar)
- {
- switch(pnmh->code)
- {
- case RBN_HEIGHTCHANGE:
- {
- MoveSubWindows(g_HWND);
- return;
- }
- }
- return ;
- }
- else
- {
- if (pnmh->code == TTN_GETDISPINFO)
- {
- LPNMTTDISPINFO info = (LPNMTTDISPINFO)pnmh;
- info->hinst = 0;
- g_ToolTipBuffer.Empty();
- SetButtonText((UINT32)info->hdr.idFrom, g_ToolTipBuffer);
- g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
- info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBufferSys;
- return;
- }
- #ifndef _UNICODE
- if (pnmh->code == TTN_GETDISPINFOW)
- {
- LPNMTTDISPINFOW info = (LPNMTTDISPINFOW)pnmh;
- info->hinst = 0;
- g_ToolTipBuffer.Empty();
- SetButtonText((UINT32)info->hdr.idFrom, g_ToolTipBuffer);
- info->lpszText = (LPWSTR)(LPCWSTR)g_ToolTipBuffer;
- return;
- }
- #endif
- }
-}
diff --git a/7zip/FileManager/App.h b/7zip/FileManager/App.h
deleted file mode 100755
index d0ffbd98..00000000
--- a/7zip/FileManager/App.h
+++ /dev/null
@@ -1,332 +0,0 @@
-// App.h
-
-#ifndef __APP_H
-#define __APP_H
-
-#include "Panel.h"
-#include "AppState.h"
-#include "Windows/Control/ImageList.h"
-
-class CApp;
-
-extern CApp g_App;
-extern HWND g_HWND;
-
-const int kNumPanelsMax = 2;
-
-extern void MoveSubWindows(HWND hWnd);
-
-enum
-{
- kAddCommand = kToolbarStartID,
- kExtractCommand,
- kTestCommand
-};
-
-class CPanelCallbackImp: public CPanelCallback
-{
- CApp *_app;
- int _index;
-public:
- void Init(CApp *app, int index)
- {
- _app = app;
- _index = index;
- }
- virtual void OnTab();
- virtual void SetFocusToPath(int index);
- virtual void OnCopy(bool move, bool copyToSame);
- virtual void OnSetSameFolder();
- virtual void OnSetSubFolder();
- virtual void PanelWasFocused();
- virtual void DragBegin();
- virtual void DragEnd();
-};
-
-class CApp;
-
-class CDropTarget:
- public IDropTarget,
- public CMyUnknownImp
-{
- CMyComPtr<IDataObject> m_DataObject;
- 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.
- // check it only if m_DropIsAllowed == true
- int m_SubFolderIndex;
- UString m_SubFolderName;
-
- CPanel *m_Panel;
- bool m_IsAppTarget; // true, if we want to drop to app window (not to panel).
-
- bool m_SetPathIsOK;
-
- bool IsItSameDrive() const;
-
- void QueryGetData(IDataObject *dataObject);
- bool IsFsFolderPath() const;
- DWORD GetEffect(DWORD keyState, POINTL pt, DWORD allowedEffect);
- void RemoveSelection();
- void PositionCursor(POINTL ptl);
- UString GetTargetPath() const;
- bool SetPath(bool enablePath) const;
- bool SetPath();
-
-public:
- MY_UNKNOWN_IMP1_MT(IDropTarget)
- 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,
- 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),
- m_SubFolderIndex(-1),
- m_SetPathIsOK(false) {}
-
- CApp *App;
- int SrcPanelIndex; // index of D&D source_panel
- int TargetPanelIndex; // what panel to use as target_panel of Application
-};
-
-class CApp
-{
-public:
- NWindows::CWindow _window;
- bool ShowSystemMenu;
- int NumPanels;
- int LastFocusedPanel;
-
- bool ShowStandardToolbar;
- bool ShowArchiveToolbar;
- bool ShowButtonsLables;
- bool LargeButtons;
-
- CAppState AppState;
- CPanelCallbackImp m_PanelCallbackImp[kNumPanelsMax];
- CPanel Panels[kNumPanelsMax];
- bool PanelsCreated[kNumPanelsMax];
-
- NWindows::NControl::CImageList _archiveButtonsImageList;
- NWindows::NControl::CImageList _standardButtonsImageList;
-
- NWindows::NControl::CReBar _rebar;
- NWindows::NControl::CToolBar _archiveToolBar;
- NWindows::NControl::CToolBar _standardToolBar;
-
- CDropTarget *_dropTargetSpec;
- CMyComPtr<IDropTarget> _dropTarget;
-
- void CreateDragTarget()
- {
- _dropTargetSpec = new CDropTarget();
- _dropTarget = _dropTargetSpec;
- _dropTargetSpec->App = (this);
- }
-
- void SetFocusedPanel(int 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;
- }
-
-
- void OnCopy(bool move, bool copyToSame, int srcPanelIndex);
- void OnSetSameFolder(int srcPanelIndex);
- void OnSetSubFolder(int srcPanelIndex);
-
- void CreateOnePanel(int panelIndex, const UString &mainPath);
- void Create(HWND hwnd, const UString &mainPath, int xSizes[2]);
- void Read();
- void Save();
- void Release();
-
-
- /*
- void SetFocus(int panelIndex)
- { Panels[panelIndex].SetFocusToList(); }
- */
- void SetFocusToLastItem()
- { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); }
-
- int GetFocusedPanelIndex() const { return LastFocusedPanel; }
-
- bool IsPanelVisible(int index) const { return (NumPanels > 1 || index == LastFocusedPanel); }
-
- /*
- void SetCurrentIndex()
- { CurrentPanel = GetFocusedPanelIndex(); }
- */
-
- CApp(): NumPanels(2), LastFocusedPanel(0) {}
- CPanel &GetFocusedPanel()
- { return Panels[GetFocusedPanelIndex()]; }
-
- // File Menu
- void OpenItem()
- { GetFocusedPanel().OpenSelectedItems(true); }
- void OpenItemInside()
- { GetFocusedPanel().OpenFocusedItemAsInternal(); }
- void OpenItemOutside()
- { GetFocusedPanel().OpenSelectedItems(false); }
- void EditItem()
- { GetFocusedPanel().EditItem(); }
- void Rename()
- { GetFocusedPanel().RenameFile(); }
- void CopyTo()
- { OnCopy(false, false, GetFocusedPanelIndex()); }
- void MoveTo()
- { OnCopy(true, false, GetFocusedPanelIndex()); }
- void Delete(bool toRecycleBin)
- { GetFocusedPanel().DeleteItems(toRecycleBin); }
- void CalculateCrc();
- void Split();
- void Combine();
- void Properties()
- { GetFocusedPanel().Properties(); }
- void Comment()
- { GetFocusedPanel().ChangeComment(); }
-
- void CreateFolder()
- { GetFocusedPanel().CreateFolder(); }
- void CreateFile()
- { GetFocusedPanel().CreateFile(); }
-
- // Edit
- void EditCopy()
- { GetFocusedPanel().EditCopy(); }
- void EditPaste()
- { GetFocusedPanel().EditPaste(); }
-
- void SelectAll(bool selectMode)
- { GetFocusedPanel().SelectAll(selectMode); }
- void InvertSelection()
- { GetFocusedPanel().InvertSelection(); }
- void SelectSpec(bool selectMode)
- { GetFocusedPanel().SelectSpec(selectMode); }
- void SelectByType(bool selectMode)
- { GetFocusedPanel().SelectByType(selectMode); }
-
- void RefreshStatusBar()
- { GetFocusedPanel().RefreshStatusBar(); }
-
- void SetListViewMode(UINT32 index)
- { GetFocusedPanel().SetListViewMode(index); }
- UINT32 GetListViewMode()
- { return GetFocusedPanel().GetListViewMode(); }
-
- void SortItemsWithPropID(PROPID propID)
- { GetFocusedPanel().SortItemsWithPropID(propID); }
-
- void OpenRootFolder()
- { GetFocusedPanel().OpenDrivesFolder(); }
- void OpenParentFolder()
- { GetFocusedPanel().OpenParentFolder(); }
- void FoldersHistory()
- { GetFocusedPanel().FoldersHistory(); }
- void RefreshView()
- { GetFocusedPanel().OnReload(); }
- void RefreshAllPanels()
- {
- for (int i = 0; i < NumPanels; i++)
- {
- int index = i;
- if (NumPanels == 1)
- index = LastFocusedPanel;
- Panels[index].OnReload();
- }
- }
- void SetListSettings();
- void SetShowSystemMenu();
- void SwitchOnOffOnePanel();
- bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); }
- void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); }
-
- void OpenBookmark(int index)
- { GetFocusedPanel().OpenBookmark(index); }
- void SetBookmark(int index)
- { GetFocusedPanel().SetBookmark(index); }
-
- void ReloadRebar(HWND hwnd);
- void ReloadToolbars();
- void ReadToolbar()
- {
- UINT32 mask = ReadToolbarsMask();
- ShowButtonsLables = ((mask & 1) != 0);
- LargeButtons = ((mask & 2) != 0);
- ShowStandardToolbar = ((mask & 4) != 0);
- ShowArchiveToolbar = ((mask & 8) != 0);
- }
- void SaveToolbar()
- {
- UINT32 mask = 0;
- if (ShowButtonsLables) mask |= 1;
- if (LargeButtons) mask |= 2;
- if (ShowStandardToolbar) mask |= 4;
- if (ShowArchiveToolbar) mask |= 8;
- 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 OnNotify(int ctrlID, LPNMHDR pnmh);
-};
-
-#endif
diff --git a/7zip/FileManager/EnumFormatEtc.cpp b/7zip/FileManager/EnumFormatEtc.cpp
deleted file mode 100755
index 1fa46918..00000000
--- a/7zip/FileManager/EnumFormatEtc.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// EnumFormatEtc.cpp
-
-#include "StdAfx.h"
-
-#include "EnumFormatEtc.h"
-#include "MyCom2.h"
-
-class CEnumFormatEtc :
- public IEnumFORMATETC,
- public CMyUnknownImp
-{
-public:
- MY_UNKNOWN_IMP1_MT(IEnumFORMATETC)
-
- STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched);
- STDMETHOD(Skip)(ULONG celt);
- STDMETHOD(Reset)(void);
- STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc);
-
- CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats);
- ~CEnumFormatEtc();
-
-private:
- LONG m_RefCount;
- ULONG m_NumFormats;
- FORMATETC *m_Formats;
- ULONG m_Index;
-};
-
-static void DeepCopyFormatEtc(FORMATETC *dest, const FORMATETC *src)
-{
- *dest = *src;
- if(src->ptd)
- {
- dest->ptd = (DVTARGETDEVICE*)CoTaskMemAlloc(sizeof(DVTARGETDEVICE));
- *(dest->ptd) = *(src->ptd);
- }
-}
-
-CEnumFormatEtc::CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats)
-{
- m_RefCount = 1;
- m_Index = 0;
- m_NumFormats = 0;
- m_Formats = new FORMATETC[numFormats];
- if(m_Formats)
- {
- m_NumFormats = numFormats;
- for(ULONG i = 0; i < numFormats; i++)
- DeepCopyFormatEtc(&m_Formats[i], &pFormatEtc[i]);
- }
-}
-
-CEnumFormatEtc::~CEnumFormatEtc()
-{
- if(m_Formats)
- {
- for(ULONG i = 0; i < m_NumFormats; i++)
- if(m_Formats[i].ptd)
- CoTaskMemFree(m_Formats[i].ptd);
- delete[]m_Formats;
- }
-}
-
-STDMETHODIMP CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pceltFetched)
-{
- ULONG copied = 0;
- if(celt == 0 || pFormatEtc == 0)
- return E_INVALIDARG;
- while(m_Index < m_NumFormats && copied < celt)
- {
- DeepCopyFormatEtc(&pFormatEtc[copied], &m_Formats[m_Index]);
- copied++;
- m_Index++;
- }
- if(pceltFetched != 0)
- *pceltFetched = copied;
- return (copied == celt) ? S_OK : S_FALSE;
-}
-
-STDMETHODIMP CEnumFormatEtc::Skip(ULONG celt)
-{
- m_Index += celt;
- return (m_Index <= m_NumFormats) ? S_OK : S_FALSE;
-}
-
-STDMETHODIMP CEnumFormatEtc::Reset(void)
-{
- m_Index = 0;
- return S_OK;
-}
-
-STDMETHODIMP CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc)
-{
- HRESULT hResult = CreateEnumFormatEtc(m_NumFormats, m_Formats, ppEnumFormatEtc);
- if(hResult == S_OK)
- ((CEnumFormatEtc *)*ppEnumFormatEtc)->m_Index = m_Index;
- return hResult;
-}
-
-// replacement for SHCreateStdEnumFmtEtc
-HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat)
-{
- if(numFormats == 0 || formats == 0 || enumFormat == 0)
- return E_INVALIDARG;
- *enumFormat = new CEnumFormatEtc(formats, numFormats);
- return (*enumFormat) ? S_OK : E_OUTOFMEMORY;
-}
diff --git a/7zip/FileManager/ExtractCallback.cpp b/7zip/FileManager/ExtractCallback.cpp
deleted file mode 100755
index 3fd94c00..00000000
--- a/7zip/FileManager/ExtractCallback.cpp
+++ /dev/null
@@ -1,377 +0,0 @@
-// ExtractCallback.h
-
-#include "StdAfx.h"
-
-#include "ExtractCallback.h"
-
-#include "Windows/FileFind.h"
-#include "Windows/FileDir.h"
-#include "Windows/Error.h"
-
-#include "Resource/OverwriteDialog/OverwriteDialog.h"
-#ifndef _NO_CRYPTO
-#include "Resource/PasswordDialog/PasswordDialog.h"
-#endif
-#include "Resource/MessagesDialog/MessagesDialog.h"
-#include "../UI/Resource/Extract/resource.h"
-
-#include "Common/Wildcard.h"
-#include "Common/StringConvert.h"
-
-#include "FormatUtils.h"
-
-#include "../Common/FilePathAutoRename.h"
-
-using namespace NWindows;
-using namespace NFile;
-using namespace NFind;
-
-CExtractCallbackImp::~CExtractCallbackImp()
-{
- if (ShowMessages && !Messages.IsEmpty())
- {
- CMessagesDialog messagesDialog;
- messagesDialog.Messages = &Messages;
- messagesDialog.Create(ParentWindow);
- }
-}
-
-void CExtractCallbackImp::Init()
-{
- Messages.Clear();
- NumArchiveErrors = 0;
-}
-
-void CExtractCallbackImp::AddErrorMessage(LPCWSTR message)
-{
- Messages.Add(message);
-}
-
-STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total)
-{
- ProgressDialog.ProgressSynch.SetProgress(total, 0);
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *completeValue)
-{
- for (;;)
- {
- if(ProgressDialog.ProgressSynch.GetStopped())
- return E_ABORT;
- if(!ProgressDialog.ProgressSynch.GetPaused())
- break;
- ::Sleep(100);
- }
- if (completeValue != NULL)
- ProgressDialog.ProgressSynch.SetPos(*completeValue);
- 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,
- Int32 *answer)
-{
- COverwriteDialog dialog;
-
- dialog.OldFileInfo.Time = *existTime;
- dialog.OldFileInfo.SizeIsDefined = (existSize != NULL);
- if (dialog.OldFileInfo.SizeIsDefined)
- dialog.OldFileInfo.Size = *existSize;
- dialog.OldFileInfo.Name = existName;
-
- if (newTime == 0)
- dialog.NewFileInfo.TimeIsDefined = false;
- else
- {
- dialog.NewFileInfo.TimeIsDefined = true;
- dialog.NewFileInfo.Time = *newTime;
- }
-
- dialog.NewFileInfo.SizeIsDefined = (newSize != NULL);
- if (dialog.NewFileInfo.SizeIsDefined)
- dialog.NewFileInfo.Size = *newSize;
- dialog.NewFileInfo.Name = newName;
-
- /*
- NOverwriteDialog::NResult::EEnum writeAnswer =
- NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
- */
- INT_PTR writeAnswer = dialog.Create(NULL); // 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:
- throw 20413;
- }
- return S_OK;
-}
-
-
-STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 /* askExtractMode */, const UInt64 * /* position */)
-{
- return SetCurrentFilePath(name);
-}
-
-STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
-{
- AddErrorMessage(message);
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *message)
-{
- AddErrorMessage(message);
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool encrypted)
-{
- switch(operationResult)
- {
- case NArchive::NExtract::NOperationResult::kOK:
- break;
- default:
- {
- UINT messageID;
- UInt32 langID;
- switch(operationResult)
- {
- case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
- messageID = IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD;
- langID = 0x02000A91;
- break;
- case NArchive::NExtract::NOperationResult::kDataError:
- 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 ?
- IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED:
- IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC;
- langID = encrypted ? 0x02000A95 : 0x02000A93;
- break;
- default:
- return E_FAIL;
- }
- if (_needWriteArchivePath)
- {
- AddErrorMessage(_currentArchivePath);
- _needWriteArchivePath = false;
- }
- AddErrorMessage(
- MyFormatNew(messageID,
- #ifdef LANG
- langID,
- #endif
- _currentFilePath));
- }
- }
- return S_OK;
-}
-
-////////////////////////////////////////
-// IExtractCallbackUI
-
-HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name)
-{
- #ifndef _SFX
- ProgressDialog.ProgressSynch.SetTitleFileName(name);
- #endif
- _currentArchivePath = name;
- return S_OK;
-}
-
-HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path)
-{
- _currentFilePath = path;
- #ifndef _SFX
- ProgressDialog.ProgressSynch.SetCurrentFileName(path);
- #endif
- return S_OK;
-}
-
-HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result)
-{
- if (result != S_OK)
- {
- MessageError(name + (UString)L" is not supported archive");
- NumArchiveErrors++;
- }
- _currentArchivePath = name;
- _needWriteArchivePath = true;
- return S_OK;
-}
-
-HRESULT CExtractCallbackImp::ThereAreNoFiles()
-{
- return S_OK;
-}
-
-HRESULT CExtractCallbackImp::ExtractResult(HRESULT result)
-{
- if (result == S_OK)
- return result;
- NumArchiveErrors++;
- if (result == E_ABORT || result == ERROR_DISK_FULL)
- return result;
- MessageError(_currentFilePath);
- MessageError(NError::MyFormatMessageW(result));
- return S_OK;
-}
-
-HRESULT CExtractCallbackImp::SetPassword(const UString &password)
-{
- PasswordIsDefined = true;
- Password = password;
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
-{
- 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;
-}
-
-
-// IExtractCallBack3
-STDMETHODIMP CExtractCallbackImp::AskWrite(
- const wchar_t *srcPath, Int32 srcIsFolder,
- const FILETIME *srcTime, const UInt64 *srcSize,
- const wchar_t *destPath,
- BSTR *destPathResult,
- Int32 *writeAnswer)
-{
- UString destPathResultTemp = destPath;
- /*
- {
- CMyComBSTR destPathResultBSTR = destPath;
- *destPathResult = destPathResultBSTR.Detach();
- }
- */
- *destPathResult = 0;
- *writeAnswer = BoolToInt(false);
-
- UString destPathSpec = destPath;
- UString destPathSys = destPathSpec;
- bool srcIsFolderSpec = IntToBool(srcIsFolder);
- CFileInfoW destFileInfo;
- if (FindFile(destPathSys, destFileInfo))
- {
- if (srcIsFolderSpec)
- {
- if (!destFileInfo.IsDirectory())
- {
- UString message = UString(L"can not replace file \'")
- + destPathSpec +
- UString(L"\' with folder with same name");
- RINOK(MessageError(message));
- return E_ABORT;
- }
- *writeAnswer = BoolToInt(false);
- return S_OK;
- }
- if (destFileInfo.IsDirectory())
- {
- UString message = UString(L"can not replace folder \'")
- + destPathSpec +
- UString(L"\' with file with same name");
- RINOK(MessageError(message));
- return E_FAIL;
- }
-
- switch(OverwriteMode)
- {
- case NExtract::NOverwriteMode::kSkipExisting:
- return S_OK;
- case NExtract::NOverwriteMode::kAskBefore:
- {
- Int32 overwiteResult;
- RINOK(AskOverwrite(
- destPathSpec,
- &destFileInfo.LastWriteTime, &destFileInfo.Size,
- srcPath,
- srcTime, srcSize,
- &overwiteResult));
- switch(overwiteResult)
- {
- case NOverwriteAnswer::kCancel:
- return E_ABORT;
- case NOverwriteAnswer::kNo:
- return S_OK;
- case NOverwriteAnswer::kNoToAll:
- OverwriteMode = NExtract::NOverwriteMode::kSkipExisting;
- return S_OK;
- case NOverwriteAnswer::kYesToAll:
- OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
- break;
- case NOverwriteAnswer::kYes:
- break;
- case NOverwriteAnswer::kAutoRename:
- OverwriteMode = NExtract::NOverwriteMode::kAutoRename;
- break;
- default:
- throw 20413;
- }
- }
- }
- if (OverwriteMode == NExtract::NOverwriteMode::kAutoRename)
- {
- if (!AutoRenamePath(destPathSys))
- {
- UString message = UString(L"can not create name of file ")
- + destPathSys;
- RINOK(MessageError(message));
- return E_ABORT;
- }
- destPathResultTemp = destPathSys;
- }
- else
- if (!NFile::NDirectory::DeleteFileAlways(destPathSys))
- {
- UString message = UString(L"can not delete output file ")
- + destPathSys;
- RINOK(MessageError(message));
- return E_ABORT;
- }
- }
- CMyComBSTR destPathResultBSTR = destPathResultTemp;
- *destPathResult = destPathResultBSTR.Detach();
- *writeAnswer = BoolToInt(true);
- return S_OK;
-}
-
diff --git a/7zip/FileManager/ExtractCallback.h b/7zip/FileManager/ExtractCallback.h
deleted file mode 100755
index ee4aa0a0..00000000
--- a/7zip/FileManager/ExtractCallback.h
+++ /dev/null
@@ -1,124 +0,0 @@
-// ExtractCallback.h
-
-#ifndef __EXTRACTCALLBACK_H
-#define __EXTRACTCALLBACK_H
-
-#include "../UI/Agent/IFolderArchive.h"
-#include "Common/String.h"
-
-#ifdef _SFX
-#include "Resource/ProgressDialog/ProgressDialog.h"
-#else
-#include "Resource/ProgressDialog2/ProgressDialog.h"
-#endif
-
-#include "Windows/ResourceString.h"
-
-#ifdef LANG
-#include "LangUtils.h"
-#endif
-
-#ifndef _NO_CRYPTO
-#include "../IPassword.h"
-#endif
-#include "Common/MyCom.h"
-#include "IFolder.h"
-
-class CExtractCallbackImp:
- public IExtractCallbackUI,
- public IFolderOperationsExtractCallback,
- #ifndef _NO_CRYPTO
- public ICryptoGetTextPassword,
- #endif
- public CMyUnknownImp
-{
-public:
- MY_UNKNOWN_IMP3(
- IFolderArchiveExtractCallback,
- IFolderOperationsExtractCallback,
- ICryptoGetTextPassword
- )
-
- // IProgress
- STDMETHOD(SetTotal)(UInt64 total);
- STDMETHOD(SetCompleted)(const UInt64 *completeValue);
-
- // IFolderArchiveExtractCallback
- STDMETHOD(AskOverwrite)(
- const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
- const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
- Int32 *answer);
- STDMETHOD (PrepareOperation)(const wchar_t *name, Int32 askExtractMode, const UInt64 *position);
-
- STDMETHOD(MessageError)(const wchar_t *message);
- STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted);
-
- // IExtractCallbackUI
-
- HRESULT BeforeOpen(const wchar_t *name);
- HRESULT OpenResult(const wchar_t *name, HRESULT result);
- HRESULT ThereAreNoFiles();
- HRESULT ExtractResult(HRESULT result);
-
- #ifndef _NO_CRYPTO
- HRESULT SetPassword(const UString &password);
- #endif
-
- // IFolderOperationsExtractCallback
- STDMETHOD(AskWrite)(
- const wchar_t *srcPath,
- Int32 srcIsFolder,
- const FILETIME *srcTime,
- const UInt64 *srcSize,
- const wchar_t *destPathRequest,
- BSTR *destPathResult,
- Int32 *writeAnswer);
- STDMETHOD(ShowMessage)(const wchar_t *message);
- STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath);
-
- // ICryptoGetTextPassword
- #ifndef _NO_CRYPTO
- STDMETHOD(CryptoGetTextPassword)(BSTR *password);
- #endif
-
-private:
- // bool _extractMode;
- UString _currentArchivePath;
- bool _needWriteArchivePath;
-
- UString _currentFilePath;
-
- // void CreateComplexDirectory(const UStringVector &aDirPathParts);
-
- void AddErrorMessage(LPCWSTR message);
-public:
- CProgressDialog ProgressDialog;
- UStringVector Messages;
- bool ShowMessages;
- HWND ParentWindow;
- INT_PTR StartProgressDialog(const UString &title)
- {
- return ProgressDialog.Create(title, ParentWindow);
- }
- UInt32 NumArchiveErrors;
- NExtract::NOverwriteMode::EEnum OverwriteMode;
-
- #ifndef _NO_CRYPTO
- bool PasswordIsDefined;
- UString Password;
- #endif
-
- CExtractCallbackImp():
- #ifndef _NO_CRYPTO
- PasswordIsDefined(false),
- #endif
- OverwriteMode(NExtract::NOverwriteMode::kAskBefore),
- ParentWindow(0),
- ShowMessages(true)
- {}
-
- ~CExtractCallbackImp();
- void Init();
-};
-
-#endif
diff --git a/7zip/FileManager/FM.cpp b/7zip/FileManager/FM.cpp
deleted file mode 100755
index 95272d2a..00000000
--- a/7zip/FileManager/FM.cpp
+++ /dev/null
@@ -1,729 +0,0 @@
-// FAM.cpp
-
-#include "StdAfx.h"
-
-#include "resource.h"
-#include "Panel.h"
-
-#include "Common/Defs.h"
-#include "Common/StringConvert.h"
-#include "Common/Alloc.h"
-
-#include "Windows/Control/Toolbar.h"
-#include "Windows/Error.h"
-#include "Windows/COM.h"
-#include "Windows/DLL.h"
-#include "Windows/Security.h"
-#include "Windows/MemoryLock.h"
-
-#include "ViewSettings.h"
-
-#include "App.h"
-#include "StringUtils.h"
-
-#include "MyLoadMenu.h"
-#include "LangUtils.h"
-#include "RegistryUtils.h"
-
-using namespace NWindows;
-
-// NWindows::NCOM::CComInitializer aComInitializer;
-
-#define MAX_LOADSTRING 100
-
-#define MENU_HEIGHT 26
-
-#ifndef _UNICODE
-bool g_IsNT = false;
-#endif
-HINSTANCE g_hInstance;
-HWND g_HWND;
-static UString g_MainPath;
-
-const int kNumDefaultPanels = 1;
-
-const int kSplitterWidth = 4;
-int kSplitterRateMax = 1 << 16;
-
-// bool OnMenuCommand(HWND hWnd, int id);
-
-static UString GetProgramPath()
-{
- UString s;
- NDLL::MyGetModuleFileName(g_hInstance, s);
- return s;
-}
-
-UString GetProgramFolderPrefix()
-{
- UString path = GetProgramPath();
- int pos = path.ReverseFind(L'\\');
- return path.Left(pos + 1);
-}
-
-
-class CSplitterPos
-{
- int _ratio; // 10000 is max
- int _pos;
- int _fullWidth;
- void SetRatioFromPos(HWND hWnd)
- { _ratio = (_pos + kSplitterWidth / 2) * kSplitterRateMax /
- MyMax(GetWidth(hWnd), 1); }
-public:
- int GetPos() const
- { return _pos; }
- int GetWidth(HWND hWnd) const
- {
- RECT rect;
- ::GetClientRect(hWnd, &rect);
- return rect.right;
- }
- void SetRatio(HWND hWnd, int 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;
- _pos = pos;
- }
- void SetPos(HWND hWnd, int pos)
- {
- _fullWidth = GetWidth(hWnd);
- SetPosPure(hWnd, pos);
- SetRatioFromPos(hWnd);
- }
- void SetPosFromRatio(HWND hWnd)
- {
- int fullWidth = GetWidth(hWnd);
- if (_fullWidth != fullWidth)
- {
- _fullWidth = fullWidth;
- SetPosPure(hWnd, GetWidth(hWnd) * _ratio / kSplitterRateMax - kSplitterWidth / 2);
- }
- }
-};
-
-bool g_CanChangeSplitter = false;
-UINT32 g_SplitterPos = 0;
-CSplitterPos g_Splitter;
-bool g_PanelsInfoDefined = false;
-
-int g_StartCaptureMousePos;
-int g_StartCaptureSplitterPos;
-
-CApp g_App;
-
-void MoveSubWindows(HWND hWnd);
-void OnSize(HWND hWnd);
-
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-
-const wchar_t *kWindowClass = L"FM";
-
-#ifndef _UNICODE
-static bool IsItWindowsNT()
-{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
-}
-#endif
-
- // FUNCTION: InitInstance(HANDLE, int)
-BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
-{
- CWindow wnd;
-
- g_hInstance = hInstance;
-
- ReloadLangSmart();
-
- // LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING);
-
- // LoadString(hInstance, IDS_APP_TITLE, title, MAX_LOADSTRING);
- UString title = LangString(IDS_APP_TITLE, 0x03000000);
-
- /*
- //If it is already running, then focus on the window
- hWnd = FindWindow(windowClass, title);
- if (hWnd)
- {
- SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));
- return 0;
- }
- */
-
- WNDCLASSW wc;
-
- // wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.style = 0;
- wc.lpfnWndProc = (WNDPROC) WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FAM));
-
- // wc.hCursor = LoadCursor (NULL, IDC_ARROW);
- wc.hCursor = ::LoadCursor(0, IDC_SIZEWE);
- // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
- wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
-
- wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
- wc.lpszClassName = kWindowClass;
-
- MyRegisterClass(&wc);
-
- // RECT rect;
- // GetClientRect(hWnd, &rect);
-
- DWORD style = WS_OVERLAPPEDWINDOW;
- // DWORD style = 0;
-
- RECT rect;
- bool maximized = false;
- int x , y, xSize, ySize;
- x = y = xSize = ySize = CW_USEDEFAULT;
- bool windowPosIsRead = ReadWindowSize(rect, maximized);
-
- if (windowPosIsRead)
- {
- // x = rect.left;
- // y = rect.top;
- xSize = rect.right - rect.left;
- ySize = rect.bottom - rect.top;
- }
-
- UINT32 numPanels, currentPanel;
- g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos);
- if (g_PanelsInfoDefined)
- {
- if (numPanels < 1 || numPanels > 2)
- numPanels = kNumDefaultPanels;
- if (currentPanel >= 2)
- currentPanel = 0;
- }
- else
- {
- numPanels = kNumDefaultPanels;
- currentPanel = 0;
- }
- g_App.NumPanels = numPanels;
- g_App.LastFocusedPanel = currentPanel;
-
- if (!wnd.Create(kWindowClass, title, style,
- x, y, xSize, ySize, NULL, NULL, hInstance, NULL))
- return FALSE;
- g_HWND = (HWND)wnd;
-
- WINDOWPLACEMENT placement;
- placement.length = sizeof(placement);
- if (wnd.GetPlacement(&placement))
- {
- if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
- nCmdShow == SW_SHOWDEFAULT)
- {
- if (maximized)
- placement.showCmd = SW_SHOWMAXIMIZED;
- else
- placement.showCmd = SW_SHOWNORMAL;
- }
- else
- placement.showCmd = nCmdShow;
- if (windowPosIsRead)
- placement.rcNormalPosition = rect;
- wnd.SetPlacement(&placement);
- // window.Show(nCmdShow);
- }
- else
- wnd.Show(nCmdShow);
- return TRUE;
-}
-
-/*
-static void GetCommands(const UString &aCommandLine, UString &aCommands)
-{
- UString aProgramName;
- aCommands.Empty();
- bool aQuoteMode = false;
- for (int i = 0; i < aCommandLine.Length(); i++)
- {
- wchar_t aChar = aCommandLine[i];
- if (aChar == L'\"')
- aQuoteMode = !aQuoteMode;
- else if (aChar == L' ' && !aQuoteMode)
- {
- if (!aQuoteMode)
- {
- i++;
- break;
- }
- }
- else
- aProgramName += aChar;
- }
- aCommands = aCommandLine.Mid(i);
-}
-*/
-
-DWORD GetDllVersion(LPCTSTR lpszDllName)
-{
- HINSTANCE hinstDll;
- DWORD dwVersion = 0;
- hinstDll = LoadLibrary(lpszDllName);
- if(hinstDll)
- {
- DLLGETVERSIONPROC pDllGetVersion;
- pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
-
- /*Because some DLLs might not implement this function, you
- must test for it explicitly. Depending on the particular
- DLL, the lack of a DllGetVersion function can be a useful
- indicator of the version.
- */
- if(pDllGetVersion)
- {
- DLLVERSIONINFO dvi;
- HRESULT hr;
-
- ZeroMemory(&dvi, sizeof(dvi));
- dvi.cbSize = sizeof(dvi);
-
- hr = (*pDllGetVersion)(&dvi);
-
- if(SUCCEEDED(hr))
- {
- dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
- }
- }
- FreeLibrary(hinstDll);
- }
- return dwVersion;
-}
-
-DWORD g_ComCtl32Version;
-
-/*
-#ifndef _WIN64
-typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
-
-static bool IsWow64()
-{
- LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
- GetModuleHandle("kernel32"), "IsWow64Process");
- if (fnIsWow64Process == NULL)
- return false;
- BOOL isWow;
- if (!fnIsWow64Process(GetCurrentProcess(),&isWow))
- return false;
- return isWow != FALSE;
-}
-#endif
-*/
-
-bool IsLargePageSupported()
-{
- #ifdef _WIN64
- return true;
- #else
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 5)
- return false;
- if (versionInfo.dwMajorVersion > 5)
- return true;
- if (versionInfo.dwMinorVersion < 1)
- return false;
- if (versionInfo.dwMinorVersion > 1)
- return true;
- // return IsWow64();
- return false;
- #endif
-}
-
-static void SetMemoryLock()
-{
- if (!IsLargePageSupported())
- return;
- // if (ReadLockMemoryAdd())
- NSecurity::AddLockMemoryPrivilege();
-
- if (ReadLockMemoryEnable())
- NSecurity::EnableLockMemoryPrivilege();
-}
-
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int nCmdShow)
-{
- #ifndef _UNICODE
- g_IsNT = IsItWindowsNT();
- #endif
-
- #ifdef _WIN32
- SetLargePageSize();
- #endif
-
- InitCommonControls();
-
- g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
-
- // OleInitialize is required for drag and drop.
- OleInitialize(NULL);
- // Maybe needs CoInitializeEx also ?
- // NCOM::CComInitializer comInitializer;
-
- UString programString, commandsString;
- // MessageBoxW(0, GetCommandLineW(), L"", 0);
- SplitStringToTwoStrings(GetCommandLineW(), programString, commandsString);
-
- commandsString.Trim();
- UString paramString, tailString;
- SplitStringToTwoStrings(commandsString, paramString, tailString);
- paramString.Trim();
-
- if (!paramString.IsEmpty())
- {
- g_MainPath = paramString;
- // MessageBoxW(0, paramString, L"", 0);
- }
-
- SetMemoryLock();
-
- MSG msg;
- if (!InitInstance (hInstance, nCmdShow))
- return FALSE;
-
- MyLoadMenu(g_HWND);
-
- #ifndef _UNICODE
- if (g_IsNT)
- {
- HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
- while (GetMessageW(&msg, NULL, 0, 0))
- {
- if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
- {
- TranslateMessage(&msg);
- DispatchMessageW(&msg);
- }
- }
- }
- else
- #endif
- {
- HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
- while (GetMessage(&msg, NULL, 0, 0))
- {
- if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
- {
- // if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
- // if (!IsDialogMessage(g_Hwnd, &msg))
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- }
-
- g_HWND = 0;
- OleUninitialize();
- return (int)msg.wParam;
-}
-
-static void SaveWindowInfo(HWND aWnd)
-{
- /*
- RECT rect;
- if (!::GetWindowRect(aWnd, &rect))
- return;
- */
- WINDOWPLACEMENT placement;
- placement.length = sizeof(placement);
- if (!::GetWindowPlacement(aWnd, &placement))
- return;
- SaveWindowSize(placement.rcNormalPosition,
- BOOLToBool(::IsZoomed(aWnd)));
- SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel,
- g_Splitter.GetPos());
-}
-
-void ExecuteCommand(UINT commandID)
-{
- switch (commandID)
- {
- case kAddCommand:
- g_App.AddToArchive();
- break;
- case kExtractCommand:
- g_App.ExtractArchives();
- break;
- case kTestCommand:
- g_App.TestArchives();
- break;
- }
-}
-
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- int wmId, wmEvent;
- switch (message)
- {
- case WM_COMMAND:
- wmId = LOWORD(wParam);
- wmEvent = HIWORD(wParam);
- if ((HWND) lParam != NULL && wmEvent != 0)
- break;
- if (wmId >= kToolbarStartID)
- {
- ExecuteCommand(wmId);
- return 0;
- }
- if (OnMenuCommand(hWnd, wmId))
- return 0;
- break;
- case WM_INITMENUPOPUP:
- OnMenuActivating(hWnd, HMENU(wParam), LOWORD(lParam));
- break;
-
- /*
- It doesn't help
- case WM_EXITMENULOOP:
- {
- OnMenuUnActivating(hWnd);
- break;
- }
- case WM_UNINITMENUPOPUP:
- OnMenuUnActivating(hWnd, HMENU(wParam), lParam);
- break;
- */
-
- case WM_CREATE:
- {
-
- /*
- INITCOMMONCONTROLSEX icex;
- icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
- icex.dwICC = ICC_BAR_CLASSES;
- InitCommonControlsEx(&icex);
-
- // Toolbar buttons used to create the first 4 buttons.
- TBBUTTON tbb [ ] =
- {
- // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
- // {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
- // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
- {VIEW_NEWFOLDER, ID_FILE_CREATEFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
- };
-
- 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]),
- 0, 0, 100, 30, sizeof (TBBUTTON)));
- */
- // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
- // ::SetCursor(cursor);
-
- if (g_PanelsInfoDefined)
- g_Splitter.SetPos(hWnd, g_SplitterPos);
- else
- {
- g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
- g_SplitterPos = g_Splitter.GetPos();
- }
-
- RECT rect;
- ::GetClientRect(hWnd, &rect);
- int xSize = rect.right;
- int xSizes[2];
- xSizes[0] = g_Splitter.GetPos();
- xSizes[1] = xSize - kSplitterWidth - xSizes[0];
- if (xSizes[1] < 0)
- xSizes[1] = 0;
-
- g_App.CreateDragTarget();
- g_App.Create(hWnd, g_MainPath, xSizes);
- // g_SplitterPos = 0;
-
- // ::DragAcceptFiles(hWnd, TRUE);
- RegisterDragDrop(hWnd, g_App._dropTarget);
-
- break;
- }
- case WM_DESTROY:
- {
- // ::DragAcceptFiles(hWnd, FALSE);
- RevokeDragDrop(hWnd);
- g_App._dropTarget.Release();
-
- g_App.Save();
- g_App.Release();
- SaveWindowInfo(hWnd);
- PostQuitMessage(0);
- break;
- }
- /*
- case WM_MOVE:
- {
- break;
- }
- */
- case WM_LBUTTONDOWN:
- g_StartCaptureMousePos = LOWORD(lParam);
- g_StartCaptureSplitterPos = g_Splitter.GetPos();
- ::SetCapture(hWnd);
- break;
- case WM_LBUTTONUP:
- {
- ::ReleaseCapture();
- break;
- }
- case WM_MOUSEMOVE:
- {
- if ((wParam & MK_LBUTTON) != 0 && ::GetCapture() == hWnd)
- {
- g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos +
- (short)LOWORD(lParam) - g_StartCaptureMousePos);
- MoveSubWindows(hWnd);
- }
- break;
- }
-
- case WM_SIZE:
- {
- if (g_CanChangeSplitter)
- g_Splitter.SetPosFromRatio(hWnd);
- else
- {
- g_Splitter.SetPos(hWnd, g_SplitterPos );
- g_CanChangeSplitter = true;
- }
-
- OnSize(hWnd);
- /*
- int xSize = LOWORD(lParam);
- int ySize = HIWORD(lParam);
- // int xSplitter = 2;
- int xWidth = g_SplitPos;
- // int xSplitPos = xWidth;
- g_Panel[0]._listView.MoveWindow(0, 0, xWidth, ySize);
- g_Panel[1]._listView.MoveWindow(xSize - xWidth, 0, xWidth, ySize);
- */
- return 0;
- break;
- }
- case WM_SETFOCUS:
- // g_App.SetFocus(g_App.LastFocusedPanel);
- g_App.SetFocusToLastItem();
- break;
- /*
- case WM_ACTIVATE:
- {
- int fActive = LOWORD(wParam);
- switch (fActive)
- {
- case WA_INACTIVE:
- {
- // g_FocusIndex = g_App.LastFocusedPanel;
- // g_App.LastFocusedPanel = g_App.GetFocusedPanelIndex();
- // return 0;
- }
- }
- break;
- }
- */
- /*
- case kLangWasChangedMessage:
- MyLoadMenu(g_HWND);
- return 0;
- */
-
- /*
- case WM_SETTINGCHANGE:
- break;
- */
- case WM_NOTIFY:
- {
- g_App.OnNotify((int)wParam, (LPNMHDR)lParam);
- break;
- }
- /*
- case WM_DROPFILES:
- {
- g_App.GetFocusedPanel().CompressDropFiles((HDROP)wParam);
- return 0 ;
- }
- */
- }
- #ifndef _UNICODE
- if (g_IsNT)
- return DefWindowProcW(hWnd, message, wParam, lParam);
- else
- #endif
- return DefWindowProc(hWnd, message, wParam, lParam);
-
-}
-
-void OnSize(HWND hWnd)
-{
- /*
- if (g_App._rebar)
- {
- RECT rect;
- ::GetClientRect(hWnd, &rect);
- int xSize = rect.right;
- int ySize = rect.bottom;
- // rect.bottom = 0;
- // g_App._rebar.SizeToRect(&rect);
- // g_App._rebar.Move(0, 0, xSize, ySize);
- }
- */
- MoveSubWindows(hWnd);
-}
-
-void MoveSubWindows(HWND hWnd)
-{
- RECT rect;
- ::GetClientRect(hWnd, &rect);
- int xSize = rect.right;
- int kHeaderSize = 0;
- int ySize = MyMax(int(rect.bottom - kHeaderSize), 0);
- if (g_App._rebar)
- {
- RECT barRect;
- g_App._rebar.GetWindowRect(&barRect);
- kHeaderSize = barRect.bottom - barRect.top;
- ySize = MyMax(int(rect.bottom - kHeaderSize), 0);
- }
-
- // g_App._headerToolBar.Move(0, 2, xSize, kHeaderSize - 2);
- RECT rect2 = rect;
- rect2.bottom = 0;
- // g_App._headerReBar.SizeToRect(&rect2);
- if (g_App.NumPanels > 1)
- {
- g_App.Panels[0].Move(0, kHeaderSize, g_Splitter.GetPos(), ySize);
- int xWidth1 = g_Splitter.GetPos() + kSplitterWidth;
- g_App.Panels[1].Move(xWidth1, kHeaderSize, xSize - xWidth1, ySize);
- }
- else
- {
- /*
- int otherPanel = 1 - g_App.LastFocusedPanel;
- if (g_App.PanelsCreated[otherPanel])
- g_App.Panels[otherPanel].Move(0, kHeaderSize, 0, ySize);
- */
- g_App.Panels[g_App.LastFocusedPanel].Move(0, kHeaderSize, xSize, ySize);
- }
-}
diff --git a/7zip/FileManager/FM.dsp b/7zip/FileManager/FM.dsp
deleted file mode 100755
index 9dc279a2..00000000
--- a/7zip/FileManager/FM.dsp
+++ /dev/null
@@ -1,1230 +0,0 @@
-# Microsoft Developer Studio Project File - Name="FM" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=FM - Win32 DebugU
-!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 "FM.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 "FM.mak" CFG="FM - Win32 DebugU"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "FM - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "FM - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE "FM - Win32 ReleaseU" (based on "Win32 (x86) Application")
-!MESSAGE "FM - Win32 DebugU" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "FM - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /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 /subsystem:windows /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 comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "FM - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /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 /subsystem:windows /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 comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ReleaseU"
-# PROP BASE Intermediate_Dir "ReleaseU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ReleaseU"
-# PROP Intermediate_Dir "ReleaseU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /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 comctl32.lib /nologo /subsystem:windows /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 comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-ZIP\7zFMn.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "FM - Win32 DebugU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "DebugU"
-# PROP BASE Intermediate_Dir "DebugU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "DebugU"
-# PROP Intermediate_Dir "DebugU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /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 comctl32.lib /nologo /subsystem:windows /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 comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7zFMn.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "FM - Win32 Release"
-# Name "FM - Win32 Debug"
-# Name "FM - Win32 ReleaseU"
-# Name "FM - Win32 DebugU"
-# Begin Group "Spec"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Resource\AboutDialog\7zipLogo.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\add.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ClassDefs.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Copy.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Delete.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Extract.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FM.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\Move.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Parent.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Properties.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\resource.rc
-# ADD BASE RSC /l 0x419
-# ADD RSC /l 0x409
-# 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
-# Begin Source File
-
-SOURCE=.\Test.bmp
-# End Source File
-# End Group
-# Begin Group "Archive Interfaces"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Archive\IArchive.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Agent\IFolderArchive.h
-# End Source File
-# End Group
-# Begin Group "Folders"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\FSDrives.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FSDrives.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FSFolder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FSFolder.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FSFolderCopy.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\IFolder.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\NetFolder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\NetFolder.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PhysDriveFolder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PhysDriveFolder.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\RootFolder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\RootFolder.h
-# End Source File
-# End Group
-# Begin Group "Registry"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\RegistryAssociations.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\RegistryAssociations.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\RegistryPlugins.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\RegistryPlugins.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\RegistryUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\RegistryUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ViewSettings.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ViewSettings.h
-# End Source File
-# End Group
-# Begin Group "Panel"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\App.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\App.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\AppState.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\EnumFormatEtc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\EnumFormatEtc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FileFolderPluginOpen.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FileFolderPluginOpen.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Panel.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Panel.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelCopy.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelCrc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelDrag.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelFolderChange.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelItemOpen.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelItems.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelKey.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelListNotify.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelMenu.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelOperations.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelSelect.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelSort.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PanelSplitFile.cpp
-# End Source File
-# End Group
-# Begin Group "Dialog"
-
-# PROP Default_Filter ""
-# Begin Group "Options"
-
-# PROP Default_Filter ""
-# Begin Group "Settings"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Resource\SettingsPage\SettingsPage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\SettingsPage\SettingsPage.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\Resource\EditPage\EditPage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\EditPage\EditPage.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\LangPage\LangPage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\LangPage\LangPage.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\PluginsPage\PluginsPage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\PluginsPage\PluginsPage.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\SystemPage\SystemPage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\SystemPage\SystemPage.h
-# End Source File
-# End Group
-# Begin Group "Password"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=Resource\PasswordDialog\PasswordDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=Resource\PasswordDialog\PasswordDialog.h
-# End Source File
-# End Group
-# Begin Group "Progress"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Resource\ProgressDialog2\ProgressDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\ProgressDialog2\ProgressDialog.h
-# End Source File
-# End Group
-# Begin Group "About"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Resource\AboutDialog\AboutDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\AboutDialog\AboutDialog.h
-# End Source File
-# End Group
-# Begin Group "Benchmark"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Resource\BenchmarkDialog\BenchmarkDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\BenchmarkDialog\BenchmarkDialog.h
-# End Source File
-# End Group
-# Begin Group "Split"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Resource\SplitDialog\SplitDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\SplitDialog\SplitDialog.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\Resource\ComboDialog\ComboDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\ComboDialog\ComboDialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\CopyDialog\CopyDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\CopyDialog\CopyDialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\ListViewDialog\ListViewDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\ListViewDialog\ListViewDialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=Resource\MessagesDialog\MessagesDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=Resource\MessagesDialog\MessagesDialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=Resource\OverwriteDialog\OverwriteDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=Resource\OverwriteDialog\OverwriteDialog.h
-# End Source File
-# End Group
-# Begin Group "FM Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ExtractCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ExtractCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FormatUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FormatUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\HelpUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\HelpUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\LangUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\LangUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ProgramLocation.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ProgramLocation.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\UpdateCallback100.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\UpdateCallback100.h
-# End Source File
-# End Group
-# Begin Group "SDK"
-
-# PROP Default_Filter ""
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# Begin Group "Control"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\ComboBox.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\ComboBox.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\CommandBar.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\Dialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\Dialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\Edit.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\ImageList.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\ProgressBar.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\PropertyPage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\PropertyPage.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\ReBar.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\Static.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\StatusBar.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\ToolBar.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\Trackbar.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\Window2.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Control\Window2.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\..\Windows\CommonDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\CommonDialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Defs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Device.h
-# End Source File
-# 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\Error.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Error.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\FileDevice.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\FileDevice.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.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\FileName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\FileSystem.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\FileSystem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Handle.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Memory.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Memory.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\MemoryLock.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\MemoryLock.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Menu.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Menu.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Net.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Net.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Process.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\PropVariantConversions.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\PropVariantConversions.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Registry.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Registry.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\ResourceString.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\ResourceString.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Security.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Security.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Shell.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Shell.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\Thread.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Time.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Timer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Window.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Windows\Window.h
-# End Source File
-# End Group
-# Begin Group "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Buffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\ComTry.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\CRC.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Defs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\DynamicBuffer.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Exception.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\Lang.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Lang.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\MyCom.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\Random.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Random.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\StdInStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\StdInStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\StdOutStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\StdOutStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\String.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\String.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
-# Begin Source File
-
-SOURCE=..\..\Common\TextConfig.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\TextConfig.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Types.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\UTFConvert.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\UTFConvert.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Vector.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Vector.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Wildcard.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\Wildcard.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "UI Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\UI\Common\ArchiveName.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\ArchiveName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\CompressCall.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\CompressCall.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\PropIDUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\PropIDUtils.h
-# End Source File
-# End Group
-# Begin Group "7-Zip Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Common\FilePathAutoRename.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\FilePathAutoRename.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\FileStreams.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\FileStreams.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\StreamObjects.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\StreamObjects.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\7zFM.exe.manifest
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zipLogo.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\Add2.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Copy2.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Delete2.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Extract2.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FilePlugins.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FilePlugins.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FM.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Info.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Info2.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Move2.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\MyCom2.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\MyLoadMenu.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\MyLoadMenu.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\OpenCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\OpenCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\OptionsDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PluginInterface.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PluginLoader.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropertyName.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PropertyName.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\resource.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\SplitUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\SplitUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\StringUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\StringUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\SysIconUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\SysIconUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Test2.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\TextPairs.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\TextPairs.h
-# End Source File
-# End Target
-# End Project
diff --git a/7zip/FileManager/FSFolder.cpp b/7zip/FileManager/FSFolder.cpp
deleted file mode 100755
index 40f04d1b..00000000
--- a/7zip/FileManager/FSFolder.cpp
+++ /dev/null
@@ -1,634 +0,0 @@
-// FSFolder.cpp
-
-#include "StdAfx.h"
-
-#include "FSFolder.h"
-
-#include "Common/StringConvert.h"
-#include "Common/StdInStream.h"
-#include "Common/StdOutStream.h"
-#include "Common/UTFConvert.h"
-
-#include "Windows/Defs.h"
-#include "Windows/PropVariant.h"
-#include "Windows/FileDir.h"
-#include "Windows/FileIO.h"
-
-#include "../PropID.h"
-
-#include "SysIconUtils.h"
-#include "FSDrives.h"
-#include "NetFolder.h"
-
-using namespace NWindows;
-using namespace NFile;
-using namespace NFind;
-
-static STATPROPSTG kProperties[] =
-{
- { NULL, kpidName, VT_BSTR},
- // { NULL, kpidIsFolder, 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, kpidComment, VT_BSTR},
- { NULL, kpidPrefix, VT_BSTR}
-};
-
-HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
-{
- _parentFolder = parentFolder;
- _path = path;
-
- _findChangeNotificationDefined = false;
-
- if (_findChangeNotification.FindFirst(_path, false,
- FILE_NOTIFY_CHANGE_FILE_NAME |
- FILE_NOTIFY_CHANGE_DIR_NAME |
- FILE_NOTIFY_CHANGE_ATTRIBUTES |
- FILE_NOTIFY_CHANGE_SIZE |
- FILE_NOTIFY_CHANGE_LAST_WRITE /*|
- FILE_NOTIFY_CHANGE_LAST_ACCESS |
- FILE_NOTIFY_CHANGE_CREATION |
- FILE_NOTIFY_CHANGE_SECURITY */) == INVALID_HANDLE_VALUE)
- {
- DWORD lastError = GetLastError();
- // return GetLastError();
- CFindFile findFile;
- CFileInfoW fileInfo;
- if (!findFile.FindFirst(_path + UString(L"*"), fileInfo))
- return lastError;
- _findChangeNotificationDefined = false;
- }
- else
- _findChangeNotificationDefined = true;
-
- return S_OK;
-}
-
-static HRESULT GetFolderSize(const UString &path, UInt64 &size, IProgress *progress)
-{
- RINOK(progress->SetCompleted(NULL));
- size = 0;
- CEnumeratorW enumerator(path + UString(L"\\*"));
- CFileInfoW fileInfo;
- while (enumerator.Next(fileInfo))
- {
- if (fileInfo.IsDirectory())
- {
- UInt64 subSize;
- RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subSize, progress));
- size += subSize;
- }
- else
- size += fileInfo.Size;
- }
- return S_OK;
-}
-
-HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
-{
- {
- CEnumeratorW enumerator(path + L"*");
- CDirItem fileInfo;
- while (enumerator.Next(fileInfo))
- {
- fileInfo.CompressedSizeIsDefined = false;
- /*
- if (!GetCompressedFileSize(_path + fileInfo.Name,
- fileInfo.CompressedSize))
- fileInfo.CompressedSize = fileInfo.Size;
- */
- if (fileInfo.IsDirectory())
- {
- // fileInfo.Size = GetFolderSize(_path + fileInfo.Name);
- fileInfo.Size = 0;
- }
- dirItem.Files.Add(fileInfo);
- }
- }
- if (!_flatMode)
- return S_OK;
-
- for (int i = 0; i < dirItem.Files.Size(); i++)
- {
- CDirItem &item = dirItem.Files[i];
- if (item.IsDirectory())
- LoadSubItems(item, path + item.Name + L'\\');
- }
- return S_OK;
-}
-
-void CFSFolder::AddRefs(CDirItem &dirItem)
-{
- int i;
- for (i = 0; i < dirItem.Files.Size(); i++)
- {
- CDirItem &item = dirItem.Files[i];
- item.Parent = &dirItem;
- _refs.Add(&item);
- }
- if (!_flatMode)
- return;
- for (i = 0; i < dirItem.Files.Size(); i++)
- {
- CDirItem &item = dirItem.Files[i];
- if (item.IsDirectory())
- AddRefs(item);
- }
-}
-
-STDMETHODIMP CFSFolder::LoadItems()
-{
- // OutputDebugString(TEXT("Start\n"));
- INT32 dummy;
- WasChanged(&dummy);
- Clear();
- RINOK(LoadSubItems(_root, _path));
- AddRefs(_root);
-
- // OutputDebugString(TEXT("Finish\n"));
- _commentsAreLoaded = false;
- return S_OK;
-}
-
-static const wchar_t *kDescriptionFileName = L"descript.ion";
-
-bool CFSFolder::LoadComments()
-{
- if (_commentsAreLoaded)
- return true;
- _comments.Clear();
- _commentsAreLoaded = true;
- NIO::CInFile file;
- if (!file.Open(_path + kDescriptionFileName))
- return false;
- UInt64 length;
- if (!file.GetLength(length))
- return false;
- if (length >= (1 << 28))
- return false;
- AString s;
- char *p = s.GetBuffer((int)((size_t)length + 1));
- UInt32 processedSize;
- file.Read(p, (UInt32)length, processedSize);
- p[length] = 0;
- s.ReleaseBuffer();
- s.Replace("\r\n", "\n");
- if (processedSize != length)
- return false;
- file.Close();
- UString unicodeString;
- if (!ConvertUTF8ToUnicode(s, unicodeString))
- return false;
- return _comments.ReadFromString(unicodeString);
-}
-
-static bool IsAscii(const UString &testString)
-{
- for (int i = 0; i < testString.Length(); i++)
- if (testString[i] >= 0x80)
- return false;
- return true;
-}
-
-bool CFSFolder::SaveComments()
-{
- NIO::COutFile file;
- if (!file.Create(_path + kDescriptionFileName, true))
- return false;
- UString unicodeString;
- _comments.SaveToString(unicodeString);
- AString utfString;
- ConvertUnicodeToUTF8(unicodeString, utfString);
- UInt32 processedSize;
- if (!IsAscii(unicodeString))
- {
- Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A };
- file.Write(bom , sizeof(bom), processedSize);
- }
- utfString.Replace("\n", "\r\n");
- file.Write(utfString, utfString.Length(), processedSize);
- _commentsAreLoaded = false;
- return true;
-}
-
-STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems)
-{
- *numItems = _refs.Size();
- return S_OK;
-}
-
-/*
-STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
-{
- UInt32 numSubFoldersLoc = 0;
- for (int i = 0; i < _files.Size(); i++)
- if (_files[i].IsDirectory())
- numSubFoldersLoc++;
- *numSubFolders = numSubFoldersLoc;
- return S_OK;
-}
-*/
-
-STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
-{
- NCOM::CPropVariant propVariant;
- 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:
- if (!fileInfo.CompressedSizeIsDefined)
- {
- fileInfo.CompressedSizeIsDefined = true;
- if (fileInfo.IsDirectory () ||
- !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;
- break;
- case kpidComment:
- {
- LoadComments();
- UString comment;
- if (_comments.GetValue(GetRelPath(fileInfo), comment))
- propVariant = comment;
- break;
- }
- case kpidPrefix:
- {
- if (_flatMode)
- {
- propVariant = GetPrefix(fileInfo);
- }
- break;
- }
- }
- propVariant.Detach(value);
- return S_OK;
-}
-
-HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
-{
- *resultFolder = 0;
- CFSFolder *folderSpec = new CFSFolder;
- CMyComPtr<IFolderFolder> subFolder = folderSpec;
- RINOK(folderSpec->Init(_path + name + UString(L'\\'), 0));
- *resultFolder = subFolder.Detach();
- return S_OK;
-}
-
-UString CFSFolder::GetPrefix(const CDirItem &item) const
-{
- UString path;
- CDirItem *cur = item.Parent;
- while (cur->Parent != 0)
- {
- path = cur->Name + UString('\\') + path;
- cur = cur->Parent;
- }
- return path;
-}
-
-UString CFSFolder::GetRelPath(const CDirItem &item) const
-{
- return GetPrefix(item) + item.Name;
-}
-
-STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
-{
- *resultFolder = 0;
- const CDirItem &fileInfo = *_refs[index];
- if (!fileInfo.IsDirectory())
- return E_INVALIDARG;
- return BindToFolderSpec(GetRelPath(fileInfo), resultFolder);
-}
-
-STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
-{
- return BindToFolderSpec(name, resultFolder);
-}
-
-STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
-{
- *resultFolder = 0;
- if (_parentFolder)
- {
- CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
- *resultFolder = parentFolder.Detach();
- return S_OK;
- }
- if (_path.IsEmpty())
- return E_INVALIDARG;
- int pos = _path.ReverseFind(L'\\');
- if (pos < 0 || pos != _path.Length() - 1)
- return E_FAIL;
- UString parentPath = _path.Left(pos);
- pos = parentPath.ReverseFind(L'\\');
- if (pos < 0)
- {
- parentPath.Empty();
- CFSDrives *drivesFolderSpec = new CFSDrives;
- CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
- drivesFolderSpec->Init();
- *resultFolder = drivesFolder.Detach();
- return S_OK;
- }
- UString parentPathReduced = parentPath.Left(pos);
- parentPath = parentPath.Left(pos + 1);
- pos = parentPathReduced.ReverseFind(L'\\');
- if (pos == 1)
- {
- if (parentPath[0] != L'\\')
- return E_FAIL;
- CNetFolder *netFolderSpec = new CNetFolder;
- CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
- netFolderSpec->Init(parentPath);
- *resultFolder = netFolder.Detach();
- return S_OK;
- }
- CFSFolder *parentFolderSpec = new CFSFolder;
- CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
- RINOK(parentFolderSpec->Init(parentPath, 0));
- *resultFolder = parentFolder.Detach();
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::GetName(BSTR * /* name */)
-{
- return E_NOTIMPL;
- /*
- CMyComBSTR aBSTRName = m_ProxyFolderItem->m_Name;
- *name = aBSTRName.Detach();
- return S_OK;
- */
-}
-
-STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties)
-{
- *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
- if (!_flatMode)
- (*numProperties)--;
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
- return E_INVALIDARG;
- const STATPROPSTG &prop = kProperties[index];
- *propID = prop.propid;
- *varType = prop.vt;
- *name = 0;
- return S_OK;
-}
-
-
-STDMETHODIMP CFSFolder::GetTypeID(BSTR *name)
-{
- CMyComBSTR temp = L"FSFolder";
- *name = temp.Detach();
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::GetPath(BSTR *path)
-{
- CMyComBSTR temp = _path;
- *path = temp.Detach();
- return S_OK;
-}
-
-
-STDMETHODIMP CFSFolder::WasChanged(INT32 *wasChanged)
-{
- bool wasChangedMain = false;
- for (;;)
- {
- if (!_findChangeNotificationDefined)
- {
- *wasChanged = BoolToInt(false);
- return S_OK;
- }
-
- DWORD waitResult = ::WaitForSingleObject(_findChangeNotification, 0);
- bool wasChangedLoc = (waitResult == WAIT_OBJECT_0);
- if (wasChangedLoc)
- {
- _findChangeNotification.FindNext();
- wasChangedMain = true;
- }
- else
- break;
- }
- *wasChanged = BoolToInt(wasChangedMain);
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
-{
- CFSFolder *fsFolderSpec = new CFSFolder;
- CMyComPtr<IFolderFolder> folderNew = fsFolderSpec;
- fsFolderSpec->Init(_path, 0);
- *resultFolder = folderNew.Detach();
- return S_OK;
-}
-
-HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
-{
- const CDirItem &fileInfo = *_refs[index];
- if (fileInfo.IsDirectory())
- {
- /*
- CMyComPtr<IFolderFolder> subFolder;
- RINOK(BindToFolder(index, &subFolder));
- CMyComPtr<IFolderReload> aFolderReload;
- subFolder.QueryInterface(&aFolderReload);
- aFolderReload->Reload();
- UInt32 numItems;
- RINOK(subFolder->GetNumberOfItems(&numItems));
- CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize;
- subFolder.QueryInterface(&aGetItemFullSize);
- for (UInt32 i = 0; i < numItems; i++)
- {
- UInt64 size;
- RINOK(aGetItemFullSize->GetItemFullSize(i, &size));
- *totalSize += size;
- }
- */
- return GetFolderSize(_path + GetRelPath(fileInfo), size, progress);
- }
- size = fileInfo.Size;
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
-{
- NCOM::CPropVariant propVariant;
- if (index >= (UInt32)_refs.Size())
- return E_INVALIDARG;
- UInt64 size = 0;
- HRESULT result = GetItemFullSize(index, size, progress);
- propVariant = size;
- propVariant.Detach(value);
- return result;
-}
-
-HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
-{
- UString newName = name;
- resultPath = _path + newName;
- if (newName.Length() < 1)
- return S_OK;
- if (newName[0] == L'\\')
- {
- resultPath = newName;
- return S_OK;
- }
- if (newName.Length() < 2)
- return S_OK;
- if (newName[1] == L':')
- resultPath = newName;
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */)
-{
- UString processedName;
- RINOK(GetComplexName(name, processedName));
- if(NDirectory::MyCreateDirectory(processedName))
- return S_OK;
- if(::GetLastError() == ERROR_ALREADY_EXISTS)
- return ::GetLastError();
- if (!NDirectory::CreateComplexDirectory(processedName))
- return ::GetLastError();
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */)
-{
- UString processedName;
- RINOK(GetComplexName(name, processedName));
- NIO::COutFile outFile;
- if (!outFile.Create(processedName, false))
- return ::GetLastError();
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */)
-{
- const CDirItem &fileInfo = *_refs[index];
- const UString fullPrefix = _path + GetPrefix(fileInfo);
- if (!NDirectory::MyMoveFile(fullPrefix + fileInfo.Name, fullPrefix + newName))
- return GetLastError();
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress)
-{
- RINOK(progress->SetTotal(numItems));
- for (UInt32 i = 0; i < numItems; i++)
- {
- const CDirItem &fileInfo = *_refs[indices[i]];
- const UString fullPath = _path + GetRelPath(fileInfo);
- bool result;
- if (fileInfo.IsDirectory())
- result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
- else
- result = NDirectory::DeleteFileAlways(fullPath);
- if (!result)
- return GetLastError();
- UInt64 completed = i;
- RINOK(progress->SetCompleted(&completed));
- }
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
- const PROPVARIANT *value, IProgress * /* progress */)
-{
- if (index >= (UInt32)_refs.Size())
- return E_INVALIDARG;
- CDirItem &fileInfo = *_refs[index];
- if (fileInfo.Parent->Parent != 0)
- return E_NOTIMPL;
- switch(propID)
- {
- case kpidComment:
- {
- UString filename = fileInfo.Name;
- filename.Trim();
- if (value->vt == VT_EMPTY)
- _comments.DeletePair(filename);
- else if (value->vt == VT_BSTR)
- {
- CTextPair pair;
- pair.ID = filename;
- pair.ID.Trim();
- pair.Value = value->bstrVal;
- pair.Value.Trim();
- if (pair.Value.IsEmpty())
- _comments.DeletePair(filename);
- else
- _comments.AddPair(pair);
- }
- else
- return E_INVALIDARG;
- SaveComments();
- break;
- }
- default:
- return E_NOTIMPL;
- }
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
-{
- if (index >= (UInt32)_refs.Size())
- return E_INVALIDARG;
- const CDirItem &fileInfo = *_refs[index];
- *iconIndex = 0;
- int iconIndexTemp;
- if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attributes, iconIndexTemp) != 0)
- {
- *iconIndex = iconIndexTemp;
- return S_OK;
- }
- return GetLastError();
-}
-
-STDMETHODIMP CFSFolder::SetFlatMode(Int32 flatMode)
-{
- _flatMode = IntToBool(flatMode);
- return S_OK;
-}
-
-// static const LPCTSTR kInvalidFileChars = TEXT("\\/:*?\"<>|");
-
diff --git a/7zip/FileManager/FSFolder.h b/7zip/FileManager/FSFolder.h
deleted file mode 100755
index 58d920b1..00000000
--- a/7zip/FileManager/FSFolder.h
+++ /dev/null
@@ -1,143 +0,0 @@
-// FSFolder.h
-
-#ifndef __FSFOLDER_H
-#define __FSFOLDER_H
-
-#include "Common/String.h"
-#include "Common/MyCom.h"
-#include "Windows/FileFind.h"
-#include "Windows/PropVariant.h"
-
-#include "IFolder.h"
-
-#include "TextPairs.h"
-
-class CFSFolder;
-
-struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
-{
- bool CompressedSizeIsDefined;
- UInt64 CompressedSize;
-};
-
-struct CDirItem;
-
-struct CDirItem: public CFileInfoEx
-{
- CDirItem *Parent;
- CObjectVector<CDirItem> Files;
-
- CDirItem(): Parent(0) {}
- void Clear()
- {
- Files.Clear();
- Parent = 0;
- }
-};
-
-class CFSFolder:
- public IFolderFolder,
- public IEnumProperties,
- public IFolderGetTypeID,
- public IFolderGetPath,
- public IFolderWasChanged,
- public IFolderOperations,
- // public IFolderOperationsDeleteToRecycleBin,
- public IFolderGetItemFullSize,
- public IFolderClone,
- public IFolderGetSystemIconIndex,
- public IFolderSetFlatMode,
- public CMyUnknownImp
-{
- UInt64 GetSizeOfItem(int anIndex) const;
-public:
- MY_QUERYINTERFACE_BEGIN
- MY_QUERYINTERFACE_ENTRY(IEnumProperties)
- MY_QUERYINTERFACE_ENTRY(IFolderGetTypeID)
- MY_QUERYINTERFACE_ENTRY(IFolderGetPath)
- MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
- // MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin)
- MY_QUERYINTERFACE_ENTRY(IFolderOperations)
- MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize)
- MY_QUERYINTERFACE_ENTRY(IFolderClone)
- MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex)
- MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
- MY_QUERYINTERFACE_END
- MY_ADDREF_RELEASE
-
-
- STDMETHOD(LoadItems)();
- STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
- STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
- STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
- STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
- STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
- STDMETHOD(GetName)(BSTR *name);
-
- STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
- STDMETHOD(GetPropertyInfo)(UInt32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType);
- STDMETHOD(GetTypeID)(BSTR *name);
- STDMETHOD(GetPath)(BSTR *path);
- STDMETHOD(WasChanged)(INT32 *wasChanged);
- STDMETHOD(Clone)(IFolderFolder **resultFolder);
- STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
-
- STDMETHOD(SetFlatMode)(Int32 flatMode);
-
- // IFolderOperations
-
- STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress);
- STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress);
- STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress);
- STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress);
- STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
- const wchar_t *path, IFolderOperationsExtractCallback *callback);
- STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems,
- const wchar_t *path, IFolderOperationsExtractCallback *callback);
- STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
- const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress);
- STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
- STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
-
-private:
- UString _path;
- CDirItem _root;
- CRecordVector<CDirItem *> _refs;
-
- CMyComPtr<IFolderFolder> _parentFolder;
-
- bool _findChangeNotificationDefined;
-
- bool _commentsAreLoaded;
- CPairsStorage _comments;
-
- bool _flatMode;
-
- NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
-
- HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
- HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
- HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
-
- bool LoadComments();
- bool SaveComments();
- HRESULT LoadSubItems(CDirItem &dirItem, const UString &path);
- void AddRefs(CDirItem &dirItem);
-public:
- HRESULT Init(const UString &path, IFolderFolder *parentFolder);
-
- CFSFolder() : _flatMode(false) {}
-
- UString GetPrefix(const CDirItem &item) const;
- UString GetRelPath(const CDirItem &item) const;
- UString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
-
- void Clear()
- {
- _root.Clear();
- _refs.Clear();
- }
-};
-
-#endif
diff --git a/7zip/FileManager/FSFolderCopy.cpp b/7zip/FileManager/FSFolderCopy.cpp
deleted file mode 100755
index bcc4cf97..00000000
--- a/7zip/FileManager/FSFolderCopy.cpp
+++ /dev/null
@@ -1,472 +0,0 @@
-// FSFolderCopy.cpp
-
-#include "StdAfx.h"
-
-#include <Winbase.h>
-
-#include "FSFolder.h"
-#include "Windows/FileDir.h"
-#include "Windows/Error.h"
-
-#include "Common/StringConvert.h"
-
-#include "../Common/FilePathAutoRename.h"
-
-using namespace NWindows;
-using namespace NFile;
-using namespace NFind;
-
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-/*
-static bool IsItWindows2000orHigher()
-{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
- (versionInfo.dwMajorVersion >= 5);
-}
-*/
-
-struct CProgressInfo
-{
- UINT64 StartPos;
- IProgress *Progress;
-};
-
-static DWORD CALLBACK CopyProgressRoutine(
- LARGE_INTEGER /* TotalFileSize */, // file size
- LARGE_INTEGER TotalBytesTransferred, // bytes transferred
- LARGE_INTEGER /* StreamSize */, // bytes in stream
- LARGE_INTEGER /* StreamBytesTransferred */, // bytes transferred for stream
- DWORD /* dwStreamNumber */, // current stream
- DWORD /* dwCallbackReason */, // callback reason
- HANDLE /* hSourceFile */, // handle to source file
- HANDLE /* hDestinationFile */, // handle to destination file
- LPVOID lpData // from CopyFileEx
-)
-{
- CProgressInfo &progressInfo = *(CProgressInfo *)lpData;
- UINT64 completed = progressInfo.StartPos + TotalBytesTransferred.QuadPart;
- if (progressInfo.Progress->SetCompleted(&completed) != S_OK)
- return PROGRESS_CANCEL;
- return PROGRESS_CONTINUE;
-}
-
-typedef BOOL (WINAPI * CopyFileExPointer)(
- IN LPCSTR lpExistingFileName,
- IN LPCSTR lpNewFileName,
- IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
- IN LPVOID lpData OPTIONAL,
- IN LPBOOL pbCancel OPTIONAL,
- IN DWORD dwCopyFlags
- );
-
-typedef BOOL (WINAPI * CopyFileExPointerW)(
- IN LPCWSTR lpExistingFileName,
- IN LPCWSTR lpNewFileName,
- IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
- IN LPVOID lpData OPTIONAL,
- IN LPBOOL pbCancel OPTIONAL,
- IN DWORD dwCopyFlags
- );
-
-#ifndef _UNICODE
-static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-static CSysString GetSysPath(LPCWSTR sysPath)
- { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
-#endif
-
-static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile,
- IProgress *progress, UINT64 &completedSize)
-{
- CProgressInfo progressInfo;
- progressInfo.Progress = progress;
- progressInfo.StartPos = completedSize;
- BOOL CancelFlag = FALSE;
- #ifndef _UNICODE
- if (g_IsNT)
- #endif
- {
- CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
- ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"),
- "CopyFileExW");
- if (copyFunctionW == 0)
- return false;
- return BOOLToBool(copyFunctionW(existingFile, newFile, CopyProgressRoutine,
- &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS));
- }
- #ifndef _UNICODE
- else
- {
- CopyFileExPointer copyFunction = (CopyFileExPointer)
- ::GetProcAddress(::GetModuleHandleA("kernel32.dll"),
- "CopyFileExA");
- if (copyFunction != 0)
- {
- if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
- CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- }
- return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
- }
- #endif
-}
-
-typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
- IN LPCWSTR lpExistingFileName,
- IN LPCWSTR lpNewFileName,
- IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
- IN LPVOID lpData OPTIONAL,
- IN DWORD dwFlags
- );
-
-static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile,
- IProgress *progress, UINT64 &completedSize)
-{
- // if (IsItWindows2000orHigher())
- // {
- CProgressInfo progressInfo;
- progressInfo.Progress = progress;
- progressInfo.StartPos = completedSize;
-
- MoveFileWithProgressPointer moveFunction = (MoveFileWithProgressPointer)
- ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
- "MoveFileWithProgressW");
- if (moveFunction != 0)
- {
- if (moveFunction(
- existingFile, newFile, CopyProgressRoutine,
- &progressInfo, MOVEFILE_COPY_ALLOWED))
- return true;
- if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return false;
- }
-
-
-
- // }
- // else
- return NDirectory::MyMoveFile(existingFile, newFile);
-}
-
-static HRESULT MyCopyFile(
- const UString &srcPath,
- const CFileInfoW &srcFileInfo,
- const UString &destPathSpec,
- IFolderOperationsExtractCallback *callback,
- UINT64 &completedSize)
-{
- UString destPath = destPathSpec;
- if (destPath.CompareNoCase(srcPath) == 0)
- {
- UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
-
- INT32 writeAskResult;
- CMyComBSTR destPathResult;
- RINOK(callback->AskWrite(
- srcPath,
- BoolToInt(false),
- &srcFileInfo.LastWriteTime, &srcFileInfo.Size,
- destPath,
- &destPathResult,
- &writeAskResult));
- if (IntToBool(writeAskResult))
- {
- UString destPathNew = UString(destPathResult);
- RINOK(callback->SetCurrentFilePath(srcPath));
- if (!::MyCopyFile(srcPath, destPathNew, callback, completedSize))
- {
- UString message = NError::MyFormatMessageW(GetLastError()) +
- UString(L" \'") +
- UString(destPathNew) +
- UString(L"\'");
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
- }
- completedSize += srcFileInfo.Size;
- return callback->SetCompleted(&completedSize);
-}
-
-static HRESULT CopyFolder(
- const UString &srcPath,
- const UString &destPathSpec,
- IFolderOperationsExtractCallback *callback,
- UINT64 &completedSize)
-{
- RINOK(callback->SetCompleted(&completedSize));
-
- UString destPath = destPathSpec;
- int len = srcPath.Length();
- if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
- {
- if (destPath.Length() == len || destPath[len] == L'\\')
- {
- UString message = UString(L"can not copy folder \'") +
- destPath + UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
- }
-
- if (!NDirectory::CreateComplexDirectory(destPath))
- {
- UString message = UString(L"can not create folder ") + destPath;
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
- CEnumeratorW enumerator(srcPath + UString(L"\\*"));
- CFileInfoEx fileInfo;
- while (enumerator.Next(fileInfo))
- {
- const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name;
- const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
- if (fileInfo.IsDirectory())
- {
- RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize));
- }
- else
- {
- RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize));
- }
- }
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
- const wchar_t *path, IFolderOperationsExtractCallback *callback)
-{
- if (numItems == 0)
- return S_OK;
- UINT64 totalSize = 0;
- UInt32 i;
- for (i = 0; i < numItems; i++)
- {
- int index = indices[i];
- if (index >= _refs.Size())
- return E_INVALIDARG;
- UINT64 size;
- RINOK(GetItemFullSize(indices[i], size, callback));
- totalSize += size;
- }
-
- callback->SetTotal(totalSize);
- UString destPath = path;
- if (destPath.IsEmpty())
- return E_INVALIDARG;
- bool directName = (destPath[destPath.Length() - 1] != L'\\');
- if (directName)
- {
- if (numItems > 1)
- return E_INVALIDARG;
- }
- /*
- // doesn't work in network
- else
- if (!NDirectory::CreateComplexDirectory(destPath)))
- {
- DWORD lastError = ::GetLastError();
- UString message = UString(L"can not create folder ") +
- destPath;
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
- */
-
- UINT64 completedSize = 0;
- RINOK(callback->SetCompleted(&completedSize));
- for (i = 0; i < numItems; i++)
- {
- const CDirItem &fileInfo = *_refs[indices[i]];
- UString destPath2 = destPath;
- if (!directName)
- destPath2 += fileInfo.Name;
- UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
- if (fileInfo.IsDirectory())
- {
- RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
- }
- else
- {
- RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize));
- }
- }
- return S_OK;
-}
-
-/////////////////////////////////////////////////
-// Move Operations
-
-HRESULT MyMoveFile(
- const UString &srcPath,
- const CFileInfoW &srcFileInfo,
- const UString &destPathSpec,
- IFolderOperationsExtractCallback *callback,
- UINT64 &completedSize)
-{
- UString destPath = destPathSpec;
- if (destPath.CompareNoCase(srcPath) == 0)
- {
- UString message = UString(L"can not move file \'")
- + destPath +
- UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
-
- INT32 writeAskResult;
- CMyComBSTR destPathResult;
- RINOK(callback->AskWrite(
- srcPath,
- BoolToInt(false),
- &srcFileInfo.LastWriteTime, &srcFileInfo.Size,
- destPath,
- &destPathResult,
- &writeAskResult));
- if (IntToBool(writeAskResult))
- {
- UString destPathNew = UString(destPathResult);
- RINOK(callback->SetCurrentFilePath(srcPath));
- if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
- {
- UString message = UString(L"can not move to file ") + destPathNew;
- RINOK(callback->ShowMessage(message));
- }
- }
- completedSize += srcFileInfo.Size;
- RINOK(callback->SetCompleted(&completedSize));
- return S_OK;
-}
-
-HRESULT MyMoveFolder(
- const UString &srcPath,
- const UString &destPathSpec,
- IFolderOperationsExtractCallback *callback,
- UINT64 &completedSize)
-{
- UString destPath = destPathSpec;
- int len = srcPath.Length();
- if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
- {
- if (destPath.Length() == len || destPath[len] == L'\\')
- {
- UString message = UString(L"can not move folder \'") +
- destPath + UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
- }
-
- if (MyMoveFile(srcPath, destPath, callback, completedSize))
- return S_OK;
-
- if (!NDirectory::CreateComplexDirectory(destPath))
- {
- UString message = UString(L"can not create folder ") + destPath;
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
- {
- CEnumeratorW enumerator(srcPath + UString(L"\\*"));
- CFileInfoEx fileInfo;
- while (enumerator.Next(fileInfo))
- {
- const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name;
- const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
- if (fileInfo.IsDirectory())
- {
- RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
- }
- else
- {
- RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, callback, completedSize));
- }
- }
- }
- if (!NDirectory::MyRemoveDirectory(srcPath))
- {
- UString message = UString(L"can not remove folder") + srcPath;
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::MoveTo(
- const UInt32 *indices,
- UInt32 numItems,
- const wchar_t *path,
- IFolderOperationsExtractCallback *callback)
-{
- if (numItems == 0)
- return S_OK;
-
- UINT64 totalSize = 0;
- UInt32 i;
- for (i = 0; i < numItems; i++)
- {
- int index = indices[i];
- if (index >= _refs.Size())
- return E_INVALIDARG;
- UINT64 size;
- RINOK(GetItemFullSize(indices[i], size, callback));
- totalSize += size;
- }
- callback->SetTotal(totalSize);
-
- UString destPath = path;
- if (destPath.IsEmpty())
- return E_INVALIDARG;
- bool directName = (destPath[destPath.Length() - 1] != L'\\');
- if (directName)
- {
- if (numItems > 1)
- return E_INVALIDARG;
- }
- else
- if (!NDirectory::CreateComplexDirectory(destPath))
- {
- UString message = UString(L"can not create folder ") +
- destPath;
- RINOK(callback->ShowMessage(message));
- return E_ABORT;
- }
-
- UINT64 completedSize = 0;
- RINOK(callback->SetCompleted(&completedSize));
- for (i = 0; i < numItems; i++)
- {
- const CDirItem &fileInfo = *_refs[indices[i]];
- UString destPath2 = destPath;
- if (!directName)
- destPath2 += fileInfo.Name;
- UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
- if (fileInfo.IsDirectory())
- {
- RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
- }
- else
- {
- RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize));
- }
- }
- return S_OK;
-}
-
-STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
- const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */)
-{
- return E_NOTIMPL;
-}
-
-
diff --git a/7zip/FileManager/FileFolderPluginOpen.cpp b/7zip/FileManager/FileFolderPluginOpen.cpp
deleted file mode 100755
index ffb6788e..00000000
--- a/7zip/FileManager/FileFolderPluginOpen.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// FileFolderPluginOpen.cpp
-
-#include "StdAfx.h"
-
-#include "Common/StringConvert.h"
-#include "Windows/Defs.h"
-#include "Windows/FileDir.h"
-#include "Windows/FileName.h"
-#include "Windows/DLL.h"
-
-#include "IFolder.h"
-#include "RegistryAssociations.h"
-#include "RegistryPlugins.h"
-
-#include "OpenCallback.h"
-#include "PluginLoader.h"
-
-using namespace NWindows;
-using namespace NRegistryAssociations;
-
-static int FindPlugin(const CObjectVector<CPluginInfo> &plugins,
- const UString &pluginName)
-{
- for (int i = 0; i < plugins.Size(); i++)
- if (plugins[i].Name.CompareNoCase(pluginName) == 0)
- return i;
- return -1;
-}
-
-HRESULT OpenFileFolderPlugin(
- const UString &path,
- HMODULE *module,
- IFolderFolder **resultFolder,
- HWND parentWindow)
-{
- CObjectVector<CPluginInfo> plugins;
- ReadFileFolderPluginInfoList(plugins);
-
- UString extension;
- UString name, pureName, dot;
-
- if(!NFile::NDirectory::GetOnlyName(path, name))
- return E_FAIL;
- NFile::NName::SplitNameToPureNameAndExtension(name, pureName, dot, extension);
-
-
- int slashPos = path.ReverseFind(L'\\');
- UString dirPrefix;
- UString fileName;
- if (slashPos >= 0)
- {
- dirPrefix = path.Left(slashPos + 1);
- fileName = path.Mid(slashPos + 1);
- }
- else
- fileName = path;
-
- if (!extension.IsEmpty())
- {
- CExtInfo extInfo;
- if (ReadInternalAssociation(extension, extInfo))
- {
- for (int i = extInfo.Plugins.Size() - 1; i >= 0; i--)
- {
- int pluginIndex = FindPlugin(plugins, extInfo.Plugins[i]);
- if (pluginIndex >= 0)
- {
- const CPluginInfo plugin = plugins[pluginIndex];
- plugins.Delete(pluginIndex);
- plugins.Insert(0, plugin);
- }
- }
- }
- }
-
- for (int i = 0; i < plugins.Size(); i++)
- {
- const CPluginInfo &plugin = plugins[i];
- CPluginLibrary library;
- CMyComPtr<IFolderManager> folderManager;
- CMyComPtr<IFolderFolder> folder;
- HRESULT result = library.LoadAndCreateManager(
- plugin.FilePath, plugin.ClassID, &folderManager);
- if (result != S_OK)
- continue;
-
- COpenArchiveCallback *openCallbackSpec = new COpenArchiveCallback;
- CMyComPtr<IProgress> openCallback = openCallbackSpec;
- openCallbackSpec->PasswordIsDefined = false;
- openCallbackSpec->ParentWindow = parentWindow;
- openCallbackSpec->LoadFileInfo(dirPrefix, fileName);
-
- result = folderManager->OpenFolderFile(path, &folder, openCallback);
- if (result == S_OK)
- {
- *module = library.Detach();
- *resultFolder = folder.Detach();
- return S_OK;
- }
- continue;
-
- /*
- if (result != S_FALSE)
- return result;
- */
- }
- return S_FALSE;
-} \ No newline at end of file
diff --git a/7zip/FileManager/FileFolderPluginOpen.h b/7zip/FileManager/FileFolderPluginOpen.h
deleted file mode 100755
index 67d27046..00000000
--- a/7zip/FileManager/FileFolderPluginOpen.h
+++ /dev/null
@@ -1,9 +0,0 @@
-// FileFolderPluginOpen.h
-
-#ifndef __FILEFOLDERPLUGINOPEN_H
-#define __FILEFOLDERPLUGINOPEN_H
-
-HRESULT OpenFileFolderPlugin(const UString &path,
- HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow);
-
-#endif
diff --git a/7zip/FileManager/MyLoadMenu.cpp b/7zip/FileManager/MyLoadMenu.cpp
deleted file mode 100755
index e464f7f3..00000000
--- a/7zip/FileManager/MyLoadMenu.cpp
+++ /dev/null
@@ -1,694 +0,0 @@
-// MyLoadMenu
-
-#include "StdAfx.h"
-
-#include "Common/StringConvert.h"
-
-#include "Windows/Menu.h"
-#include "Windows/Error.h"
-
-#include "../PropID.h"
-
-#include "resource.h"
-#include "App.h"
-#include "Resource/AboutDialog/AboutDialog.h"
-#include "Resource/BenchmarkDialog/BenchmarkDialog.h"
-
-#include "HelpUtils.h"
-#include "LangUtils.h"
-#include "PluginInterface.h"
-
-static const UINT kOpenBookmarkMenuID = 730;
-static const UINT kSetBookmarkMenuID = 740;
-
-extern HINSTANCE g_hInstance;
-
-static LPCWSTR kFMHelpTopic = L"FM/index.htm";
-
-extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance);
-
-using namespace NWindows;
-
-static const int kFileMenuIndex = 0;
-static const int kViewMenuIndex = 2;
-static const int kBookmarksMenuIndex = kViewMenuIndex + 1;
-
-struct CStringLangPair
-{
- wchar_t *String;
- UINT32 LangID;
-};
-
-static CStringLangPair kStringLangPairs[] =
-{
- { L"&File", 0x03000102 },
- { L"&Edit", 0x03000103 },
- { L"&View", 0x03000104 },
- { L"&Bookmarks", 0x03000107 },
- { L"&Tools", 0x03000105 },
- { L"&Help", 0x03000106 },
-};
-
-UINT32 kAddToFavoritesLangID = 0x03000710;
-UINT32 kToolbarsLangID = 0x03000451;
-
-/*
-static int FindStringLangItem(const UString &anItem)
-{
- for (int i = 0; i < sizeof(kStringLangPairs) /
- sizeof(kStringLangPairs[0]); i++)
- if (anItem.CompareNoCase(kStringLangPairs[i].String) == 0)
- return i;
- return -1;
-}
-*/
-
-static CIDLangPair kIDLangPairs[] =
-{
- // File
- { IDM_FILE_OPEN, 0x03000210 },
- { IDM_FILE_OPEN_INSIDE, 0x03000211 },
- { IDM_FILE_OPEN_OUTSIDE, 0x03000212 },
- { IDM_FILE_VIEW, 0x03000220 },
- { IDM_FILE_EDIT, 0x03000221 },
- { IDM_RENAME, 0x03000230 },
- { IDM_COPY_TO, 0x03000231 },
- { IDM_MOVE_TO, 0x03000232 },
- { IDM_DELETE, 0x03000233 },
- { IDM_FILE_PROPERTIES, 0x03000240 },
- { IDM_FILE_COMMENT, 0x03000241 },
- { IDM_FILE_CRC, 0x03000242 },
- { IDM_FILE_SPLIT, 0x03000270 },
- { IDM_FILE_COMBINE, 0x03000271 },
- { IDM_CREATE_FOLDER, 0x03000250 },
- { IDM_CREATE_FILE, 0x03000251 },
- { IDCLOSE, 0x03000260 },
-
- // Edit
- { IDM_EDIT_CUT, 0x03000320 },
- { IDM_EDIT_COPY, 0x03000321 },
- { IDM_EDIT_PASTE, 0x03000322 },
-
- { IDM_SELECT_ALL, 0x03000330 },
- { IDM_DESELECT_ALL, 0x03000331 },
- { IDM_INVERT_SELECTION, 0x03000332 },
- { IDM_SELECT, 0x03000333 },
- { IDM_DESELECT, 0x03000334 },
- { IDM_SELECT_BY_TYPE, 0x03000335 },
- { IDM_DESELECT_BY_TYPE, 0x03000336 },
-
- { IDM_VIEW_LARGE_ICONS, 0x03000410 },
- { IDM_VIEW_SMALL_ICONS, 0x03000411 },
- { IDM_VIEW_LIST, 0x03000412 },
- { IDM_VIEW_DETAILS, 0x03000413 },
-
- { IDM_VIEW_ARANGE_BY_NAME, 0x02000204 },
- { IDM_VIEW_ARANGE_BY_TYPE, 0x02000214 },
- { IDM_VIEW_ARANGE_BY_DATE, 0x0200020C },
- { IDM_VIEW_ARANGE_BY_SIZE, 0x02000207 },
- { IDM_VIEW_ARANGE_NO_SORT, 0x03000420 },
-
- { IDM_OPEN_ROOT_FOLDER, 0x03000430 },
- { IDM_OPEN_PARENT_FOLDER, 0x03000431 },
- { IDM_FOLDERS_HISTORY, 0x03000432 },
-
- { IDM_VIEW_REFRESH, 0x03000440 },
-
- { IDM_VIEW_FLAT_VIEW, 0x03000449 },
- { IDM_VIEW_TWO_PANELS, 0x03000450 },
- { IDM_VIEW_ARCHIVE_TOOLBAR, 0x03000460 },
- { IDM_VIEW_STANDARD_TOOLBAR, 0x03000461 },
- { IDM_VIEW_TOOLBARS_LARGE_BUTTONS, 0x03000462 },
- { IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, 0x03000463 },
-
- { IDM_OPTIONS, 0x03000510 },
- { IDM_BENCHMARK, 0x03000511 },
-
- { IDM_HELP_CONTENTS, 0x03000610 },
- { IDM_ABOUT, 0x03000620 }
-};
-
-
-static int FindLangItem(int ControlID)
-{
- for (int i = 0; i < sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]); i++)
- if (kIDLangPairs[i].ControlID == ControlID)
- return i;
- return -1;
-}
-
-
-/*
-static bool g_IsNew_fMask = true;
-
-class CInit_fMask
-{
-public:
- CInit_fMask()
- {
- g_IsNew_fMask = false;
- OSVERSIONINFO vi;
- vi.dwOSVersionInfoSize = sizeof(vi);
- if (::GetVersionEx(&vi))
- {
- g_IsNew_fMask = (vi.dwMajorVersion > 4 ||
- (vi.dwMajorVersion == 4 && vi.dwMinorVersion > 0));
- }
- g_IsNew_fMask = false;
- }
-} g_Init_fMask;
-
-// it's hack for supporting Windows NT
-// constants are from WinUser.h
-
-#if(WINVER < 0x0500)
-#define MIIM_STRING 0x00000040
-#define MIIM_BITMAP 0x00000080
-#define MIIM_FTYPE 0x00000100
-#endif
-
-static UINT Get_fMaskForString()
-{
- return g_IsNew_fMask ? MIIM_STRING : MIIM_TYPE;
-}
-
-static UINT Get_fMaskForFTypeAndString()
-{
- return g_IsNew_fMask ? (MIIM_STRING | MIIM_FTYPE) : MIIM_TYPE;
-}
-*/
-
-static UINT Get_fMaskForString()
-{
- return MIIM_TYPE;
-}
-
-static UINT Get_fMaskForFTypeAndString()
-{
- return MIIM_TYPE;
-}
-
-
-
-static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
-{
- CMenu menu;
- menu.Attach(menuLoc);
- for (int i = 0; i < menu.GetItemCount(); i++)
- {
- CMenuItem item;
- item.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID;
- item.fType = MFT_STRING;
- if (menu.GetItem(i, true, item))
- {
- UString newString;
- if (item.hSubMenu)
- {
- if (level == 1 && menuIndex == kBookmarksMenuIndex)
- newString = LangString(kAddToFavoritesLangID);
- else
- {
- MyChangeMenu(item.hSubMenu, level + 1, i);
- if (level == 1 && menuIndex == kViewMenuIndex)
- {
- newString = LangString(kToolbarsLangID);
- }
- else
- {
- if (level == 0 && i < sizeof(kStringLangPairs) /
- sizeof(kStringLangPairs[0]))
- newString = LangString(kStringLangPairs[i].LangID);
- else
- continue;
- }
- }
- if (newString.IsEmpty())
- continue;
- }
- else
- {
- int langPos = FindLangItem(item.wID);
- if (langPos < 0)
- continue;
- newString = LangString(kIDLangPairs[langPos].LangID);
- if (newString.IsEmpty())
- continue;
- UString shorcutString = item.StringValue;
- int tabPos = shorcutString.ReverseFind(wchar_t('\t'));
- if (tabPos >= 0)
- newString += shorcutString.Mid(tabPos);
- }
- {
- item.StringValue = newString;
- item.fMask = Get_fMaskForString();
- item.fType = MFT_STRING;
- menu.SetItem(i, true, item);
- }
- }
- }
-}
-
-CMenu g_FileMenu;
-
-class CFileMenuDestroyer
-{
-public:
- ~CFileMenuDestroyer()
- {
- if ((HMENU)g_FileMenu != 0)
- g_FileMenu.Destroy();
- }
-} g_FileMenuDestroyer;
-
-
-void MyLoadMenu(HWND hWnd)
-{
- if ((HMENU)g_FileMenu != 0)
- g_FileMenu.Destroy();
- HMENU oldMenu = ::GetMenu(hWnd);
- HMENU baseMenu = ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU));
- ::SetMenu(hWnd, baseMenu);
- ::DestroyMenu(oldMenu);
- if (!g_LangID.IsEmpty())
- {
- HMENU menuOld = ::GetMenu(hWnd);
- MyChangeMenu(menuOld, 0, 0);
- }
- ::DrawMenuBar(hWnd);
-}
-
-extern HWND g_HWND;
-void MyLoadMenu()
-{
- MyLoadMenu(g_HWND);
-}
-
-static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
-{
- CMenu srcMenu;
- srcMenu.Attach(srcMenuSpec);
- CMenu destMenu;
- destMenu.Attach(destMenuSpec);
- int startPos = 0;
- for (int i = 0; i < srcMenu.GetItemCount(); i++)
- {
- CMenuItem item;
- item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
- item.fType = MFT_STRING;
- if (srcMenu.GetItem(i, true, item))
- if (destMenu.InsertItem(startPos, true, item))
- startPos++;
- }
-}
-
-void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
-{
- if (::GetSubMenu(::GetMenu(g_HWND), position) != hMenu)
- return;
- if (position == kFileMenuIndex)
- {
- if ((HMENU)g_FileMenu == 0)
- {
- g_FileMenu.CreatePopup();
- CopyMenu(hMenu, g_FileMenu);
- }
- CMenu menu;
- menu.Attach(hMenu);
- while (menu.GetItemCount() > 0)
- {
- if (!menu.RemoveItem(0, MF_BYPOSITION))
- break;
- }
- // CopyMenu(g_FileMenu, hMenu);
- g_App.GetFocusedPanel().CreateFileMenu(hMenu);
-
- }
- else if (position == kViewMenuIndex)
- {
- // View;
- CMenu menu;
- menu.Attach(hMenu);
- 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));
- menu.CheckItem(IDM_VIEW_FLAT_VIEW, MF_BYCOMMAND |
- ((g_App.GetFlatMode()) ? MF_CHECKED : MF_UNCHECKED));
- menu.CheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, MF_BYCOMMAND |
- (g_App.ShowArchiveToolbar ? MF_CHECKED : MF_UNCHECKED));
- menu.CheckItem(IDM_VIEW_STANDARD_TOOLBAR, MF_BYCOMMAND |
- (g_App.ShowStandardToolbar ? MF_CHECKED : MF_UNCHECKED));
- menu.CheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, MF_BYCOMMAND |
- (g_App.LargeButtons ? MF_CHECKED : MF_UNCHECKED));
- menu.CheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, MF_BYCOMMAND |
- (g_App.ShowButtonsLables ? MF_CHECKED : MF_UNCHECKED));
- }
- else if (position == kBookmarksMenuIndex)
- {
- CMenu menu;
- menu.Attach(hMenu);
-
- CMenu subMenu;
- subMenu.Attach(menu.GetSubMenu(0));
- while (subMenu.GetItemCount() > 0)
- subMenu.RemoveItem(subMenu.GetItemCount() - 1, MF_BYPOSITION);
- int i;
- for (i = 0; i < 10; i++)
- {
- UString s = LangString(IDS_BOOKMARK, 0x03000720);
- s += L" ";
- wchar_t c = (wchar_t)(L'0' + i);
- s += c;
- s += L"\tAlt+Shift+";
- s += c;
- subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s);
- }
-
- while (menu.GetItemCount() > 2)
- menu.RemoveItem(menu.GetItemCount() - 1, MF_BYPOSITION);
-
- for (i = 0; i < 10; i++)
- {
- UString path = g_App.AppState.FastFolders.GetString(i);
- const int kMaxSize = 100;
- const int kFirstPartSize = kMaxSize / 2;
- if (path.Length() > kMaxSize)
- {
- path = path.Left(kFirstPartSize) + UString(L" ... ") +
- path.Right(kMaxSize - kFirstPartSize);
- }
- UString s = path;
- if (s.IsEmpty())
- s = L"-";
- s += L"\tAlt+";
- s += (wchar_t)(L'0' + i);
- menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
- }
- }
-}
-
-/*
-It doesn't help
-void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id)
-{
- if (::GetSubMenu(::GetMenu(g_HWND), 0) != hMenu)
- return;
- // g_App.GetFocusedPanel()._contextMenu.Release();
-}
-
-void OnMenuUnActivating(HWND hWnd)
-{
-}
-*/
-
-
-void LoadFileMenu(HMENU hMenu, int startPos, bool /* forFileMode */, bool programMenu)
-{
- {
- CMenu srcMenu;
- srcMenu.Attach(::GetSubMenu(::GetMenu(g_HWND), 0));
- if ((HMENU)g_FileMenu == 0)
- {
- g_FileMenu.CreatePopup();
- CopyMenu(srcMenu, g_FileMenu);
- }
- }
-
- CMenu destMenu;
- destMenu.Attach(hMenu);
-
- for (int i = 0; i < g_FileMenu.GetItemCount(); i++)
- {
- CMenuItem item;
-
- item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
- item.fType = MFT_STRING;
- if (g_FileMenu.GetItem(i, true, item))
- {
- if (!programMenu)
- if (item.wID == IDCLOSE)
- continue;
- /*
- bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE);
- if (forFileMode)
- {
- if (createItem)
- continue;
- }
- else
- {
- if (!createItem)
- continue;
- }
- */
- if (destMenu.InsertItem(startPos, true, item))
- startPos++;
- }
- }
- while (destMenu.GetItemCount() > 0)
- {
- CMenuItem item;
- item.fMask = MIIM_TYPE;
- item.fType = 0;
- // item.dwTypeData = 0;
- int lastIndex = destMenu.GetItemCount() - 1;
- if (!destMenu.GetItem(lastIndex, true, item))
- break;
- if(item.fType != MFT_SEPARATOR)
- break;
- if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION))
- break;
- }
-}
-
-bool ExecuteFileCommand(int id)
-{
- if (id >= kPluginMenuStartID)
- {
- g_App.GetFocusedPanel().InvokePluginCommand(id);
- g_App.GetFocusedPanel()._sevenZipContextMenu.Release();
- g_App.GetFocusedPanel()._systemContextMenu.Release();
- return true;
- }
-
- switch (id)
- {
- // File
- case IDM_FILE_OPEN:
- g_App.OpenItem();
- break;
- case IDM_FILE_OPEN_INSIDE:
- g_App.OpenItemInside();
- break;
- case IDM_FILE_OPEN_OUTSIDE:
- g_App.OpenItemOutside();
- break;
- case IDM_FILE_VIEW:
- break;
- case IDM_FILE_EDIT:
- g_App.EditItem();
- break;
- case IDM_RENAME:
- g_App.Rename();
- break;
- case IDM_COPY_TO:
- g_App.CopyTo();
- break;
- case IDM_MOVE_TO:
- g_App.MoveTo();
- break;
- case IDM_DELETE:
- {
- bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
- g_App.Delete(!shift);
- break;
- }
- case IDM_FILE_CRC:
- g_App.CalculateCrc();
- break;
- case IDM_FILE_SPLIT:
- g_App.Split();
- break;
- case IDM_FILE_COMBINE:
- g_App.Combine();
- break;
- case IDM_FILE_PROPERTIES:
- g_App.Properties();
- break;
- case IDM_FILE_COMMENT:
- g_App.Comment();
- break;
-
- case IDM_CREATE_FOLDER:
- g_App.CreateFolder();
- break;
- case IDM_CREATE_FILE:
- g_App.CreateFile();
- break;
- default:
- return false;
- }
- return true;
-}
-
-bool OnMenuCommand(HWND hWnd, int id)
-{
- if (ExecuteFileCommand(id))
- return true;
-
- switch (id)
- {
- // File
- case IDCLOSE:
- SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
- SendMessage (hWnd, WM_CLOSE, 0, 0);
- break;
-
- // Edit
- case IDM_EDIT_COPY:
- g_App.EditCopy();
- break;
- case IDM_EDIT_PASTE:
- g_App.EditPaste();
- break;
- case IDM_SELECT_ALL:
- g_App.SelectAll(true);
- g_App.RefreshStatusBar();
- break;
- case IDM_DESELECT_ALL:
- g_App.SelectAll(false);
- g_App.RefreshStatusBar();
- break;
- case IDM_INVERT_SELECTION:
- g_App.InvertSelection();
- g_App.RefreshStatusBar();
- break;
- case IDM_SELECT:
- g_App.SelectSpec(true);
- g_App.RefreshStatusBar();
- break;
- case IDM_DESELECT:
- g_App.SelectSpec(false);
- g_App.RefreshStatusBar();
- break;
- case IDM_SELECT_BY_TYPE:
- g_App.SelectByType(true);
- g_App.RefreshStatusBar();
- break;
- case IDM_DESELECT_BY_TYPE:
- g_App.SelectByType(false);
- g_App.RefreshStatusBar();
- break;
-
- //View
- case IDM_VIEW_LARGE_ICONS:
- case IDM_VIEW_SMALL_ICONS:
- case IDM_VIEW_LIST:
- case IDM_VIEW_DETAILS:
- {
- UINT index = id - IDM_VIEW_LARGE_ICONS;
- if (index < 4)
- {
- g_App.SetListViewMode(index);
- /*
- CMenu menu;
- menu.Attach(::GetSubMenu(::GetMenu(hWnd), kViewMenuIndex));
- menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
- id, MF_BYCOMMAND);
- */
- }
- break;
- }
- case IDM_VIEW_ARANGE_BY_NAME:
- {
- g_App.SortItemsWithPropID(kpidName);
- break;
- }
- case IDM_VIEW_ARANGE_BY_TYPE:
- {
- g_App.SortItemsWithPropID(kpidExtension);
- break;
- }
- case IDM_VIEW_ARANGE_BY_DATE:
- {
- g_App.SortItemsWithPropID(kpidLastWriteTime);
- break;
- }
- case IDM_VIEW_ARANGE_BY_SIZE:
- {
- g_App.SortItemsWithPropID(kpidSize);
- break;
- }
- case IDM_VIEW_ARANGE_NO_SORT:
- {
- g_App.SortItemsWithPropID(kpidNoProperty);
- break;
- }
-
- case IDM_OPEN_ROOT_FOLDER:
- g_App.OpenRootFolder();
- break;
- case IDM_OPEN_PARENT_FOLDER:
- g_App.OpenParentFolder();
- break;
- case IDM_FOLDERS_HISTORY:
- g_App.FoldersHistory();
- break;
- case IDM_VIEW_REFRESH:
- g_App.RefreshView();
- break;
- case IDM_VIEW_FLAT_VIEW:
- g_App.ChangeFlatMode();
- break;
- case IDM_VIEW_TWO_PANELS:
- g_App.SwitchOnOffOnePanel();
- break;
- case IDM_VIEW_STANDARD_TOOLBAR:
- g_App.SwitchStandardToolbar();
- break;
- case IDM_VIEW_ARCHIVE_TOOLBAR:
- g_App.SwitchArchiveToolbar();
- break;
- case IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT:
- g_App.SwitchButtonsLables();
- break;
- case IDM_VIEW_TOOLBARS_LARGE_BUTTONS:
- g_App.SwitchLargeButtons();
- break;
-
- // Tools
- case IDM_OPTIONS:
- OptionsDialog(hWnd, g_hInstance);
- break;
-
- case IDM_BENCHMARK:
- Benchmark(hWnd);
- break;
- // Help
- case IDM_HELP_CONTENTS:
- ShowHelpWindow(NULL, kFMHelpTopic);
- break;
- case IDM_ABOUT:
- {
- CAboutDialog dialog;
- dialog.Create(hWnd);
- break;
- }
- default:
- {
- if (id >= kOpenBookmarkMenuID && id <= kOpenBookmarkMenuID + 9)
- {
- g_App.OpenBookmark(id - kOpenBookmarkMenuID);
- return true;
- }
- else if (id >= kSetBookmarkMenuID && id <= kSetBookmarkMenuID + 9)
- {
- g_App.SetBookmark(id - kSetBookmarkMenuID);
- return true;
- }
- return false;
- }
- }
- return true;
-}
-
diff --git a/7zip/FileManager/OpenCallback.cpp b/7zip/FileManager/OpenCallback.cpp
deleted file mode 100755
index 9ba2da05..00000000
--- a/7zip/FileManager/OpenCallback.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-// OpenCallback.cpp
-
-#include "StdAfx.h"
-
-#include "OpenCallback.h"
-
-#include "Common/StringConvert.h"
-#include "Resource/PasswordDialog/PasswordDialog.h"
-#include "Windows/PropVariant.h"
-#include "../Common/FileStreams.h"
-
-STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 * /* numFiles */, const UINT64 * /* numBytes */)
-{
- return S_OK;
-}
-
-STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 * /* numFiles */, const UINT64 * /* numBytes */)
-{
- return S_OK;
-}
-
-STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 /* total */)
-{
- return S_OK;
-}
-
-STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 * /* completed */)
-{
- return S_OK;
-}
-
-STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value)
-{
- NWindows::NCOM::CPropVariant propVariant;
- if (_subArchiveMode)
- {
- switch(propID)
- {
- case kpidName:
- propVariant = _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;
- }
- propVariant.Detach(value);
- return S_OK;
-}
-
-STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
- IInStream **inStream)
-{
- *inStream = NULL;
- if (_subArchiveMode)
- return S_FALSE;
-
- NWindows::NFile::NFind::CFileInfoW fileInfo;
-
- UString fullPath = _folderPrefix + name;
- if (!NWindows::NFile::NFind::FindFile(fullPath, fileInfo))
- return S_FALSE;
- _fileInfo = fileInfo;
- if (_fileInfo.IsDirectory())
- return S_FALSE;
- CInFileStream *inFile = new CInFileStream;
- CMyComPtr<IInStream> inStreamTemp = inFile;
- if (!inFile->Open(fullPath))
- return ::GetLastError();
- *inStream = inStreamTemp.Detach();
- return S_OK;
-}
-
-STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
-{
- 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;
-}
diff --git a/7zip/FileManager/OpenCallback.h b/7zip/FileManager/OpenCallback.h
deleted file mode 100755
index 9e1fbc8f..00000000
--- a/7zip/FileManager/OpenCallback.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// OpenCallback.h
-
-#ifndef __OPENCALLBACK_H
-#define __OPENCALLBACK_H
-
-#include "Common/String.h"
-#include "Common/MyCom.h"
-#include "Windows/FileFind.h"
-
-#include "../IPassword.h"
-
-#include "../Archive/IArchive.h"
-
-class COpenArchiveCallback:
- public IArchiveOpenCallback,
- public IArchiveOpenVolumeCallback,
- public IArchiveOpenSetSubArchiveName,
- public IProgress,
- public ICryptoGetTextPassword,
- public CMyUnknownImp
-{
- UString _folderPrefix;
- NWindows::NFile::NFind::CFileInfoW _fileInfo;
-public:
- bool PasswordIsDefined;
- UString Password;
- HWND ParentWindow;
-
- bool _subArchiveMode;
- UString _subArchiveName;
-
-public:
- MY_UNKNOWN_IMP5(
- IArchiveOpenCallback,
- IArchiveOpenVolumeCallback,
- IArchiveOpenSetSubArchiveName,
- 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);
-
- // ICryptoGetTextPassword
- STDMETHOD(CryptoGetTextPassword)(BSTR *password);
-
- STDMETHOD(SetSubArchiveName(const wchar_t *name))
- {
- _subArchiveMode = true;
- _subArchiveName = name;
- return S_OK;
- }
-
- COpenArchiveCallback()
- {
- _subArchiveMode = false;
- }
- /*
- void Init()
- {
- PasswordIsDefined = false;
- _subArchiveMode = false;
- }
- */
- void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
- {
- _folderPrefix = folderPrefix;
- if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo))
- throw 1;
- }
- void ShowMessage(const UINT64 *completed);
-};
-
-#endif
diff --git a/7zip/FileManager/Panel.cpp b/7zip/FileManager/Panel.cpp
deleted file mode 100755
index da695053..00000000
--- a/7zip/FileManager/Panel.cpp
+++ /dev/null
@@ -1,848 +0,0 @@
-// Panel.cpp
-
-#include "StdAfx.h"
-
-#include <Windowsx.h>
-
-#include "Common/Defs.h"
-#include "Common/StringConvert.h"
-#include "Windows/Error.h"
-#include "Windows/PropVariant.h"
-
-#include "../PropID.h"
-
-#include "Panel.h"
-#include "RootFolder.h"
-#include "FSFolder.h"
-#include "FormatUtils.h"
-#include "App.h"
-
-#include "../UI/Common/CompressCall.h"
-#include "../UI/Common/ArchiveName.h"
-
-using namespace NWindows;
-
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-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;
-// static const UINT kFileChangeNotifyMessage = WM_APP;
-
-extern HINSTANCE g_hInstance;
-extern DWORD g_ComCtl32Version;
-
-void CPanel::Release()
-{
- // It's for unloading COM dll's: don't change it.
- CloseOpenFolders();
- _sevenZipContextMenu.Release();
- _systemContextMenu.Release();
-}
-
-CPanel::~CPanel()
-{
- CloseOpenFolders();
-}
-
-static LPCWSTR kClassName = L"7-Zip::Panel";
-
-
-LRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
- const UString &currentFolderPrefix, CPanelCallback *panelCallback, CAppState *appState)
-{
- _mainWindow = mainWindow;
- _processTimer = true;
- _processNotify = true;
-
- _panelCallback = panelCallback;
- _appState = appState;
- // _index = index;
- _baseID = id;
- _comboBoxID = _baseID + 3;
- _statusBarID = _comboBoxID + 1;
-
- UString cfp = currentFolderPrefix;
-
- if (!currentFolderPrefix.IsEmpty())
- if (currentFolderPrefix[0] == L'.')
- if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp))
- cfp = currentFolderPrefix;
- BindToPath(cfp);
-
- 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;
-}
-
-LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch(message)
- {
- case kShiftSelectMessage:
- OnShiftSelectMessage();
- return 0;
- case kReLoadMessage:
- RefreshListCtrl(_selectedState);
- return 0;
- case kSetFocusToListView:
- _listView.SetFocus();
- return 0;
- case kOpenItemChanged:
- return OnOpenItemChanged(lParam);
- case kRefreshStatusBar:
- OnRefreshStatusBar();
- return 0;
- case WM_TIMER:
- OnTimer();
- return 0;
- case WM_CONTEXTMENU:
- if (OnContextMenu(HANDLE(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))
- return 0;
- break;
- /*
- case WM_DROPFILES:
- CompressDropFiles(HDROP(wParam));
- return 0;
- */
- }
- return CWindow2::OnMessage(message, wParam, 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)
-{
- if (message == WM_CHAR)
- {
- UINT scanCode = (UINT)((lParam >> 16) & 0xFF);
- bool extended = ((lParam & 0x1000000) != 0);
- UINT virtualKey = MapVirtualKey(scanCode, 1);
- if (virtualKey == VK_MULTIPLY || virtualKey == VK_ADD ||
- virtualKey == VK_SUBTRACT)
- return 0;
- if ((wParam == '/' && extended)
- || wParam == '\\' || wParam == '/')
- {
- _panel->OpenDrivesFolder();
- return 0;
- }
- }
- else if (message == WM_SYSCHAR)
- {
- // For Alt+Enter Beep disabling
- UINT scanCode = (UINT)(lParam >> 16) & 0xFF;
- UINT virtualKey = MapVirtualKey(scanCode, 1);
- if (virtualKey == VK_RETURN || virtualKey == VK_MULTIPLY ||
- virtualKey == VK_ADD || virtualKey == VK_SUBTRACT)
- return 0;
- }
- /*
- else if (message == WM_SYSKEYDOWN)
- {
- // return 0;
- }
- */
- else if (message == WM_KEYDOWN)
- {
- bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
- bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
- // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
- // bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
- bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
- switch(wParam)
- {
- case VK_RETURN:
- {
- if (shift && !alt && !ctrl)
- {
- _panel->OpenSelectedItems(false);
- return 0;
- }
- break;
- }
- case VK_NEXT:
- {
- if (ctrl && !alt && !shift)
- {
- _panel->OpenFocusedItemAsInternal();
- return 0;
- }
- break;
- }
- case VK_PRIOR:
- if (ctrl && !alt && !shift)
- {
- _panel->OpenParentFolder();
- return 0;
- }
- }
- }
- else if (message == WM_SETFOCUS)
- {
- _panel->_lastFocusedIsList = true;
- _panel->_panelCallback->PanelWasFocused();
- }
- #ifndef _UNICODE
- if (g_IsNT)
- return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
- else
- #endif
- return CallWindowProc(_origWindowProc, *this, message, wParam, 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);
-}
-*/
-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:
- {
- // check ALT
- if ((lParam & (1<<29)) == 0)
- break;
- bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
- bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
- bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
- if (alt && !ctrl && !shift)
- {
- _panel->_panelCallback->SetFocusToPath(wParam == VK_F1 ? 0 : 1);
- return 0;
- }
- break;
- }
- }
- break;
- case WM_KEYDOWN:
- switch (wParam)
- {
- case VK_TAB:
- // SendMessage(hwndMain, WM_ENTER, 0, 0);
- _panel->SetFocusToList();
- return 0;
- case VK_F9:
- {
- bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
- bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
- bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
- if (!alt && !ctrl && !shift)
- {
- g_App.SwitchOnOffOnePanel();;
- return 0;
- }
- break;
- }
- }
- break;
- case WM_CHAR:
- switch (wParam)
- {
- case VK_TAB:
- case VK_ESCAPE:
- return 0;
- }
- }
- #ifndef _UNICODE
- if (g_IsNT)
- return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
- else
- #endif
- return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
-}
-
-bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
-{
- // _virtualMode = false;
- // _sortIndex = 0;
- _sortID = kpidName;
- _ascending = true;
- _lastFocusedIsList = true;
-
- DWORD style = WS_CHILD | WS_VISIBLE; // | WS_BORDER ; // | LVS_SHAREIMAGELISTS; // | LVS_SHOWSELALWAYS;;
-
- style |= LVS_SHAREIMAGELISTS;
- // style |= LVS_AUTOARRANGE;
- style |= WS_CLIPCHILDREN;
- style |= WS_CLIPSIBLINGS;
-
- const UINT32 kNumListModes = sizeof(kStyles) / sizeof(kStyles[0]);
- if (_ListViewMode >= kNumListModes)
- _ListViewMode = kNumListModes - 1;
-
- style |= kStyles[_ListViewMode]
- | WS_TABSTOP
- | LVS_EDITLABELS;
- if (_mySelectMode)
- style |= LVS_SINGLESEL;
-
- /*
- if (_virtualMode)
- style |= LVS_OWNERDATA;
- */
-
- DWORD exStyle;
- exStyle = WS_EX_CLIENTEDGE;
-
- if (!_listView.CreateEx(exStyle, style, 0, 0, 116, 260,
- HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL))
- return false;
-
- _listView.SetUnicodeFormat(true);
-
- _listView.SetUserDataLongPtr(LONG_PTR(&_listView));
- _listView._panel = this;
-
- #ifndef _UNICODE
- if(g_IsNT)
- _listView._origWindowProc =
- (WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
- else
- #endif
- _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);
-
- // _exStyle |= LVS_EX_HEADERDRAGDROP;
- // DWORD extendedStyle = _listView.GetExtendedListViewStyle();
- // extendedStyle |= _exStyle;
- // _listView.SetExtendedListViewStyle(extendedStyle);
- SetExtendedStyle();
-
- _listView.Show(SW_SHOW);
- _listView.InvalidateRect(NULL, true);
- _listView.Update();
-
- // Ensure that the common control DLL is loaded.
- INITCOMMONCONTROLSEX icex;
-
- icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
- icex.dwICC = ICC_BAR_CLASSES;
- InitCommonControlsEx(&icex);
-
- TBBUTTON tbb [ ] =
- {
- // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
- {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
- // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
- // {VIEW_NEWFOLDER, kCreateFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
- };
-
- if (g_ComCtl32Version >= MAKELONG(71, 4))
- {
- icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
- icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
- InitCommonControlsEx(&icex);
-
- _headerReBar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
- REBARCLASSNAME,
- NULL, WS_VISIBLE | WS_BORDER | WS_CHILD |
- WS_CLIPCHILDREN | WS_CLIPSIBLINGS
- | CCS_NODIVIDER
- | CCS_NOPARENTALIGN
- | CCS_TOP
- | RBS_VARHEIGHT
- | RBS_BANDBORDERS
- ,0,0,0,0, HWND(*this), NULL, g_hInstance, NULL));
- }
-
- DWORD toolbarStyle = WS_CHILD | WS_VISIBLE ;
- if (_headerReBar)
- {
- toolbarStyle |= 0
- // | WS_CLIPCHILDREN
- // | WS_CLIPSIBLINGS
-
- | TBSTYLE_TOOLTIPS
- | CCS_NODIVIDER
- | CCS_NORESIZE
- | TBSTYLE_FLAT
- ;
- }
-
- _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);
- icex.dwICC = ICC_USEREX_CLASSES;
- InitCommonControlsEx(&icex);
-
- _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
- WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
- 0, 0, 100, 20,
- ((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
- (HMENU)(UINT_PTR)(_comboBoxID),
- g_hInstance, NULL);
- // _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
-
-
- _headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
-
- /*
- _headerComboBox.SetUserDataLongPtr(LONG_PTR(&_headerComboBox));
- _headerComboBox._panel = this;
- _headerComboBox._origWindowProc =
- (WNDPROC)_headerComboBox.SetLongPtr(GWLP_WNDPROC,
- LONG_PTR(ComboBoxSubclassProc));
- */
- _comboBoxEdit.Attach(_headerComboBox.GetEditControl());
-
- // _comboBoxEdit.SendMessage(CCM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
-
- _comboBoxEdit.SetUserDataLongPtr(LONG_PTR(&_comboBoxEdit));
- _comboBoxEdit._panel = this;
- #ifndef _UNICODE
- if(g_IsNT)
- _comboBoxEdit._origWindowProc =
- (WNDPROC)_comboBoxEdit.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
- else
- #endif
- _comboBoxEdit._origWindowProc =
- (WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
-
-
-
- if (_headerReBar)
- {
- REBARINFO rbi;
- rbi.cbSize = sizeof(REBARINFO); // Required when using this struct.
- rbi.fMask = 0;
- 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);
- SIZE size;
- _headerToolBar.GetMaxSize(&size);
-
- REBARBANDINFO rbBand;
- rbBand.cbSize = sizeof(REBARBANDINFO); // Required
- rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
- rbBand.fStyle = RBBS_NOGRIPPER;
- rbBand.cxMinChild = size.cx;
- rbBand.cyMinChild = size.cy;
- rbBand.cyChild = size.cy;
- rbBand.cx = size.cx;
- rbBand.hwndChild = _headerToolBar;
- _headerReBar.InsertBand(-1, &rbBand);
-
- RECT rc;
- ::GetWindowRect(_headerComboBox, &rc);
- rbBand.cxMinChild = 30;
- rbBand.cyMinChild = rc.bottom - rc.top;
- rbBand.cx = 1000;
- rbBand.hwndChild = _headerComboBox;
- _headerReBar.InsertBand(-1, &rbBand);
- // _headerReBar.MaximizeBand(1, false);
- }
-
- _statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
- // _statusBar2.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID + 1);
-
- int sizes[] = {150, 200, 250, -1};
- _statusBar.SetParts(4, sizes);
- // _statusBar2.SetParts(5, sizes);
-
- /*
- RECT rect;
- GetClientRect(&rect);
- OnSize(0, rect.right - rect.left, rect.top - rect.bottom);
- */
-
- SetTimer(kTimerID, kTimerElapse);
-
- // InitListCtrl();
- RefreshListCtrl();
- RefreshStatusBar();
-
- return true;
-}
-
-void CPanel::OnDestroy()
-{
- SaveListViewInfo();
- CWindow2::OnDestroy();
-}
-
-void CPanel::ChangeWindowSize(int xSize, int ySize)
-{
- int kHeaderSize;
- int kStatusBarSize;
- // int kStatusBar2Size;
- RECT rect;
- if (_headerReBar)
- _headerReBar.GetWindowRect(&rect);
- else
- _headerToolBar.GetWindowRect(&rect);
-
- kHeaderSize = rect.bottom - rect.top;
-
- _statusBar.GetWindowRect(&rect);
- kStatusBarSize = rect.bottom - rect.top;
-
- // _statusBar2.GetWindowRect(&rect);
- // kStatusBar2Size = rect.bottom - rect.top;
-
- int yListViewSize = MyMax(ySize - kHeaderSize - kStatusBarSize, 0);
- const int kStartXPos = 32;
- if (_headerReBar)
- {
- }
- else
- {
- _headerToolBar.Move(0, 0, xSize, 0);
- _headerComboBox.Move(kStartXPos, 2,
- MyMax(xSize - kStartXPos - 10, kStartXPos), 0);
- }
- _listView.Move(0, kHeaderSize, xSize, yListViewSize);
- _statusBar.Move(0, kHeaderSize + yListViewSize, xSize, kStatusBarSize);
- // _statusBar2.MoveWindow(0, kHeaderSize + yListViewSize + kStatusBarSize, xSize, kStatusBar2Size);
- // _statusBar.MoveWindow(0, 100, xSize, kStatusBarSize);
- // _statusBar2.MoveWindow(0, 200, xSize, kStatusBar2Size);
-}
-
-bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
-{
- if (_headerReBar)
- _headerReBar.Move(0, 0, xSize, 0);
- ChangeWindowSize(xSize, ySize);
- return true;
-}
-
-bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */)
-{
- switch(header->code)
- {
- case RBN_HEIGHTCHANGE:
- {
- RECT rect;
- GetWindowRect(&rect);
- ChangeWindowSize(rect.right - rect.left, rect.bottom - rect.top);
- return false;
- }
- }
- return false;
-}
-
-bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
-{
- if (!_processNotify)
- return false;
- if (header->hwndFrom == _headerComboBox)
- return OnNotifyComboBox(header, result);
- else if (header->hwndFrom == _headerReBar)
- return OnNotifyReBar(header, result);
- // if (header->hwndFrom == _listView)
- else if (header->hwndFrom == _listView)
- return OnNotifyList(header, result);
- else if (::GetParent(header->hwndFrom) == _listView &&
- header->code == NM_RCLICK)
- return OnRightClick((LPNMITEMACTIVATE)header, result);
- return false;
-}
-
-bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result)
-{
- if (itemID == kParentFolderID)
- {
- OpenParentFolder();
- result = 0;
- return true;
- }
- /*
- if (itemID == kCreateFolderID)
- {
- CreateFolder();
- result = 0;
- return true;
- }
- */
- if (itemID == _comboBoxID)
- {
- OnComboBoxCommand(code, lParam);
- }
- return CWindow2::OnCommand(code, itemID, lParam, result);
-}
-
-void CPanel::MessageBoxInfo(LPCWSTR message, LPCWSTR caption)
- { ::MessageBoxW(HWND(*this), message, caption, MB_OK); }
-void CPanel::MessageBox(LPCWSTR message, LPCWSTR caption)
- { ::MessageBoxW(HWND(*this), message, caption, MB_OK | MB_ICONSTOP); }
-void CPanel::MessageBox(LPCWSTR message)
- { MessageBox(message, L"7-Zip"); }
-void CPanel::MessageBoxMyError(LPCWSTR message)
- { MessageBox(message, L"Error"); }
-void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption)
- { MessageBox(NError::MyFormatMessageW(errorCode), caption); }
-void CPanel::MessageBoxError(HRESULT errorCode)
- { MessageBoxError(errorCode, L"7-Zip"); }
-void CPanel::MessageBoxLastError(LPCWSTR caption)
- { MessageBoxError(::GetLastError(), caption); }
-void CPanel::MessageBoxLastError()
- { MessageBoxLastError(L"Error"); }
-
-void CPanel::SetFocusToList()
-{
- _listView.SetFocus();
- // SetCurrentPathText();
-}
-
-void CPanel::SetFocusToLastRememberedItem()
-{
- if (_lastFocusedIsList)
- SetFocusToList();
- else
- _headerComboBox.SetFocus();
-}
-
-UString CPanel::GetFolderTypeID() const
-{
- CMyComPtr<IFolderGetTypeID> folderGetTypeID;
- if(_folder.QueryInterface(IID_IFolderGetTypeID, &folderGetTypeID) != S_OK)
- return L"";
- CMyComBSTR typeID;
- folderGetTypeID->GetTypeID(&typeID);
- return (wchar_t *)typeID;
-}
-
-bool CPanel::IsRootFolder() const
-{
- return (GetFolderTypeID() == L"RootFolder");
-}
-
-bool CPanel::IsFSFolder() const
-{
- return (GetFolderTypeID() == L"FSFolder");
-}
-
-bool CPanel::IsFSDrivesFolder() const
-{
- return (GetFolderTypeID() == L"FSDrives");
-}
-
-UString CPanel::GetFsPath() const
-{
- if (IsFSDrivesFolder())
- return UString();
- return _currentFolderPrefix;
-}
-
-UString CPanel::GetDriveOrNetworkPrefix() const
-{
- if (!IsFSFolder())
- return UString();
- UString drive = GetFsPath();
- if (drive.Length() < 3)
- return UString();
- if (drive[0] == L'\\' && drive[1] == L'\\')
- {
- // if network
- int pos = drive.Find(L'\\', 2);
- if (pos < 0)
- return UString();
- pos = drive.Find(L'\\', pos + 1);
- if (pos < 0)
- return UString();
- return drive.Left(pos + 1);
- }
- if (drive[1] != L':' || drive[2] != L'\\')
- return UString();
- return drive.Left(3);
-}
-
-bool CPanel::DoesItSupportOperations() const
-{
- CMyComPtr<IFolderOperations> folderOperations;
- return _folder.QueryInterface(IID_IFolderOperations, &folderOperations) == S_OK;
-}
-
-void CPanel::SetListViewMode(UINT32 index)
-{
- if (index >= 4)
- return;
- _ListViewMode = index;
- DWORD oldStyle = (DWORD)_listView.GetStyle();
- DWORD newStyle = kStyles[index];
- if ((oldStyle & LVS_TYPEMASK) != newStyle)
- _listView.SetStyle((oldStyle & ~LVS_TYPEMASK) | newStyle);
- // RefreshListCtrlSaveFocused();
-}
-
-void CPanel::ChangeFlatMode()
-{
- _flatMode = !_flatMode;
- RefreshListCtrlSaveFocused();
-}
-
-
-void CPanel::RefreshStatusBar()
-{
- PostMessage(kRefreshStatusBar);
-}
-
-void CPanel::AddToArchive()
-{
- CRecordVector<UINT32> indices;
- GetOperatedItemIndices(indices);
- if (!IsFSFolder())
- {
- MessageBox(L"Compress operation is not supported for that folder");
- return;
- }
- if (indices.Size() == 0)
- {
- MessageBox(kSelectFiles);
- return;
- }
- UStringVector names;
- for (int i = 0; i < indices.Size(); i++)
- {
- int index = indices[i];
- names.Add(_currentFolderPrefix + GetItemRelPath(index));
- }
- const UString archiveName = CreateArchiveName(
- names.Front(), (names.Size() > 1), false);
- CompressFiles(_currentFolderPrefix, archiveName, L"", names, false, true, false);
- // KillSelection();
-}
-
-static UString GetSubFolderNameForExtract(const UString &archiveName)
-{
- int slashPos = archiveName.ReverseFind(L'\\');
- int dotPos = archiveName.ReverseFind(L'.');
- if (dotPos < 0 || slashPos > dotPos)
- return archiveName + UString(L"~");
- UString res = archiveName.Left(dotPos);
- res.TrimRight();
- return res;
-}
-
-void CPanel::ExtractArchives()
-{
- if (_parentFolders.Size() > 0)
- {
- _panelCallback->OnCopy(false, false);
- return;
- }
- CRecordVector<UINT32> indices;
- GetOperatedItemIndices(indices);
- UStringVector paths;
- if (indices.Size() == 0)
- {
- MessageBox(kSelectOneFile);
- 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]));
- else
- folderName = L"*";
- ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(L"\\"), true);
-}
-
-void CPanel::TestArchives()
-{
- CRecordVector<UINT32> indices;
- GetOperatedItemIndices(indices);
- if (!IsFSFolder())
- {
- MessageBox(L"Test archive operation is not supported for that folder");
- return;
- }
- UStringVector paths;
- if (indices.Size() == 0)
- {
- MessageBox(kSelectOneFile);
- 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/7zip/FileManager/Panel.h b/7zip/FileManager/Panel.h
deleted file mode 100755
index e4e48d73..00000000
--- a/7zip/FileManager/Panel.h
+++ /dev/null
@@ -1,509 +0,0 @@
-// Panel.h
-
-#ifndef __PANEL_H
-#define __PANEL_H
-
-#include "Common/MyCom.h"
-
-#include "Windows/DLL.h"
-#include "Windows/FileFind.h"
-#include "Windows/FileDir.h"
-#include "Windows/Synchronization.h"
-#include "Windows/Handle.h"
-
-#include "Windows/Control/ToolBar.h"
-#include "Windows/Control/ReBar.h"
-#include "Windows/Control/ListView.h"
-#include "Windows/Control/Static.h"
-#include "Windows/Control/Edit.h"
-#include "Windows/Control/ComboBox.h"
-#include "Windows/Control/Window2.h"
-#include "Windows/Control/StatusBar.h"
-
-#include "SysIconUtils.h"
-#include "IFolder.h"
-#include "ViewSettings.h"
-#include "AppState.h"
-#include "MyCom2.h"
-
-const int kParentFolderID = 100;
-const int kPluginMenuStartID = 1000;
-const int kToolbarStartID = 2000;
-
-const int kParentIndex = -1;
-
-class CPanelCallback
-{
-public:
- virtual void OnTab() = 0;
- virtual void SetFocusToPath(int index) = 0;
- virtual void OnCopy(bool move, bool copyToSame) = 0;
- virtual void OnSetSameFolder() = 0;
- virtual void OnSetSubFolder() = 0;
- virtual void PanelWasFocused() = 0;
- virtual void DragBegin() = 0;
- virtual void DragEnd() = 0;
-};
-
-void PanelCopyItems();
-
-struct CItemProperty
-{
- UString Name;
- PROPID ID;
- VARTYPE Type;
- int Order;
- bool IsVisible;
- UInt32 Width;
-};
-
-inline bool operator<(const CItemProperty &a1, const CItemProperty &a2)
- { return (a1.Order < a2.Order); }
-
-inline bool operator==(const CItemProperty &a1, const CItemProperty &a2)
- { return (a1.Order == a2.Order); }
-
-class CItemProperties: public CObjectVector<CItemProperty>
-{
-public:
- int FindItemWithID(PROPID id)
- {
- for (int i = 0; i < Size(); i++)
- if ((*this)[i].ID == id)
- return i;
- return -1;
- }
-};
-
-struct CTempFileInfo
-{
- UString ItemName;
- UString FolderPath;
- UString FilePath;
- NWindows::NFile::NFind::CFileInfoW FileInfo;
- void DeleteDirAndFile()
- {
- NWindows::NFile::NDirectory::DeleteFileAlways(FilePath);
- NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath);
- }
-};
-
-struct CFolderLink: public CTempFileInfo
-{
- NWindows::NDLL::CLibrary Library;
- CMyComPtr<IFolderFolder> ParentFolder;
-};
-
-enum MyMessages
-{
- kShiftSelectMessage = WM_USER + 1,
- kReLoadMessage,
- kSetFocusToListView,
- kOpenItemChanged,
- kRefreshStatusBar
-};
-
-UString GetFolderPath(IFolderFolder * folder);
-
-class CPanel;
-
-class CMyListView: public NWindows::NControl::CListView
-{
-public:
- WNDPROC _origWindowProc;
- CPanel *_panel;
- LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
-};
-
-/*
-class CMyComboBox: public NWindows::NControl::CComboBoxEx
-{
-public:
- WNDPROC _origWindowProc;
- CPanel *_panel;
- LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
-};
-*/
-class CMyComboBoxEdit: public NWindows::NControl::CEdit
-{
-public:
- WNDPROC _origWindowProc;
- CPanel *_panel;
- LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
-};
-
-struct CSelectedState
-{
- int FocusedItem;
- UString FocusedName;
- bool SelectFocused;
- UStringVector SelectedNames;
- CSelectedState(): FocusedItem(-1), SelectFocused(false) {}
-};
-
-class CPanel:public NWindows::NControl::CWindow2
-{
- HWND _mainWindow;
-
- CExtToIconMap _extToIconMap;
- UINT _baseID;
- int _comboBoxID;
- UINT _statusBarID;
-
- CAppState *_appState;
-
- bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result);
- LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
- virtual bool OnCreate(CREATESTRUCT *createStruct);
- 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);
- bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
- #ifndef _UNICODE
- bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
- #endif
- bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result);
- bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result);
- void OnItemChanged(NMLISTVIEW *item);
- bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
- void OnDrag(LPNMLISTVIEW nmListView);
- bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
- BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
- BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
- void OnColumnClick(LPNMLISTVIEW info);
- bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
-
-public:
- CPanelCallback *_panelCallback;
-
- void DeleteItems(bool toRecycleBin);
- void CreateFolder();
- void CreateFile();
-
-private:
-
- void ChangeWindowSize(int xSize, int ySize);
-
- void InitColumns();
- // void InitColumns2(PROPID sortID);
- void InsertColumn(int index);
-
- void SetFocusedSelectedItem(int index, bool select);
- void RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
- const UStringVector &selectedNames);
-
- void OnShiftSelectMessage();
- void OnArrowWithShift();
-
- void OnInsert();
- // void OnUpWithShift();
- // void OnDownWithShift();
-public:
- void UpdateSelection();
- void SelectSpec(bool selectMode);
- void SelectByType(bool selectMode);
- void SelectAll(bool selectMode);
- void InvertSelection();
-private:
-
- // UString GetFileType(UInt32 index);
- LRESULT SetItemText(LVITEMW &item);
-
- // CRecordVector<PROPID> m_ColumnsPropIDs;
-
-public:
- NWindows::NControl::CReBar _headerReBar;
- NWindows::NControl::CToolBar _headerToolBar;
- NWindows::NControl::CComboBoxEx _headerComboBox;
- // CMyComboBox _headerComboBox;
- CMyComboBoxEdit _comboBoxEdit;
- CMyListView _listView;
- NWindows::NControl::CStatusBar _statusBar;
- bool _lastFocusedIsList;
- // NWindows::NControl::CStatusBar _statusBar2;
-
- DWORD _exStyle;
- bool _showDots;
- bool _showRealFileIcons;
- // bool _virtualMode;
- // CUIntVector _realIndices;
- bool _enableItemChangeNotify;
- bool _mySelectMode;
- CBoolVector _selectedStatusVector;
-
- CSelectedState _selectedState;
-
- UInt32 GetRealIndex(const LVITEMW &item) const
- {
- /*
- if (_virtualMode)
- return _realIndices[item.iItem];
- */
- return (UInt32)item.lParam;
- }
- int GetRealItemIndex(int indexInListView) const
- {
- /*
- if (_virtualMode)
- return indexInListView;
- */
- LPARAM param;
- if (!_listView.GetItemParam(indexInListView, param))
- throw 1;
- return (int)param;
- }
-
- UInt32 _ListViewMode;
- int _xSize;
-
- bool _flatMode;
-
- bool _dontShowMode;
-
-
- UString _currentFolderPrefix;
-
- CObjectVector<CFolderLink> _parentFolders;
- NWindows::NDLL::CLibrary _library;
- CMyComPtr<IFolderFolder> _folder;
- // CMyComPtr<IFolderGetSystemIconIndex> _folderGetSystemIconIndex;
-
- UStringVector _fastFolders;
-
- void GetSelectedNames(UStringVector &selectedNames);
- void SaveSelectedState(CSelectedState &s);
- void RefreshListCtrl(const CSelectedState &s);
- void RefreshListCtrlSaveFocused();
-
- UString GetItemName(int itemIndex) const;
- UString GetItemPrefix(int itemIndex) const;
- UString GetItemRelPath(int itemIndex) const;
- bool IsItemFolder(int itemIndex) const;
- UInt64 GetItemSize(int itemIndex) const;
-
- ////////////////////////
- // PanelFolderChange.cpp
-
- void SetToRootFolder();
- HRESULT BindToPath(const UString &fullPath); // can be prefix
- HRESULT BindToPathAndRefresh(const UString &path);
- void OpenDrivesFolder();
-
- void SetBookmark(int index);
- void OpenBookmark(int index);
-
- void LoadFullPath();
- void LoadFullPathAndShow();
- void FoldersHistory();
- void OpenParentFolder();
- void CloseOpenFolders();
- void OpenRootFolder();
-
-
- LRESULT Create(HWND mainWindow, HWND parentWindow,
- UINT id,
- const UString &currentFolderPrefix,
- CPanelCallback *panelCallback,
- CAppState *appState);
- void SetFocusToList();
- void SetFocusToLastRememberedItem();
-
-
- void ReadListViewInfo();
- void SaveListViewInfo();
-
- CPanel() :
- // _virtualMode(flase),
- _exStyle(0),
- _showDots(false),
- _showRealFileIcons(false),
- _needSaveInfo(false),
- _startGroupSelect(0),
- _selectionIsDefined(false),
- _ListViewMode(3),
- _flatMode(false),
- _xSize(300),
- _mySelectMode(false),
- _enableItemChangeNotify(true),
- _dontShowMode(false)
- {}
-
- void SetExtendedStyle()
- {
- if (_listView != 0)
- _listView.SetExtendedListViewStyle(_exStyle);
- }
-
-
- bool _needSaveInfo;
- UString _typeIDString;
- CListViewInfo _listViewInfo;
- CItemProperties _properties;
- CItemProperties _visibleProperties;
-
- PROPID _sortID;
- // int _sortIndex;
- bool _ascending;
-
- void Release();
- ~CPanel();
- void OnLeftClick(LPNMITEMACTIVATE itemActivate);
- bool OnRightClick(LPNMITEMACTIVATE itemActivate, LRESULT &result);
-
- void OnTimer();
- void OnReload();
- bool OnContextMenu(HANDLE windowHandle, int xPos, int yPos);
-
- CMyComPtr<IContextMenu> _sevenZipContextMenu;
- CMyComPtr<IContextMenu> _systemContextMenu;
- HRESULT CreateShellContextMenu(
- const CRecordVector<UInt32> &operatedIndices,
- CMyComPtr<IContextMenu> &systemContextMenu);
- void CreateSystemMenu(HMENU menu,
- const CRecordVector<UInt32> &operatedIndices,
- CMyComPtr<IContextMenu> &systemContextMenu);
- void CreateSevenZipMenu(HMENU menu,
- const CRecordVector<UInt32> &operatedIndices,
- CMyComPtr<IContextMenu> &sevenZipContextMenu);
- 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,
- IContextMenu *systemContextMenu);
-
- void InvokeSystemCommand(const char *command);
- void Properties();
- void EditCopy();
- void EditPaste();
-
- int _startGroupSelect;
-
- bool _selectionIsDefined;
- bool _selectMark;
- int _prevFocusedItem;
-
-
- // void SortItems(int index);
- void SortItemsWithPropID(PROPID propID);
-
- void GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const;
- void GetOperatedItemIndices(CRecordVector<UInt32> &indices) const;
- // void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const;
- void KillSelection();
-
- UString GetFolderTypeID() const;
- bool IsRootFolder() const;
- bool IsFSFolder() const;
- bool IsFSDrivesFolder() const;
-
- UString GetFsPath() const;
- UString GetDriveOrNetworkPrefix() const;
-
- bool DoesItSupportOperations() const;
-
- bool _processTimer;
- bool _processNotify;
-
- class CDisableTimerProcessing
- {
- bool _processTimerMem;
- bool _processNotifyMem;
-
- CPanel &_panel;
- public:
-
- CDisableTimerProcessing(CPanel &panel): _panel(panel)
- {
- Disable();
- }
- void Disable()
- {
- _processTimerMem = _panel._processTimer;
- _processNotifyMem = _panel._processNotify;
- _panel._processTimer = false;
- _panel._processNotify = false;
- }
- void Restore()
- {
- _panel._processTimer = _processTimerMem;
- _panel._processNotify = _processNotifyMem;
- }
- ~CDisableTimerProcessing()
- {
- Restore();
- }
- CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
- };
-
- // bool _passwordIsDefined;
- // UString _password;
-
- void RefreshListCtrl();
-
- void MessageBoxInfo(LPCWSTR message, LPCWSTR caption);
- void MessageBox(LPCWSTR message);
- void MessageBox(LPCWSTR message, LPCWSTR caption);
- void MessageBoxMyError(LPCWSTR message);
- void MessageBoxError(HRESULT errorCode, LPCWSTR caption);
- void MessageBoxError(HRESULT errorCode);
- void MessageBoxLastError(LPCWSTR caption);
- void MessageBoxLastError();
-
-
- void OpenFocusedItemAsInternal();
- void OpenSelectedItems(bool internal);
-
- void OpenFolderExternal(int index);
-
- void OpenFolder(int index);
- HRESULT OpenParentArchiveFolder();
- HRESULT OpenItemAsArchive(const UString &name,
- const UString &folderPath,
- const UString &filePath);
- HRESULT OpenItemAsArchive(const UString &aName);
- HRESULT OpenItemAsArchive(int index);
- void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
- bool editMode);
- HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName);
- LRESULT OnOpenItemChanged(LPARAM lParam);
-
- void OpenItem(int index, bool tryInternal, bool tryExternal);
- void EditItem();
- void EditItem(int index);
-
- void RenameFile();
- void ChangeComment();
-
- void SetListViewMode(UInt32 index);
- UInt32 GetListViewMode() const { return _ListViewMode; };
-
- void ChangeFlatMode();
- bool GetFlatMode() const { return _flatMode; };
-
- void RefreshStatusBar();
- void OnRefreshStatusBar();
-
- void AddToArchive();
- void ExtractArchives();
- void TestArchives();
-
- HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
- bool moveMode, bool showErrorMessages, UStringVector *messages);
-
- HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
- bool showErrorMessages, UStringVector *messages);
-
- void CopyFrom(const UStringVector &filePaths);
-
- // empty folderPath means create new Archive to path of first fileName.
- void DropObject(IDataObject * dataObject, const UString &folderPath);
-
- // empty folderPath means create new Archive to path of first fileName.
- void CompressDropFiles(const UStringVector &fileNames, const UString &folderPath);
-};
-
-#endif
diff --git a/7zip/FileManager/PanelCopy.cpp b/7zip/FileManager/PanelCopy.cpp
deleted file mode 100755
index 5aa19173..00000000
--- a/7zip/FileManager/PanelCopy.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-// PanelExtract.cpp
-
-#include "StdAfx.h"
-
-#include "Windows/COM.h"
-
-#include "Panel.h"
-#include "resource.h"
-#include "LangUtils.h"
-#include "ExtractCallback.h"
-#include "Windows/Thread.h"
-////////////////////////////////////////////////////////////////
-
-#include "..\UI\Resource\Extract\resource.h"
-
-#include "UpdateCallback100.h"
-
-using namespace NWindows;
-
-struct CThreadExtractInArchive2
-{
- CMyComPtr<IFolderOperations> FolderOperations;
- CRecordVector<UInt32> Indices;
- UString DestPath;
- CExtractCallbackImp *ExtractCallbackSpec;
- CMyComPtr<IFolderOperationsExtractCallback> ExtractCallback;
- HRESULT Result;
- bool MoveMode;
-
- CThreadExtractInArchive2(): MoveMode(false) {}
-
- DWORD Extract()
- {
- // NCOM::CComInitializer comInitializer;
- ExtractCallbackSpec->ProgressDialog.WaitCreating();
- if (MoveMode)
- Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(),
- DestPath, ExtractCallback);
- else
- Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(),
- DestPath, ExtractCallback);
- ExtractCallbackSpec->ProgressDialog.MyClose();
- return 0;
- }
-
- static DWORD WINAPI MyThreadFunction(void *param)
- {
- return ((CThreadExtractInArchive2 *)param)->Extract();
- }
-};
-
-HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
- bool moveMode, bool showErrorMessages, UStringVector *messages)
-{
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- {
- UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
- if (showErrorMessages)
- MessageBox(errorMessage);
- else if (messages != 0)
- messages->Add(errorMessage);
- return E_FAIL;
- }
-
- CThreadExtractInArchive2 extracter;
-
- extracter.ExtractCallbackSpec = new CExtractCallbackImp;
- extracter.ExtractCallback = extracter.ExtractCallbackSpec;
- extracter.ExtractCallbackSpec->ParentWindow = GetParent();
- extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages;
-
- UString title = moveMode ?
- LangString(IDS_MOVING, 0x03020206):
- LangString(IDS_COPYING, 0x03020205);
- UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
-
- extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent();
- extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
- extracter.ExtractCallbackSpec->ProgressDialog.MainAddTitle = title + L" ";
-
- extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
- extracter.ExtractCallbackSpec->Init();
- extracter.Indices = indices;
- extracter.DestPath = folder;
- extracter.FolderOperations = folderOperations;
- extracter.MoveMode = moveMode;
-
- CThread extractThread;
- if (!extractThread.Create(CThreadExtractInArchive2::MyThreadFunction, &extracter))
- throw 271824;
- extracter.ExtractCallbackSpec->StartProgressDialog(title);
-
- if (messages != 0)
- *messages = extracter.ExtractCallbackSpec->Messages;
- return extracter.Result;
-}
-
-
-struct CThreadUpdate
-{
- CMyComPtr<IFolderOperations> FolderOperations;
- UString FolderPrefix;
- UStringVector FileNames;
- CRecordVector<const wchar_t *> FileNamePointers;
- CMyComPtr<IFolderArchiveUpdateCallback> UpdateCallback;
- CUpdateCallback100Imp *UpdateCallbackSpec;
- HRESULT Result;
-
- DWORD Process()
- {
- NCOM::CComInitializer comInitializer;
- UpdateCallbackSpec->ProgressDialog.WaitCreating();
- Result = FolderOperations->CopyFrom(
- FolderPrefix,
- &FileNamePointers.Front(),
- FileNamePointers.Size(),
- UpdateCallback);
- UpdateCallbackSpec->ProgressDialog.MyClose();
- return 0;
- }
-
- static DWORD WINAPI MyThreadFunction(void *param)
- {
- return ((CThreadUpdate *)param)->Process();
- }
-};
-
-
-HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
- bool showErrorMessages, UStringVector *messages)
-{
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- {
- UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
- if (showErrorMessages)
- MessageBox(errorMessage);
- else if (messages != 0)
- messages->Add(errorMessage);
- return E_FAIL;
- }
-
- CThreadUpdate updater;
- updater.UpdateCallbackSpec = new CUpdateCallback100Imp;
- updater.UpdateCallback = updater.UpdateCallbackSpec;
-
- UString title = LangString(IDS_COPYING, 0x03020205);
- UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
-
- updater.UpdateCallbackSpec->ProgressDialog.MainWindow = GetParent();
- updater.UpdateCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
- updater.UpdateCallbackSpec->ProgressDialog.MainAddTitle = title + UString(L" ");
-
- updater.UpdateCallbackSpec->Init((HWND)*this, false, L"");
- updater.FolderOperations = folderOperations;
- updater.FolderPrefix = folderPrefix;
- updater.FileNames.Reserve(filePaths.Size());
- int i;
- for(i = 0; i < filePaths.Size(); i++)
- updater.FileNames.Add(filePaths[i]);
- updater.FileNamePointers.Reserve(updater.FileNames.Size());
- for(i = 0; i < updater.FileNames.Size(); i++)
- updater.FileNamePointers.Add(updater.FileNames[i]);
-
- CThread thread;
- if (!thread.Create(CThreadUpdate::MyThreadFunction, &updater))
- throw 271824;
- updater.UpdateCallbackSpec->StartProgressDialog(title);
-
- if (messages != 0)
- *messages = updater.UpdateCallbackSpec->Messages;
-
- return updater.Result;
-}
-
-void CPanel::CopyFrom(const UStringVector &filePaths)
-{
- UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222);
- UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223);
- message += L"\n\'";
- message += _currentFolderPrefix;
- message += L"\' ?";
- int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION | MB_SYSTEMMODAL);
- if (res != IDYES)
- return;
-
- CDisableTimerProcessing disableTimerProcessing(*this);
-
- CSelectedState srcSelState;
- SaveSelectedState(srcSelState);
-
- HRESULT result = CopyFrom(L"", filePaths, true, 0);
-
- if (result != S_OK)
- {
- disableTimerProcessing.Restore();
- // For Password:
- SetFocusToList();
- if (result != E_ABORT)
- MessageBoxError(result);
- return;
- }
-
- RefreshListCtrl(srcSelState);
-
- disableTimerProcessing.Restore();
- SetFocusToList();
-}
-
diff --git a/7zip/FileManager/PanelDrag.cpp b/7zip/FileManager/PanelDrag.cpp
deleted file mode 100755
index 95273102..00000000
--- a/7zip/FileManager/PanelDrag.cpp
+++ /dev/null
@@ -1,796 +0,0 @@
-// PanelDrag.cpp
-
-#include "StdAfx.h"
-
-#include "Common/StringConvert.h"
-
-#include "Windows/Memory.h"
-#include "Windows/FileDir.h"
-#include "Windows/Shell.h"
-
-#include "../UI/Common/ArchiveName.h"
-#include "../UI/Common/CompressCall.h"
-
-#include "Resource/MessagesDialog/MessagesDialog.h"
-
-#include "App.h"
-#include "EnumFormatEtc.h"
-
-using namespace NWindows;
-
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-static wchar_t *kTempDirPrefix = L"7zE";
-static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
-
-////////////////////////////////////////////////////////
-
-class CDataObject:
- public IDataObject,
- public CMyUnknownImp
-{
-private:
- FORMATETC m_Etc;
- UINT m_SetFolderFormat;
-
-public:
- MY_UNKNOWN_IMP1_MT(IDataObject)
-
- STDMETHODIMP GetData(LPFORMATETC pformatetcIn, LPSTGMEDIUM medium);
- STDMETHODIMP GetDataHere(LPFORMATETC pformatetc, LPSTGMEDIUM medium);
- STDMETHODIMP QueryGetData(LPFORMATETC pformatetc );
-
- STDMETHODIMP GetCanonicalFormatEtc ( LPFORMATETC /* pformatetc */, LPFORMATETC pformatetcOut)
- { pformatetcOut->ptd = NULL; return ResultFromScode(E_NOTIMPL); }
-
- STDMETHODIMP SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL release);
- STDMETHODIMP EnumFormatEtc(DWORD drection, LPENUMFORMATETC *enumFormatEtc);
-
- STDMETHODIMP DAdvise(FORMATETC * /* etc */, DWORD /* advf */, LPADVISESINK /* pAdvSink */, DWORD * /* pdwConnection */)
- { return OLE_E_ADVISENOTSUPPORTED; }
- STDMETHODIMP DUnadvise(DWORD /* dwConnection */) { return OLE_E_ADVISENOTSUPPORTED; }
- STDMETHODIMP EnumDAdvise( LPENUMSTATDATA * /* ppenumAdvise */) { return OLE_E_ADVISENOTSUPPORTED; }
-
- CDataObject();
-
- NMemory::CGlobal hGlobal;
- UString Path;
-};
-
-CDataObject::CDataObject()
-{
- m_SetFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat);
- m_Etc.cfFormat = CF_HDROP;
- m_Etc.ptd = NULL;
- m_Etc.dwAspect = DVASPECT_CONTENT;
- m_Etc.lindex = -1;
- m_Etc.tymed = TYMED_HGLOBAL;
-}
-
-STDMETHODIMP CDataObject::SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL /* release */)
-{
- 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;
- size_t size = GlobalSize(medium->hGlobal) / sizeof(wchar_t);
- const wchar_t *src = (const wchar_t *)GlobalLock(medium->hGlobal);
- if (src != 0)
- {
- for (size_t i = 0; i < size; i++)
- {
- wchar_t c = src[i];
- if (c == 0)
- break;
- Path += c;
- }
- GlobalUnlock(medium->hGlobal);
- return S_OK;
- }
- }
- return E_NOTIMPL;
-}
-
-static HGLOBAL DuplicateGlobalMem(HGLOBAL srcGlobal)
-{
- SIZE_T size = GlobalSize(srcGlobal);
- const void *src = GlobalLock(srcGlobal);
- if (src == 0)
- return 0;
- HGLOBAL destGlobal = GlobalAlloc(GHND | GMEM_SHARE, size);
- if (destGlobal != 0)
- {
- void *dest = GlobalLock(destGlobal);
- if (dest == 0)
- {
- GlobalFree(destGlobal);
- destGlobal = 0;
- }
- else
- {
- memcpy(dest, src, size);
- GlobalUnlock(destGlobal);
- }
- }
- GlobalUnlock(srcGlobal);
- return destGlobal;
-}
-
-STDMETHODIMP CDataObject::GetData(LPFORMATETC etc, LPSTGMEDIUM medium)
-{
- RINOK(QueryGetData(etc));
- medium->tymed = m_Etc.tymed;
- medium->pUnkForRelease = 0;
- medium->hGlobal = DuplicateGlobalMem(hGlobal);
- if (medium->hGlobal == 0)
- return E_OUTOFMEMORY;
- return S_OK;
-}
-
-STDMETHODIMP CDataObject::GetDataHere(LPFORMATETC /* etc */, LPSTGMEDIUM /* medium */)
-{
- // Seems Windows doesn't call it, so we will not implement it.
- return E_UNEXPECTED;
-}
-
-
-STDMETHODIMP CDataObject::QueryGetData(LPFORMATETC etc)
-{
- if ((m_Etc.tymed & etc->tymed) &&
- m_Etc.cfFormat == etc->cfFormat &&
- m_Etc.dwAspect == etc->dwAspect)
- return S_OK;
- return DV_E_FORMATETC;
-}
-
-STDMETHODIMP CDataObject::EnumFormatEtc(DWORD direction, LPENUMFORMATETC FAR* enumFormatEtc)
-{
- if(direction != DATADIR_GET)
- return E_NOTIMPL;
- return CreateEnumFormatEtc(1, &m_Etc, enumFormatEtc);
-}
-
-////////////////////////////////////////////////////////
-
-class CDropSource:
- public IDropSource,
- public CMyUnknownImp
-{
- DWORD m_Effect;
-public:
- MY_UNKNOWN_IMP1_MT(IDropSource)
- STDMETHOD(QueryContinueDrag)(BOOL escapePressed, DWORD keyState);
- STDMETHOD(GiveFeedback)(DWORD effect);
-
-
- bool NeedExtract;
- CPanel *Panel;
- CRecordVector<UInt32> Indices;
- UString Folder;
- CDataObject *DataObjectSpec;
- CMyComPtr<IDataObject> DataObject;
-
- bool NeedPostCopy;
- HRESULT Result;
- UStringVector Messages;
-
- CDropSource(): NeedPostCopy(false), Panel(0), Result(S_OK), m_Effect(DROPEFFECT_NONE) {}
-};
-
-STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState)
-{
- if(escapePressed == TRUE)
- return DRAGDROP_S_CANCEL;
- if((keyState & MK_LBUTTON) == 0)
- {
- if (m_Effect == DROPEFFECT_NONE)
- return DRAGDROP_S_CANCEL;
- Result = S_OK;
- bool needExtract = NeedExtract;
- // MoveMode = (((keyState & MK_SHIFT) != 0) && MoveIsAllowed);
- if (!DataObjectSpec->Path.IsEmpty())
- {
- needExtract = false;
- NeedPostCopy = true;
- }
- if (needExtract)
- {
- Result = Panel->CopyTo(Indices, Folder,
- false, // moveMode,
- false, // showMessages
- &Messages);
- if (Result != S_OK || !Messages.IsEmpty())
- return DRAGDROP_S_CANCEL;
- }
- return DRAGDROP_S_DROP;
- }
- return S_OK;
-}
-
-STDMETHODIMP CDropSource::GiveFeedback(DWORD effect)
-{
- m_Effect = effect;
- return DRAGDROP_S_USEDEFAULTCURSORS;
-}
-
-static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &names)
-{
- size_t totalLength = 1;
-
- #ifndef _UNICODE
- if (!g_IsNT)
- {
- AStringVector namesA;
- int i;
- for (i = 0; i < names.Size(); i++)
- namesA.Add(GetSystemString(names[i]));
- for (i = 0; i < names.Size(); i++)
- totalLength += namesA[i].Length() + 1;
-
- if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(CHAR) + sizeof(DROPFILES)))
- return false;
-
- NMemory::CGlobalLock dropLock(hgDrop);
- DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
- if (dropFiles == 0)
- return false;
- dropFiles->fNC = FALSE;
- dropFiles->pt.x = 0;
- dropFiles->pt.y = 0;
- dropFiles->pFiles = sizeof(DROPFILES);
- dropFiles->fWide = FALSE;
- CHAR *p = (CHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
- for (i = 0; i < names.Size(); i++)
- {
- const AString &s = namesA[i];
- int fullLength = s.Length() + 1;
- MyStringCopy(p, (const char *)s);
- p += fullLength;
- totalLength -= fullLength;
- }
- *p = 0;
- }
- else
- #endif
- {
- int i;
- for (i = 0; i < names.Size(); i++)
- totalLength += names[i].Length() + 1;
-
- if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(WCHAR) + sizeof(DROPFILES)))
- return false;
-
- NMemory::CGlobalLock dropLock(hgDrop);
- DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
- if (dropFiles == 0)
- return false;
- dropFiles->fNC = FALSE;
- dropFiles->pt.x = 0;
- dropFiles->pt.y = 0;
- dropFiles->pFiles = sizeof(DROPFILES);
- dropFiles->fWide = TRUE;
- WCHAR *p = (WCHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
- for (i = 0; i < names.Size(); i++)
- {
- const UString &s = names[i];
- int fullLength = s.Length() + 1;
- MyStringCopy(p, (const WCHAR *)s);
- p += fullLength;
- totalLength -= fullLength;
- }
- *p = 0;
- }
- return true;
-}
-
-void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
-{
- CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
- if (!DoesItSupportOperations())
- return;
- CRecordVector<UInt32> indices;
- GetOperatedItemIndices(indices);
- if (indices.Size() == 0)
- return;
-
- // CSelectedState selState;
- // SaveSelectedState(selState);
-
- UString dirPrefix;
- NFile::NDirectory::CTempDirectoryW tempDirectory;
-
- bool isFSFolder = IsFSFolder();
- if (isFSFolder)
- dirPrefix = _currentFolderPrefix;
- else
- {
- tempDirectory.Create(kTempDirPrefix);
- dirPrefix = tempDirectory.GetPath();
- NFile::NName::NormalizeDirPathPrefix(dirPrefix);
- }
-
- CDataObject *dataObjectSpec = new CDataObject;
- CMyComPtr<IDataObject> dataObject = dataObjectSpec;
-
- {
- UStringVector names;
- for (int i = 0; i < indices.Size(); i++)
- {
- UInt32 index = indices[i];
- UString s;
- if (isFSFolder)
- s = GetItemRelPath(index);
- else
- s = GetItemName(index);
- names.Add(dirPrefix + s);
- }
- if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names))
- return;
- }
-
- CDropSource *dropSourceSpec = new CDropSource;
- CMyComPtr<IDropSource> dropSource = dropSourceSpec;
- dropSourceSpec->NeedExtract = !isFSFolder;
- dropSourceSpec->Panel = this;
- dropSourceSpec->Indices = indices;
- dropSourceSpec->Folder = dirPrefix;
- dropSourceSpec->DataObjectSpec = dataObjectSpec;
- dropSourceSpec->DataObject = dataObjectSpec;
-
- bool moveIsAllowed = isFSFolder;
-
- DWORD effectsOK = DROPEFFECT_COPY;
- if (moveIsAllowed)
- effectsOK |= DROPEFFECT_MOVE;
- DWORD effect;
- _panelCallback->DragBegin();
- HRESULT res = DoDragDrop(dataObject, dropSource, effectsOK, &effect);
- _panelCallback->DragEnd();
- bool canceled = (res == DRAGDROP_S_CANCEL);
- if (res == DRAGDROP_S_DROP)
- {
- res = dropSourceSpec->Result;
- if (dropSourceSpec->NeedPostCopy)
- if (!dataObjectSpec->Path.IsEmpty())
- {
- NFile::NName::NormalizeDirPathPrefix(dataObjectSpec->Path);
- res = CopyTo(indices, dataObjectSpec->Path,
- (effect == DROPEFFECT_MOVE),// dropSourceSpec->MoveMode,
- false, // showErrorMessages
- &dropSourceSpec->Messages);
- }
- /*
- if (effect == DROPEFFECT_MOVE)
- RefreshListCtrl(selState);
- */
- }
- else
- {
- if (res != DRAGDROP_S_CANCEL && res != S_OK)
- MessageBoxError(res);
- res = dropSourceSpec->Result;
- }
-
- if (!dropSourceSpec->Messages.IsEmpty())
- {
- CMessagesDialog messagesDialog;
- messagesDialog.Messages = &dropSourceSpec->Messages;
- messagesDialog.Create((*this));
- }
- if (res != S_OK && res != E_ABORT)
- MessageBoxError(res);
- if (res == S_OK && dropSourceSpec->Messages.IsEmpty() && !canceled)
- KillSelection();
-}
-
-void CDropTarget::QueryGetData(IDataObject *dataObject)
-{
- FORMATETC etc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
- m_DropIsAllowed = (dataObject->QueryGetData(&etc) == S_OK);
-
-}
-
-static void MySetDropHighlighted(HWND hWnd, int index, bool enable)
-{
- LVITEM item;
- item.mask = LVIF_STATE;
- item.iItem = index;
- item.iSubItem = 0;
- item.state = enable ? LVIS_DROPHILITED : 0;
- item.stateMask = LVIS_DROPHILITED;
- item.pszText = 0;
- ListView_SetItem(hWnd, &item);
-}
-
-void CDropTarget::RemoveSelection()
-{
- if (m_SelectionIndex >= 0 && m_Panel != 0)
- MySetDropHighlighted(m_Panel->_listView, m_SelectionIndex, false);
- m_SelectionIndex = -1;
-}
-
-void CDropTarget::PositionCursor(POINTL ptl)
-{
- m_SubFolderIndex = -1;
- POINT pt;
- pt.x = ptl.x;
- pt.y = ptl.y;
-
- RemoveSelection();
- m_IsAppTarget = true;
- m_Panel = NULL;
-
- m_PanelDropIsAllowed = true;
- if (!m_DropIsAllowed)
- return;
- {
- POINT pt2 = pt;
- App->_window.ScreenToClient(&pt2);
- for (int i = 0; i < kNumPanelsMax; i++)
- if (App->IsPanelVisible(i))
- if (App->Panels[i].IsEnabled())
- if (ChildWindowFromPointEx(App->_window, pt2,
- CWP_SKIPINVISIBLE | CWP_SKIPDISABLED) == (HWND)App->Panels[i])
- {
- m_Panel = &App->Panels[i];
- m_IsAppTarget = false;
- if (i == SrcPanelIndex)
- {
- m_PanelDropIsAllowed = false;
- return;
- }
- break;
- }
- if (m_IsAppTarget)
- {
- if (TargetPanelIndex >= 0)
- m_Panel = &App->Panels[TargetPanelIndex];
- return;
- }
- }
-
- /*
- m_PanelDropIsAllowed = m_Panel->DoesItSupportOperations();
- if (!m_PanelDropIsAllowed)
- return;
- */
-
- if (!m_Panel->IsFSFolder() && !m_Panel->IsFSDrivesFolder())
- return;
-
- if (WindowFromPoint(pt) != (HWND)m_Panel->_listView)
- return;
-
- LVHITTESTINFO info;
- m_Panel->_listView.ScreenToClient(&pt);
- info.pt = pt;
- int index = ListView_HitTest(m_Panel->_listView, &info);
- if (index < 0)
- return;
- int realIndex = m_Panel->GetRealItemIndex(index);
- if (realIndex == kParentIndex)
- return;
- if (!m_Panel->IsItemFolder(realIndex))
- return;
- m_SubFolderIndex = realIndex;
- m_SubFolderName = m_Panel->GetItemName(m_SubFolderIndex);
- MySetDropHighlighted(m_Panel->_listView, index, true);
- m_SelectionIndex = index;
-}
-
-bool CDropTarget::IsFsFolderPath() const
-{
- if (!m_IsAppTarget && m_Panel != 0)
- return (m_Panel->IsFSFolder() || (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0));
- return false;
-}
-
-static void ReadUnicodeStrings(const wchar_t *p, size_t size, UStringVector &names)
-{
- names.Clear();
- UString name;
- for (;size > 0; size--)
- {
- wchar_t c = *p++;
- if (c == 0)
- {
- if (name.IsEmpty())
- break;
- names.Add(name);
- name.Empty();
- }
- else
- name += c;
- }
-}
-
-static void ReadAnsiStrings(const char *p, size_t size, UStringVector &names)
-{
- names.Clear();
- AString name;
- for (;size > 0; size--)
- {
- char c = *p++;
- if (c == 0)
- {
- if (name.IsEmpty())
- break;
- names.Add(GetUnicodeString(name));
- name.Empty();
- }
- else
- name += c;
- }
-}
-
-static void GetNamesFromDataObject(IDataObject *dataObject, UStringVector &names)
-{
- names.Clear();
- FORMATETC etc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
- STGMEDIUM medium;
- HRESULT res = dataObject->GetData(&etc, &medium);
- if (res != S_OK)
- return;
- if (medium.tymed != TYMED_HGLOBAL)
- return;
- {
- NMemory::CGlobal global;
- global.Attach(medium.hGlobal);
- size_t blockSize = GlobalSize(medium.hGlobal);
- NMemory::CGlobalLock dropLock(medium.hGlobal);
- const DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
- if (dropFiles == 0)
- return;
- if (blockSize < dropFiles->pFiles)
- return;
- size_t size = blockSize - dropFiles->pFiles;
- const void *namesData = (const Byte *)dropFiles + dropFiles->pFiles;
- if (dropFiles->fWide)
- ReadUnicodeStrings((const wchar_t *)namesData, size / sizeof(wchar_t), names);
- else
- ReadAnsiStrings((const char *)namesData, size, names);
- }
-}
-
-bool CDropTarget::IsItSameDrive() const
-{
- if (m_Panel == 0)
- return false;
- if (!IsFsFolderPath())
- return false;
- UString drive;
- if (m_Panel->IsFSFolder())
- {
- drive = m_Panel->GetDriveOrNetworkPrefix();
- if (drive.IsEmpty())
- return false;
- }
- else if (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0)
- drive = m_SubFolderName + L'\\';
- else
- return false;
-
- if (m_SourcePaths.Size() == 0)
- return false;
- for (int i = 0; i < m_SourcePaths.Size(); i++)
- {
- const UString &path = m_SourcePaths[i];
- if (drive.CompareNoCase(path.Left(drive.Length())) != 0)
- return false;
- }
- return true;
-
-}
-
-DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffect)
-{
- if (!m_DropIsAllowed || !m_PanelDropIsAllowed)
- return DROPEFFECT_NONE;
-
- if (!IsFsFolderPath())
- allowedEffect &= ~DROPEFFECT_MOVE;
-
- if (!m_SetPathIsOK)
- allowedEffect &= ~DROPEFFECT_MOVE;
-
- DWORD effect = 0;
- if(keyState & MK_CONTROL)
- effect = allowedEffect & DROPEFFECT_COPY;
- else if(keyState & MK_SHIFT)
- effect = allowedEffect & DROPEFFECT_MOVE;
- if(effect == 0)
- {
- if(allowedEffect & DROPEFFECT_COPY)
- effect = DROPEFFECT_COPY;
- if(allowedEffect & DROPEFFECT_MOVE)
- {
- if (IsItSameDrive())
- effect = DROPEFFECT_MOVE;
- }
- }
- if(effect == 0)
- return DROPEFFECT_NONE;
- return effect;
-}
-
-UString CDropTarget::GetTargetPath() const
-{
- if (!IsFsFolderPath())
- return UString();
- UString path = m_Panel->_currentFolderPrefix;
- if (m_Panel->IsFSDrivesFolder())
- path.Empty();
- if (m_SubFolderIndex >= 0 && !m_SubFolderName.IsEmpty())
- {
- path += m_SubFolderName;
- path += L"\\";
- }
- return path;
-}
-
-bool CDropTarget::SetPath(bool enablePath) const
-{
- UINT setFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat);
-
- FORMATETC etc = { (CLIPFORMAT)setFolderFormat, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
- STGMEDIUM medium;
- medium.tymed = etc.tymed;
- medium.pUnkForRelease = 0;
- UString path;
- if (enablePath)
- path = GetTargetPath();
- size_t size = path.Length() + 1;
- medium.hGlobal = GlobalAlloc(GHND | GMEM_SHARE, size * sizeof(wchar_t));
- if (medium.hGlobal == 0)
- return false;
- wchar_t *dest = (wchar_t *)GlobalLock(medium.hGlobal);
- if (dest == 0)
- {
- GlobalUnlock(medium.hGlobal);
- return false;
- }
- MyStringCopy(dest, (const wchar_t *)path);
- GlobalUnlock(medium.hGlobal);
- bool res = m_DataObject->SetData(&etc, &medium, FALSE) == S_OK;
- GlobalFree(medium.hGlobal);
- return res;
-}
-
-bool CDropTarget::SetPath()
-{
- m_SetPathIsOK = SetPath(m_DropIsAllowed && m_PanelDropIsAllowed && IsFsFolderPath());
- return m_SetPathIsOK;
-}
-
-STDMETHODIMP CDropTarget::DragEnter(IDataObject * dataObject, DWORD keyState,
- POINTL pt, DWORD *effect)
-{
- GetNamesFromDataObject(dataObject, m_SourcePaths);
- QueryGetData(dataObject);
- m_DataObject = dataObject;
- return DragOver(keyState, pt, effect);
-}
-
-
-STDMETHODIMP CDropTarget::DragOver(DWORD keyState, POINTL pt, DWORD *effect)
-{
- PositionCursor(pt);
- SetPath();
- *effect = GetEffect(keyState, pt, *effect);
- return S_OK;
-}
-
-
-STDMETHODIMP CDropTarget::DragLeave()
-{
- RemoveSelection();
- SetPath(false);
- m_DataObject.Release();
- return S_OK;
-}
-
-// 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,
- POINTL pt, DWORD * effect)
-{
- QueryGetData(dataObject);
- PositionCursor(pt);
- m_DataObject = dataObject;
- bool needDrop = true;
- if(m_DropIsAllowed && m_PanelDropIsAllowed)
- if (IsFsFolderPath())
- needDrop = !SetPath();
- *effect = GetEffect(keyState, pt, *effect);
- if(m_DropIsAllowed && m_PanelDropIsAllowed)
- {
- if (needDrop)
- {
- UString path = GetTargetPath();
- if (m_IsAppTarget && m_Panel)
- if (m_Panel->IsFSFolder())
- path = m_Panel->_currentFolderPrefix;
- m_Panel->DropObject(dataObject, path);
- }
- }
- RemoveSelection();
- m_DataObject.Release();
- return S_OK;
-}
-
-void CPanel::DropObject(IDataObject *dataObject, const UString &folderPath)
-{
- UStringVector names;
- GetNamesFromDataObject(dataObject, names);
- CompressDropFiles(names, folderPath);
-}
-
-/*
-void CPanel::CompressDropFiles(HDROP dr)
-{
- UStringVector fileNames;
- {
- NShell::CDrop drop(true);
- drop.Attach(dr);
- drop.QueryFileNames(fileNames);
- }
- CompressDropFiles(fileNamesUnicode);
-}
-*/
-
-static bool IsFolderInTemp(const UString &path)
-{
- UString tempPath;
- if (!NFile::NDirectory::MyGetTempPath(tempPath))
- return false;
- if (tempPath.IsEmpty())
- return false;
- return (tempPath.CompareNoCase(path.Left(tempPath.Length())) == 0);
-}
-
-static bool AreThereNamesFromTemp(const UStringVector &fileNames)
-{
- UString tempPath;
- if (!NFile::NDirectory::MyGetTempPath(tempPath))
- return false;
- if (tempPath.IsEmpty())
- return false;
- for (int i = 0; i < fileNames.Size(); i++)
- if (tempPath.CompareNoCase(fileNames[i].Left(tempPath.Length())) == 0)
- return true;
- return false;
-}
-
-void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &folderPath)
-{
- if (fileNames.Size() == 0)
- return;
- const UString archiveName = CreateArchiveName(fileNames.Front(),
- (fileNames.Size() > 1), false);
- bool createNewArchive = true;
- if (!IsFSFolder())
- createNewArchive = !DoesItSupportOperations();
-
- if (createNewArchive)
- {
- UString folderPath2 = folderPath;
- if (folderPath2.IsEmpty())
- {
- NFile::NDirectory::GetOnlyDirPrefix(fileNames.Front(), folderPath2);
- if (IsFolderInTemp(folderPath2))
- folderPath2 = L"C:\\"; // fix it
- }
- CompressFiles(folderPath2, archiveName, L"", fileNames,
- false, // email
- true, // showDialog
- AreThereNamesFromTemp(fileNames) // waitFinish
- );
- }
- else
- CopyFrom(fileNames);
-}
diff --git a/7zip/FileManager/PanelFolderChange.cpp b/7zip/FileManager/PanelFolderChange.cpp
deleted file mode 100755
index 1db8196c..00000000
--- a/7zip/FileManager/PanelFolderChange.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-// PanelFolderChange.cpp
-
-#include "StdAfx.h"
-
-#include "Common/StringConvert.h"
-#include "Common/Wildcard.h"
-#include "Windows/FileDir.h"
-
-#include "Panel.h"
-#include "Resource/ListViewDialog/ListViewDialog.h"
-#include "RootFolder.h"
-#include "ViewSettings.h"
-#include "FSDrives.h"
-#include "LangUtils.h"
-#include "resource.h"
-
-using namespace NWindows;
-using namespace NFile;
-using namespace NFind;
-
-void CPanel::SetToRootFolder()
-{
- _folder.Release();
- _library.Free();
- CRootFolder *rootFolderSpec = new CRootFolder;
- _folder = rootFolderSpec;
- rootFolderSpec->Init();
-}
-
-HRESULT CPanel::BindToPath(const UString &fullPath)
-{
- CDisableTimerProcessing disableTimerProcessing1(*this);
- CloseOpenFolders();
- UString sysPath = fullPath;
- CFileInfoW fileInfo;
- UStringVector reducedParts;
- while(!sysPath.IsEmpty())
- {
- if (FindFile(sysPath, fileInfo))
- break;
- int pos = sysPath.ReverseFind(L'\\');
- if (pos < 0)
- sysPath.Empty();
- else
- {
- if (reducedParts.Size() > 0 || pos < sysPath.Length() - 1)
- reducedParts.Add(sysPath.Mid(pos + 1));
- sysPath = sysPath.Left(pos);
- }
- }
- SetToRootFolder();
- CMyComPtr<IFolderFolder> newFolder;
- if (sysPath.IsEmpty())
- {
- if (_folder->BindToFolder(fullPath, &newFolder) == S_OK)
- _folder = newFolder;
- }
- else if (fileInfo.IsDirectory())
- {
- NName::NormalizeDirPathPrefix(sysPath);
- if (_folder->BindToFolder(sysPath, &newFolder) == S_OK)
- _folder = newFolder;
- }
- else
- {
- UString dirPrefix;
- if (!NDirectory::GetOnlyDirPrefix(sysPath, dirPrefix))
- dirPrefix.Empty();
- if (_folder->BindToFolder(dirPrefix, &newFolder) == S_OK)
- {
- _folder = newFolder;
- LoadFullPath();
- UString fileName;
- if (NDirectory::GetOnlyName(sysPath, fileName))
- {
- if (OpenItemAsArchive(fileName, _currentFolderPrefix,
- _currentFolderPrefix + fileName) == S_OK)
- {
- for (int i = reducedParts.Size() - 1; i >= 0; i--)
- {
- CMyComPtr<IFolderFolder> newFolder;
- _folder->BindToFolder(reducedParts[i], &newFolder);
- if (!newFolder)
- break;
- _folder = newFolder;
- }
- }
- }
- }
- }
- return S_OK;
-}
-
-HRESULT CPanel::BindToPathAndRefresh(const UString &path)
-{
- CDisableTimerProcessing disableTimerProcessing1(*this);
- RINOK(BindToPath(path));
- RefreshListCtrl(UString(), -1, true, UStringVector());
- return S_OK;
-}
-
-void CPanel::SetBookmark(int index)
-{
- _appState->FastFolders.SetString(index, _currentFolderPrefix);
-}
-
-void CPanel::OpenBookmark(int index)
-{
- BindToPathAndRefresh(_appState->FastFolders.GetString(index));
-}
-
-UString GetFolderPath(IFolderFolder * folder)
-{
- CMyComPtr<IFolderGetPath> folderGetPath;
- if (folder->QueryInterface(IID_IFolderGetPath, (void **)&folderGetPath) == S_OK)
- {
- CMyComBSTR path;
- if (folderGetPath->GetPath(&path) == S_OK)
- return (const wchar_t *)path;
- }
- return UString();
-}
-
-void CPanel::LoadFullPath()
-{
- _currentFolderPrefix.Empty();
- for (int i = 0; i < _parentFolders.Size(); i++)
- {
- const CFolderLink &folderLink = _parentFolders[i];
- _currentFolderPrefix += GetFolderPath(folderLink.ParentFolder);
- _currentFolderPrefix += folderLink.ItemName;
- _currentFolderPrefix += L'\\';
- }
- if (_folder)
- _currentFolderPrefix += GetFolderPath(_folder);
-}
-
-void CPanel::LoadFullPathAndShow()
-{
- LoadFullPath();
- _appState->FolderHistory.AddString(_currentFolderPrefix);
-
- // _headerComboBox.SendMessage(CB_RESETCONTENT, 0, 0);
- _headerComboBox.SetText(_currentFolderPrefix);
-
- /*
- for (int i = 0; i < g_Folders.m_Strings.Size(); i++)
- {
- UString string = g_Folders.m_Strings[i];
- COMBOBOXEXITEM item;
- item.mask = CBEIF_TEXT;
- item.iItem = i;
- item.pszText = (LPTSTR)(LPCTSTR)string;
- _headerComboBox.InsertItem(&item);
- }
- */
-}
-
-bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result)
-{
- if (info->iWhy == CBENF_ESCAPE)
- {
- _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(info->szText) != S_OK)
- {
- result = TRUE;
- return true;
- }
- result = FALSE;
- PostMessage(kSetFocusToListView);
- return true;
- }
- return false;
-}
-
-#ifndef _UNICODE
-bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
-{
- if (info->iWhy == CBENF_ESCAPE)
- {
- _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);
- return true;
- }
- return false;
-}
-#endif
-
-void CPanel::OnComboBoxCommand(UINT /* code */, LPARAM & /* param */)
-{
- /*
- if (code == CBN_SELENDOK)
- {
- 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);
- }
- */
-}
-
-bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result)
-{
- switch(header->code)
- {
- case CBEN_BEGINEDIT:
- {
- _lastFocusedIsList = false;
- _panelCallback->PanelWasFocused();
- }
- #ifndef _UNICODE
- case CBEN_ENDEDIT:
- {
- return OnNotifyComboBoxEndEdit((PNMCBEENDEDIT)header, result);
- }
- #endif
- case CBEN_ENDEDITW:
- {
- return OnNotifyComboBoxEndEdit((PNMCBEENDEDITW)header, result);
- }
- }
- return false;
-}
-
-
-void CPanel::FoldersHistory()
-{
- CListViewDialog listViewDialog;
- listViewDialog.DeleteIsAllowed = true;
- listViewDialog.Title = LangString(IDS_FOLDERS_HISTORY, 0x03020260);
- _appState->FolderHistory.GetList(listViewDialog.Strings);
- if (listViewDialog.Create(GetParent()) == IDCANCEL)
- return;
- UString selectString;
- if (listViewDialog.StringsWereChanged)
- {
- _appState->FolderHistory.RemoveAll();
- for (int i = listViewDialog.Strings.Size() - 1; i >= 0; i--)
- _appState->FolderHistory.AddString(listViewDialog.Strings[i]);
- if (listViewDialog.FocusedItemIndex >= 0)
- selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
- }
- else
- {
- if (listViewDialog.FocusedItemIndex >= 0)
- selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
- }
- if (listViewDialog.FocusedItemIndex >= 0)
- BindToPathAndRefresh(selectString);
-}
-
-void CPanel::OpenParentFolder()
-{
- LoadFullPath(); // Maybe we don't need it ??
- UString focucedName;
- if (!_currentFolderPrefix.IsEmpty())
- {
- UString string = _currentFolderPrefix;
- string.Delete(string.Length() - 1);
- int pos = string.ReverseFind(L'\\');
- if (pos < 0)
- pos = 0;
- else
- pos++;
- focucedName = string.Mid(pos);
- }
-
- CDisableTimerProcessing disableTimerProcessing1(*this);
- CMyComPtr<IFolderFolder> newFolder;
- _folder->BindToParentFolder(&newFolder);
- if (newFolder)
- _folder = newFolder;
- else
- {
- if (_parentFolders.IsEmpty())
- {
- SetToRootFolder();
- if (focucedName.IsEmpty())
- focucedName = GetItemName(0);
- }
- else
- {
- _folder.Release();
- _library.Free();
- CFolderLink &link = _parentFolders.Back();
- _folder = link.ParentFolder;
- _library.Attach(link.Library.Detach());
- focucedName = link.ItemName;
- if (_parentFolders.Size () > 1)
- OpenParentArchiveFolder();
- _parentFolders.DeleteBack();
- }
- }
-
- UStringVector selectedItems;
- /*
- if (!focucedName.IsEmpty())
- selectedItems.Add(focucedName);
- */
- LoadFullPath();
- // ::SetCurrentDirectory(::_currentFolderPrefix);
- RefreshListCtrl(focucedName, -1, true, selectedItems);
- _listView.EnsureVisible(_listView.GetFocusedItem(), false);
- RefreshStatusBar();
-}
-
-void CPanel::CloseOpenFolders()
-{
- while(_parentFolders.Size() > 0)
- {
- _folder.Release();
- _library.Free();
- _folder = _parentFolders.Back().ParentFolder;
- _library.Attach(_parentFolders.Back().Library.Detach());
- if (_parentFolders.Size () > 1)
- OpenParentArchiveFolder();
- _parentFolders.DeleteBack();
- }
- _folder.Release();
- _library.Free();
-}
-
-void CPanel::OpenRootFolder()
-{
- CDisableTimerProcessing disableTimerProcessing1(*this);
- _parentFolders.Clear();
- SetToRootFolder();
- RefreshListCtrl(UString(), -1, true, UStringVector());
- // ::SetCurrentDirectory(::_currentFolderPrefix);
- /*
- BeforeChangeFolder();
- _currentFolderPrefix.Empty();
- AfterChangeFolder();
- SetCurrentPathText();
- RefreshListCtrl(UString(), 0, UStringVector());
- _listView.EnsureVisible(_listView.GetFocusedItem(), false);
- */
-}
-
-void CPanel::OpenDrivesFolder()
-{
- CloseOpenFolders();
- CFSDrives *fsFolderSpec = new CFSDrives;
- _folder = fsFolderSpec;
- fsFolderSpec->Init();
- RefreshListCtrl();
-}
-
-void CPanel::OpenFolder(int index)
-{
- if (index == kParentIndex)
- {
- OpenParentFolder();
- return;
- }
- CMyComPtr<IFolderFolder> newFolder;
- _folder->BindToFolder(index, &newFolder);
- if (!newFolder)
- return;
- _folder = newFolder;
- LoadFullPath();
- // ::SetCurrentDirectory(::_currentFolderPrefix);
- RefreshListCtrl();
- UINT state = LVIS_SELECTED;
- _listView.SetItemState(_listView.GetFocusedItem(), state, state);
- _listView.EnsureVisible(_listView.GetFocusedItem(), false);
-}
diff --git a/7zip/FileManager/PanelItemOpen.cpp b/7zip/FileManager/PanelItemOpen.cpp
deleted file mode 100755
index 9baaeebb..00000000
--- a/7zip/FileManager/PanelItemOpen.cpp
+++ /dev/null
@@ -1,539 +0,0 @@
-// PanelItemOpen.cpp
-
-#include "StdAfx.h"
-
-#include "resource.h"
-
-#include "Common/StringConvert.h"
-#include "Common/Random.h"
-#include "Common/StringConvert.h"
-#include "Common/AutoPtr.h"
-
-#include "Windows/FileDir.h"
-#include "Windows/FileFind.h"
-#include "Windows/Thread.h"
-#include "Windows/Synchronization.h"
-#include "Windows/Error.h"
-#include "Windows/COM.h"
-
-#include "ExtractCallback.h"
-#include "IFolder.h"
-#include "FileFolderPluginOpen.h"
-#include "FormatUtils.h"
-#include "Panel.h"
-#include "RegistryUtils.h"
-
-using namespace NWindows;
-using namespace NSynchronization;
-using namespace NFile;
-using namespace NDirectory;
-
-extern HWND g_HWND;
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-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)
-{
- return (name.Find(L" ") >= 0);
-}
-
-struct CTmpProcessInfo: public CTempFileInfo
-{
- HANDLE ProcessHandle;
- HWND Window;
- UString FullPathFolderPrefix;
-};
-
-class CTmpProcessInfoRelease
-{
- CTmpProcessInfo *_tmpProcessInfo;
-public:
- bool _needDelete;
- CTmpProcessInfoRelease(CTmpProcessInfo &tmpProcessInfo):
- _tmpProcessInfo(&tmpProcessInfo), _needDelete(true) {}
- ~CTmpProcessInfoRelease()
- {
- if (_needDelete)
- _tmpProcessInfo->DeleteDirAndFile();
- }
-};
-
-HRESULT CPanel::OpenItemAsArchive(const UString &name,
- const UString &folderPath, const UString &filePath)
-{
- CFolderLink folderLink;
- if (!NFile::NFind::FindFile(filePath, folderLink.FileInfo))
- return E_FAIL;
- if (folderLink.FileInfo.IsDirectory())
- return S_FALSE;
-
- folderLink.FilePath = filePath;
- folderLink.FolderPath = folderPath;
-
- CMyComPtr<IFolderFolder> newFolder;
-
- // _passwordIsDefined = false;
- // _password.Empty();
-
- NDLL::CLibrary library;
- RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent()));
-
- folderLink.ParentFolder = _folder;
- folderLink.ItemName = name;
- _parentFolders.Add(folderLink);
- _parentFolders.Back().Library.Attach(_library.Detach());
-
- _folder.Release();
- _library.Free();
- _folder = newFolder;
- _library.Attach(library.Detach());
-
- return S_OK;
-}
-
-HRESULT CPanel::OpenItemAsArchive(const UString &name)
-{
- return OpenItemAsArchive(name, _currentFolderPrefix, _currentFolderPrefix + name);
-}
-
-HRESULT CPanel::OpenItemAsArchive(int index)
-{
- CDisableTimerProcessing disableTimerProcessing1(*this);
- RINOK(OpenItemAsArchive(GetItemRelPath(index)));
- RefreshListCtrl();
- return S_OK;
-}
-
-HRESULT CPanel::OpenParentArchiveFolder()
-{
- CDisableTimerProcessing disableTimerProcessing1(*this);
- if (_parentFolders.Size() < 2)
- return S_OK;
- CFolderLink &folderLink = _parentFolders.Back();
- NFind::CFileInfoW newFileInfo;
- if (NFind::FindFile(folderLink.FilePath, newFileInfo))
- {
- if (newFileInfo.Size != folderLink.FileInfo.Size ||
- CompareFileTime(&newFileInfo.LastWriteTime,
- &folderLink.FileInfo.LastWriteTime) != 0)
- {
- 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)
- {
- ::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
- 0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
- return S_OK;
- }
- }
- }
- }
- folderLink.DeleteDirAndFile();
- return S_OK;
-}
-
-static const wchar_t *kStartExtensions[] =
-{
- L"exe",
- L"bat",
- L"com",
- L"chm",
- L"doc",
- L"pdf",
- L"xls"
-};
-
-static bool DoItemAlwaysStart(const UString &name)
-{
- int extPos = name.ReverseFind('.');
- if (extPos < 0)
- return false;
- UString ext = name.Mid(extPos + 1);
- ext.MakeLower();
- for (int i = 0; i < sizeof(kStartExtensions) / sizeof(kStartExtensions[0]); i++)
- if (ext.Compare(kStartExtensions[i]) == 0)
- return true;
- return false;
-}
-
-static HANDLE StartEditApplication(const UString &path, HWND window)
-{
- UString command;
- ReadRegEditor(command);
- if (command.IsEmpty())
- {
- if (!MyGetWindowsDirectory(command))
- return 0;
- NFile::NName::NormalizeDirPathPrefix(command);
- command += L"notepad.exe";
- }
- command = UString(L"\"") + command + UString(L"\"");
- command += L" \"";
- command += UString(path);
- command += L"\"";
-
- PROCESS_INFORMATION processInformation;
- BOOL result;
- #ifndef _UNICODE
- if (!g_IsNT)
- {
- STARTUPINFOA startupInfo;
- startupInfo.cb = sizeof(startupInfo);
- startupInfo.lpReserved = 0;
- startupInfo.lpDesktop = 0;
- startupInfo.lpTitle = 0;
- startupInfo.dwFlags = 0;
- startupInfo.cbReserved2 = 0;
- startupInfo.lpReserved2 = 0;
-
- result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command),
- NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
- }
- else
- #endif
- {
- STARTUPINFOW startupInfo;
- startupInfo.cb = sizeof(startupInfo);
- startupInfo.lpReserved = 0;
- startupInfo.lpDesktop = 0;
- startupInfo.lpTitle = 0;
- startupInfo.dwFlags = 0;
- startupInfo.cbReserved2 = 0;
- startupInfo.lpReserved2 = 0;
-
- result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command,
- NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
- }
-
- if (result != FALSE)
- {
- ::CloseHandle(processInformation.hThread);
- return processInformation.hProcess;
- }
- ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282),
- L"7-Zip", MB_OK | MB_ICONSTOP);
- return 0;
-}
-
-#ifndef _UNICODE
-typedef BOOL (WINAPI * ShellExecuteExWP)(LPSHELLEXECUTEINFOW lpExecInfo);
-#endif
-
-static HANDLE StartApplication(const UString &path, HWND window)
-{
- UINT32 result;
- HANDLE hProcess;
- #ifndef _UNICODE
- if (g_IsNT)
- {
- SHELLEXECUTEINFOW execInfo;
- execInfo.cbSize = sizeof(execInfo);
- execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
- execInfo.hwnd = NULL;
- execInfo.lpVerb = NULL;
- execInfo.lpFile = path;
- execInfo.lpParameters = NULL;
- execInfo.lpDirectory = NULL;
- execInfo.nShow = SW_SHOWNORMAL;
- execInfo.hProcess = 0;
- ShellExecuteExWP shellExecuteExW = (ShellExecuteExWP)
- ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "ShellExecuteExW");
- if (shellExecuteExW == 0)
- return 0;
- shellExecuteExW(&execInfo);
- result = (UINT32)(UINT_PTR)execInfo.hInstApp;
- hProcess = execInfo.hProcess;
- }
- else
- #endif
- {
- SHELLEXECUTEINFO execInfo;
- execInfo.cbSize = sizeof(execInfo);
- execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
- execInfo.hwnd = NULL;
- execInfo.lpVerb = NULL;
- const CSysString sysPath = GetSystemString(path);
- execInfo.lpFile = sysPath;
- execInfo.lpParameters = NULL;
- execInfo.lpDirectory = NULL;
- execInfo.nShow = SW_SHOWNORMAL;
- execInfo.hProcess = 0;
- ::ShellExecuteEx(&execInfo);
- result = (UINT32)(UINT_PTR)execInfo.hInstApp;
- hProcess = execInfo.hProcess;
- }
- if(result <= 32)
- {
- switch(result)
- {
- case SE_ERR_NOASSOC:
- ::MessageBoxW(window,
- NError::MyFormatMessageW(::GetLastError()),
- // L"There is no application associated with the given file name extension",
- L"7-Zip", MB_OK | MB_ICONSTOP);
- }
- }
- return hProcess;
-}
-
-void CPanel::EditItem(int index)
-{
- if (!_parentFolders.IsEmpty())
- {
- OpenItemInArchive(index, false, true, true);
- return;
- }
- HANDLE hProcess = StartEditApplication(_currentFolderPrefix + GetItemRelPath(index), (HWND)*this);
- if (hProcess != 0)
- ::CloseHandle(hProcess);
-}
-
-void CPanel::OpenFolderExternal(int index)
-{
- HANDLE hProcess = StartApplication(GetFsPath() + GetItemRelPath(index), (HWND)*this);
- if (hProcess != 0)
- ::CloseHandle(hProcess);
-}
-
-void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal)
-{
- CDisableTimerProcessing disableTimerProcessing1(*this);
- if (!_parentFolders.IsEmpty())
- {
- OpenItemInArchive(index, tryInternal, tryExternal, false);
- return;
- }
- UString name = GetItemRelPath(index);
- if (IsNameVirus(name))
- {
- MessageBoxMyError(virusMessage);
- return;
- }
- UString fullPath = _currentFolderPrefix + name;
- if (tryInternal)
- if (!tryExternal || !DoItemAlwaysStart(name))
- if (OpenItemAsArchive(index) == S_OK)
- return;
- if (tryExternal)
- {
- NDirectory::MySetCurrentDirectory(_currentFolderPrefix);
- HANDLE hProcess = StartApplication(fullPath, (HWND)*this);
- if (hProcess != 0)
- ::CloseHandle(hProcess);
- }
-}
-
-HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName)
-{
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- {
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return E_FAIL;
- }
- UStringVector fileNames;
- CRecordVector<const wchar_t *> fileNamePointers;
- fileNames.Add(itemName);
- fileNamePointers.Add(fileNames[0]);
-
- UString pathPrefix = folderPath;
- NName::NormalizeDirPathPrefix(pathPrefix);
- return folderOperations->CopyFrom(pathPrefix, &fileNamePointers.Front(),fileNamePointers.Size(), NULL);
-}
-
-LRESULT CPanel::OnOpenItemChanged(LPARAM lParam)
-{
- CTmpProcessInfo &tmpProcessInfo = *(CTmpProcessInfo *)lParam;
- // LoadCurrentPath()
- if (tmpProcessInfo.FullPathFolderPrefix != _currentFolderPrefix)
- return 0;
-
- CSelectedState state;
- SaveSelectedState(state);
-
- HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName);
- if (result != S_OK)
- return 0;
- RefreshListCtrl(state);
- return 1;
-}
-
-/*
-class CTmpProcessInfoList
-{
-public:
- CObjectVector<CTmpProcessInfo> _items;
-} g_TmpProcessInfoList;
-*/
-
-class CExitEventLauncher
-{
-public:
- CManualResetEvent _exitEvent;
- CExitEventLauncher(): _exitEvent(false) {};
- ~CExitEventLauncher() { _exitEvent.Set(); }
-} g_ExitEventLauncher;
-
-static DWORD WINAPI MyThreadFunction(void *param)
-{
- CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr((CTmpProcessInfo *)param);
- CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
-
- HANDLE hProcess = tmpProcessInfo->ProcessHandle;
- HANDLE events[2] = { g_ExitEventLauncher._exitEvent, hProcess};
- DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
- ::CloseHandle(hProcess);
- if (waitResult == WAIT_OBJECT_0 + 0)
- return 0;
- if (waitResult != WAIT_OBJECT_0 + 1)
- return 1;
- Sleep(200);
- NFind::CFileInfoW newFileInfo;
- if (NFind::FindFile(tmpProcessInfo->FilePath, newFileInfo))
- {
- if (newFileInfo.Size != tmpProcessInfo->FileInfo.Size ||
- CompareFileTime(&newFileInfo.LastWriteTime,
- &tmpProcessInfo->FileInfo.LastWriteTime) != 0)
- {
- 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,
- 0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
- return 0;
- }
- }
- }
- }
- tmpProcessInfo->DeleteDirAndFile();
- return 0;
-}
-
-void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
- bool editMode)
-{
- const UString name = GetItemName(index);
- if (IsNameVirus(name))
- {
- MessageBoxMyError(virusMessage);
- return;
- }
-
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- {
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
-
- NFile::NDirectory::CTempDirectoryW tempDirectory;
- tempDirectory.Create(kTempDirPrefix);
- UString tempDir = tempDirectory.GetPath();
- UString tempDirNorm = tempDir;
- NFile::NName::NormalizeDirPathPrefix(tempDirNorm);
-
- CRecordVector<UInt32> indices;
- indices.Add(index);
-
- UStringVector messages;
- HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages);
-
- if (!messages.IsEmpty())
- return;
- if (result != S_OK)
- {
- if (result != E_ABORT)
- MessageBoxError(result);
- return;
- }
-
- UString tempFilePath = tempDirNorm + name;
-
- CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo());
- CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
- tmpProcessInfo->FolderPath = tempDir;
- tmpProcessInfo->FilePath = tempFilePath;
- if (!NFind::FindFile(tempFilePath, tmpProcessInfo->FileInfo))
- return;
-
- if (tryInternal)
- {
- if (!tryExternal || !DoItemAlwaysStart(name))
- if (OpenItemAsArchive(name, tempDir, tempFilePath) == S_OK)
- {
- RefreshListCtrl();
- return;
- }
- }
-
- CTmpProcessInfoRelease tmpProcessInfoRelease(*tmpProcessInfo);
-
- if (!tryExternal)
- return;
-
- HANDLE hProcess;
- if (editMode)
- hProcess = StartEditApplication(tempFilePath, (HWND)*this);
- else
- hProcess = StartApplication(tempFilePath, (HWND)*this);
-
- if (hProcess == 0)
- return;
-
- tmpProcessInfo->Window = (HWND)(*this);
- tmpProcessInfo->FullPathFolderPrefix = _currentFolderPrefix;
- tmpProcessInfo->ItemName = name;
- tmpProcessInfo->ProcessHandle = hProcess;
-
- CThread thread;
- if (!thread.Create(MyThreadFunction, tmpProcessInfo))
- throw 271824;
- tempDirectory.DisableDeleting();
- tmpProcessInfoPtr.release();
- tmpProcessInfoRelease._needDelete = false;
-}
-
-/*
-static const UINT64 kTimeLimit = UINT64(10000000) * 3600 * 24;
-
-static bool CheckDeleteItem(UINT64 currentFileTime, UINT64 folderFileTime)
-{
- return (currentFileTime - folderFileTime > kTimeLimit &&
- folderFileTime - currentFileTime > kTimeLimit);
-}
-
-void DeleteOldTempFiles()
-{
- UString tempPath;
- if(!NFile::NDirectory::MyGetTempPath(tempPath))
- throw 1;
-
- SYSTEMTIME systemTime;
- ::GetSystemTime(&systemTime);
- UINT64 currentFileTime;
- if(!::SystemTimeToFileTime(&systemTime, (FILETIME *)&currentFileTime))
- throw 2;
- UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
- searchWildCard += WCHAR(NName::kAnyStringWildcard);
- NFind::CEnumeratorW enumerator(searchWildCard);
- NFind::CFileInfoW fileInfo;
- while(enumerator.Next(fileInfo))
- {
- if (!fileInfo.IsDirectory())
- continue;
- const UINT64 &creationTime = *(const UINT64 *)(&fileInfo.CreationTime);
- if(CheckDeleteItem(creationTime, currentFileTime))
- RemoveDirectoryWithSubItems(tempPath + fileInfo.Name);
- }
-}
-*/
diff --git a/7zip/FileManager/PanelItems.cpp b/7zip/FileManager/PanelItems.cpp
deleted file mode 100755
index c7483eb5..00000000
--- a/7zip/FileManager/PanelItems.cpp
+++ /dev/null
@@ -1,817 +0,0 @@
-// PanelItems.cpp
-
-#include "StdAfx.h"
-
-#include "Common/String.h"
-#include "Common/StringConvert.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"
-
-using namespace NWindows;
-
-static int GetColumnAlign(PROPID propID, VARTYPE varType)
-{
- switch(propID)
- {
- case kpidCreationTime:
- case kpidLastAccessTime:
- case kpidLastWriteTime:
- return LVCFMT_LEFT;
- }
- switch(varType)
- {
- case VT_UI1:
- case VT_I2:
- case VT_UI2:
- case VT_I4:
- case VT_INT:
- case VT_UI4:
- case VT_UINT:
- case VT_I8:
- case VT_UI8:
- case VT_BOOL:
- return LVCFMT_RIGHT;
-
- case VT_EMPTY:
- case VT_I1:
- case VT_FILETIME:
- case VT_BSTR:
- return LVCFMT_LEFT;
-
- default:
- return LVCFMT_CENTER;
- }
-}
-
-void CPanel::InitColumns()
-{
- if (_needSaveInfo)
- SaveListViewInfo();
-
- _listView.DeleteAllItems();
- _selectedStatusVector.Clear();
-
- ReadListViewInfo();
-
-
- PROPID sortID;
- /*
- if (_listViewInfo.SortIndex >= 0)
- sortID = _listViewInfo.Columns[_listViewInfo.SortIndex].PropID;
- */
- sortID = _listViewInfo.SortID;
-
- _ascending = _listViewInfo.Ascending;
-
- _properties.Clear();
-
- CMyComPtr<IEnumProperties> enumProperties;
- // CMyComPtr<IEnumSTATPROPSTG> enumSTATPROPSTG;
- /*
- if (m_ArchiveHandler)
- {
- if (m_ArchiveHandler->EnumProperties(&enumSTATPROPSTG) != S_OK)
- throw 1;
- }
- else
- */
- {
- if (_folder.QueryInterface(IID_IEnumProperties, &enumProperties) != S_OK)
- throw 1;
- /*
- if (enumProperties->EnumProperties(&enumSTATPROPSTG)!= S_OK)
- throw 1;
- */
- }
-
- _needSaveInfo = true;
-
- UINT32 numProperties;
- enumProperties->GetNumberOfProperties(&numProperties);
- int i;
- for (i = 0; i < (int)numProperties; i++)
- {
- CMyComBSTR name;
- PROPID propID;
- VARTYPE varType;
-
- if (enumProperties->GetPropertyInfo(i, &name, &propID, &varType) != S_OK)
- throw 1;
-
- CItemProperty destProperty;
- destProperty.Type = varType;
- destProperty.ID = propID;
- if (propID == kpidIsFolder)
- 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);
- }
- // InitColumns2(sortID);
-
- for (;;)
- if (!_listView.DeleteColumn(0))
- break;
-
- int order = 0;
- for(i = 0; i < _listViewInfo.Columns.Size(); i++)
- {
- const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
- int index = _properties.FindItemWithID(columnInfo.PropID);
- if (index >= 0)
- {
- CItemProperty &item = _properties[index];
- item.IsVisible = columnInfo.IsVisible;
- item.Width = columnInfo.Width;
- if (columnInfo.IsVisible)
- item.Order = order++;
- continue;
- }
- }
- for(i = 0; i < _properties.Size(); i++)
- {
- CItemProperty &item = _properties[i];
- if (item.Order < 0)
- item.Order = order++;
- }
-
- _visibleProperties.Clear();
- for (i = 0; i < _properties.Size(); i++)
- {
- const CItemProperty &property = _properties[i];
- if (property.IsVisible)
- _visibleProperties.Add(property);
- }
-
- // _sortIndex = 0;
- _sortID = kpidName;
- /*
- if (_listViewInfo.SortIndex >= 0)
- {
- int sortIndex = _properties.FindItemWithID(sortID);
- if (sortIndex >= 0)
- _sortIndex = sortIndex;
- }
- */
- _sortID = _listViewInfo.SortID;
-
- for (i = 0; i < _visibleProperties.Size(); i++)
- {
- InsertColumn(i);
- }
-}
-
-void CPanel::InsertColumn(int index)
-{
- const CItemProperty &property = _visibleProperties[index];
- LV_COLUMNW column;
- column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
- column.cx = property.Width;
- 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;
- _listView.InsertColumn(index, &column);
-}
-
-void CPanel::RefreshListCtrl()
-{
- RefreshListCtrl(UString(), -1, true, UStringVector());
-}
-
-int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
-
-
-void CPanel::GetSelectedNames(UStringVector &selectedNames)
-{
- selectedNames.Clear();
-
- CRecordVector<UINT32> indices;
- GetSelectedItemsIndices(indices);
- selectedNames.Reserve(indices.Size());
- for (int i = 0; i < indices.Size(); i++)
- selectedNames.Add(GetItemRelPath(indices[i]));
-
- /*
- for (int i = 0; i < _listView.GetItemCount(); i++)
- {
- const int kSize = 1024;
- WCHAR name[kSize + 1];
- LVITEMW item;
- item.iItem = i;
- item.pszText = name;
- item.cchTextMax = kSize;
- item.iSubItem = 0;
- item.mask = LVIF_TEXT | LVIF_PARAM;
- if (!_listView.GetItem(&item))
- continue;
- int realIndex = GetRealIndex(item);
- if (realIndex == kParentIndex)
- continue;
- if (_selectedStatusVector[realIndex])
- selectedNames.Add(item.pszText);
- }
- */
- selectedNames.Sort();
-}
-
-void CPanel::SaveSelectedState(CSelectedState &s)
-{
- s.FocusedName.Empty();
- s.SelectedNames.Clear();
- s.FocusedItem = _listView.GetFocusedItem();
- {
- if (s.FocusedItem >= 0)
- {
- int realIndex = GetRealItemIndex(s.FocusedItem);
- if (realIndex != kParentIndex)
- s.FocusedName = GetItemRelPath(realIndex);
- /*
- const int kSize = 1024;
- WCHAR name[kSize + 1];
- LVITEMW item;
- item.iItem = focusedItem;
- item.pszText = name;
- item.cchTextMax = kSize;
- item.iSubItem = 0;
- item.mask = LVIF_TEXT;
- if (_listView.GetItem(&item))
- focusedName = item.pszText;
- */
- }
- }
- GetSelectedNames(s.SelectedNames);
-}
-
-void CPanel::RefreshListCtrl(const CSelectedState &s)
-{
- bool selectFocused = s.SelectFocused;
- if (_mySelectMode)
- selectFocused = true;
- RefreshListCtrl(s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
-}
-
-void CPanel::RefreshListCtrlSaveFocused()
-{
- CSelectedState state;
- SaveSelectedState(state);
- RefreshListCtrl(state);
-}
-
-void CPanel::SetFocusedSelectedItem(int index, bool select)
-{
- UINT state = LVIS_FOCUSED;
- if (select)
- state |= LVIS_SELECTED;
- _listView.SetItemState(index, state, state);
- if (!_mySelectMode && select)
- {
- int realIndex = GetRealItemIndex(index);
- if (realIndex != kParentIndex)
- _selectedStatusVector[realIndex] = true;
- }
-}
-
-void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
- const UStringVector &selectedNames)
-{
- _dontShowMode = false;
- LoadFullPathAndShow();
- // OutputDebugStringA("=======\n");
- // OutputDebugStringA("s1 \n");
- CDisableTimerProcessing timerProcessing(*this);
-
- if (focusedPos < 0)
- focusedPos = 0;
-
- _listView.SetRedraw(false);
- // m_RedrawEnabled = false;
-
- LVITEMW item;
- ZeroMemory(&item, sizeof(item));
-
- _listView.DeleteAllItems();
- _selectedStatusVector.Clear();
- // _realIndices.Clear();
- _startGroupSelect = 0;
-
- _selectionIsDefined = false;
-
- // m_Files.Clear();
- // _folder.Release();
-
- if (!_folder)
- {
- // throw 1;
- SetToRootFolder();
- }
-
- _headerToolBar.EnableButton(kParentFolderID, !IsRootFolder());
-
- CMyComPtr<IFolderSetFlatMode> folderSetFlatMode;
- _folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode);
- if (folderSetFlatMode)
- folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
-
- if (_folder->LoadItems() != S_OK)
- return;
-
- InitColumns();
-
-
- // OutputDebugString(TEXT("Start Dir\n"));
- UINT32 numItems;
- _folder->GetNumberOfItems(&numItems);
-
- bool showDots = _showDots && !IsRootFolder();
-
- _listView.SetItemCount(numItems + (showDots ? 1 : 0));
-
- _selectedStatusVector.Reserve(numItems);
- int cursorIndex = -1;
-
- CMyComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
- if (!IsFSFolder() || _showRealFileIcons)
- _folder.QueryInterface(IID_IFolderGetSystemIconIndex, &folderGetSystemIconIndex);
-
- if (showDots)
- {
- UString itemName = L"..";
- item.iItem = _listView.GetItemCount();
- if (itemName.CompareNoCase(focusedName) == 0)
- cursorIndex = item.iItem;
- item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
- int subItem = 0;
- item.iSubItem = subItem++;
- item.lParam = kParentIndex;
- item.pszText = (wchar_t *)(const wchar_t *)itemName;
- UINT32 attributes = FILE_ATTRIBUTE_DIRECTORY;
- item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
- if (item.iImage < 0)
- item.iImage = 0;
- if(_listView.InsertItem(&item) == -1)
- return;
- }
-
- // OutputDebugStringA("S1\n");
-
- for(UInt32 i = 0; i < numItems; i++)
- {
- UString itemName = GetItemName(i);
- const UString relPath = GetItemRelPath(i);
- if (relPath.CompareNoCase(focusedName) == 0)
- cursorIndex = _listView.GetItemCount();
- bool selected = false;
- if (selectedNames.FindInSorted(relPath) >= 0)
- selected = true;
- _selectedStatusVector.Add(selected);
-
- item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
-
- if (!_mySelectMode)
- if (selected)
- {
- item.mask |= LVIF_STATE;
- item.state = LVIS_SELECTED;
- }
-
- int subItem = 0;
- item.iItem = _listView.GetItemCount();
-
- item.iSubItem = subItem++;
- item.lParam = i;
-
- UString correctedName;
- if (itemName.Find(L" ") >= 0)
- {
- int pos = 0;
- for (;;)
- {
- int posNew = itemName.Find(L" ", pos);
- if (posNew < 0)
- {
- correctedName += itemName.Mid(pos);
- break;
- }
- correctedName += itemName.Mid(pos, posNew - pos);
- correctedName += L" ... ";
- pos = posNew;
- while (itemName[++pos] == ' ');
- }
- item.pszText = (wchar_t *)(const wchar_t *)correctedName;
- }
- else
- item.pszText = (wchar_t *)(const wchar_t *)itemName;
-
- NCOM::CPropVariant propVariant;
- _folder->GetProperty(i, kpidAttributes, &propVariant);
- UINT32 attributes = 0;
- if (propVariant.vt == VT_UI4)
- attributes = propVariant.ulVal;
- else
- {
- if (IsItemFolder(i))
- attributes |= FILE_ATTRIBUTE_DIRECTORY;
- }
-
- bool defined = false;
-
- if (folderGetSystemIconIndex)
- {
- folderGetSystemIconIndex->GetSystemIconIndex(i, &item.iImage);
- defined = (item.iImage > 0);
- }
- if (!defined)
- {
- if (_currentFolderPrefix.IsEmpty())
- {
- int iconIndexTemp;
- GetRealIconIndex(itemName + L"\\", attributes, iconIndexTemp);
- item.iImage = iconIndexTemp;
- }
- else
- {
- item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
- }
- }
- if (item.iImage < 0)
- item.iImage = 0;
-
- if(_listView.InsertItem(&item) == -1)
- return; // error
- }
- // OutputDebugStringA("End2\n");
-
- if(_listView.GetItemCount() > 0 && cursorIndex >= 0)
- SetFocusedSelectedItem(cursorIndex, selectFocused);
- _listView.SortItems(CompareItems, (LPARAM)this);
- if (cursorIndex < 0 && _listView.GetItemCount() > 0)
- {
- if (focusedPos >= _listView.GetItemCount())
- focusedPos = _listView.GetItemCount() - 1;
- SetFocusedSelectedItem(focusedPos, true);
- }
- // m_RedrawEnabled = true;
- _listView.EnsureVisible(_listView.GetFocusedItem(), false);
- _listView.SetRedraw(true);
- _listView.InvalidateRect(NULL, true);
- // OutputDebugStringA("End1\n");
- /*
- _listView.UpdateWindow();
- */
-}
-
-void CPanel::GetSelectedItemsIndices(CRecordVector<UINT32> &indices) const
-{
- indices.Clear();
- /*
- int itemIndex = -1;
- while ((itemIndex = _listView.GetNextItem(itemIndex, LVNI_SELECTED)) != -1)
- {
- LPARAM param;
- if (_listView.GetItemParam(itemIndex, param))
- indices.Add(param);
- }
- */
- for (int i = 0; i < _selectedStatusVector.Size(); i++)
- if (_selectedStatusVector[i])
- indices.Add(i);
- indices.Sort();
-}
-
-void CPanel::GetOperatedItemIndices(CRecordVector<UINT32> &indices) const
-{
- GetSelectedItemsIndices(indices);
- if (!indices.IsEmpty())
- return;
- if (_listView.GetSelectedCount() == 0)
- return;
- int focusedItem = _listView.GetFocusedItem();
- if (focusedItem >= 0)
- {
- if(_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
- {
- int realIndex = GetRealItemIndex(focusedItem);
- if (realIndex != kParentIndex)
- indices.Add(realIndex);
- }
- }
-}
-
-/*
-void CPanel::GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const
-{
- indices.Clear();
- int numItems = _listView.GetItemCount();
- for (int i = 0; i < numItems; i++)
- {
- int realIndex = GetRealItemIndex(i);
- if (realIndex >= 0)
- if (_selectedStatusVector[realIndex])
- indices.Add(i);
- }
- if (indices.IsEmpty())
- {
- int focusedItem = _listView.GetFocusedItem();
- if (focusedItem >= 0)
- indices.Add(focusedItem);
- }
-}
-*/
-
-void CPanel::EditItem()
-{
- int focusedItem = _listView.GetFocusedItem();
- if (focusedItem < 0)
- return;
- int realIndex = GetRealItemIndex(focusedItem);
- if (realIndex == kParentIndex)
- return;
- if (!IsItemFolder(realIndex))
- EditItem(realIndex);
-}
-
-void CPanel::OpenFocusedItemAsInternal()
-{
- int focusedItem = _listView.GetFocusedItem();
- if (focusedItem < 0)
- return;
- int realIndex = GetRealItemIndex(focusedItem);
- if (IsItemFolder(realIndex))
- OpenFolder(realIndex);
- else
- OpenItem(realIndex, true, false);
-}
-
-void CPanel::OpenSelectedItems(bool tryInternal)
-{
- CRecordVector<UINT32> indices;
- GetOperatedItemIndices(indices);
- if (indices.Size() > 20)
- {
- MessageBox(LangString(IDS_TOO_MANY_ITEMS, 0x02000606));
- return;
- }
-
- int focusedItem = _listView.GetFocusedItem();
- if (focusedItem >= 0)
- {
- int realIndex = GetRealItemIndex(focusedItem);
- if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0))
- indices.Insert(0, realIndex);
- }
-
- bool dirIsStarted = false;
- for(int i = 0; i < indices.Size(); i++)
- {
- UINT32 index = indices[i];
- // CFileInfo &aFile = m_Files[index];
- if (IsItemFolder(index))
- {
- if (!dirIsStarted)
- {
- if (tryInternal)
- {
- OpenFolder(index);
- dirIsStarted = true;
- break;
- }
- else
- OpenFolderExternal(index);
- }
- }
- else
- OpenItem(index, (tryInternal && indices.Size() == 1), true);
- }
-}
-
-UString CPanel::GetItemName(int itemIndex) const
-{
- if (itemIndex == kParentIndex)
- return L"..";
- NCOM::CPropVariant propVariant;
- if (_folder->GetProperty(itemIndex, kpidName, &propVariant) != S_OK)
- throw 2723400;
- if (propVariant.vt != VT_BSTR)
- throw 2723401;
- return (propVariant.bstrVal);
-}
-
-UString CPanel::GetItemPrefix(int itemIndex) const
-{
- if (itemIndex == kParentIndex)
- return UString();
- NCOM::CPropVariant propVariant;
- if (_folder->GetProperty(itemIndex, kpidPrefix, &propVariant) != S_OK)
- throw 2723400;
- UString prefix;
- if (propVariant.vt == VT_BSTR)
- prefix = propVariant.bstrVal;
- return prefix;
-}
-
-UString CPanel::GetItemRelPath(int itemIndex) const
-{
- return GetItemPrefix(itemIndex) + GetItemName(itemIndex);
-}
-
-
-bool CPanel::IsItemFolder(int itemIndex) const
-{
- if (itemIndex == kParentIndex)
- return true;
- NCOM::CPropVariant propVariant;
- if (_folder->GetProperty(itemIndex, kpidIsFolder, &propVariant) != S_OK)
- throw 2723400;
- if (propVariant.vt == VT_BOOL)
- return VARIANT_BOOLToBool(propVariant.boolVal);
- if (propVariant.vt == VT_EMPTY)
- return false;
- return false;
-}
-
-UINT64 CPanel::GetItemSize(int itemIndex) const
-{
- if (itemIndex == kParentIndex)
- return 0;
- NCOM::CPropVariant propVariant;
- if (_folder->GetProperty(itemIndex, kpidSize, &propVariant) != S_OK)
- throw 2723400;
- if (propVariant.vt == VT_EMPTY)
- return 0;
- return ConvertPropVariantToUInt64(propVariant);
-}
-
-void CPanel::ReadListViewInfo()
-{
- CMyComPtr<IFolderGetTypeID> folderGetTypeID;
- if(_folder.QueryInterface(IID_IFolderGetTypeID, &folderGetTypeID) != S_OK)
- return;
- CMyComBSTR typeID;
- folderGetTypeID->GetTypeID(&typeID);
- _typeIDString = typeID;
- ::ReadListViewInfo(_typeIDString, _listViewInfo);
-}
-
-void CPanel::SaveListViewInfo()
-{
- int i;
- for(i = 0; i < _visibleProperties.Size(); i++)
- {
- CItemProperty &property = _visibleProperties[i];
- LVCOLUMN winColumnInfo;
- winColumnInfo.mask = LVCF_ORDER | LVCF_WIDTH;
- if (!_listView.GetColumn(i, &winColumnInfo))
- throw 1;
- property.Order = winColumnInfo.iOrder;
- property.Width = winColumnInfo.cx;
- }
-
- CListViewInfo viewInfo;
-
- // PROPID sortPropID = _properties[_sortIndex].ID;
- PROPID sortPropID = _sortID;
-
- _visibleProperties.Sort();
- for(i = 0; i < _visibleProperties.Size(); i++)
- {
- const CItemProperty &property = _visibleProperties[i];
- CColumnInfo columnInfo;
- columnInfo.IsVisible = property.IsVisible;
- columnInfo.PropID = property.ID;
- columnInfo.Width = property.Width;
- viewInfo.Columns.Add(columnInfo);
- }
- for(i = 0; i < _properties.Size(); i++)
- {
- const CItemProperty &property = _properties[i];
- if (!property.IsVisible)
- {
- CColumnInfo columnInfo;
- columnInfo.IsVisible = property.IsVisible;
- columnInfo.PropID = property.ID;
- columnInfo.Width = property.Width;
- viewInfo.Columns.Add(columnInfo);
- }
- }
-
- // viewInfo.SortIndex = viewInfo.FindColumnWithID(sortPropID);
- viewInfo.SortID = sortPropID;
-
- viewInfo.Ascending = _ascending;
- if (!_listViewInfo.IsEqual(viewInfo))
- {
- ::SaveListViewInfo(_typeIDString, viewInfo);
- _listViewInfo = viewInfo;
- }
-}
-
-bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result)
-{
- if(itemActiveate->hdr.hwndFrom == HWND(_listView))
- return false;
-
- POINT point;
- ::GetCursorPos(&point);
-
- CMenu menu;
- CMenuDestroyer menuDestroyer(menu);
-
- menu.CreatePopup();
-
- const int kCommandStart = 100;
- for(int i = 0; i < _properties.Size(); i++)
- {
- const CItemProperty &property = _properties[i];
- UINT flags = MF_STRING;
- if (property.IsVisible)
- flags |= MF_CHECKED;
- if (i == 0)
- flags |= MF_GRAYED;
- menu.AppendItem(flags, kCommandStart + i, GetSystemString(property.Name));
- }
- int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY,
- point.x, point.y, _listView);
- if (menuResult >= kCommandStart && menuResult <= kCommandStart + _properties.Size())
- {
- int index = menuResult - kCommandStart;
- CItemProperty &property = _properties[index];
- property.IsVisible = !property.IsVisible;
-
- if (property.IsVisible)
- {
- int prevVisibleSize = _visibleProperties.Size();
- property.Order = prevVisibleSize;
- _visibleProperties.Add(property);
- InsertColumn(prevVisibleSize);
- }
- else
- {
- int visibleIndex = _visibleProperties.FindItemWithID(property.ID);
- _visibleProperties.Delete(visibleIndex);
- /*
- if (_sortIndex == index)
- {
- _sortIndex = 0;
- _ascending = true;
- }
- */
- if (_sortID == property.ID)
- {
- _sortID = kpidName;
- _ascending = true;
- }
-
- _listView.DeleteColumn(visibleIndex);
- }
- }
- result = TRUE;
- return true;
-}
-
-void CPanel::OnReload()
-{
- RefreshListCtrlSaveFocused();
- OnRefreshStatusBar();
-}
-
-void CPanel::OnTimer()
-{
- if (!_processTimer)
- return;
- CMyComPtr<IFolderWasChanged> folderWasChanged;
- if (_folder.QueryInterface(IID_IFolderWasChanged, &folderWasChanged) != S_OK)
- return;
- INT32 wasChanged;
- if (folderWasChanged->WasChanged(&wasChanged) != S_OK)
- return;
- if (wasChanged == 0)
- return;
- OnReload();
-}
-
diff --git a/7zip/FileManager/PanelOperations.cpp b/7zip/FileManager/PanelOperations.cpp
deleted file mode 100755
index 9616dca7..00000000
--- a/7zip/FileManager/PanelOperations.cpp
+++ /dev/null
@@ -1,382 +0,0 @@
-// PanelOperations.cpp
-
-#include "StdAfx.h"
-
-#include "resource.h"
-
-#include "Panel.h"
-
-#include "Common/StringConvert.h"
-#include "Common/DynamicBuffer.h"
-#include "Windows/FileDir.h"
-#include "Windows/ResourceString.h"
-#include "Windows/Thread.h"
-#include "Windows/COM.h"
-
-#include "Resource/ComboDialog/ComboDialog.h"
-
-#include "FSFolder.h"
-#include "LangUtils.h"
-#include "FormatUtils.h"
-
-#include "UpdateCallback100.h"
-
-using namespace NWindows;
-using namespace NFile;
-
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-struct CThreadDelete
-{
- CMyComPtr<IFolderOperations> FolderOperations;
- CRecordVector<UInt32> Indices;
- CMyComPtr<IFolderArchiveUpdateCallback> UpdateCallback;
- CUpdateCallback100Imp *UpdateCallbackSpec;
- HRESULT Result;
-
- DWORD Process()
- {
- NCOM::CComInitializer comInitializer;
- UpdateCallbackSpec->ProgressDialog.WaitCreating();
- Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback);
- UpdateCallbackSpec->ProgressDialog.MyClose();
- return 0;
- }
-
- static DWORD WINAPI MyThreadFunction(void *param)
- {
- return ((CThreadDelete *)param)->Process();
- }
-};
-
-#ifndef _UNICODE
-typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp);
-#endif
-
-void CPanel::DeleteItems(bool toRecycleBin)
-{
- CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
- CRecordVector<UInt32> indices;
- GetOperatedItemIndices(indices);
- if (indices.IsEmpty())
- return;
- CSelectedState state;
- SaveSelectedState(state);
- if (IsFSFolder())
- {
- #ifndef _UNICODE
- if (!g_IsNT)
- {
- CDynamicBuffer<CHAR> buffer;
- size_t size = 0;
- for (int i = 0; i < indices.Size(); i++)
- {
- const AString path = GetSystemString(GetFsPath() + GetItemRelPath(indices[i]));
- buffer.EnsureCapacity(size + path.Length() + 1);
- memmove(((CHAR *)buffer) + size, (const CHAR *)path, (path.Length() + 1) * sizeof(CHAR));
- size += path.Length() + 1;
- }
- buffer.EnsureCapacity(size + 1);
- ((CHAR *)buffer)[size] = 0;
- SHFILEOPSTRUCTA fo;
- fo.hwnd = GetParent();
- fo.wFunc = FO_DELETE;
- fo.pFrom = (const CHAR *)buffer;
- fo.pTo = 0;
- fo.fFlags = 0;
- if (toRecycleBin)
- fo.fFlags |= FOF_ALLOWUNDO;
- // fo.fFlags |= FOF_NOCONFIRMATION;
- // fo.fFlags |= FOF_NOERRORUI;
- // fo.fFlags |= FOF_SILENT;
- // fo.fFlags |= FOF_WANTNUKEWARNING;
- fo.fAnyOperationsAborted = FALSE;
- fo.hNameMappings = 0;
- fo.lpszProgressTitle = 0;
- /* int res = */ ::SHFileOperationA(&fo);
- }
- else
- #endif
- {
- CDynamicBuffer<WCHAR> buffer;
- size_t size = 0;
- for (int i = 0; i < indices.Size(); i++)
- {
- const UString path = GetFsPath() + GetItemRelPath(indices[i]);
- buffer.EnsureCapacity(size + path.Length() + 1);
- memmove(((WCHAR *)buffer) + size, (const WCHAR *)path, (path.Length() + 1) * sizeof(WCHAR));
- size += path.Length() + 1;
- }
- buffer.EnsureCapacity(size + 1);
- ((WCHAR *)buffer)[size] = 0;
- SHFILEOPSTRUCTW fo;
- fo.hwnd = GetParent();
- fo.wFunc = FO_DELETE;
- fo.pFrom = (const WCHAR *)buffer;
- fo.pTo = 0;
- fo.fFlags = 0;
- if (toRecycleBin)
- fo.fFlags |= FOF_ALLOWUNDO;
- fo.fAnyOperationsAborted = FALSE;
- fo.hNameMappings = 0;
- fo.lpszProgressTitle = 0;
- int res;
- #ifdef _UNICODE
- res = ::SHFileOperationW(&fo);
- #else
- SHFileOperationWP shFileOperationW = (SHFileOperationWP)
- ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHFileOperationW");
- if (shFileOperationW == 0)
- return;
- res = shFileOperationW(&fo);
- #endif
- }
- /*
- if (fo.fAnyOperationsAborted)
- {
- MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
- }
- */
- /*
- (!result)
- return GetLastError();
- */
- }
- else
- {
-
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- {
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
-
- UString title;
- UString message;
- if (indices.Size() == 1)
- {
- int index = indices[0];
- const UString itemName = GetItemRelPath(index);
- if (IsItemFolder(index))
- {
- title = LangString(IDS_CONFIRM_FOLDER_DELETE, 0x03020211);
- message = MyFormatNew(IDS_WANT_TO_DELETE_FOLDER, 0x03020214, itemName);
- }
- else
- {
- title = LangString(IDS_CONFIRM_FILE_DELETE, 0x03020210);
- message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName);
- }
- }
- else
- {
- title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
- 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;
-
- CThread thread;
- if (!thread.Create(CThreadDelete::MyThreadFunction, &deleter))
- throw 271824;
- deleter.UpdateCallbackSpec->StartProgressDialog(progressTitle);
-
- HRESULT result = deleter.Result;
- if (result != S_OK)
- MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
- }
-
- RefreshListCtrl(state);
-}
-
-BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
-{
- int realIndex = GetRealIndex(lpnmh->item);
- if (realIndex == kParentIndex)
- return TRUE;
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- return TRUE;
- return FALSE;
-}
-
-BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
-{
- if (lpnmh->item.pszText == NULL)
- return FALSE;
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- {
- MessageBoxMyError(L"Renaming is not supported");
- return FALSE;
- }
- const UString newName = lpnmh->item.pszText;
- CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
-
- SaveSelectedState(_selectedState);
-
- int realIndex = GetRealIndex(lpnmh->item);
- 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;
- }
- // Can't use RefreshListCtrl here.
- // RefreshListCtrlSaveFocused();
- _selectedState.FocusedName = prefix + newName;
- _selectedState.SelectFocused = true;
-
- // 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)
- // so we can't delete items.
-
- _dontShowMode = true;
-
- PostMessage(kReLoadMessage);
- return TRUE;
-}
-
-void CPanel::CreateFolder()
-{
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- {
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
- CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
- CSelectedState state;
- SaveSelectedState(state);
- CComboDialog comboDialog;
- comboDialog.Title = LangString(IDS_CREATE_FOLDER, 0x03020230);
- comboDialog.Static = LangString(IDS_CREATE_FOLDER_NAME, 0x03020231);
- comboDialog.Value = LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
- if (comboDialog.Create(GetParent()) == IDCANCEL)
- return;
- UString newName = comboDialog.Value;
- HRESULT result = folderOperations->CreateFolder(newName, 0);
- if (result != S_OK)
- {
- MessageBoxError(result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
- return;
- }
- int pos = newName.Find(L'\\');
- if (pos >= 0)
- newName = newName.Left(pos);
- if (!_mySelectMode)
- state.SelectedNames.Clear();
- state.FocusedName = newName;
- state.SelectFocused = true;
- RefreshListCtrl(state);
-}
-
-void CPanel::CreateFile()
-{
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- {
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
- CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
- CSelectedState state;
- SaveSelectedState(state);
- CComboDialog comboDialog;
- comboDialog.Title = LangString(IDS_CREATE_FILE, 0x03020240);
- comboDialog.Static = LangString(IDS_CREATE_FILE_NAME, 0x03020241);
- comboDialog.Value = LangString(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
- if (comboDialog.Create(GetParent()) == IDCANCEL)
- return;
- UString newName = comboDialog.Value;
- HRESULT result = folderOperations->CreateFile(newName, 0);
- if (result != S_OK)
- {
- MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243));
- return;
- }
- int pos = newName.Find(L'\\');
- if (pos >= 0)
- newName = newName.Left(pos);
- if (!_mySelectMode)
- state.SelectedNames.Clear();
- state.FocusedName = newName;
- state.SelectFocused = true;
- RefreshListCtrl(state);
-}
-
-void CPanel::RenameFile()
-{
- int index = _listView.GetFocusedItem();
- if (index >= 0)
- _listView.EditLabel(index);
-}
-
-void CPanel::ChangeComment()
-{
- CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
- int index = _listView.GetFocusedItem();
- if (index < 0)
- return;
- int realIndex = GetRealItemIndex(index);
- if (realIndex == kParentIndex)
- return;
- CSelectedState state;
- SaveSelectedState(state);
- CMyComPtr<IFolderOperations> folderOperations;
- if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
- {
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
-
- UString comment;
- {
- NCOM::CPropVariant propVariant;
- if (_folder->GetProperty(realIndex, kpidComment, &propVariant) != S_OK)
- return;
- if (propVariant.vt == VT_BSTR)
- comment = propVariant.bstrVal;
- else if (propVariant.vt != VT_EMPTY)
- return;
- }
- UString name = GetItemRelPath(realIndex);
- CComboDialog comboDialog;
- comboDialog.Title = name + L" " + LangString(IDS_COMMENT, 0x03020290);
- comboDialog.Value = comment;
- comboDialog.Static = LangString(IDS_COMMENT2, 0x03020291);
- if (comboDialog.Create(GetParent()) == IDCANCEL)
- return;
- NCOM::CPropVariant propVariant = comboDialog.Value;
-
- HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);
- if (result != S_OK)
- {
- MessageBoxError(result, L"Set Comment Error");
- }
- RefreshListCtrl(state);
-}
-
diff --git a/7zip/FileManager/PanelSplitFile.cpp b/7zip/FileManager/PanelSplitFile.cpp
deleted file mode 100755
index 2449f45f..00000000
--- a/7zip/FileManager/PanelSplitFile.cpp
+++ /dev/null
@@ -1,471 +0,0 @@
-// PanelSplitFile.cpp
-
-#include "StdAfx.h"
-
-#include "resource.h"
-
-#include "Common/Alloc.h"
-#include "Common/Types.h"
-
-#include "Windows/COM.h"
-#include "Windows/FileIO.h"
-#include "Windows/FileFind.h"
-#include "Windows/Thread.h"
-#include "Resource/ProgressDialog2/ProgressDialog.h"
-#include "Resource/SplitDialog/SplitDialog.h"
-#include "Resource/CopyDialog/CopyDialog.h"
-
-#include "App.h"
-#include "FormatUtils.h"
-#include "LangUtils.h"
-
-using namespace NWindows;
-
-class CMyBuffer
-{
- void *_data;
-public:
- CMyBuffer(): _data(0) {}
- operator void *() { return _data; }
- bool Allocate(size_t size)
- {
- if (_data != 0)
- return false;
- _data = ::MidAlloc(size);
- return _data != 0;
- }
- ~CMyBuffer() { ::MidFree(_data); }
-};
-
-struct CVolSeqName
-{
- UString UnchangedPart;
- UString ChangedPart;
- CVolSeqName(): ChangedPart(L"000") {};
-
- bool ParseName(const UString &name)
- {
- if (name.Right(2) != L"01")
- return false;
- int numLetters = 2;
- while (numLetters < name.Length())
- {
- if (name[name.Length() - numLetters - 1] != '0')
- break;
- numLetters++;
- }
- UnchangedPart = name.Left(name.Length() - numLetters);
- ChangedPart = name.Right(numLetters);
- return true;
- }
-
- UString GetNextName()
- {
- UString newName;
- 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 = c + newName;
- i--;
- for (; i >= 0; i--)
- newName = ChangedPart[i] + newName;
- break;
- }
- ChangedPart = newName;
- return UnchangedPart + ChangedPart;
- }
-};
-
-static const UInt32 kBufSize = (1 << 20);
-
-struct CThreadSplit
-{
- // HRESULT Result;
- // CPanel *Panel;
- CProgressDialog *ProgressDialog;
- UString FilePath;
- UString VolBasePath;
- CRecordVector<UInt64> VolumeSizes;
- UString Error;
-
- void Process2()
- {
- // NCOM::CComInitializer comInitializer;
- ProgressDialog->WaitCreating();
- NFile::NIO::CInFile inFile;
- if (!inFile.Open(FilePath))
- throw L"Can not open file";
- NFile::NIO::COutFile outFile;
- CMyBuffer bufferObject;
- if (!bufferObject.Allocate(kBufSize))
- throw L"Can not allocate buffer";
- Byte *buffer = (Byte *)(void *)bufferObject;
- UInt64 curVolSize = 0;
- CVolSeqName seqName;
- UInt64 length;
- if (!inFile.GetLength(length))
- throw "error";
-
- ProgressDialog->ProgressSynch.SetProgress(length, 0);
- UInt64 pos = 0;
-
- int volIndex = 0;
-
- for (;;)
- {
- UInt64 volSize;
- if (volIndex < VolumeSizes.Size())
- volSize = VolumeSizes[volIndex];
- else
- volSize = VolumeSizes.Back();
-
- UInt32 needSize = (UInt32)(MyMin((UInt64)kBufSize, volSize - curVolSize));
- UInt32 processedSize;
- if (!inFile.Read(buffer, needSize, processedSize))
- throw L"Can not read input file";
- if (processedSize == 0)
- break;
- needSize = processedSize;
- if (curVolSize == 0)
- {
- UString name = VolBasePath;
- name += L".";
- name += seqName.GetNextName();
- if (!outFile.Create(name, false))
- throw L"Can not create output file";
- ProgressDialog->ProgressSynch.SetCurrentFileName(name);
- }
- if (!outFile.Write(buffer, needSize, processedSize))
- throw L"Can not write output file";
- if (needSize != processedSize)
- throw L"Can not write output file";
- curVolSize += processedSize;
- if (curVolSize == volSize)
- {
- outFile.Close();
- volIndex++;
- curVolSize = 0;
- }
- pos += processedSize;
- HRESULT res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos);
- if (res != S_OK)
- return;
- }
- }
- DWORD Process()
- {
- try { Process2(); }
- catch(const wchar_t *s) { Error = s; }
- catch(...) { Error = L"Error"; }
- ProgressDialog->MyClose();
- return 0;
- }
-
- static DWORD WINAPI MyThreadFunction(void *param)
- {
- return ((CThreadSplit *)param)->Process();
- }
-};
-
-void CApp::Split()
-{
- int srcPanelIndex = GetFocusedPanelIndex();
- CPanel &srcPanel = Panels[srcPanelIndex];
- if (!srcPanel.IsFSFolder())
- {
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
- CRecordVector<UInt32> indices;
- srcPanel.GetOperatedItemIndices(indices);
- if (indices.IsEmpty())
- return;
- if (indices.Size() != 1)
- {
- srcPanel.MessageBox(L"Select one file");
- return;
- }
- int index = indices[0];
- if (srcPanel.IsItemFolder(index))
- {
- srcPanel.MessageBox(L"Select one file");
- return;
- }
- const UString itemName = srcPanel.GetItemName(index);
-
- UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index);
- UString path = srcPath;
- int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
- CPanel &destPanel = Panels[destPanelIndex];
- if (NumPanels > 1)
- if (destPanel.IsFSFolder())
- path = destPanel._currentFolderPrefix;
- CSplitDialog splitDialog;
- splitDialog.FilePath = srcPanel.GetItemRelPath(index);
- splitDialog.Path = path;
- if (splitDialog.Create(srcPanel.GetParent()) == IDCANCEL)
- return;
-
- CThreadSplit spliter;
- // spliter.Panel = this;
-
- CProgressDialog progressDialog;
- spliter.ProgressDialog = &progressDialog;
-
- UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
- UString title = LangString(IDS_SPLITTING, 0x03020510);
-
- progressDialog.MainWindow = _window;
- progressDialog.MainTitle = progressWindowTitle;
- progressDialog.MainAddTitle = title + UString(L" ");
- progressDialog.ProgressSynch.SetTitleFileName(itemName);
-
- path = splitDialog.Path;
- NFile::NName::NormalizeDirPathPrefix(path);
- if (!NFile::NDirectory::CreateComplexDirectory(path))
- {
- srcPanel.MessageBoxMyError(L"Can not create output folder");
- return;
- }
-
- spliter.FilePath = srcPath + itemName;
- spliter.VolBasePath = path + itemName;
- spliter.VolumeSizes = splitDialog.VolumeSizes;
- if (splitDialog.VolumeSizes.Size() == 0)
- {
- srcPanel.MessageBoxMyError(L"Incorrect volume size");
- return;
- }
-
- NFile::NFind::CFileInfoW fileInfo;
- if (!NFile::NFind::FindFile(spliter.FilePath, fileInfo))
- {
- srcPanel.MessageBoxMyError(L"Can not find file");
- return;
- }
- if (fileInfo.Size <= splitDialog.VolumeSizes.Front())
- {
- srcPanel.MessageBoxMyError(L"File is not larger than volume");
- return;
- }
-
-
-
- // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
- // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
-
- CThread thread;
- if (!thread.Create(CThreadSplit::MyThreadFunction, &spliter))
- throw 271824;
- progressDialog.Create(title, _window);
-
- if (!spliter.Error.IsEmpty())
- srcPanel.MessageBoxMyError(spliter.Error);
- // disableTimerProcessing1.Restore();
- // disableTimerProcessing2.Restore();
- // srcPanel.SetFocusToList();
- // srcPanel.RefreshListCtrlSaveFocused();
-}
-
-
-struct CThreadCombine
-{
- CProgressDialog *ProgressDialog;
- UString InputDirPrefix;
- UString FirstVolumeName;
- UString OutputDirPrefix;
- UString Error;
-
- 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::NFind::CFileInfoW fileInfo;
- if (!NFile::NFind::FindFile(nextName, fileInfo))
- break;
- if (fileInfo.IsDirectory())
- break;
- totalSize += fileInfo.Size;
- nextName = InputDirPrefix + volSeqName.GetNextName();
- }
- 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";
-
- 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 (;;)
- {
- if (needOpen)
- {
- 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;
- }
- UInt32 processedSize;
- if (!inFile.Read(buffer, kBufSize, processedSize))
- throw L"Can not read input file";
- if (processedSize == 0)
- {
- needOpen = true;
- continue;
- }
- 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()
- {
- try { Process2(); }
- catch(const wchar_t *s) { Error = s; }
- catch(...) { Error = L"Error";}
- ProgressDialog->MyClose();
- return 0;
- }
-
- static DWORD WINAPI MyThreadFunction(void *param)
- {
- return ((CThreadCombine *)param)->Process();
- }
-};
-
-void CApp::Combine()
-{
- int srcPanelIndex = GetFocusedPanelIndex();
- CPanel &srcPanel = Panels[srcPanelIndex];
- if (!srcPanel.IsFSFolder())
- {
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
- return;
- }
- CRecordVector<UInt32> indices;
- srcPanel.GetOperatedItemIndices(indices);
- if (indices.IsEmpty())
- return;
- if (indices.Size() != 1)
- {
- srcPanel.MessageBox(L"Select only first file");
- return;
- }
- int index = indices[0];
- if (srcPanel.IsItemFolder(index))
- {
- srcPanel.MessageBox(L"Select only first file");
- return;
- }
- const UString itemName = srcPanel.GetItemName(index);
-
- UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index);
- UString path = srcPath;
- int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
- CPanel &destPanel = Panels[destPanelIndex];
- 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;
-
- CThreadCombine combiner;
- // combiner.Panel = this;
-
- 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" ");
-
- path = copyDialog.Value;
- NFile::NName::NormalizeDirPathPrefix(path);
- if (!NFile::NDirectory::CreateComplexDirectory(path))
- {
- srcPanel.MessageBoxMyError(L"Can not create output folder");
- return;
- }
-
- combiner.InputDirPrefix = srcPath;
- combiner.FirstVolumeName = itemName;
- combiner.OutputDirPrefix = path;
-
- // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
- // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
-
- CThread thread;
- if (!thread.Create(CThreadCombine::MyThreadFunction, &combiner))
- throw 271824;
- progressDialog.Create(title, _window);
-
- if (!combiner.Error.IsEmpty())
- srcPanel.MessageBoxMyError(combiner.Error);
- // disableTimerProcessing1.Restore();
- // disableTimerProcessing2.Restore();
- // srcPanel.SetFocusToList();
- // srcPanel.RefreshListCtrlSaveFocused();
-}
diff --git a/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp b/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp
deleted file mode 100755
index fd627d30..00000000
--- a/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp
+++ /dev/null
@@ -1,976 +0,0 @@
-// BenchmarkDialog.cpp
-
-#include "StdAfx.h"
-
-#include "Common/IntToString.h"
-#include "Common/StringToInt.h"
-#include "Common/Exception.h"
-#include "Common/Alloc.h"
-#include "Windows/Thread.h"
-#include "Windows/PropVariant.h"
-#include "Windows/Error.h"
-#include "Windows/DLL.h"
-#include "Windows/FileFind.h"
-#include "../../ProgramLocation.h"
-#include "../../HelpUtils.h"
-#include "../../../Common/StreamObjects.h"
-#include "resource.h"
-#include "BenchmarkDialog.h"
-#include "Common/CRC.h"
-
-using namespace NWindows;
-
-static LPCWSTR kHelpTopic = L"fm/benchmark.htm";
-
-static const UINT_PTR kTimerID = 4;
-static const UINT kTimerElapse = 1000;
-
-static const UInt32 kAdditionalSize = (6 << 20);
-static const UInt32 kCompressedAdditionalSize = (1 << 10);
-static const int kSubBits = 8;
-
-#ifdef LANG
-#include "../../LangUtils.h"
-#endif
-
-using namespace NWindows;
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDC_BENCHMARK_DICTIONARY, 0x02000D0C },
- { IDC_BENCHMARK_MEMORY, 0x03080001 },
- { IDC_BENCHMARK_MULTITHREADING, 0x02000D09 },
- { IDC_BENCHMARK_SPEED_LABEL, 0x03080004 },
- { IDC_BENCHMARK_RATING_LABEL, 0x03080005 },
- { IDC_BENCHMARK_COMPRESSING, 0x03080002 },
- { IDC_BENCHMARK_DECOMPRESSING, 0x03080003 },
- { IDC_BENCHMARK_CURRENT, 0x03080007 },
- { IDC_BENCHMARK_RESULTING, 0x03080008 },
- { IDC_BENCHMARK_CURRENT2, 0x03080007 },
- { IDC_BENCHMARK_RESULTING2, 0x03080008 },
- { IDC_BENCHMARK_TOTAL_RATING, 0x03080006 },
- { IDC_BENCHMARK_ELAPSED, 0x02000C01 },
- { IDC_BENCHMARK_SIZE, 0x02000C03 },
- { IDC_BENCHMARK_PASSES, 0x03080009 },
- { IDC_BENCHMARK_ERRORS, 0x0308000A },
- { IDC_BUTTON_STOP, 0x02000714 },
- { IDC_BUTTON_RESTART, 0x02000715 },
- { IDHELP, 0x02000720 },
- { IDCANCEL, 0x02000710 }
-};
-#endif
-
-static void MyMessageBoxError(HWND hwnd, LPCWSTR message)
-{
- MessageBoxW(hwnd, message, L"7-Zip", MB_ICONERROR);
-}
-
-UInt64 GetTimeCount()
-{
- return GetTickCount();
- /*
- LARGE_INTEGER value;
- if (::QueryPerformanceCounter(&value))
- return value.QuadPart;
- return GetTickCount();
- */
-}
-
-UInt64 GetFreq()
-{
- return 1000;
- /*
- LARGE_INTEGER value;
- if (::QueryPerformanceFrequency(&value))
- return value.QuadPart;
- return 1000;
- */
-}
-
-class CRandomGenerator
-{
- UInt32 A1;
- UInt32 A2;
-public:
- CRandomGenerator() { Init(); }
- void Init() { A1 = 362436069; A2 = 521288629;}
- UInt32 GetRnd()
- {
- return
- ((A1 = 36969 * (A1 & 0xffff) + (A1 >> 16)) << 16) ^
- ((A2 = 18000 * (A2 & 0xffff) + (A2 >> 16)) );
- }
-};
-
-class CBitRandomGenerator
-{
- CRandomGenerator RG;
- UInt32 Value;
- int NumBits;
-public:
- void Init()
- {
- Value = 0;
- NumBits = 0;
- }
- UInt32 GetRnd(int numBits)
- {
- if (NumBits > numBits)
- {
- UInt32 result = Value & ((1 << numBits) - 1);
- Value >>= numBits;
- NumBits -= numBits;
- return result;
- }
- numBits -= NumBits;
- UInt32 result = (Value << numBits);
- Value = RG.GetRnd();
- result |= Value & ((1 << numBits) - 1);
- Value >>= numBits;
- NumBits = 32 - numBits;
- return result;
- }
-};
-
-class CBenchRandomGenerator
-{
- CBitRandomGenerator RG;
- UInt32 Pos;
- UInt32 Rep0;
-public:
- UInt32 BufferSize;
- Byte *Buffer;
- CBenchRandomGenerator(): Buffer(0) {}
- ~CBenchRandomGenerator() { Free(); }
- void Free()
- {
- ::MidFree(Buffer);
- Buffer = 0;
- }
- bool Alloc(UInt32 bufferSize)
- {
- if (Buffer != 0 && BufferSize == bufferSize)
- return true;
- Free();
- Buffer = (Byte *)::MidAlloc(bufferSize);
- Pos = 0;
- BufferSize = bufferSize;
- return (Buffer != 0);
- }
- UInt32 GetRndBit() { return RG.GetRnd(1); }
- /*
- UInt32 GetLogRand(int maxLen)
- {
- UInt32 len = GetRnd() % (maxLen + 1);
- return GetRnd() & ((1 << len) - 1);
- }
- */
- UInt32 GetLogRandBits(int numBits)
- {
- UInt32 len = RG.GetRnd(numBits);
- return RG.GetRnd(len);
- }
- UInt32 GetOffset()
- {
- if (GetRndBit() == 0)
- return GetLogRandBits(4);
- return (GetLogRandBits(4) << 10) | RG.GetRnd(10);
- }
- UInt32 GetLen1() { return RG.GetRnd(1 + RG.GetRnd(2)); }
- UInt32 GetLen2() { return RG.GetRnd(2 + RG.GetRnd(2)); }
- void Generate()
- {
- RG.Init();
- Rep0 = 1;
- while(Pos < BufferSize)
- {
- if (GetRndBit() == 0 || Pos < 1)
- Buffer[Pos++] = Byte(RG.GetRnd(8));
- else
- {
- UInt32 len;
- if (RG.GetRnd(3) == 0)
- len = 1 + GetLen1();
- else
- {
- do
- Rep0 = GetOffset();
- while (Rep0 >= Pos);
- Rep0++;
- len = 2 + GetLen2();
- }
- for (UInt32 i = 0; i < len && Pos < BufferSize; i++, Pos++)
- Buffer[Pos] = Buffer[Pos - Rep0];
- }
- }
- }
-};
-
-const LPCTSTR kProcessingString = TEXT("...");
-const LPCTSTR kMB = TEXT(" MB");
-const LPCTSTR kMIPS = TEXT(" MIPS");
-const LPCTSTR kKBs = TEXT(" KB/s");
-
-bool CBenchmarkDialog::OnInit()
-{
- #ifdef LANG
- LangSetWindowText(HWND(*this), 0x03080000);
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- #endif
-
- m_Dictionary.Attach(GetItem(IDC_BENCHMARK_COMBO_DICTIONARY));
- for (int i = kNumBenchDictionaryBitsStart; i <= 30; i++)
- for (int j = 0; j < 2; j++)
- {
- UInt32 dictionary = (1 << i) + (j << (i - 1));
- if(dictionary >
- #ifdef _WIN64
- (1 << 30)
- #else
- (1 << 27)
- #endif
- )
- continue;
- TCHAR s[40];
- ConvertUInt64ToString((dictionary >> 20), s);
- lstrcat(s, kMB);
- int index = (int)m_Dictionary.AddString(s);
- m_Dictionary.SetItemData(index, dictionary);
- }
- m_Dictionary.SetCurSel(0);
- OnChangeSettings();
-
- _syncInfo.Init();
- _syncInfo.InitSettings();
-
- _syncInfo._startEvent.Set();
- _timer = SetTimer(kTimerID, kTimerElapse);
- return CModalDialog::OnInit();
-}
-
-static UInt64 GetLZMAUsage(UInt32 dictionary)
-{
- UInt32 hs = dictionary - 1;
- hs |= (hs >> 1);
- hs |= (hs >> 2);
- hs |= (hs >> 4);
- hs |= (hs >> 8);
- hs >>= 1;
- hs |= 0xFFFF;
- if (hs > (1 << 24))
- hs >>= 1;
- hs++;
- return ((hs + (1 << 16)) + (UInt64)dictionary * 2) * 4 + (UInt64)dictionary * 3 / 2 + (1 << 20);
-}
-
-static UInt64 GetMemoryUsage(UInt32 dictionary, bool mtMode)
-{
- const UInt32 kBufferSize = dictionary + kAdditionalSize;
- const UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
- return (mtMode ? (6 << 20) : 0 )+ kBufferSize + kCompressedBufferSize +
- GetLZMAUsage(dictionary) + dictionary + (2 << 20);
-}
-
-UInt32 CBenchmarkDialog::OnChangeDictionary()
-{
- UInt32 dictionary = (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
- UInt64 memUsage = GetMemoryUsage(dictionary, IsButtonCheckedBool(IDC_BENCHMARK_MULTITHREADING));
- memUsage = (memUsage + (1 << 20) - 1) >> 20;
- TCHAR s[40];
- ConvertUInt64ToString(memUsage, s);
- lstrcat(s, kMB);
- SetItemText(IDC_BENCHMARK_MEMORY_VALUE, s);
- return dictionary;
-}
-
-void CBenchmarkDialog::OnChangeSettings()
-{
- EnableItem(IDC_BUTTON_STOP, true);
- UInt32 dictionary = OnChangeDictionary();
- SetItemText(IDC_BENCHMARK_COMPRESSING_SPEED, kProcessingString);
- SetItemText(IDC_BENCHMARK_COMPRESSING_SPEED2, kProcessingString);
- SetItemText(IDC_BENCHMARK_COMPRESSING_RATING, kProcessingString);
- SetItemText(IDC_BENCHMARK_COMPRESSING_RATING2, kProcessingString);
- SetItemText(IDC_BENCHMARK_DECOMPRESSING_SPEED, kProcessingString);
- SetItemText(IDC_BENCHMARK_DECOMPRESSING_SPEED2, kProcessingString);
- SetItemText(IDC_BENCHMARK_DECOMPRESSING_RATING, kProcessingString);
- SetItemText(IDC_BENCHMARK_DECOMPRESSING_RATING2, kProcessingString);
- SetItemText(IDC_BENCHMARK_TOTAL_RATING_VALUE, kProcessingString);
- _startTime = GetTickCount();
- PrintTime();
- NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
- _syncInfo.Init();
- _syncInfo.DictionarySize = dictionary;
- _syncInfo.Changed = true;
- _syncInfo.MultiThread = IsButtonCheckedBool(IDC_BENCHMARK_MULTITHREADING);
-}
-
-void CBenchmarkDialog::OnRestartButton()
-{
- OnChangeSettings();
-}
-
-void CBenchmarkDialog::OnStopButton()
-{
- EnableItem(IDC_BUTTON_STOP, false);
- _syncInfo.Pause();
-}
-
-void CBenchmarkDialog::OnHelp()
-{
- ShowHelpWindow(NULL, kHelpTopic);
-}
-
-void CBenchmarkDialog::OnCancel()
-{
- _syncInfo.Stop();
- KillTimer(_timer);
- CModalDialog::OnCancel();
-}
-
-static void GetTimeString(UInt64 timeValue, TCHAR *s)
-{
- wsprintf(s, TEXT("%02d:%02d:%02d"),
- UInt32(timeValue / 3600),
- UInt32((timeValue / 60) % 60),
- UInt32(timeValue % 60));
-}
-
-void CBenchmarkDialog::PrintTime()
-{
- UInt32 curTime = ::GetTickCount();
- UInt32 elapsedTime = (curTime - _startTime);
- UInt32 elapsedSec = elapsedTime / 1000;
- TCHAR s[40];
- GetTimeString(elapsedSec, s);
- SetItemText(IDC_BENCHMARK_ELAPSED_VALUE, s);
-}
-
-static UInt32 GetLogSize(UInt32 size)
-{
- for (int i = kSubBits; i < 32; i++)
- for (UInt32 j = 0; j < (1 << kSubBits); j++)
- if (size <= (((UInt32)1) << i) + (j << (i - kSubBits)))
- return (i << kSubBits) + j;
- return (32 << kSubBits);
-}
-
-static UInt64 GetCompressRating(UInt32 dictionarySize,
- UInt64 elapsedTime, UInt64 size)
-{
- if (elapsedTime == 0)
- elapsedTime = 1;
- UInt64 t = GetLogSize(dictionarySize) - (18 << kSubBits);
- UInt64 numCommandsForOne = 1060 + ((t * t * 10) >> (2 * kSubBits));
- UInt64 numCommands = (UInt64)(size) * numCommandsForOne;
- return numCommands * GetFreq() / elapsedTime;
-}
-
-static UInt64 GetDecompressRating(UInt64 elapsedTime,
- UInt64 outSize, UInt64 inSize)
-{
- if (elapsedTime == 0)
- elapsedTime = 1;
- UInt64 numCommands = inSize * 220 + outSize * 20;
- return numCommands * GetFreq() / elapsedTime;
-}
-
-static UInt64 GetTotalRating(
- UInt32 dictionarySize,
- UInt64 elapsedTimeEn, UInt64 sizeEn,
- UInt64 elapsedTimeDe,
- UInt64 inSizeDe, UInt64 outSizeDe)
-{
- return (GetCompressRating(dictionarySize, elapsedTimeEn, sizeEn) +
- GetDecompressRating(elapsedTimeDe, inSizeDe, outSizeDe)) / 2;
-}
-
-void CBenchmarkDialog::PrintRating(UInt64 rating, UINT controlID)
-{
- TCHAR s[40];
- ConvertUInt64ToString(rating / 1000000, s);
- lstrcat(s, kMIPS);
- SetItemText(controlID, s);
-}
-
-void CBenchmarkDialog::PrintResults(
- UInt32 dictionarySize,
- UInt64 elapsedTime,
- UInt64 size, UINT speedID, UINT ratingID,
- bool decompressMode, UInt64 secondSize)
-{
- TCHAR s[40];
- UInt64 speed = size * GetFreq() / elapsedTime;
- ConvertUInt64ToString(speed / 1024, s);
- lstrcat(s, kKBs);
- SetItemText(speedID, s);
- UInt64 rating;
- if (decompressMode)
- rating = GetDecompressRating(elapsedTime, size, secondSize);
- else
- rating = GetCompressRating(dictionarySize, elapsedTime, size);
- PrintRating(rating, ratingID);
-}
-
-bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
-{
- PrintTime();
- NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
-
- TCHAR s[40];
- ConvertUInt64ToString((_syncInfo.ProcessedSize >> 20), s);
- lstrcat(s, kMB);
- SetItemText(IDC_BENCHMARK_SIZE_VALUE, s);
-
- ConvertUInt64ToString(_syncInfo.NumPasses, s);
- SetItemText(IDC_BENCHMARK_PASSES_VALUE, s);
-
- ConvertUInt64ToString(_syncInfo.NumErrors, s);
- SetItemText(IDC_BENCHMARK_ERRORS_VALUE, s);
-
- UInt64 elapsedTime = _syncInfo.CompressingInfoTemp.Time;
- if (elapsedTime >= 1)
- {
- UInt32 dicSizeTemp = (UInt32)MyMax(_syncInfo.ProcessedSize, UInt64(1) << 20);
- dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize),
- PrintResults(dicSizeTemp, elapsedTime,
- _syncInfo.CompressingInfoTemp.InSize,
- IDC_BENCHMARK_COMPRESSING_SPEED,
- IDC_BENCHMARK_COMPRESSING_RATING);
- }
-
- if (_syncInfo.CompressingInfo.Time >= 1)
- {
- PrintResults(
- _syncInfo.DictionarySize,
- _syncInfo.CompressingInfo.Time,
- _syncInfo.CompressingInfo.InSize,
- IDC_BENCHMARK_COMPRESSING_SPEED2,
- IDC_BENCHMARK_COMPRESSING_RATING2);
- }
-
- if (_syncInfo.DecompressingInfoTemp.Time >= 1)
- {
- PrintResults(
- _syncInfo.DictionarySize,
- _syncInfo.DecompressingInfoTemp.Time,
- _syncInfo.DecompressingInfoTemp.OutSize,
- IDC_BENCHMARK_DECOMPRESSING_SPEED,
- IDC_BENCHMARK_DECOMPRESSING_RATING,
- true,
- _syncInfo.DecompressingInfoTemp.InSize);
- }
- if (_syncInfo.DecompressingInfo.Time >= 1)
- {
- PrintResults(
- _syncInfo.DictionarySize,
- _syncInfo.DecompressingInfo.Time,
- _syncInfo.DecompressingInfo.OutSize,
- IDC_BENCHMARK_DECOMPRESSING_SPEED2,
- IDC_BENCHMARK_DECOMPRESSING_RATING2,
- true,
- _syncInfo.DecompressingInfo.InSize);
- if (_syncInfo.CompressingInfo.Time >= 1)
- {
- PrintRating(GetTotalRating(
- _syncInfo.DictionarySize,
- _syncInfo.CompressingInfo.Time,
- _syncInfo.CompressingInfo.InSize,
- _syncInfo.DecompressingInfo.Time,
- _syncInfo.DecompressingInfo.OutSize,
- _syncInfo.DecompressingInfo.InSize),
- IDC_BENCHMARK_TOTAL_RATING_VALUE);
- }
- }
- return true;
-}
-
-bool CBenchmarkDialog::OnCommand(int code, int itemID, LPARAM lParam)
-{
- if (code == CBN_SELCHANGE && itemID == IDC_BENCHMARK_COMBO_DICTIONARY)
- {
- OnChangeSettings();
- return true;
- }
- return CModalDialog::OnCommand(code, itemID, lParam);
-}
-
-bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
- switch(buttonID)
- {
- case IDC_BUTTON_RESTART:
- OnRestartButton();
- return true;
- case IDC_BUTTON_STOP:
- OnStopButton();
- return true;
- case IDC_BENCHMARK_MULTITHREADING:
- OnChangeSettings();
- return true;
- }
- return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
-}
-
-class CBenchmarkInStream:
- public ISequentialInStream,
- public CMyUnknownImp
-{
- const Byte *Data;
- UInt32 Pos;
- UInt32 Size;
-public:
- MY_UNKNOWN_IMP
- void Init(const Byte *data, UInt32 size)
- {
- Data = data;
- Size = size;
- Pos = 0;
- }
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
-};
-
-STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
-{
- UInt32 remain = Size - Pos;
- if (size > remain)
- size = remain;
- for (UInt32 i = 0; i < size; i++)
- {
- ((Byte *)data)[i] = Data[Pos + i];
- }
- Pos += size;
- if(processedSize != NULL)
- *processedSize = size;
- return S_OK;
-}
-
-class CBenchmarkOutStream:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
- UInt32 BufferSize;
-public:
- UInt32 Pos;
- Byte *Buffer;
- CBenchmarkOutStream(): Buffer(0) {}
- ~CBenchmarkOutStream() { Free(); }
- void Free()
- {
- ::MidFree(Buffer);
- Buffer = 0;
- }
-
- bool Alloc(UInt32 bufferSize)
- {
- if (Buffer != 0 && BufferSize == bufferSize)
- return true;
- Free();
- Buffer = (Byte *)::MidAlloc(bufferSize);
- Init();
- BufferSize = bufferSize;
- return (Buffer != 0);
- }
-
- void Init()
- {
- Pos = 0;
- }
-
- MY_UNKNOWN_IMP
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
-};
-
-STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
-{
- UInt32 i;
- for (i = 0; i < size && Pos < BufferSize; i++)
- Buffer[Pos++] = ((const Byte *)data)[i];
- if(processedSize != NULL)
- *processedSize = i;
- if (i != size)
- {
- MessageBoxW(0, L"Buffer is full", L"7-zip error", 0);
- return E_FAIL;
- }
- return S_OK;
-}
-
-class CCompareOutStream:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
-public:
- CCRC CRC;
- MY_UNKNOWN_IMP
- void Init() { CRC.Init(); }
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
-};
-
-STDMETHODIMP CCompareOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
-{
- CRC.Update(data, size);
- if(processedSize != NULL)
- *processedSize = size;
- return S_OK;
-}
-
-typedef UInt32 (WINAPI * CreateObjectPointer)(const GUID *clsID,
- const GUID *interfaceID, void **outObject);
-
-struct CDecoderProgressInfo:
- public ICompressProgressInfo,
- public CMyUnknownImp
-{
- CProgressSyncInfo *SyncInfo;
- MY_UNKNOWN_IMP
- STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
-};
-
-STDMETHODIMP CDecoderProgressInfo::SetRatioInfo(
- const UInt64 * /* inSize */, const UInt64 * /* outSize */)
-{
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (SyncInfo->Changed)
- return E_ABORT;
- return S_OK;
-}
-
-struct CThreadBenchmark:
- public ICompressProgressInfo,
- public CMyUnknownImp
-{
- CProgressSyncInfo *SyncInfo;
- UInt64 _startTime;
- UInt64 _approvedStart;
- NDLL::CLibrary Library;
- CMyComPtr<ICompressCoder> Encoder;
- CMyComPtr<ICompressCoder> Decoder;
- HRESULT Process();
- HRESULT Result;
- static DWORD WINAPI MyThreadFunction(void *param)
- {
- ((CThreadBenchmark *)param)->Result = ((CThreadBenchmark *)param)->Process();
- return 0;
- }
- MY_UNKNOWN_IMP
- STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
-};
-
-HRESULT CThreadBenchmark::Process()
-{
- try
- {
- SyncInfo->WaitCreating();
- CBenchRandomGenerator randomGenerator;
- CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
- Encoder.QueryInterface(IID_ICompressWriteCoderProperties,
- &writeCoderProperties);
- CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
- Decoder.QueryInterface(
- IID_ICompressSetDecoderProperties2, &compressSetDecoderProperties);
- CSequentialOutStreamImp *propStreamSpec = 0;
- CMyComPtr<ISequentialOutStream> propStream;
- if (writeCoderProperties != NULL)
- {
- propStreamSpec = new CSequentialOutStreamImp;
- propStream = propStreamSpec;
- }
-
- CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
- Encoder.QueryInterface(IID_ICompressSetCoderProperties,
- &setCoderProperties);
-
- CDecoderProgressInfo *decoderProgressInfoSpec = new
- CDecoderProgressInfo;
- CMyComPtr<ICompressProgressInfo> decoderProgress = decoderProgressInfoSpec;
- decoderProgressInfoSpec->SyncInfo = SyncInfo;
-
- for (;;)
- {
- if (SyncInfo->WasStopped())
- return 0;
- if (SyncInfo->WasPaused())
- {
- Sleep(200);
- continue;
- }
- UInt32 dictionarySize;
- bool multiThread;
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- dictionarySize = SyncInfo->DictionarySize;
- multiThread = SyncInfo->MultiThread;
- if (SyncInfo->Changed)
- SyncInfo->Init();
- }
-
- const UInt32 kBufferSize = dictionarySize + kAdditionalSize;
- const UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
-
- if (setCoderProperties)
- {
- PROPID propIDs[] =
- {
- NCoderPropID::kDictionarySize,
- NCoderPropID::kMultiThread
- };
- const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
- NWindows::NCOM::CPropVariant properties[kNumProps];
- properties[0] = UInt32(dictionarySize);
- properties[1] = bool(multiThread);
- HRESULT res = setCoderProperties->SetCoderProperties(propIDs,
- properties, kNumProps);
- if (res != S_OK)
- {
- // SyncInfo->Pause();
- MessageBox(0, NError::MyFormatMessage(res), TEXT("7-Zip"), MB_ICONERROR);
- return res;
- }
- }
-
- if (propStream)
- {
- propStreamSpec->Init();
- writeCoderProperties->WriteCoderProperties(propStream);
- }
-
- if (!randomGenerator.Alloc(kBufferSize))
- return E_OUTOFMEMORY;
-
- randomGenerator.Generate();
- CCRC crc;
-
- // randomGenerator.BufferSize
- crc.Update(randomGenerator.Buffer, randomGenerator.BufferSize);
-
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (SyncInfo->Changed)
- continue;
- }
-
- CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
- CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
- CBenchmarkOutStream *outStreamSpec = new CBenchmarkOutStream;
- CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
- if (!outStreamSpec->Alloc(kCompressedBufferSize))
- return E_OUTOFMEMORY;
-
- {
- // this code is for reducing time of memory allocationg
- inStreamSpec->Init(randomGenerator.Buffer, MyMin((UInt32)1, randomGenerator.BufferSize));
- outStreamSpec->Init();
- /* HRESULT result = */ Encoder->Code(inStream, outStream, 0, 0, NULL);
- }
-
- inStreamSpec->Init(randomGenerator.Buffer, randomGenerator.BufferSize);
- outStreamSpec->Init();
-
- _approvedStart = dictionarySize;
- _startTime = ::GetTimeCount();
- HRESULT result = Encoder->Code(inStream, outStream, 0, 0, this);
- UInt64 tickCount = ::GetTimeCount() - _startTime;
- UInt32 compressedSize = outStreamSpec->Pos;
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (result == S_OK)
- {
- if (SyncInfo->ApprovedInfo.InSize != 0)
- {
- SyncInfo->CompressingInfoTemp.InSize = kBufferSize - SyncInfo->ApprovedInfo.InSize;
- SyncInfo->CompressingInfoTemp.OutSize = compressedSize - SyncInfo->ApprovedInfo.OutSize;
- SyncInfo->CompressingInfoTemp.Time = tickCount - SyncInfo->ApprovedInfo.Time;
- if (SyncInfo->CompressingInfo.Time == 0)
- SyncInfo->CompressingInfo = SyncInfo->CompressingInfoTemp;
- }
- }
- SyncInfo->ApprovedInfo.Init();
- }
- if(result != S_OK)
- {
- if (result != E_ABORT)
- {
- SyncInfo->Pause();
- MessageBox(0, NError::MyFormatMessage(result), TEXT("7-Zip"), MB_ICONERROR);
- }
- continue;
- }
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- SyncInfo->NumPasses++;
- }
-
- ///////////////////////
- // Decompressing
-
-
- CCompareOutStream *outCompareStreamSpec = new CCompareOutStream;
- CMyComPtr<ISequentialOutStream> outCompareStream = outCompareStreamSpec;
-
- for (int i = 0; i < 2; i++)
- {
- inStreamSpec->Init(outStreamSpec->Buffer, compressedSize);
- outCompareStreamSpec->Init();
-
- if (compressSetDecoderProperties)
- {
- RINOK(compressSetDecoderProperties->SetDecoderProperties2(
- propStreamSpec->GetBuffer(), (UInt32)propStreamSpec->GetSize()));
- }
-
- UInt64 outSize = kBufferSize;
- UInt64 startTime = ::GetTimeCount();
- result = Decoder->Code(inStream, outCompareStream, 0, &outSize, decoderProgress);
- tickCount = ::GetTimeCount() - startTime;
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (result == S_OK)
- {
- SyncInfo->DecompressingInfoTemp.InSize = compressedSize;
- SyncInfo->DecompressingInfoTemp.OutSize = kBufferSize;
- SyncInfo->DecompressingInfoTemp.Time = tickCount;
- if (SyncInfo->DecompressingInfo.Time == 0 && i >= 1)
- SyncInfo->DecompressingInfo = SyncInfo->DecompressingInfoTemp;
- if (outCompareStreamSpec->CRC.GetDigest() != crc.GetDigest())
- {
- SyncInfo->NumErrors++;
- break;
- }
- }
- else
- {
- if(result != E_ABORT)
- {
- SyncInfo->NumErrors++;
- break;
- }
- }
- }
- }
- }
- }
- catch(CSystemException &e)
- {
- MessageBox(0, NError::MyFormatMessage(e.ErrorCode), TEXT("7-Zip"), MB_ICONERROR);
- return E_FAIL;
- }
- catch(...)
- {
- MyMessageBoxError(0, L"Some error");
- return E_FAIL;
- }
-}
-
-STDMETHODIMP CThreadBenchmark::SetRatioInfo(
- const UInt64 *inSize, const UInt64 *outSize)
-{
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (SyncInfo->Changed || SyncInfo->WasPaused() || SyncInfo->WasStopped())
- return E_ABORT;
- CProgressInfo ci;
- ci.InSize = *inSize;
- ci.OutSize = *outSize;
- ci.Time = ::GetTimeCount() - _startTime;
- SyncInfo->ProcessedSize = *inSize;
-
- UInt64 deltaTime = ci.Time - SyncInfo->CompressingInfoPrev.Time;
- if (deltaTime >= GetFreq())
- {
- SyncInfo->CompressingInfoTemp.Time = deltaTime;
- SyncInfo->CompressingInfoTemp.InSize = ci.InSize - SyncInfo->CompressingInfoPrev.InSize;
- SyncInfo->CompressingInfoTemp.OutSize = ci.InSize - SyncInfo->CompressingInfoPrev.OutSize;
- SyncInfo->CompressingInfoPrev = ci;
- }
- if (*inSize >= _approvedStart && SyncInfo->ApprovedInfo.InSize == 0)
- SyncInfo->ApprovedInfo = ci;
- return S_OK;
-}
-
-static bool GetCoderPath(UString &path)
-{
- if (!GetProgramFolderPath(path))
- return false;
- path += L"Codecs\\LZMA.dll";
- return true;
-}
-
-typedef UInt32 (WINAPI *GetMethodPropertyFunc)(
- UInt32 index, PROPID propID, PROPVARIANT *value);
-
-static bool LoadCoder(
- const UString &filePath,
- NWindows::NDLL::CLibrary &library,
- CLSID &encoder, CLSID &decoder)
-{
- if (!library.Load(filePath))
- return false;
- GetMethodPropertyFunc getMethodProperty = (GetMethodPropertyFunc)
- library.GetProcAddress("GetMethodProperty");
- if (getMethodProperty == NULL)
- return false;
-
- NWindows::NCOM::CPropVariant propVariant;
- if (getMethodProperty (0, NMethodPropID::kEncoder, &propVariant) != S_OK)
- return false;
- if (propVariant.vt != VT_BSTR)
- return false;
- encoder = *(const GUID *)propVariant.bstrVal;
- propVariant.Clear();
-
- if (getMethodProperty (0, NMethodPropID::kDecoder, &propVariant) != S_OK)
- return false;
- if (propVariant.vt != VT_BSTR)
- return false;
- decoder = *(const GUID *)propVariant.bstrVal;
- propVariant.Clear();
- return true;
-}
-
-void Benchmark(HWND hwnd)
-{
- UString path;
- if (!GetCoderPath(path))
- {
- MyMessageBoxError(hwnd, L"Can't find LZMA.dll");
- return;
- }
- CLSID encoder;
- CLSID decoder;
- CThreadBenchmark benchmarker;
- if (!LoadCoder(path, benchmarker.Library, encoder, decoder))
- {
- MyMessageBoxError(hwnd, L"Can't load LZMA.dll");
- return;
- }
-
- CreateObjectPointer createObject = (CreateObjectPointer)
- benchmarker.Library.GetProcAddress("CreateObject");
- if (createObject == NULL)
- {
- MyMessageBoxError(hwnd, L"Incorrect LZMA.dll");
- return;
- }
- if (createObject(&encoder, &IID_ICompressCoder, (void **)&benchmarker.Encoder) != S_OK)
- {
- MyMessageBoxError(hwnd, L"Can't create codec");
- return;
- }
- if (createObject(&decoder, &IID_ICompressCoder, (void **)&benchmarker.Decoder) != S_OK)
- {
- MyMessageBoxError(hwnd, L"Can't create codec");
- return;
- }
-
- CBenchmarkDialog benchmarkDialog;
- benchmarker.SyncInfo = &benchmarkDialog._syncInfo;
- CThread thread;
- if (!thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker))
- {
- MyMessageBoxError(hwnd, L"error");
- return;
- }
- benchmarkDialog.Create(hwnd);
- WaitForSingleObject(thread, INFINITE);
-}
diff --git a/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h b/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h
deleted file mode 100755
index 16bb113b..00000000
--- a/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h
+++ /dev/null
@@ -1,136 +0,0 @@
-// BenchmarkDialog.h
-
-#ifndef __BENCHMARKDIALOG_H
-#define __BENCHMARKDIALOG_H
-
-#include "resource.h"
-
-#include "Common/MyCom.h"
-#include "Windows/Control/Dialog.h"
-#include "Windows/Control/ComboBox.h"
-#include "Windows/Synchronization.h"
-#include "../../../ICoder.h"
-
-const int kNumBenchDictionaryBitsStart = 21;
-
-struct CProgressInfo
-{
- UINT64 InSize;
- UINT64 OutSize;
- UINT64 Time;
- void Init()
- {
- InSize = 0;
- OutSize = 0;
- Time = 0;
- }
-};
-
-class CProgressSyncInfo
-{
- bool Stopped;
- bool Paused;
-public:
- bool Changed;
- UINT32 DictionarySize;
- bool MultiThread;
- UINT64 NumPasses;
- UINT64 NumErrors;
- NWindows::NSynchronization::CManualResetEvent _startEvent;
- NWindows::NSynchronization::CCriticalSection CS;
-
- CProgressInfo ApprovedInfo;
- CProgressInfo CompressingInfoPrev;
- CProgressInfo CompressingInfoTemp;
- CProgressInfo CompressingInfo;
- UINT64 ProcessedSize;
-
- CProgressInfo DecompressingInfoTemp;
- CProgressInfo DecompressingInfo;
-
- void Init()
- {
- Changed = false;
- ApprovedInfo.Init();
- CompressingInfoPrev.Init();
- CompressingInfoTemp.Init();
- CompressingInfo.Init();
- ProcessedSize = 0;
-
- DecompressingInfoTemp.Init();
- DecompressingInfo.Init();
-
- Stopped = false;
- Paused = false;
- NumPasses = 0;
- NumErrors = 0;
- }
- void InitSettings()
- {
- DictionarySize = (1 << kNumBenchDictionaryBitsStart);
- MultiThread = false;
- }
- void Stop()
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(CS);
- Stopped = true;
- }
- bool WasStopped()
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(CS);
- return Stopped;
- }
- void Pause()
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(CS);
- Paused = true;
- }
- void Start()
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(CS);
- Paused = false;
- }
- bool WasPaused()
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(CS);
- return Paused;
- }
- void WaitCreating() { _startEvent.Lock(); }
-};
-
-class CBenchmarkDialog:
- public NWindows::NControl::CModalDialog
-{
- NWindows::NControl::CComboBox m_Dictionary;
- UINT_PTR _timer;
- UINT32 _startTime;
-
- bool OnTimer(WPARAM timerID, LPARAM callback);
- virtual bool OnInit();
- void OnRestartButton();
- void OnStopButton();
- void OnHelp();
- virtual void OnCancel();
- bool OnButtonClicked(int buttonID, HWND buttonHWND);
- bool OnCommand(int code, int itemID, LPARAM lParam);
-
- void PrintTime();
- void PrintRating(UINT64 rating, UINT controlID);
- void PrintResults(
- UINT32 dictionarySize,
- UINT64 elapsedTime,
- UINT64 size, UINT speedID, UINT ratingID,
- bool decompressMode = false, UINT64 secondSize = 0);
-
- UINT32 OnChangeDictionary();
- void OnChangeSettings();
-public:
- CProgressSyncInfo _syncInfo;
-
- CBenchmarkDialog(): _timer(0) {}
- INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
-};
-
-void Benchmark(HWND hwnd);
-
-#endif
diff --git a/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp b/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp
deleted file mode 100755
index 9272b3b4..00000000
--- a/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-// CopyDialog.cpp
-
-#include "StdAfx.h"
-#include "CopyDialog.h"
-
-#include "Common/StringConvert.h"
-
-#include "Windows/Control/Static.h"
-#include "Windows/Shell.h"
-#include "Windows/FileName.h"
-
-#ifdef LANG
-#include "../../LangUtils.h"
-#endif
-
-using namespace NWindows;
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDOK, 0x02000702 },
- { IDCANCEL, 0x02000710 }
-};
-#endif
-
-bool CCopyDialog::OnInit()
-{
- #ifdef LANG
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- #endif
- _path.Attach(GetItem(IDC_COPY_COMBO));
- SetText(Title);
-
- NControl::CStatic staticContol;
- staticContol.Attach(GetItem(IDC_COPY_STATIC));
- staticContol.SetText(Static);
- for(int i = 0; i < Strings.Size(); i++)
- _path.AddString(Strings[i]);
- _path.SetText(Value);
- return CModalDialog::OnInit();
-}
-
-bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
- switch(buttonID)
- {
- case IDC_COPY_SET_PATH:
- OnButtonSetPath();
- return true;
- }
- return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
-}
-
-void CCopyDialog::OnButtonSetPath()
-{
- UString currentPath;
- _path.GetText(currentPath);
-
- /*
- #ifdef LANG
- UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
- #else
- UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
- #endif
- */
- UString title = L"Specify a location for output folder";
-
- UString resultPath;
- if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
- return;
- NFile::NName::NormalizeDirPathPrefix(resultPath);
- _path.SetCurSel(-1);
- _path.SetText(resultPath);
-}
-
-void CCopyDialog::OnOK()
-{
- _path.GetText(Value);
- CModalDialog::OnOK();
-}
diff --git a/7zip/FileManager/Resource/CopyDialog/resource.h b/7zip/FileManager/Resource/CopyDialog/resource.h
deleted file mode 100755
index 9da354fd..00000000
--- a/7zip/FileManager/Resource/CopyDialog/resource.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#define IDD_DIALOG_COPY 202
-
-#define IDC_COPY_STATIC 1000
-#define IDC_COPY_COMBO 1001
-#define IDC_COPY_SET_PATH 1002
diff --git a/7zip/FileManager/Resource/CopyDialog/resource.rc b/7zip/FileManager/Resource/CopyDialog/resource.rc
deleted file mode 100755
index c4c5c221..00000000
--- a/7zip/FileManager/Resource/CopyDialog/resource.rc
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "resource.h"
-#include "../../../GuiCommon.rc"
-
-#define xSize2 346
-#define ySize2 57
-
-#define xSize (xSize2 + marg + marg)
-#define ySize (ySize2 + marg + marg)
-
-#define bYPos (ySize - marg - bYSize)
-#define b1XPos (xSize - marg - bXSize)
-#define b2XPos (b1XPos - 10 - bXSize)
-
-IDD_DIALOG_COPY DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
-CAPTION "Copy"
-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
- DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize
- PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize
-END
diff --git a/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp b/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp
deleted file mode 100755
index ed39508e..00000000
--- a/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-// MessagesDialog.cpp
-
-#include "StdAfx.h"
-#include "MessagesDialog.h"
-#include "Common/StringConvert.h"
-#include "Common/IntToString.h"
-#include "Windows/ResourceString.h"
-
-#ifdef LANG
-#include "../../LangUtils.h"
-#endif
-
-using namespace NWindows;
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDOK, 0x02000713 }
-};
-#endif
-
-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);
-}
-
-void CMessagesDialog::AddMessage(LPCWSTR message)
-{
- UString s = message;
- while (!s.IsEmpty())
- {
- int pos = s.Find(L'\n');
- if (pos < 0)
- break;
- AddMessageDirect(s.Left(pos));
- s.Delete(0, pos + 1);
- }
- AddMessageDirect(s);
-}
-
-bool CMessagesDialog::OnInit()
-{
- #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
-
- columnInfo.pszText = (LPWSTR)(LPCWSTR)s;
- columnInfo.iSubItem = 1;
- columnInfo.cx = 450;
-
- _messageList.InsertColumn(1, &columnInfo);
-
- for(int i = 0; i < Messages->Size(); i++)
- AddMessage((*Messages)[i]);
-
- /*
- if(_messageList.GetItemCount() > 0)
- {
- UINT aState = LVIS_SELECTED | LVIS_FOCUSED;
- _messageList.SetItemState(0, aState, aState);
- }
- */
- return CModalDialog::OnInit();
-}
diff --git a/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h b/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h
deleted file mode 100755
index aa7c788a..00000000
--- a/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// MessagesDialog.h
-
-#ifndef __MESSAGESDIALOG_H
-#define __MESSAGESDIALOG_H
-
-#include "resource.h"
-
-#include "Windows/Control/Dialog.h"
-#include "Windows/Control/ListView.h"
-
-class CMessagesDialog: public NWindows::NControl::CModalDialog
-{
- NWindows::NControl::CListView _messageList;
- void AddMessageDirect(LPCWSTR message);
- void AddMessage(LPCWSTR message);
- virtual bool OnInit();
-public:
- const UStringVector *Messages;
- INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_MESSAGES, parent); }
-};
-
-#endif
diff --git a/7zip/FileManager/Resource/MessagesDialog/resource.rc b/7zip/FileManager/Resource/MessagesDialog/resource.rc
deleted file mode 100755
index 2fe18103..00000000
--- a/7zip/FileManager/Resource/MessagesDialog/resource.rc
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "resource.h"
-#include "../../../GuiCommon.rc"
-
-#define xSize2 335
-#define ySize2 121
-#define xSize (xSize2 + marg + marg)
-#define ySize (ySize2 + marg + marg)
-#define bXPos (xSize - marg - bXSize)
-#define bYPos (ySize - marg - bYSize)
-
-
-IDD_DIALOG_MESSAGES DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
-CAPTION "7-Zip: Diagnostic messages"
-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,
- marg, marg, xSize2, ySize2 - bYSize - 6
-END
-
-STRINGTABLE
-BEGIN
- IDS_MESSAGES_DIALOG_MESSAGE_COLUMN "Message"
-END
diff --git a/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp b/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp
deleted file mode 100755
index 4e85306c..00000000
--- a/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-// OverwriteDialog.cpp
-
-#include "StdAfx.h"
-
-#include "OverwriteDialog.h"
-
-#include "Common/StringConvert.h"
-#include "Windows/FileName.h"
-#include "Windows/Defs.h"
-#include "Windows/ResourceString.h"
-#include "Windows/Control/Static.h"
-#include "Windows/PropVariantConversions.h"
-
-#include "../../FormatUtils.h"
-
-// #include "../resource.h"
-
-#ifdef LANG
-#include "../../LangUtils.h"
-#endif
-
-using namespace NWindows;
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDC_STATIC_OVERWRITE_HEADER, 0x02000901},
- { IDC_STATIC_OVERWRITE_QUESTION_BEGIN, 0x02000902 },
- { IDC_STATIC_OVERWRITE_QUESTION_END, 0x02000903 },
- { IDYES, 0x02000705 },
- { IDC_BUTTON_OVERWRITE_YES_TO_ALL, 0x02000707 },
- { IDNO, 0x02000709 },
- { IDC_BUTTON_OVERWRITE_NO_TO_ALL,0x0200070B },
- { IDC_BUTTON_OVERWRITE_AUTO_RENAME, 0x02000911 },
- { IDCANCEL, 0x02000711 }
-};
-#endif
-
-void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
- const NOverwriteDialog::CFileInfo &fileInfo)
-{
- UString sizeString;
- if (fileInfo.SizeIsDefined)
- sizeString = MyFormatNew(IDS_FILE_SIZE,
- #ifdef LANG
- 0x02000982,
- #endif
- NumberToString(fileInfo.Size));
-
- UString reducedName;
- const int kLineSize = 88;
- for (int i = 0; i < fileInfo.Name.Length();)
- {
- reducedName += fileInfo.Name.Mid(i, kLineSize);
- reducedName += L" ";
- i += kLineSize;
- }
-
- UString fullString = reducedName;
- fullString += L"\n";
- fullString += sizeString;
- fullString += L"\n";
-
- if (fileInfo.TimeIsDefined)
- {
- UString timeString;
- FILETIME localFileTime;
- if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
- throw 4190402;
- timeString = ConvertFileTimeToString(localFileTime);
-
- fullString +=
- #ifdef LANG
- LangString(IDS_FILE_MODIFIED, 0x02000983);
- #else
- MyLoadStringW(IDS_FILE_MODIFIED);
- #endif
-
- fullString += L" ";
- fullString += timeString;
- }
-
- NWindows::NControl::CDialogChildControl control;
- control.Init(*this, textID);
- control.SetText(fullString);
-
- SHFILEINFO shellFileInfo;
- if (::SHGetFileInfo(
- GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo,
- sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON))
- {
- NControl::CStatic staticContol;
- staticContol.Attach(GetItem(iconID));
- staticContol.SetIcon(shellFileInfo.hIcon);
- }
-}
-
-bool COverwriteDialog::OnInit()
-{
- #ifdef LANG
- LangSetWindowText(HWND(*this), 0x02000900);
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- #endif
- SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME,
- IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo);
- 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)
-{
- switch(buttonID)
- {
- case IDYES:
- case IDC_BUTTON_OVERWRITE_YES_TO_ALL:
- case IDNO:
- case IDC_BUTTON_OVERWRITE_NO_TO_ALL:
- case IDC_BUTTON_OVERWRITE_AUTO_RENAME:
- End(buttonID);
- return true;
- }
- return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
-}
diff --git a/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h b/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h
deleted file mode 100755
index 0bfbe059..00000000
--- a/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// OverwriteDialog.h
-
-#ifndef __OVERWRITEDIALOG_H
-#define __OVERWRITEDIALOG_H
-
-#include "resource.h"
-#include "Windows/Control/Dialog.h"
-
-namespace NOverwriteDialog
-{
- struct CFileInfo
- {
- bool SizeIsDefined;
- UINT64 Size;
- bool TimeIsDefined;
- FILETIME Time;
- UString Name;
- };
-}
-
-class COverwriteDialog: public NWindows::NControl::CModalDialog
-{
- void SetFileInfoControl(int textID, int iconID,
- const NOverwriteDialog::CFileInfo &fileInfo);
- virtual bool OnInit();
- bool OnButtonClicked(int buttonID, HWND buttonHWND);
-public:
- INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_OVERWRITE, parent); }
-
- NOverwriteDialog::CFileInfo OldFileInfo;
- NOverwriteDialog::CFileInfo NewFileInfo;
-};
-
-#endif
diff --git a/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp b/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
deleted file mode 100755
index 40453ccb..00000000
--- a/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-// ProgressDialog.cpp
-
-#include "StdAfx.h"
-#include "resource.h"
-#include "ProgressDialog.h"
-#include "Common/IntToString.h"
-#include "Common/IntToString.h"
-
-using namespace NWindows;
-
-static const UINT_PTR kTimerID = 3;
-static const UINT kTimerElapse = 50;
-
-#ifdef LANG
-#include "../../LangUtils.h"
-#endif
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDCANCEL, 0x02000711 }
-};
-#endif
-
-#ifndef _SFX
-CProgressDialog::~CProgressDialog()
-{
- AddToTitle(TEXT(""));
-}
-void CProgressDialog::AddToTitle(LPCWSTR s)
-{
- if (MainWindow != 0)
- ::MySetWindowText(MainWindow, UString(s) + MainTitle);
-}
-#endif
-
-
-
-bool CProgressDialog::OnInit()
-{
- _range = UINT64(-1);
- _prevPercentValue = -1;
-
- #ifdef LANG
- // LangSetWindowText(HWND(*this), 0x02000C00);
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- #endif
-
- m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
- _timer = SetTimer(kTimerID, kTimerElapse);
- _dialogCreatedEvent.Set();
- SetText(_title);
- return CModalDialog::OnInit();
-}
-
-void CProgressDialog::OnCancel()
-{
- ProgressSynch.SetStopped(true);
-}
-
-void CProgressDialog::SetRange(UINT64 range)
-{
- _range = range;
- _peviousPos = (UInt64)(Int64)-1;
- _converter.Init(range);
- m_ProgressBar.SetRange32(0 , _converter.Count(range)); // Test it for 100%
-}
-
-void CProgressDialog::SetPos(UINT64 pos)
-{
- bool redraw = true;
- if (pos < _range && pos > _peviousPos)
- {
- UINT64 posDelta = pos - _peviousPos;
- if (posDelta < (_range >> 10))
- redraw = false;
- }
- if(redraw)
- {
- m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100%
- _peviousPos = pos;
- }
-}
-
-bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
-{
- if (ProgressSynch.GetPaused())
- return true;
- UINT64 total, completed;
- ProgressSynch.GetProgress(total, completed);
- if (total != _range)
- SetRange(total);
- SetPos(completed);
-
- if (total == 0)
- total = 1;
-
- int percentValue = (int)(completed * 100 / total);
- if (percentValue != _prevPercentValue)
- {
- wchar_t s[64];
- ConvertUInt64ToString(percentValue, s);
- UString title = s;
- title += L"% ";
- SetText(title + _title);
- #ifndef _SFX
- AddToTitle(title + MainAddTitle);
- #endif
- _prevPercentValue = percentValue;
- }
- return true;
-}
-
-
-////////////////////
-// CU64ToI32Converter
-
-static const UINT64 kMaxIntValue = 0x7FFFFFFF;
-
-void CU64ToI32Converter::Init(UINT64 range)
-{
- _numShiftBits = 0;
- while(range > kMaxIntValue)
- {
- range >>= 1;
- _numShiftBits++;
- }
-}
-
-int CU64ToI32Converter::Count(UINT64 aValue)
-{
- return int(aValue >> _numShiftBits);
-}
-
-const UINT CProgressDialog::kCloseMessage = WM_USER + 1;
-
-bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch(message)
- {
- case kCloseMessage:
- {
- KillTimer(_timer);
- _timer = 0;
- End(0);
- return true;
- }
- case WM_SETTEXT:
- {
- if (_timer == 0)
- return true;
- }
- }
- return CModalDialog::OnMessage(message, wParam, lParam);
-}
-
-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?",
- _title, MB_YESNOCANCEL);
- ProgressSynch.SetPaused(paused);
- if (res == IDCANCEL || res == IDNO)
- return true;
- break;
- }
- }
- return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
-}
diff --git a/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h b/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h
deleted file mode 100755
index 81a0f9a6..00000000
--- a/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h
+++ /dev/null
@@ -1,129 +0,0 @@
-// ProgressDialog.h
-
-#ifndef __PROGRESSDIALOG_H
-#define __PROGRESSDIALOG_H
-
-#include "resource.h"
-
-#include "Windows/Control/Dialog.h"
-#include "Windows/Control/ProgressBar.h"
-#include "Windows/Synchronization.h"
-
-class CProgressSynch
-{
- NWindows::NSynchronization::CCriticalSection _criticalSection;
- bool _stopped;
- bool _paused;
- UINT64 _total;
- UINT64 _completed;
-public:
- CProgressSynch(): _stopped(false), _paused(false), _total(1), _completed(0) {}
-
- bool GetStopped()
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- return _stopped;
- }
- void SetStopped(bool value)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- _stopped = value;
- }
- bool GetPaused()
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- return _paused;
- }
- void SetPaused(bool value)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- _paused = value;
- }
- void SetProgress(UINT64 total, UINT64 completed)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- _total = total;
- _completed = completed;
- }
- void SetPos(UINT64 completed)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- _completed = completed;
- }
- void GetProgress(UINT64 &total, UINT64 &completed)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- total = _total;
- completed = _completed;
- }
-};
-
-class CU64ToI32Converter
-{
- UINT64 _numShiftBits;
-public:
- void Init(UINT64 _range);
- int Count(UINT64 aValue);
-};
-
-// class CProgressDialog: public NWindows::NControl::CModelessDialog
-
-class CProgressDialog: public NWindows::NControl::CModalDialog
-{
-private:
- UINT_PTR _timer;
-
- UString _title;
- CU64ToI32Converter _converter;
- UINT64 _peviousPos;
- UINT64 _range;
- NWindows::NControl::CProgressBar m_ProgressBar;
-
- int _prevPercentValue;
-
- bool OnTimer(WPARAM timerID, LPARAM callback);
- void SetRange(UINT64 range);
- void SetPos(UINT64 pos);
- virtual bool OnInit();
- virtual void OnCancel();
- NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
- #ifndef _SFX
- void AddToTitle(LPCWSTR string);
- #endif
- bool OnButtonClicked(int buttonID, HWND buttonHWND);
-public:
- CProgressSynch ProgressSynch;
-
- #ifndef _SFX
- HWND MainWindow;
- UString MainTitle;
- UString MainAddTitle;
- ~CProgressDialog();
- #endif
-
- CProgressDialog(): _timer(0)
- #ifndef _SFX
- ,MainWindow(0)
- #endif
- {}
-
- void WaitCreating() { _dialogCreatedEvent.Lock(); }
-
-
- INT_PTR Create(const UString &title, HWND wndParent = 0)
- {
- _title = title;
- return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
- }
-
- static const UINT kCloseMessage;
-
- virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
-
- void MyClose()
- {
- PostMessage(kCloseMessage);
- };
-};
-
-#endif
diff --git a/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp b/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp
deleted file mode 100755
index 128081aa..00000000
--- a/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp
+++ /dev/null
@@ -1,432 +0,0 @@
-// ProgressDialog.cpp
-
-#include "StdAfx.h"
-#include "resource.h"
-#include "ProgressDialog.h"
-#include "Common/IntToString.h"
-#include "Common/IntToString.h"
-
-using namespace NWindows;
-
-static const UINT_PTR kTimerID = 3;
-static const UINT kTimerElapse = 50;
-
-#ifdef LANG
-#include "../../LangUtils.h"
-#endif
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDCANCEL, 0x02000C00 },
- { IDC_PROGRESS_ELAPSED, 0x02000C01 },
- { IDC_PROGRESS_REMAINING, 0x02000C02 },
- { IDC_PROGRESS_TOTAL, 0x02000C03 },
- { IDC_PROGRESS_SPEED, 0x02000C04 },
- { IDC_BUTTON_PROGRESS_PRIORITY, 0x02000C10 },
- { IDC_BUTTON_PAUSE, 0x02000C12 },
- { IDCANCEL, 0x02000711 },
-};
-#endif
-
-HRESULT CProgressSynch::SetPosAndCheckPaused(UInt64 completed)
-{
- for (;;)
- {
- if(GetStopped())
- return E_ABORT;
- if(!GetPaused())
- break;
- ::Sleep(100);
- }
- SetPos(completed);
- return S_OK;
-}
-
-#ifndef _SFX
-CProgressDialog::~CProgressDialog()
-{
- AddToTitle(L"");
-}
-void CProgressDialog::AddToTitle(LPCWSTR s)
-{
- if (MainWindow != 0)
- {
- CWindow window(MainWindow);
- window.SetText(s + UString(MainTitle));
- }
-}
-
-static const int kTitleFileNameSizeLimit = 36;
-static const int kCurrentFileNameSizeLimit = 68;
-
-static void ReduceString(UString &s, int size)
-{
- if (s.Length() > size)
- s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2);
-}
-#endif
-
-bool CProgressDialog::OnInit()
-{
- _range = (UInt64)(Int64)(-1);
- _prevPercentValue = UInt32(-1);
- _prevElapsedSec = UInt32(-1);
- _prevRemainingSec = UInt32(-1);
- _prevSpeed = UInt32(-1);
- _prevMode = kSpeedBytes;
- _prevTime = ::GetTickCount();
- _elapsedTime = 0;
- _foreground = true;
-
- #ifdef LANG
- // LangSetWindowText(HWND(*this), 0x02000C00);
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- #endif
-
-
- CWindow window(GetItem(IDC_BUTTON_PROGRESS_PRIORITY));
- window.GetText(backgroundString);
- backgroundedString = backgroundString;
- backgroundedString.Replace(L"&", L"");
-
- window = GetItem(IDC_BUTTON_PAUSE);
- window.GetText(pauseString);
-
- foregroundString = LangString(IDS_PROGRESS_FOREGROUND, 0x02000C11);
- continueString = LangString(IDS_PROGRESS_CONTINUE, 0x02000C13);
- pausedString = LangString(IDS_PROGRESS_PAUSED, 0x02000C20);
-
- m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
- _timer = SetTimer(kTimerID, kTimerElapse);
- _dialogCreatedEvent.Set();
- SetText(_title);
- SetPauseText();
- SetPriorityText();
- return CModalDialog::OnInit();
-}
-
-void CProgressDialog::OnCancel()
-{
- ProgressSynch.SetStopped(true);
-}
-
-static void ConvertSizeToString(UInt64 value, wchar_t *s)
-{
- const wchar_t *kModif = L" KMGTP";
- for (int i = 0; ; i++)
- if (i == 5 || value < (UInt64(10000) << (i * 10)))
- {
- ConvertUInt64ToString(value >> (i * 10), s);
- s += wcslen(s);
- *s++ = ' ';
- if (i != 0)
- *s++ = kModif[i];
- *s++ = L'B';
- *s++ = L'\0';
- return;
- }
-}
-
-void CProgressDialog::SetRange(UInt64 range)
-{
- _range = range;
- _previousPos = (UInt64)(Int64)-1;
- _converter.Init(range);
- m_ProgressBar.SetRange32(0 , _converter.Count(range)); // Test it for 100%
-
- wchar_t s[32];
- ConvertSizeToString(_range, s);
- SetItemText(IDC_PROGRESS_SPEED_TOTAL_VALUE, s);
-}
-
-void CProgressDialog::SetPos(UInt64 pos)
-{
- bool redraw = true;
- if (pos < _range && pos > _previousPos)
- {
- if (pos - _previousPos < (_range >> 10))
- redraw = false;
- }
- if(redraw)
- {
- m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100%
- _previousPos = pos;
- }
-}
-
-static void GetTimeString(UInt64 timeValue, TCHAR *s)
-{
- wsprintf(s, TEXT("%02d:%02d:%02d"),
- UInt32(timeValue / 3600),
- UInt32((timeValue / 60) % 60),
- UInt32(timeValue % 60));
-}
-
-bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
-{
- if (ProgressSynch.GetPaused())
- return true;
- UInt64 total, completed;
- ProgressSynch.GetProgress(total, completed);
-
- UInt32 curTime = ::GetTickCount();
-
- if (total != _range)
- SetRange(total);
- if (total == (UInt64)(Int64)-1)
- {
- SetPos(0);
- SetRange(completed);
- }
- else
- SetPos(completed);
-
- _elapsedTime += (curTime - _prevTime);
- _prevTime = curTime;
-
- UInt32 elapsedSec = _elapsedTime / 1000;
-
- bool elapsedChanged = false;
- if (elapsedSec != _prevElapsedSec)
- {
- TCHAR s[40];
- GetTimeString(elapsedSec, s);
- SetItemText(IDC_PROGRESS_ELAPSED_VALUE, s);
- _prevElapsedSec = elapsedSec;
- elapsedChanged = true;
- }
-
- if (completed != 0 && elapsedChanged)
- {
- if (total == (UInt64)(Int64)-1)
- {
- SetItemText(IDC_PROGRESS_REMAINING_VALUE, L"");
- }
- else
- {
- UInt64 remainingTime = 0;
- if (completed < total)
- remainingTime = _elapsedTime * (total - completed) / completed;
- UInt64 remainingSec = remainingTime / 1000;
- if (remainingSec != _prevRemainingSec)
- {
- TCHAR s[40];
- GetTimeString(remainingSec, s);
- SetItemText(IDC_PROGRESS_REMAINING_VALUE, s);
- _prevRemainingSec = remainingSec;
- }
- }
- // if (elapsedChanged)
- {
- UInt64 speedB = (completed * 1000) / _elapsedTime;
- UInt64 speedKB = speedB / 1024;
- UInt64 speedMB = speedKB / 1024;
- const UInt32 kLimit1 = 10;
- TCHAR s[40];
- bool needRedraw = false;
- if (speedMB >= kLimit1)
- {
- if (_prevMode != kSpeedMBytes || speedMB != _prevSpeed)
- {
- ConvertUInt64ToString(speedMB, s);
- lstrcat(s, TEXT(" MB/s"));
- _prevMode = kSpeedMBytes;
- _prevSpeed = speedMB;
- needRedraw = true;
- }
- }
- else if (speedKB >= kLimit1)
- {
- if (_prevMode != kSpeedKBytes || speedKB != _prevSpeed)
- {
- ConvertUInt64ToString(speedKB, s);
- lstrcat(s, TEXT(" KB/s"));
- _prevMode = kSpeedKBytes;
- _prevSpeed = speedKB;
- needRedraw = true;
- }
- }
- else
- {
- if (_prevMode != kSpeedBytes || speedB != _prevSpeed)
- {
- ConvertUInt64ToString(speedB, s);
- lstrcat(s, TEXT(" B/s"));
- _prevMode = kSpeedBytes;
- _prevSpeed = speedB;
- needRedraw = true;
- }
- }
- if (needRedraw)
- SetItemText(IDC_PROGRESS_SPEED_VALUE, s);
- }
- }
-
- if (total == 0)
- total = 1;
- UInt32 percentValue = (UInt32)(completed * 100 / total);
- UString titleName;
- ProgressSynch.GetTitleFileName(titleName);
- if (percentValue != _prevPercentValue || _prevTitleName != titleName)
- {
- _prevPercentValue = percentValue;
- SetTitleText();
- _prevTitleName = titleName;
- }
- UString fileName;
- ProgressSynch.GetCurrentFileName(fileName);
- if (_prevFileName != fileName)
- {
- ReduceString(fileName, kCurrentFileNameSizeLimit);
- SetItemText(IDC_PROGRESS_FILE_NAME, fileName);
- _prevFileName == fileName;
- }
-
- return true;
-}
-
-
-////////////////////
-// CU64ToI32Converter
-
-static const UInt64 kMaxIntValue = 0x7FFFFFFF;
-
-void CU64ToI32Converter::Init(UInt64 range)
-{
- _numShiftBits = 0;
- while(range > kMaxIntValue)
- {
- range >>= 1;
- _numShiftBits++;
- }
-}
-
-int CU64ToI32Converter::Count(UInt64 aValue)
-{
- return int(aValue >> _numShiftBits);
-}
-
-const UINT CProgressDialog::kCloseMessage = WM_USER + 1;
-
-bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch(message)
- {
- case kCloseMessage:
- {
- KillTimer(_timer);
- _timer = 0;
- End(0);
- return true;
- }
- case WM_SETTEXT:
- {
- if (_timer == 0)
- return true;
- }
- }
- return CModalDialog::OnMessage(message, wParam, lParam);
-}
-
-void CProgressDialog::SetTitleText()
-{
- UString title;
- if (ProgressSynch.GetPaused())
- {
- title = pausedString;
- title += L" ";
- }
- if (_prevPercentValue != UInt32(-1))
- {
- wchar_t s[64];
- ConvertUInt64ToString(_prevPercentValue, s);
- title += s;
- title += L"%";
- }
- if (!_foreground)
- {
- title += L" ";
- title += backgroundedString;
- }
- title += L" ";
- UString totalTitle = title + _title;
- UString fileName;
- ProgressSynch.GetTitleFileName(fileName);
- if (!fileName.IsEmpty())
- {
- ReduceString(fileName, kTitleFileNameSizeLimit);
- totalTitle += L" ";
- totalTitle += fileName;
- }
- SetText(totalTitle);
- #ifndef _SFX
- AddToTitle(title + MainAddTitle);
- #endif
-}
-
-void CProgressDialog::SetPauseText()
-{
- SetItemText(IDC_BUTTON_PAUSE, ProgressSynch.GetPaused() ?
- continueString : pauseString);
- SetTitleText();
-}
-
-void CProgressDialog::OnPauseButton()
-{
- bool paused = !ProgressSynch.GetPaused();
- ProgressSynch.SetPaused(paused);
- UInt32 curTime = ::GetTickCount();
- if (paused)
- _elapsedTime += (curTime - _prevTime);
- _prevTime = curTime;
- SetPauseText();
-}
-
-void CProgressDialog::SetPriorityText()
-{
- SetItemText(IDC_BUTTON_PROGRESS_PRIORITY, _foreground ?
- backgroundString :
- foregroundString);
- SetTitleText();
-}
-
-void CProgressDialog::OnPriorityButton()
-{
- _foreground = !_foreground;
- SetPriorityClass(GetCurrentProcess(), _foreground ?
- NORMAL_PRIORITY_CLASS: IDLE_PRIORITY_CLASS);
- SetPriorityText();
-}
-
-bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
- switch(buttonID)
- {
- case IDCANCEL:
- {
- bool paused = ProgressSynch.GetPaused();;
- // ProgressSynch.SetPaused(true);
- if (!paused)
- OnPauseButton();
- int res = ::MessageBoxW(HWND(*this),
- LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30),
- _title, MB_YESNOCANCEL);
- // ProgressSynch.SetPaused(paused);
- if (!paused)
- OnPauseButton();
- if (res == IDCANCEL || res == IDNO)
- return true;
- break;
- }
- case IDC_BUTTON_PAUSE:
- OnPauseButton();
- return true;
- case IDC_BUTTON_PROGRESS_PRIORITY:
- {
- OnPriorityButton();
- return true;
- }
- }
- return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
-}
diff --git a/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h b/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h
deleted file mode 100755
index 1803ce8b..00000000
--- a/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h
+++ /dev/null
@@ -1,184 +0,0 @@
-// ProgressDialog.h
-
-#ifndef __PROGRESSDIALOG_H
-#define __PROGRESSDIALOG_H
-
-#include "resource.h"
-
-#include "Common/Types.h"
-
-#include "Windows/Control/Dialog.h"
-#include "Windows/Control/ProgressBar.h"
-#include "Windows/Synchronization.h"
-
-class CProgressSynch
-{
- NWindows::NSynchronization::CCriticalSection _criticalSection;
- bool _stopped;
- bool _paused;
- UInt64 _total;
- UInt64 _completed;
- UString TitleFileName;
- UString CurrentFileName;
-public:
- CProgressSynch(): _stopped(false), _paused(false), _total((UInt64)(Int64)-1), _completed(0) {}
-
- bool GetStopped()
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- return _stopped;
- }
- void SetStopped(bool value)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- _stopped = value;
- }
- bool GetPaused()
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- return _paused;
- }
- void SetPaused(bool value)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- _paused = value;
- }
- void SetProgress(UInt64 total, UInt64 completed)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- _total = total;
- _completed = completed;
- }
- void SetPos(UInt64 completed)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- _completed = completed;
- }
- HRESULT SetPosAndCheckPaused(UInt64 completed);
- void GetProgress(UInt64 &total, UInt64 &completed)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- total = _total;
- completed = _completed;
- }
- void SetTitleFileName(const UString &fileName)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- TitleFileName = fileName;
- }
- void GetTitleFileName(UString &fileName)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- fileName = TitleFileName;
- }
- void SetCurrentFileName(const UString &fileName)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- CurrentFileName = fileName;
- }
- void GetCurrentFileName(UString &fileName)
- {
- NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
- fileName = CurrentFileName;
- }
-};
-
-class CU64ToI32Converter
-{
- UInt64 _numShiftBits;
-public:
- void Init(UInt64 _range);
- int Count(UInt64 aValue);
-};
-
-// class CProgressDialog: public NWindows::NControl::CModelessDialog
-
-enum ESpeedMode
-{
- kSpeedBytes,
- kSpeedKBytes,
- kSpeedMBytes
-};
-
-class CProgressDialog: public NWindows::NControl::CModalDialog
-{
- UString _prevFileName;
- UString _prevTitleName;
-private:
- UString backgroundString;
- UString backgroundedString;
- UString foregroundString;
- UString pauseString;
- UString continueString;
- UString pausedString;
-
-
-
- UINT_PTR _timer;
-
- UString _title;
- CU64ToI32Converter _converter;
- UInt64 _previousPos;
- UInt64 _range;
- NWindows::NControl::CProgressBar m_ProgressBar;
-
- UInt32 _prevPercentValue;
- UInt32 _prevTime;
- UInt32 _elapsedTime;
- UInt32 _prevElapsedSec;
- UInt64 _prevRemainingSec;
- ESpeedMode _prevMode;
- UInt64 _prevSpeed;
-
- bool _foreground;
-
- bool OnTimer(WPARAM timerID, LPARAM callback);
- void SetRange(UInt64 range);
- void SetPos(UInt64 pos);
- virtual bool OnInit();
- virtual void OnCancel();
- NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
- #ifndef _SFX
- void AddToTitle(LPCWSTR string);
- #endif
-
- void SetPauseText();
- void SetPriorityText();
- void OnPauseButton();
- void OnPriorityButton();
- bool OnButtonClicked(int buttonID, HWND buttonHWND);
-
- void SetTitleText();
-public:
- CProgressSynch ProgressSynch;
-
- #ifndef _SFX
- HWND MainWindow;
- UString MainTitle;
- UString MainAddTitle;
- ~CProgressDialog();
- #endif
-
- CProgressDialog(): _timer(0)
- #ifndef _SFX
- ,MainWindow(0)
- #endif
- {}
-
- void WaitCreating() { _dialogCreatedEvent.Lock(); }
-
-
- INT_PTR Create(const UString &title, HWND wndParent = 0)
- {
- _title = title;
- return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
- }
-
- static const UINT kCloseMessage;
-
- virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
-
- void MyClose() { PostMessage(kCloseMessage); };
-};
-
-#endif
diff --git a/7zip/FileManager/Resource/ProgressDialog2/resource.rc b/7zip/FileManager/Resource/ProgressDialog2/resource.rc
deleted file mode 100755
index 98515ce3..00000000
--- a/7zip/FileManager/Resource/ProgressDialog2/resource.rc
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "resource.h"
-#include "../../../GuiCommon.rc"
-
-#define xSize2 290
-#define ySize2 76
-
-#define xSize (xSize2 + marg + marg)
-#define ySize (ySize2 + marg + marg)
-
-#define bYPos (ySize - marg - bYSize)
-
-#undef bXSize
-#define bXSize 72
-
-#define bXPos1 (xSize - marg - bXSize)
-#define bXPos2 (bXPos1 - 10 - bXSize)
-#define bXPos3 (bXPos2 - 10 - bXSize)
-
-#define valSize 42
-#define timeSize 91
-#define labelPos 178
-#define valPos1 (marg + timeSize)
-#define valPos2 (xSize - marg - valSize)
-#define labelSize (valPos2 - labelPos)
-
-#undef yPos
-#define yPos (marg + 11)
-
-
-IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
-CAPTION "Progress"
-MY_FONT
-BEGIN
- PUSHBUTTON "&Background", IDC_BUTTON_PROGRESS_PRIORITY, bXPos3, bYPos, bXSize, bYSize
- PUSHBUTTON "&Pause", IDC_BUTTON_PAUSE, bXPos2, bYPos, bXSize, bYSize
- PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize
- LTEXT "Elapsed time:", IDC_PROGRESS_ELAPSED, marg, marg, timeSize, 8
- LTEXT "Remaining time:", IDC_PROGRESS_REMAINING, marg, yPos, timeSize, 8
- LTEXT "Size:", IDC_PROGRESS_TOTAL, labelPos, marg, labelSize, 8
- LTEXT "Speed:", IDC_PROGRESS_SPEED, labelPos, yPos, labelSize, 8
- RTEXT "00:00:00", IDC_PROGRESS_ELAPSED_VALUE, valPos1, marg, valSize, 8
- RTEXT "", IDC_PROGRESS_REMAINING_VALUE, valPos1, yPos, valSize, 8
- RTEXT "", IDC_PROGRESS_SPEED_TOTAL_VALUE, valPos2, marg, valSize, 8
- RTEXT "", IDC_PROGRESS_SPEED_VALUE, valPos2, yPos, valSize, 8
- LTEXT "", IDC_PROGRESS_FILE_NAME, marg, yPos + 16, xSize2, 8, SS_NOPREFIX
- CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER,
- marg, bYPos - 20, xSize2, 13
-END
-
-
-STRINGTABLE DISCARDABLE
-BEGIN
- IDS_PROGRESS_PAUSED "Paused"
- IDS_PROGRESS_FOREGROUND "&Foreground"
- IDS_PROGRESS_CONTINUE "&Continue"
- IDS_PROGRESS_ASK_CANCEL "Are you sure you want to cancel?"
-END
diff --git a/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp b/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp
deleted file mode 100755
index a84dc0bd..00000000
--- a/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-// SplitDialog.cpp
-
-#include "StdAfx.h"
-#include "SplitDialog.h"
-
-#include "Common/StringToInt.h"
-#include "Windows/Shell.h"
-#include "Windows/FileName.h"
-
-#include "../../SplitUtils.h"
-#ifdef LANG
-#include "../../LangUtils.h"
-#endif
-
-using namespace NWindows;
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDC_STATIC_SPLIT_PATH, 0x03020501 },
- { IDC_STATIC_SPLIT_VOLUME, 0x02000D40 },
-};
-#endif
-
-
-bool CSplitDialog::OnInit()
-{
- #ifdef LANG
- LangSetWindowText(HWND(*this), 0x03020500);
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- #endif
- _pathCombo.Attach(GetItem(IDC_COMBO_SPLIT_PATH));
- _volumeCombo.Attach(GetItem(IDC_COMBO_SPLIT_VOLUME));
-
- if (!FilePath.IsEmpty())
- {
- UString title;
- GetText(title);
- title += L' ';
- title += FilePath;
- SetText(title);
- }
- _pathCombo.SetText(Path);
- AddVolumeItems(_volumeCombo);
- _volumeCombo.SetCurSel(0);
- return CModalDialog::OnInit();
-}
-
-bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
- switch(buttonID)
- {
- case IDC_BUTTON_SPLIT_PATH:
- OnButtonSetPath();
- return true;
- }
- return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
-}
-
-void CSplitDialog::OnButtonSetPath()
-{
- UString currentPath;
- _pathCombo.GetText(currentPath);
- UString title = L"Specify a location for output folder";
- UString resultPath;
- if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
- return;
- NFile::NName::NormalizeDirPathPrefix(resultPath);
- _pathCombo.SetCurSel(-1);
- _pathCombo.SetText(resultPath);
-}
-
-void CSplitDialog::OnOK()
-{
- _pathCombo.GetText(Path);
- UString volumeString;
- _volumeCombo.GetText(volumeString);
- volumeString.Trim();
- if (!ParseVolumeSizes(volumeString, VolumeSizes))
- {
- MessageBoxW((HWND)*this, L"Incorrect volume size", L"7-Zip", MB_ICONERROR);
- return;
- }
- CModalDialog::OnOK();
-}
diff --git a/7zip/FileManager/Resource/SplitDialog/StdAfx.h b/7zip/FileManager/Resource/SplitDialog/StdAfx.h
deleted file mode 100755
index 3f82c0c2..00000000
--- a/7zip/FileManager/Resource/SplitDialog/StdAfx.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// stdafx.h
-
-#ifndef __STDAFX_H
-#define __STDAFX_H
-
-#define _WIN32_WINNT 0x0400
-
-// it's for Windows NT supporting (MENUITEMINFOW)
-#define WINVER 0x0400
-
-#include <windows.h>
-#include <commctrl.h>
-
-// #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-
-#include "Common/NewHandler.h"
-
-#endif
diff --git a/7zip/FileManager/Resource/SplitDialog/resource.h b/7zip/FileManager/Resource/SplitDialog/resource.h
deleted file mode 100755
index 478dc0aa..00000000
--- a/7zip/FileManager/Resource/SplitDialog/resource.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#define IDD_DIALOG_SPLIT 504
-#define IDC_STATIC_SPLIT_PATH 1000
-#define IDC_COMBO_SPLIT_PATH 1001
-#define IDC_BUTTON_SPLIT_PATH 1002
-#define IDC_STATIC_SPLIT_VOLUME 1010
-#define IDC_COMBO_SPLIT_VOLUME 1011
diff --git a/7zip/FileManager/Resource/SplitDialog/resource.rc b/7zip/FileManager/Resource/SplitDialog/resource.rc
deleted file mode 100755
index 68e259c2..00000000
--- a/7zip/FileManager/Resource/SplitDialog/resource.rc
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "resource.h"
-#include "../../../GuiCommon.rc"
-
-#define xSize2 223
-#define ySize2 89
-
-#define xSize (xSize2 + marg + marg)
-#define ySize (ySize2 + marg + marg)
-
-#define bYPos (ySize - marg - bYSize)
-#define b1XPos (xSize - marg - bXSize)
-#define b2XPos (b1XPos - 10 - bXSize)
-
-
-
-IDD_DIALOG_SPLIT DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
-CAPTION "Split File"
-MY_FONT
-BEGIN
- LTEXT "&Split to:", IDC_STATIC_SPLIT_PATH, marg, marg, xSize2, 8
- COMBOBOX IDC_COMBO_SPLIT_PATH, marg, 18, xSize2 - bDotsSize - 12, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "...", IDC_BUTTON_SPLIT_PATH, xSize - marg - bDotsSize, 17, bDotsSize, bYSize, WS_GROUP
- LTEXT "Split to &volumes, bytes:", IDC_STATIC_SPLIT_VOLUME, marg, 38, xSize2, 8
- COMBOBOX IDC_COMBO_SPLIT_VOLUME, marg, 50, 120, 52, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize
- PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize
-END
diff --git a/7zip/FileManager/SplitUtils.cpp b/7zip/FileManager/SplitUtils.cpp
deleted file mode 100755
index 0264c06d..00000000
--- a/7zip/FileManager/SplitUtils.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// SplitUtils.cpp
-
-#include "StdAfx.h"
-
-#include "Common/StringToInt.h"
-
-#include "SplitUtils.h"
-#include "StringUtils.h"
-
-bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values)
-{
- values.Clear();
- UStringVector destStrings;
- SplitString(s, destStrings);
- bool prevIsNumber = false;
- for (int i = 0; i < destStrings.Size(); i++)
- {
- UString subString = destStrings[i];
- subString.MakeUpper();
- if (subString.IsEmpty())
- return false;
- if (subString == L"-")
- return true;
- if (prevIsNumber)
- {
- wchar_t c = subString[0];
- UInt64 &value = values.Back();
- prevIsNumber = false;
- switch(c)
- {
- case L'B':
- continue;
- case L'K':
- value <<= 10;
- continue;
- case L'M':
- value <<= 20;
- continue;
- case L'G':
- value <<= 30;
- continue;
- }
- }
- const wchar_t *start = subString;
- const wchar_t *end;
- UInt64 value = ConvertStringToUInt64(start, &end);
- if (start == end)
- return false;
- if (value == 0)
- return false;
- values.Add(value);
- prevIsNumber = true;
- UString rem = subString.Mid((int)(end - start));
- if (!rem.IsEmpty())
- destStrings.Insert(i + 1, rem);
- }
- return true;
-}
-
-void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo)
-{
- volumeCombo.AddString(TEXT("1457664 - 3.5\" floppy"));
- volumeCombo.AddString(TEXT("650M - CD"));
- volumeCombo.AddString(TEXT("700M - CD"));
- volumeCombo.AddString(TEXT("4480M - DVD"));
-}
diff --git a/7zip/FileManager/SplitUtils.h b/7zip/FileManager/SplitUtils.h
deleted file mode 100755
index e41efa67..00000000
--- a/7zip/FileManager/SplitUtils.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// SplitUtils.h
-
-#ifndef __SPLITUTILS_H
-#define __SPLITUTILS_H
-
-#include "Common/String.h"
-#include "Common/Types.h"
-#include "Windows/Control/ComboBox.h"
-
-bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values);
-void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo);
-
-#endif
diff --git a/7zip/FileManager/StdAfx.cpp b/7zip/FileManager/StdAfx.cpp
deleted file mode 100755
index 4cdd30e1..00000000
--- a/7zip/FileManager/StdAfx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : source file that includes just the standard includes
-// FAM.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
diff --git a/7zip/FileManager/StdAfx.h b/7zip/FileManager/StdAfx.h
deleted file mode 100755
index e0b5d6e5..00000000
--- a/7zip/FileManager/StdAfx.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// stdafx.h
-
-#ifndef __STDAFX_H
-#define __STDAFX_H
-
-#define _WIN32_WINNT 0x0400
-
-// it's for Windows NT supporting (MENUITEMINFOW)
-#define WINVER 0x0400
-
-#include <windows.h>
-#include <stdio.h>
-#include <commctrl.h>
-#include <ShlObj.h>
-#include <limits.h>
-#include <tchar.h>
-#include <shlwapi.h>
-
-// #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-
-#include "Common/NewHandler.h"
-
-#endif
diff --git a/7zip/FileManager/makefile b/7zip/FileManager/makefile
deleted file mode 100755
index 697b1507..00000000
--- a/7zip/FileManager/makefile
+++ /dev/null
@@ -1,180 +0,0 @@
-PROG = 7zFM.exe
-LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib shell32.lib ole32.lib comctl32.lib htmlhelp.lib Mpr.lib Gdi32.lib comdlg32.lib
-CFLAGS = $(CFLAGS) -I../../ -DLANG
-
-FM_OBJS = \
- $O\App.obj \
- $O\ClassDefs.obj \
- $O\EnumFormatEtc.obj \
- $O\ExtractCallback.obj \
- $O\FileFolderPluginOpen.obj \
- $O\FilePlugins.obj \
- $O\FM.obj \
- $O\FormatUtils.obj \
- $O\FSDrives.obj \
- $O\FSFolder.obj \
- $O\FSFolderCopy.obj \
- $O\HelpUtils.obj \
- $O\LangUtils.obj \
- $O\MyLoadMenu.obj \
- $O\NetFolder.obj \
- $O\OpenCallback.obj \
- $O\OptionsDialog.obj \
- $O\Panel.obj \
- $O\PanelCopy.obj \
- $O\PanelCrc.obj \
- $O\PanelDrag.obj \
- $O\PanelFolderChange.obj \
- $O\PanelItemOpen.obj \
- $O\PanelItems.obj \
- $O\PanelKey.obj \
- $O\PanelListNotify.obj \
- $O\PanelMenu.obj \
- $O\PanelOperations.obj \
- $O\PanelSelect.obj \
- $O\PanelSort.obj \
- $O\PanelSplitFile.obj \
- $O\PhysDriveFolder.obj \
- $O\ProgramLocation.obj \
- $O\PropertyName.obj \
- $O\RegistryAssociations.obj \
- $O\RegistryPlugins.obj \
- $O\RegistryUtils.obj \
- $O\RootFolder.obj \
- $O\SplitUtils.obj \
- $O\StringUtils.obj \
- $O\SysIconUtils.obj \
- $O\TextPairs.obj \
- $O\UpdateCallback100.obj \
- $O\ViewSettings.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CRC.obj \
- $O\IntToString.obj \
- $O\Lang.obj \
- $O\ListFileUtils.obj \
- $O\NewHandler.obj \
- $O\Random.obj \
- $O\StdInStream.obj \
- $O\StdOutStream.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\TextConfig.obj \
- $O\UTFConvert.obj \
- $O\Vector.obj \
- $O\Wildcard.obj \
-
-WIN_OBJS = \
- $O\CommonDialog.obj \
- $O\DLL.obj \
- $O\Error.obj \
- $O\FileDevice.obj \
- $O\FileDir.obj \
- $O\FileFind.obj \
- $O\FileIO.obj \
- $O\FileName.obj \
- $O\FileSystem.obj \
- $O\Memory.obj \
- $O\MemoryLock.obj \
- $O\Menu.obj \
- $O\Net.obj \
- $O\PropVariant.obj \
- $O\PropVariantConversions.obj \
- $O\Registry.obj \
- $O\ResourceString.obj \
- $O\Security.obj \
- $O\Shell.obj \
- $O\Synchronization.obj \
- $O\Window.obj \
-
-WIN_CTRL_OBJS = \
- $O\ComboBox.obj \
- $O\Dialog.obj \
- $O\ListView.obj \
- $O\PropertyPage.obj \
- $O\Window2.obj \
-
-7ZIP_COMMON_OBJS = \
- $O\FilePathAutoRename.obj \
- $O\FileStreams.obj \
- $O\StreamObjects.obj \
-
-UI_COMMON_OBJS = \
- $O\ArchiveName.obj \
- $O\CompressCall.obj \
- $O\PropIDUtils.obj \
-
-OBJS = \
- $O\StdAfx.obj \
- $(FM_OBJS)\
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(WIN_CTRL_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(UI_COMMON_OBJS) \
- $O\AboutDialog.obj \
- $O\BenchmarkDialog.obj \
- $O\ComboDialog.obj \
- $O\CopyDialog.obj \
- $O\EditPage.obj \
- $O\LangPage.obj \
- $O\ListViewDialog.obj \
- $O\MessagesDialog.obj \
- $O\OverwriteDialog.obj \
- $O\PasswordDialog.obj \
- $O\PluginsPage.obj \
- $O\ProgressDialog.obj \
- $O\SettingsPage.obj \
- $O\SplitDialog.obj \
- $O\SystemPage.obj \
- $O\resource.res \
-
-!include "../../Build.mak"
-
-$(FM_OBJS): $(*B).cpp
- $(COMPL)
-$(COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../Windows/$(*B).cpp
- $(COMPL)
-$(WIN_CTRL_OBJS): ../../Windows/Control/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../Common/$(*B).cpp
- $(COMPL)
-$(UI_COMMON_OBJS): ../UI/Common/$(*B).cpp
- $(COMPL)
-
-$O\AboutDialog.obj: Resource/AboutDialog/AboutDialog.cpp
- $(COMPL)
-$O\BenchmarkDialog.obj: Resource/BenchmarkDialog/BenchmarkDialog.cpp
- $(COMPL)
-$O\ComboDialog.obj: Resource/ComboDialog/ComboDialog.cpp
- $(COMPL)
-$O\CopyDialog.obj: Resource/CopyDialog/CopyDialog.cpp
- $(COMPL)
-$O\EditPage.obj: Resource/EditPage/EditPage.cpp
- $(COMPL)
-$O\LangPage.obj: Resource/LangPage/LangPage.cpp
- $(COMPL)
-$O\ListViewDialog.obj: Resource/ListViewDialog/ListViewDialog.cpp
- $(COMPL)
-$O\MessagesDialog.obj: Resource/MessagesDialog/MessagesDialog.cpp
- $(COMPL)
-$O\OverwriteDialog.obj: Resource/OverwriteDialog/OverwriteDialog.cpp
- $(COMPL)
-$O\PasswordDialog.obj: Resource/PasswordDialog/PasswordDialog.cpp
- $(COMPL)
-$O\PluginsPage.obj: Resource/PluginsPage/PluginsPage.cpp
- $(COMPL)
-$O\ProgressDialog.obj: Resource/ProgressDialog2/ProgressDialog.cpp
- $(COMPL)
-$O\SettingsPage.obj: Resource/SettingsPage/SettingsPage.cpp
- $(COMPL)
-$O\SplitDialog.obj: Resource/SplitDialog/SplitDialog.cpp
- $(COMPL)
-$O\SystemPage.obj: Resource/SystemPage/SystemPage.cpp
- $(COMPL)
-
-
diff --git a/7zip/FileManager/resource.h b/7zip/FileManager/resource.h
deleted file mode 100755
index 78673475..00000000
--- a/7zip/FileManager/resource.h
+++ /dev/null
@@ -1,150 +0,0 @@
-#define IDI_FAM 101
-#define IDI_FM 101
-#define IDR_MENUBAR1 103
-#define IDM_MENU 103
-#define IDR_ACCELERATOR1 209
-#define IDM_FILE_OPEN 210
-#define IDM_FILE_OPEN_INSIDE 211
-#define IDM_FILE_OPEN_OUTSIDE 212
-#define IDM_FILE_VIEW 220
-#define IDM_FILE_EDIT 221
-#define IDM_RENAME 230
-#define IDM_COPY_TO 231
-#define IDM_MOVE_TO 232
-#define IDM_DELETE 233
-#define IDM_FILE_SPLIT 238
-#define IDM_FILE_COMBINE 239
-#define IDM_FILE_PROPERTIES 240
-#define IDM_FILE_COMMENT 241
-#define IDM_FILE_CRC 242
-#define IDM_CREATE_FOLDER 250
-#define IDM_CREATE_FILE 251
-#define IDM_EDIT_CUT 320
-#define IDM_EDIT_COPY 321
-#define IDM_EDIT_PASTE 322
-#define IDM_SELECT_ALL 330
-#define IDM_DESELECT_ALL 331
-#define IDM_INVERT_SELECTION 332
-#define IDM_SELECT 333
-#define IDM_DESELECT 334
-#define IDM_SELECT_BY_TYPE 335
-#define IDM_DESELECT_BY_TYPE 336
-#define IDM_VIEW_LARGE_ICONS 410
-#define IDM_VIEW_SMALL_ICONS 411
-#define IDM_VIEW_LIST 412
-#define IDM_VIEW_DETAILS 413
-#define IDM_VIEW_ARANGE_BY_NAME 420
-#define IDM_VIEW_ARANGE_BY_TYPE 421
-#define IDM_VIEW_ARANGE_BY_DATE 422
-#define IDM_VIEW_ARANGE_BY_SIZE 423
-#define IDM_VIEW_ARANGE_NO_SORT 424
-#define IDM_OPEN_ROOT_FOLDER 430
-#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_TWO_PANELS 450
-#define IDM_VIEW_TOOLBARS 451
-#define IDM_VIEW_STANDARD_TOOLBAR 460
-#define IDM_VIEW_ARCHIVE_TOOLBAR 461
-#define IDM_VIEW_TOOLBARS_LARGE_BUTTONS 462
-#define IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 463
-#define IDM_OPTIONS 510
-#define IDM_BENCHMARK 511
-#define IDM_HELP_CONTENTS 610
-#define IDM_ABOUT 620
-#define IDS_BOOKMARK 720
-#define IDB_ADD 2002
-#define IDB_EXTRACT 2003
-#define IDB_TEST 2004
-#define IDB_COPY 2010
-#define IDB_MOVE 2011
-#define IDB_DELETE 2012
-#define IDB_INFO 2013
-#define IDB_ADD2 2082
-#define IDB_EXTRACT2 2083
-#define IDB_TEST2 2084
-#define IDB_COPY2 2090
-#define IDB_MOVE2 2091
-#define IDB_DELETE2 2092
-#define IDB_INFO2 2093
-#define IDS_APP_TITLE 2200
-#define IDS_COPY 2201
-#define IDS_MOVE 2202
-#define IDS_COPY_TO 2203
-#define IDS_MOVE_TO 2204
-#define IDS_COPYING 2205
-#define IDS_MOVING 2206
-#define IDS_CANNOT_COPY 2207
-#define IDS_OPERATION_IS_NOT_SUPPORTED 2208
-
-#define IDS_CONFIRM_FILE_DELETE 2210
-#define IDS_CONFIRM_FOLDER_DELETE 2211
-#define IDS_CONFIRM_ITEMS_DELETE 2212
-#define IDS_WANT_TO_DELETE_FILE 2213
-#define IDS_WANT_TO_DELETE_FOLDER 2214
-#define IDS_WANT_TO_DELETE_ITEMS 2215
-#define IDS_DELETING 2216
-#define IDS_ERROR_DELETING 2217
-
-#define IDS_RENAMING 2220
-#define IDS_ERROR_RENAMING 2221
-#define IDS_CONFIRM_FILE_COPY 2222
-#define IDS_WANT_TO_COPY_FILES 2223
-
-
-#define IDS_CREATE_FOLDER 2230
-#define IDS_CREATE_FOLDER_NAME 2231
-#define IDS_CREATE_FOLDER_DEFAULT_NAME 2232
-#define IDS_CREATE_FOLDER_ERROR 2233
-#define IDS_CREATE_FILE 2240
-#define IDS_CREATE_FILE_NAME 2241
-#define IDS_CREATE_FOLDER_DEFAULT_FILE_NAME 2242
-#define IDS_CREATE_FILE_DEFAULT_NAME 2242
-#define IDS_CREATE_FILE_ERROR 2243
-#define IDS_SELECT 2250
-#define IDS_DESELECT 2251
-#define IDS_SELECT_MASK 2252
-#define IDS_FOLDERS_HISTORY 2260
-#define IDS_N_SELECTED_ITEMS 2270
-#define IDS_FILES_COLON 2274
-#define IDS_FOLDERS_COLON 2275
-#define IDS_SIZE_COLON 2276
-
-#define IDS_TOO_MANY_ITEMS 2279
-#define IDS_WANT_UPDATE_MODIFIED_FILE 2280
-#define IDS_CANNOT_UPDATE_FILE 2281
-#define IDS_CANNOT_START_EDITOR 2282
-#define IDS_OPENNING 2283
-#define IDS_COMPUTER 2300
-#define IDS_NETWORK 2301
-#define IDS_ADD 2400
-#define IDS_EXTRACT 2401
-#define IDS_TEST 2402
-#define IDS_BUTTON_COPY 2420
-#define IDS_BUTTON_MOVE 2421
-#define IDS_BUTTON_DELETE 2422
-#define IDS_BUTTON_INFO 2423
-#define IDS_PROPERTY_TOTAL_SIZE 3100
-#define IDS_PROPERTY_FREE_SPACE 3101
-#define IDS_PROPERTY_CLUSTER_SIZE 3102
-#define IDS_PROPERTY_VOLUME_NAME 3103
-#define IDS_PROPERTY_LOCAL_NAME 3200
-#define IDS_PROPERTY_PROVIDER 3201
-#define IDS_OPTIONS 4000
-#define IDS_COMMENT 4001
-#define IDS_COMMENT2 4002
-#define IDS_SYSTEM 4010
-
-#define IDS_SPLITTING 4020
-
-#define IDS_COMBINE 4030
-#define IDS_COMBINE_TO 4031
-#define IDS_COMBINING 4032
-
-#define IDS_CHECKSUM_CALCULATING 4040
-#define IDS_CHECKSUM_INFORMATION 4041
-#define IDS_CHECKSUM_CRC_DATA 4042
-#define IDS_CHECKSUM_CRC_DATA_NAMES 4043
-
-#define IDS_SCANNING 4050
diff --git a/7zip/FileManager/resource.rc b/7zip/FileManager/resource.rc
deleted file mode 100755
index b6e79eb1..00000000
--- a/7zip/FileManager/resource.rc
+++ /dev/null
@@ -1,226 +0,0 @@
-#include "../MyVersionInfo.rc"
-#include "../GuiCommon.rc"
-#include "resource.h"
-
-MY_VERSION_INFO_APP("7-Zip File Manager", "7zFM")
-
-
-IDR_ACCELERATOR1 ACCELERATORS
-BEGIN
- "N", IDM_CREATE_FILE, VIRTKEY, CONTROL, NOINVERT
- VK_F1, IDM_HELP_CONTENTS, VIRTKEY, NOINVERT
- VK_F12, IDM_FOLDERS_HISTORY, VIRTKEY, ALT, NOINVERT
- VK_F7, IDM_CREATE_FOLDER, VIRTKEY, NOINVERT
-END
-
-
-IDM_MENU MENU
-BEGIN
- POPUP "&File"
- BEGIN
- MENUITEM "&Open\tEnter", IDM_FILE_OPEN
- MENUITEM "Open &Inside\tCtrl+PgDn", IDM_FILE_OPEN_INSIDE
- MENUITEM "Open O&utside\tShift+Enter", IDM_FILE_OPEN_OUTSIDE
- MENUITEM "&Edit\tF4", IDM_FILE_EDIT
- MENUITEM SEPARATOR
- MENUITEM "Rena&me\tF2", IDM_RENAME
- MENUITEM "&Copy To...\tF5", IDM_COPY_TO
- MENUITEM "&Move To...\tF6", IDM_MOVE_TO
- MENUITEM "&Delete\tDel", IDM_DELETE
- MENUITEM SEPARATOR
- MENUITEM "&Split file...", IDM_FILE_SPLIT
- MENUITEM "Com&bine files...", IDM_FILE_COMBINE
- MENUITEM SEPARATOR
- MENUITEM "P&roperties\tAlt+Enter", IDM_FILE_PROPERTIES
- MENUITEM "Comme&nt\tCtrl+Z", IDM_FILE_COMMENT
- MENUITEM "Calculate checksum", IDM_FILE_CRC
- MENUITEM SEPARATOR
- MENUITEM "Create Folder\tF7", IDM_CREATE_FOLDER
- MENUITEM "Create File\tCtrl+N", IDM_CREATE_FILE
- MENUITEM SEPARATOR
- MENUITEM "E&xit\tAlt+F4", IDCLOSE
- 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 "Select &All\tShift+[Grey +]", IDM_SELECT_ALL
- MENUITEM "Deselect All\tShift+[Grey -]", IDM_DESELECT_ALL
- MENUITEM "&Invert Selection\tGrey *", IDM_INVERT_SELECTION
- MENUITEM "Select...\tGrey +", IDM_SELECT
- MENUITEM "Deselect...\tGrey -", IDM_DESELECT
- MENUITEM "Select by Type\tAlt+[Grey+]", IDM_SELECT_BY_TYPE
- MENUITEM "Deselect by Type\tAlt+[Grey -]", IDM_DESELECT_BY_TYPE
- END
- POPUP "&View"
- BEGIN
- MENUITEM "Lar&ge Icons\tCtrl+1", IDM_VIEW_LARGE_ICONS
- MENUITEM "S&mall Icons\tCtrl+2", IDM_VIEW_SMALL_ICONS
- MENUITEM "&List\tCtrl+3", IDM_VIEW_LIST
- MENUITEM "&Details\tCtrl+4", IDM_VIEW_DETAILS, CHECKED
- MENUITEM SEPARATOR
- MENUITEM "Name\tCtrl+F3", IDM_VIEW_ARANGE_BY_NAME
- MENUITEM "Type\tCtrl+F4", IDM_VIEW_ARANGE_BY_TYPE
- MENUITEM "Date\tCtrl+F5", IDM_VIEW_ARANGE_BY_DATE
- MENUITEM "Size\tCtrl+F6", IDM_VIEW_ARANGE_BY_SIZE
- MENUITEM "Unsorted\tCtrl+F7", IDM_VIEW_ARANGE_NO_SORT
- MENUITEM SEPARATOR
- MENUITEM "Flat View", IDM_VIEW_FLAT_VIEW
- MENUITEM "&2 Panels\tF9", IDM_VIEW_TWO_PANELS
- POPUP "Toolbars"
- BEGIN
- MENUITEM "Archive Toolbar", IDM_VIEW_ARCHIVE_TOOLBAR
- MENUITEM "Standard Toolbar", IDM_VIEW_STANDARD_TOOLBAR
- MENUITEM SEPARATOR
- MENUITEM "Large Buttons", IDM_VIEW_TOOLBARS_LARGE_BUTTONS
- MENUITEM "Show Buttons Text", IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT
- END
- MENUITEM SEPARATOR
- MENUITEM "Open Root Folder\t\\", IDM_OPEN_ROOT_FOLDER
- MENUITEM "Up One Level\tBackspace", IDM_OPEN_PARENT_FOLDER
- MENUITEM "Folders History...\tAlt+F12", IDM_FOLDERS_HISTORY
- MENUITEM SEPARATOR
- MENUITEM "&Refresh\tCtrl+R", IDM_VIEW_REFRESH
- END
- POPUP "F&avorites"
- BEGIN
- POPUP "&Add folder to Favorites as"
- BEGIN
- MENUITEM SEPARATOR
- END
- MENUITEM SEPARATOR
- END
- POPUP "&Tools"
- BEGIN
- MENUITEM "&Options...", IDM_OPTIONS
- MENUITEM "&Benchmark", IDM_BENCHMARK
- END
- POPUP "&Help"
- BEGIN
- MENUITEM "&Contents...\tF1", IDM_HELP_CONTENTS
- MENUITEM SEPARATOR
- MENUITEM "&About 7-Zip...", IDM_ABOUT
- END
-END
-
-
-IDI_FM ICON "FM.ico"
-
-1 24 MOVEABLE PURE "7zFM.exe.manifest"
-
-IDB_ADD BITMAP "Add.bmp"
-IDB_EXTRACT BITMAP "Extract.bmp"
-IDB_TEST BITMAP "Test.bmp"
-IDB_COPY BITMAP "Copy.bmp"
-IDB_MOVE BITMAP "Move.bmp"
-IDB_DELETE BITMAP "Delete.bmp"
-IDB_INFO BITMAP "Info.bmp"
-IDB_ADD2 BITMAP "Add2.bmp"
-IDB_EXTRACT2 BITMAP "Extract2.bmp"
-IDB_TEST2 BITMAP "Test2.bmp"
-IDB_COPY2 BITMAP "Copy2.bmp"
-IDB_MOVE2 BITMAP "Move2.bmp"
-IDB_DELETE2 BITMAP "Delete2.bmp"
-IDB_INFO2 BITMAP "Info2.bmp"
-
-
-STRINGTABLE
-BEGIN
- IDS_APP_TITLE "7-Zip File Manager"
- IDS_COPY "Copy"
- IDS_MOVE "Move"
- IDS_COPY_TO "Copy to:"
- IDS_MOVE_TO "Move to:"
- IDS_COPYING "Copying..."
- IDS_MOVING "Moving..."
- IDS_CANNOT_COPY "You cannot move or copy items for such folders."
- IDS_SPLITTING "Splitting..."
- IDS_COMBINE "Combine Files"
- IDS_COMBINE_TO "&Combine to:"
- IDS_COMBINING "Combining..."
- IDS_CHECKSUM_CALCULATING "Checksum calculating..."
- IDS_CHECKSUM_INFORMATION "Checksum information"
- IDS_CHECKSUM_CRC_DATA "CRC checksum for data:"
- IDS_CHECKSUM_CRC_DATA_NAMES "CRC checksum for data and names:"
-
- IDS_SCANNING "Scanning..."
-
- IDS_OPERATION_IS_NOT_SUPPORTED "Operation is not supported."
-
- IDS_CONFIRM_FILE_DELETE "Confirm File Delete"
- IDS_CONFIRM_FOLDER_DELETE "Confirm Folder Delete"
- IDS_CONFIRM_ITEMS_DELETE "Confirm Multiple File Delete"
- IDS_WANT_TO_DELETE_FILE "Are you sure you want to delete '{0}'?"
- IDS_WANT_TO_DELETE_FOLDER "Are you sure you want to delete the folder '{0}' and all its contents?"
- 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_RENAMING "Renaming..."
- IDS_ERROR_RENAMING "Error Renaming File or Folder"
- IDS_CONFIRM_FILE_COPY "Confirm File Copy"
- IDS_WANT_TO_COPY_FILES "Are you sure you want to copy files to archive"
-
- IDS_CREATE_FOLDER "Create Folder"
- IDS_CREATE_FOLDER_NAME "Folder name:"
- IDS_CREATE_FOLDER_DEFAULT_NAME "New Folder"
- IDS_CREATE_FOLDER_ERROR "Error Creating Folder"
- IDS_CREATE_FILE "Create File"
- IDS_CREATE_FILE_NAME "File Name:"
- IDS_CREATE_FILE_DEFAULT_NAME "New File"
- IDS_CREATE_FILE_ERROR "Error Creating File"
- IDS_SELECT "Select"
- IDS_DESELECT "Deselect"
- IDS_SELECT_MASK "Mask:"
- IDS_FOLDERS_HISTORY "Folders History"
- IDS_N_SELECTED_ITEMS "{0} object(s) selected"
- IDS_FILES_COLON "Files:"
- IDS_FOLDERS_COLON "Folders:"
- IDS_SIZE_COLON "Size:"
-
- IDS_PROPERTY_TOTAL_SIZE "Total Size"
- IDS_PROPERTY_FREE_SPACE "Free Space"
- IDS_PROPERTY_CLUSTER_SIZE "Cluster Size"
- IDS_PROPERTY_VOLUME_NAME "Label"
- IDS_PROPERTY_LOCAL_NAME "Local Name"
- IDS_PROPERTY_PROVIDER "Provider"
- IDS_OPTIONS "Options"
- IDS_COMMENT "Comment"
- IDS_COMMENT2 "&Comment:"
- IDS_SYSTEM "System"
- IDS_TOO_MANY_ITEMS "Too many items"
- IDS_WANT_UPDATE_MODIFIED_FILE "File '{0}' was modified.\nDo you want to update it in the archive?"
- IDS_CANNOT_UPDATE_FILE "Can not update file\n'{0}'"
- IDS_CANNOT_START_EDITOR "Cannot start editor."
- IDS_OPENNING "Opening..."
- IDS_ADD "Add"
- IDS_EXTRACT "Extract"
- IDS_TEST "Test"
- IDS_BUTTON_COPY "Copy"
- IDS_BUTTON_MOVE "Move"
- IDS_BUTTON_DELETE "Delete"
- IDS_BUTTON_INFO "Info"
- IDS_BOOKMARK "Bookmark"
- IDS_COMPUTER "Computer"
- IDS_NETWORK "Network"
-END
-
-
-#include "Resource/ComboDialog/resource.rc"
-#include "Resource/CopyDialog/resource.rc"
-#include "Resource/ListViewDialog/resource.rc"
-#include "Resource/PropertyName/resource.rc"
-#include "Resource/MessagesDialog/resource.rc"
-#include "Resource/OverwriteDialog/resource.rc"
-#include "Resource/PasswordDialog/resource.rc"
-#include "Resource/SplitDialog/resource.rc"
-#include "Resource/ProgressDialog2/resource.rc"
-#include "Resource/BenchmarkDialog/resource.rc"
-#include "Resource/AboutDialog/resource.rc"
-#include "Resource/LangPage/resource.rc"
-#include "Resource/PluginsPage/resource.rc"
-#include "Resource/SystemPage/resource.rc"
-#include "Resource/EditPage/resource.rc"
-#include "Resource/SettingsPage/resource.rc"
-#include "../UI/Resource/Extract/resource.rc"
diff --git a/7zip/MyVersion.h b/7zip/MyVersion.h
deleted file mode 100755
index dd539afb..00000000
--- a/7zip/MyVersion.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#define MY_VER_MAJOR 4
-#define MY_VER_MINOR 43
-#define MY_VER_BUILD 7
-#define MY_VERSION "4.43 beta"
-#define MY_7ZIP_VERSION "7-Zip 4.43"
-#define MY_DATE "2006-09-15"
-#define MY_COPYRIGHT "Copyright (c) 1999-2006 Igor Pavlov"
-#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE
diff --git a/7zip/UI/Agent/Agent.cpp b/7zip/UI/Agent/Agent.cpp
deleted file mode 100755
index b47e7ec5..00000000
--- a/7zip/UI/Agent/Agent.cpp
+++ /dev/null
@@ -1,572 +0,0 @@
-// Agent.cpp
-
-#include "StdAfx.h"
-
-#include "Common/StringConvert.h"
-#include "Common/ComTry.h"
-#include "Windows/Defs.h"
-#include "Windows/PropVariant.h"
-#include "Windows/FileFind.h"
-
-#include "../Common/DefaultName.h"
-#include "../Common/ArchiveExtractCallback.h"
-
-#include "Agent.h"
-
-#ifdef FORMAT_7Z
-#include "../../Archive/7z/7zHandler.h"
-#endif
-
-using namespace NWindows;
-
-STDMETHODIMP CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder)
-{
- *agentFolder = this;
- return S_OK;
-}
-
-void CAgentFolder::LoadFolder(CProxyFolder *folder)
-{
- int i;
- CProxyItem item;
- item.Folder = folder;
- for (i = 0; i < folder->Folders.Size(); i++)
- {
- item.Index = i;
- _items.Add(item);
- LoadFolder(&folder->Folders[i]);
- }
- int start = folder->Folders.Size();
- for (i = 0; i < folder->Files.Size(); i++)
- {
- item.Index = start + i;
- _items.Add(item);
- }
-}
-
-
-STDMETHODIMP CAgentFolder::LoadItems()
-{
- _items.Clear();
- if (_flatMode)
- LoadFolder(_proxyFolderItem);
- return S_OK;
-}
-
-STDMETHODIMP CAgentFolder::GetNumberOfItems(UINT32 *numItems)
-{
- if (_flatMode)
- *numItems = _items.Size();
- else
- *numItems = _proxyFolderItem->Folders.Size() +_proxyFolderItem->Files.Size();
- return S_OK;
-}
-
-/*
-STDMETHODIMP CAgentFolder::GetNumberOfSubFolders(UINT32 *aNumSubFolders)
-{
- *aNumSubFolders = _proxyFolderItem->Folders.Size();
- return S_OK;
-}
-*/
-
-UString CAgentFolder::GetName(UInt32 index) const
-{
- UInt32 realIndex;
- const CProxyFolder *folder;
- if (_flatMode)
- {
- const CProxyItem &item = _items[index];
- folder = item.Folder;
- realIndex = item.Index;
- }
- else
- {
- folder = _proxyFolderItem;
- realIndex = index;
- }
-
- if (realIndex < (UINT32)folder->Folders.Size())
- return folder->Folders[realIndex].Name;
- return folder->Files[realIndex - folder->Folders.Size()].Name;
-}
-
-UString CAgentFolder::GetPrefix(UInt32 index) const
-{
- if (!_flatMode)
- return UString();
- const CProxyItem &item = _items[index];
- const CProxyFolder *folder = item.Folder;
- UString path;
- while(folder != _proxyFolderItem)
- {
- path = folder->Name + UString(L"\\") + path;
- folder = folder->Parent;
- }
- return path;
-}
-
-UString CAgentFolder::GetFullPathPrefixPlusPrefix(UInt32 index) const
-{
- return _proxyFolderItem->GetFullPathPrefix() + GetPrefix(index);
-}
-
-void CAgentFolder::GetPrefixIfAny(UInt32 index, NCOM::CPropVariant &propVariant) const
-{
- if (!_flatMode)
- return;
- propVariant = GetPrefix(index);
-}
-
-
-STDMETHODIMP CAgentFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
-{
- NCOM::CPropVariant propVariant;
- const CProxyFolder *folder;
- UInt32 realIndex;
- if (_flatMode)
- {
- const CProxyItem &item = _items[itemIndex];
- folder = item.Folder;
- realIndex = item.Index;
- }
- else
- {
- folder = _proxyFolderItem;
- realIndex = itemIndex;
- }
-
- if (realIndex < (UINT32)folder->Folders.Size())
- {
- const CProxyFolder &item = folder->Folders[realIndex];
- switch(propID)
- {
- case kpidIsFolder:
- propVariant = true;
- break;
- case kpidName:
- propVariant = item.Name;
- break;
- case kpidPrefix:
- GetPrefixIfAny(itemIndex, propVariant);
- break;
- default:
- if (item.IsLeaf)
- return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
- }
- }
- else
- {
- realIndex -= folder->Folders.Size();
- const CProxyFile &item = folder->Files[realIndex];
- switch(propID)
- {
- case kpidIsFolder:
- propVariant = false;
- break;
- case kpidName:
- propVariant = item.Name;
- break;
- case kpidPrefix:
- GetPrefixIfAny(itemIndex, propVariant);
- break;
- default:
- return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
- }
- }
- propVariant.Detach(value);
- return S_OK;
-}
-
-HRESULT CAgentFolder::BindToFolder(CProxyFolder *folder, IFolderFolder **resultFolder)
-{
- CMyComPtr<IFolderFolder> parentFolder;
- if (folder->Parent != _proxyFolderItem)
- {
- RINOK(BindToFolder(folder->Parent, &parentFolder));
- }
- else
- parentFolder = this;
- CAgentFolder *folderSpec = new CAgentFolder;
- CMyComPtr<IFolderFolder> agentFolder = folderSpec;
- folderSpec->Init(_proxyArchive, folder, parentFolder, _agentSpec);
- *resultFolder = agentFolder.Detach();
- return S_OK;
-}
-
-STDMETHODIMP CAgentFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
-{
- COM_TRY_BEGIN
-
- CProxyFolder *folder;
- UInt32 realIndex;
- if (_flatMode)
- {
- const CProxyItem &item = _items[index];
- folder = item.Folder;
- realIndex = item.Index;
- }
- else
- {
- folder = _proxyFolderItem;
- realIndex = index;
- }
- if (realIndex >= (UINT32)folder->Folders.Size())
- return E_INVALIDARG;
- return BindToFolder(&folder->Folders[realIndex], resultFolder);
- COM_TRY_END
-}
-
-STDMETHODIMP CAgentFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
-{
- COM_TRY_BEGIN
- int index = _proxyFolderItem->FindDirSubItemIndex(name);
- if (index < 0)
- return E_INVALIDARG;
- return BindToFolder(index, resultFolder);
- COM_TRY_END
-}
-
-STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
-{
- COM_TRY_BEGIN
- CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
- *resultFolder = parentFolder.Detach();
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CAgentFolder::GetName(BSTR *name)
-{
- CMyComBSTR temp = _proxyFolderItem->Name;
- *name = temp.Detach();
- return S_OK;
-}
-
-
-#ifdef NEW_FOLDER_INTERFACE
-
-struct CArchiveItemPropertyTemp
-{
- UString Name;
- PROPID ID;
- VARTYPE Type;
-};
-
-STDMETHODIMP CAgentFolder::GetNumberOfProperties(UINT32 *numProperties)
-{
- COM_TRY_BEGIN
- RINOK(_agentSpec->GetArchive()->GetNumberOfProperties(numProperties));
- if (_flatMode)
- (*numProperties)++;
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CAgentFolder::GetPropertyInfo(UINT32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- COM_TRY_BEGIN
- UINT32 numProperties;
- _agentSpec->GetArchive()->GetNumberOfProperties(&numProperties);
- if (index < numProperties)
- {
- RINOK(_agentSpec->GetArchive()->GetPropertyInfo(index, name, propID, varType));
- if (*propID == kpidPath)
- *propID = kpidName;
- }
- else
- {
- *name = NULL;
- *propID = kpidPrefix;
- *varType = VT_BSTR;
- }
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CAgentFolder::GetTypeID(BSTR *name)
-{
- COM_TRY_BEGIN
- UString temp = UString(L"7-Zip.") + _agentSpec->ArchiveType;
- CMyComBSTR bstrTemp = temp;
- *name = bstrTemp.Detach();
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CAgentFolder::GetPath(BSTR *path)
-{
- COM_TRY_BEGIN
- UStringVector pathParts;
- pathParts.Clear();
- CMyComPtr<IFolderFolder> currentFolder = this;
- for (;;)
- {
- CMyComPtr<IFolderFolder> newFolder;
- currentFolder->BindToParentFolder(&newFolder);
- if (newFolder == NULL)
- break;
- CMyComBSTR aName;
- currentFolder->GetName(&aName);
- pathParts.Insert(0, (const wchar_t *)aName);
- currentFolder = newFolder;
- }
-
- UString prefix;
- for(int i = 0; i < pathParts.Size(); i++)
- {
- prefix += pathParts[i];
- prefix += L'\\';
- }
-
- CMyComBSTR tempPath = prefix;
- *path = tempPath.Detach();
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CAgentFolder::SetFlatMode(Int32 flatMode)
-{
- _flatMode = IntToBool(flatMode);
- return S_OK;
-}
-
-#endif
-
-void CAgentFolder::GetRealIndices(const UINT32 *indices, UINT32 numItems, CUIntVector &realIndices) const
-{
- if (!_flatMode)
- {
- _proxyFolderItem->GetRealIndices(indices, numItems, realIndices);
- return;
- }
- realIndices.Clear();
- for(UINT32 i = 0; i < numItems; i++)
- {
- const CProxyItem &item = _items[indices[i]];
- const CProxyFolder *folder = item.Folder;
- UInt32 realIndex = item.Index;
- if (realIndex < (UINT32)folder->Folders.Size())
- continue;
- realIndices.Add(folder->Files[realIndex - folder->Folders.Size()].Index);
- }
- realIndices.Sort();
-}
-
-STDMETHODIMP CAgentFolder::Extract(const UINT32 *indices,
- UINT32 numItems,
- NExtract::NPathMode::EEnum pathMode,
- NExtract::NOverwriteMode::EEnum overwriteMode,
- const wchar_t *path,
- INT32 testMode,
- IFolderArchiveExtractCallback *extractCallback2)
-{
- COM_TRY_BEGIN
- CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
- CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
- UStringVector pathParts;
- CProxyFolder *currentProxyFolder = _proxyFolderItem;
- while (currentProxyFolder->Parent)
- {
- pathParts.Insert(0, currentProxyFolder->Name);
- currentProxyFolder = currentProxyFolder->Parent;
- }
-
- /*
- if (_flatMode)
- pathMode = NExtract::NPathMode::kNoPathnames;
- */
-
- extractCallbackSpec->Init(_agentSpec->GetArchive(),
- extractCallback2,
- false,
- path,
- pathMode,
- overwriteMode,
- pathParts,
- _agentSpec->DefaultName,
- _agentSpec->DefaultTime,
- _agentSpec->DefaultAttributes
- // ,_agentSpec->_srcDirectoryPrefix
- );
- CUIntVector realIndices;
- GetRealIndices(indices, numItems, realIndices);
- return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
- realIndices.Size(), testMode, extractCallback);
- COM_TRY_END
-}
-
-/////////////////////////////////////////
-// CAgent
-
-CAgent::CAgent():
- _proxyArchive(NULL)
-{
-}
-
-CAgent::~CAgent()
-{
- if (_proxyArchive != NULL)
- delete _proxyArchive;
-}
-
-STDMETHODIMP CAgent::Open(
- const wchar_t *filePath,
- BSTR *archiveType,
- // CLSID *clsIDResult,
- IArchiveOpenCallback *openArchiveCallback)
-{
- COM_TRY_BEGIN
- _archiveFilePath = filePath;
- NFile::NFind::CFileInfoW fileInfo;
- if (!NFile::NFind::FindFile(_archiveFilePath, fileInfo))
- return ::GetLastError();
- if (fileInfo.IsDirectory())
- return E_FAIL;
- CArchiverInfo archiverInfo0, archiverInfo1;
- HRESULT res = OpenArchive(_archiveFilePath, _archiveLink, openArchiveCallback);
- // _archive = _archiveLink.GetArchive();
- DefaultName = _archiveLink.GetDefaultItemName();
- const CArchiverInfo &ai = _archiveLink.GetArchiverInfo();
-
- RINOK(res);
- DefaultTime = fileInfo.LastWriteTime;
- DefaultAttributes = fileInfo.Attributes;
- ArchiveType = ai.Name;
- if (archiveType != 0)
- {
- CMyComBSTR name = ArchiveType;
- *archiveType = name.Detach();
- }
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CAgent::ReOpen(
- // const wchar_t *filePath,
- IArchiveOpenCallback * /* openArchiveCallback */)
-{
- COM_TRY_BEGIN
- if (_proxyArchive != NULL)
- {
- delete _proxyArchive;
- _proxyArchive = NULL;
- }
- RINOK(ReOpenArchive(_archiveLink, _archiveFilePath));
- return ReadItems();
- COM_TRY_END
-}
-
-STDMETHODIMP CAgent::Close()
-{
- COM_TRY_BEGIN
- RINOK(_archiveLink.Close());
- if (_archiveLink.GetNumLevels() > 1)
- {
- // return S_OK;
- }
- // _archive->Close();
- return S_OK;
- COM_TRY_END
-}
-
-/*
-STDMETHODIMP CAgent::EnumProperties(IEnumSTATPROPSTG **EnumProperties)
-{
- return _archive->EnumProperties(EnumProperties);
-}
-*/
-
-HRESULT CAgent::ReadItems()
-{
- if (_proxyArchive != NULL)
- return S_OK;
- _proxyArchive = new CProxyArchive();
- return _proxyArchive->Load(GetArchive(),
- DefaultName,
- // _defaultTime,
- // _defaultAttributes,
- NULL);
-}
-
-STDMETHODIMP CAgent::BindToRootFolder(IFolderFolder **resultFolder)
-{
- COM_TRY_BEGIN
- RINOK(ReadItems());
- CAgentFolder *folderSpec = new CAgentFolder;
- CMyComPtr<IFolderFolder> rootFolder = folderSpec;
- folderSpec->Init(_proxyArchive, &_proxyArchive->RootFolder, NULL, this);
- *resultFolder = rootFolder.Detach();
- return S_OK;
- COM_TRY_END
-}
-
-
-STDMETHODIMP CAgent::Extract(
- NExtract::NPathMode::EEnum pathMode,
- NExtract::NOverwriteMode::EEnum overwriteMode,
- const wchar_t *path,
- INT32 testMode,
- IFolderArchiveExtractCallback *extractCallback2)
-{
- COM_TRY_BEGIN
- CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
- CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
- extractCallbackSpec->Init(GetArchive(),
- extractCallback2,
- false,
- path,
- pathMode,
- overwriteMode,
- UStringVector(),
- DefaultName,
- DefaultTime,
- DefaultAttributes
- // ,_srcDirectoryPrefix
- );
- return GetArchive()->Extract(0, (UInt32)(Int32)-1, testMode, extractCallback);
- COM_TRY_END
-}
-
-STDMETHODIMP CAgent::GetNumberOfProperties(UINT32 *numProperties)
-{
- COM_TRY_BEGIN
- return GetArchive()->GetNumberOfProperties(numProperties);
- COM_TRY_END
-}
-
-STDMETHODIMP CAgent::GetPropertyInfo(UINT32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- COM_TRY_BEGIN
- RINOK(GetArchive()->GetPropertyInfo(index, name, propID, varType));
- if (*propID == kpidPath)
- *propID = kpidName;
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CAgent::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
-{
- COM_TRY_BEGIN
- return GetArchive()->GetArchiveProperty(propID, value);
- COM_TRY_END
-}
-
-STDMETHODIMP CAgent::GetNumberOfArchiveProperties(UINT32 *numProperties)
-{
- COM_TRY_BEGIN
- return GetArchive()->GetNumberOfArchiveProperties(numProperties);
- COM_TRY_END
-}
-
-STDMETHODIMP CAgent::GetArchivePropertyInfo(UINT32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- COM_TRY_BEGIN
- return GetArchive()->GetArchivePropertyInfo(index,
- name, propID, varType);
- COM_TRY_END
-}
-
diff --git a/7zip/UI/Agent/AgentProxy.cpp b/7zip/UI/Agent/AgentProxy.cpp
deleted file mode 100755
index 757231c6..00000000
--- a/7zip/UI/Agent/AgentProxy.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-// AgentProxy.cpp
-
-#include "StdAfx.h"
-
-#include "AgentProxy.h"
-
-#include "Common/MyCom.h"
-#include "Windows/PropVariant.h"
-#include "Windows/Defs.h"
-#include "../Common/OpenArchive.h"
-
-using namespace NWindows;
-
-int CProxyFolder::FindDirSubItemIndex(const UString &name, int &insertPos) const
-{
- int left = 0, right = Folders.Size();
- for (;;)
- {
- if (left == right)
- {
- insertPos = left;
- return -1;
- }
- int mid = (left + right) / 2;
- int compare = name.CompareNoCase(Folders[mid].Name);
- if (compare == 0)
- return mid;
- if (compare < 0)
- right = mid;
- else
- left = mid + 1;
- }
-}
-
-int CProxyFolder::FindDirSubItemIndex(const UString &name) const
-{
- int insertPos;
- return FindDirSubItemIndex(name, insertPos);
-}
-
-void CProxyFolder::AddFileSubItem(UINT32 index, const UString &name)
-{
- Files.Add(CProxyFile());
- Files.Back().Name = name;
- Files.Back().Index = index;
-}
-
-CProxyFolder* CProxyFolder::AddDirSubItem(UINT32 index, bool leaf,
- const UString &name)
-{
- int insertPos;
- int folderIndex = FindDirSubItemIndex(name, insertPos);
- if (folderIndex >= 0)
- {
- CProxyFolder *item = &Folders[folderIndex];
- if(leaf)
- {
- item->Index = index;
- item->IsLeaf = true;
- }
- return item;
- }
- Folders.Insert(insertPos, CProxyFolder());
- CProxyFolder *item = &Folders[insertPos];
- item->Name = name;
- item->Index = index;
- item->Parent = this;
- item->IsLeaf = leaf;
- return item;
-}
-
-void CProxyFolder::Clear()
-{
- Folders.Clear();
- Files.Clear();
-}
-
-UString CProxyFolder::GetFullPathPrefix() const
-{
- UString result;
- const CProxyFolder *current = this;
- while (current->Parent != NULL)
- {
- result = current->Name + UString(L'\\') + result;
- current = current->Parent;
- }
- return result;
-}
-
-UString CProxyFolder::GetItemName(UINT32 index) const
-{
- if (index < (UINT32)Folders.Size())
- return Folders[index].Name;
- return Files[index - Folders.Size()].Name;
-}
-
-void CProxyFolder::AddRealIndices(CUIntVector &realIndices) const
-{
- if (IsLeaf)
- realIndices.Add(Index);
- int i;
- for(i = 0; i < Folders.Size(); i++)
- Folders[i].AddRealIndices(realIndices);
- for(i = 0; i < Files.Size(); i++)
- realIndices.Add(Files[i].Index);
-}
-
-void CProxyFolder::GetRealIndices(const UINT32 *indices,
- UINT32 numItems, CUIntVector &realIndices) const
-{
- realIndices.Clear();
- for(UINT32 i = 0; i < numItems; i++)
- {
- int index = indices[i];
- int numDirItems = Folders.Size();
- if (index < numDirItems)
- Folders[index].AddRealIndices(realIndices);
- else
- realIndices.Add(Files[index - numDirItems].Index);
- }
- realIndices.Sort();
-}
-
-///////////////////////////////////////////////
-// CProxyArchive
-
-HRESULT CProxyArchive::Reload(IInArchive *archive, IProgress *progress)
-{
- RootFolder.Clear();
- return ReadObjects(archive, progress);
-}
-
-HRESULT CProxyArchive::Load(IInArchive *archive,
- const UString &defaultName,
- // const FILETIME &defaultTime,
- // UINT32 defaultAttributes,
- IProgress *progress)
-{
- DefaultName = defaultName;
- // DefaultTime = defaultTime;
- // DefaultAttributes = defaultAttributes;
- return Reload(archive, progress);
-}
-
-
-HRESULT CProxyArchive::ReadObjects(IInArchive *archiveHandler, IProgress *progress)
-{
- UINT32 numItems;
- RINOK(archiveHandler->GetNumberOfItems(&numItems));
- if (progress != NULL)
- {
- UINT64 totalItems = numItems;
- RINOK(progress->SetTotal(totalItems));
- }
- for(UINT32 i = 0; i < numItems; i++)
- {
- if (progress != NULL)
- {
- UINT64 currentItemIndex = i;
- RINOK(progress->SetCompleted(&currentItemIndex));
- }
- NCOM::CPropVariant propVariantPath;
- RINOK(archiveHandler->GetProperty(i, kpidPath, &propVariantPath));
- CProxyFolder *currentItem = &RootFolder;
- UString fileName;
- if(propVariantPath.vt == VT_EMPTY)
- fileName = DefaultName;
- else
- {
- if(propVariantPath.vt != VT_BSTR)
- return E_FAIL;
- UString filePath = propVariantPath.bstrVal;
-
- int len = filePath.Length();
- for (int i = 0; i < len; i++)
- {
- wchar_t c = filePath[i];
- if (c == '\\' || c == '/')
- {
- currentItem = currentItem->AddDirSubItem((UInt32)(Int32)-1, false, fileName);
- fileName.Empty();
- }
- else
- fileName += c;
- }
- }
-
- NCOM::CPropVariant propVariantIsFolder;
- bool isFolder;
- RINOK(IsArchiveItemFolder(archiveHandler, i, isFolder));
- if(isFolder)
- currentItem->AddDirSubItem(i, true, fileName);
- else
- currentItem->AddFileSubItem(i, fileName);
- }
- return S_OK;
-}
-
diff --git a/7zip/UI/Common/ArchiveCommandLine.cpp b/7zip/UI/Common/ArchiveCommandLine.cpp
deleted file mode 100755
index f56f982c..00000000
--- a/7zip/UI/Common/ArchiveCommandLine.cpp
+++ /dev/null
@@ -1,984 +0,0 @@
-// ArchiveCommandLine.cpp
-
-#include "StdAfx.h"
-
-#include <io.h>
-#include <stdio.h>
-
-#include "Common/ListFileUtils.h"
-#include "Common/StringConvert.h"
-#include "Common/StringToInt.h"
-
-#include "Windows/FileName.h"
-#include "Windows/FileDir.h"
-#ifdef _WIN32
-#include "Windows/FileMapping.h"
-#include "Windows/Synchronization.h"
-#endif
-
-#include "ArchiveCommandLine.h"
-#include "UpdateAction.h"
-#include "Update.h"
-#include "ArchiverInfo.h"
-#include "SortUtils.h"
-#include "EnumDirItems.h"
-
-using namespace NCommandLineParser;
-using namespace NWindows;
-using namespace NFile;
-
-static const int kNumSwitches = 28;
-
-namespace NKey {
-enum Enum
-{
- kHelp1 = 0,
- kHelp2,
- kHelp3,
- kDisableHeaders,
- kDisablePercents,
- kArchiveType,
- kYes,
- kPassword,
- kProperty,
- kOutputDir,
- kWorkingDir,
- kInclude,
- kExclude,
- kArInclude,
- kArExclude,
- kNoArName,
- kUpdate,
- kVolume,
- kRecursed,
- kSfx,
- kStdIn,
- kStdOut,
- kOverwrite,
- kEmail,
- kShowDialog,
- kLargePages,
- kCharSet,
- kTechMode
-};
-
-}
-
-
-static const wchar_t kRecursedIDChar = 'R';
-static const wchar_t *kRecursedPostCharSet = L"0-";
-
-static const wchar_t *kDefaultArchiveType = L"7z";
-static const wchar_t *kSFXExtension =
- #ifdef _WIN32
- L"exe";
- #else
- L"";
- #endif
-
-namespace NRecursedPostCharIndex {
- enum EEnum
- {
- kWildCardRecursionOnly = 0,
- kNoRecursion = 1
- };
-}
-
-static const char kImmediateNameID = '!';
-static const char kMapNameID = '#';
-static const char kFileListID = '@';
-
-static const char kSomeCludePostStringMinSize = 2; // at least <@|!><N>ame must be
-static const char kSomeCludeAfterRecursedPostStringMinSize = 2; // at least <@|!><N>ame must be
-
-static const wchar_t *kOverwritePostCharSet = L"asut";
-
-NExtract::NOverwriteMode::EEnum k_OverwriteModes[] =
-{
- NExtract::NOverwriteMode::kWithoutPrompt,
- NExtract::NOverwriteMode::kSkipExisting,
- NExtract::NOverwriteMode::kAutoRename,
- NExtract::NOverwriteMode::kAutoRenameExisting
-};
-
-static const CSwitchForm kSwitchForms[kNumSwitches] =
- {
- { L"?", NSwitchType::kSimple, false },
- { L"H", NSwitchType::kSimple, false },
- { L"-HELP", NSwitchType::kSimple, false },
- { L"BA", NSwitchType::kSimple, false },
- { L"BD", NSwitchType::kSimple, false },
- { L"T", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"Y", NSwitchType::kSimple, false },
- { L"P", NSwitchType::kUnLimitedPostString, false, 0 },
- { L"M", NSwitchType::kUnLimitedPostString, true, 1 },
- { L"O", NSwitchType::kUnLimitedPostString, false, 1 },
- { L"W", NSwitchType::kUnLimitedPostString, false, 0 },
- { L"I", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
- { L"X", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
- { L"AI", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
- { L"AX", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
- { L"AN", NSwitchType::kSimple, false },
- { L"U", NSwitchType::kUnLimitedPostString, true, 1},
- { L"V", NSwitchType::kUnLimitedPostString, true, 1},
- { L"R", NSwitchType::kPostChar, false, 0, 0, kRecursedPostCharSet },
- { L"SFX", NSwitchType::kUnLimitedPostString, false, 0 },
- { L"SI", NSwitchType::kUnLimitedPostString, false, 0 },
- { L"SO", NSwitchType::kSimple, false, 0 },
- { L"AO", NSwitchType::kPostChar, false, 1, 1, kOverwritePostCharSet},
- { L"SEML", NSwitchType::kUnLimitedPostString, false, 0},
- { L"AD", NSwitchType::kSimple, false },
- { L"SLP", NSwitchType::kUnLimitedPostString, false, 0},
- { L"SCS", NSwitchType::kUnLimitedPostString, false, 0},
- { L"SLT", NSwitchType::kSimple, false }
- };
-
-static const int kNumCommandForms = 7;
-
-static const CCommandForm g_CommandForms[kNumCommandForms] =
-{
- { L"A", false },
- { L"U", false },
- { L"D", false },
- { L"T", false },
- { L"E", false },
- { L"X", false },
- { L"L", false }
-};
-
-static const int kMaxCmdLineSize = 1000;
-static const wchar_t *kUniversalWildcard = L"*";
-static const int kMinNonSwitchWords = 1;
-static const int kCommandIndex = 0;
-
-// ---------------------------
-// exception messages
-
-static const char *kUserErrorMessage = "Incorrect command line";
-static const char *kIncorrectListFile = "Incorrect wildcard in listfile";
-static const char *kIncorrectWildCardInListFile = "Incorrect wildcard in listfile";
-static const char *kIncorrectWildCardInCommandLine = "Incorrect wildcard in command line";
-static const char *kTerminalOutError = "I won't write compressed data to a terminal";
-
-static void ThrowException(const char *errorMessage)
-{
- throw CArchiveCommandLineException(errorMessage);
-};
-
-static void ThrowUserErrorException()
-{
- ThrowException(kUserErrorMessage);
-};
-
-// ---------------------------
-
-bool CArchiveCommand::IsFromExtractGroup() const
-{
- switch(CommandType)
- {
- case NCommandType::kTest:
- case NCommandType::kExtract:
- case NCommandType::kFullExtract:
- return true;
- default:
- return false;
- }
-}
-
-NExtract::NPathMode::EEnum CArchiveCommand::GetPathMode() const
-{
- switch(CommandType)
- {
- case NCommandType::kTest:
- case NCommandType::kFullExtract:
- return NExtract::NPathMode::kFullPathnames;
- default:
- return NExtract::NPathMode::kNoPathnames;
- }
-}
-
-bool CArchiveCommand::IsFromUpdateGroup() const
-{
- return (CommandType == NCommandType::kAdd ||
- CommandType == NCommandType::kUpdate ||
- CommandType == NCommandType::kDelete);
-}
-
-static NRecursedType::EEnum GetRecursedTypeFromIndex(int index)
-{
- switch (index)
- {
- case NRecursedPostCharIndex::kWildCardRecursionOnly:
- return NRecursedType::kWildCardOnlyRecursed;
- case NRecursedPostCharIndex::kNoRecursion:
- return NRecursedType::kNonRecursed;
- default:
- return NRecursedType::kRecursed;
- }
-}
-
-static bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &command)
-{
- UString commandStringUpper = commandString;
- commandStringUpper.MakeUpper();
- UString postString;
- int commandIndex = ParseCommand(kNumCommandForms, g_CommandForms, commandStringUpper,
- postString) ;
- if (commandIndex < 0)
- return false;
- command.CommandType = (NCommandType::EEnum)commandIndex;
- return true;
-}
-
-// ------------------------------------------------------------------
-// filenames functions
-
-static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
- const UString &name, bool include, NRecursedType::EEnum type)
-{
- bool isWildCard = DoesNameContainWildCard(name);
- bool recursed = false;
-
- switch (type)
- {
- case NRecursedType::kWildCardOnlyRecursed:
- recursed = isWildCard;
- break;
- case NRecursedType::kRecursed:
- recursed = true;
- break;
- case NRecursedType::kNonRecursed:
- recursed = false;
- break;
- }
- wildcardCensor.AddItem(include, name, recursed);
- return true;
-}
-
-static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-
-static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
- LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
-{
- UStringVector names;
- if (!ReadNamesFromListFile(GetSystemString(fileName, GetCurrentCodePage()), names, codePage))
- throw kIncorrectListFile;
- for (int i = 0; i < names.Size(); i++)
- if (!AddNameToCensor(wildcardCensor, names[i], include, type))
- throw kIncorrectWildCardInListFile;
-}
-
-static void AddCommandLineWildCardToCensr(NWildcard::CCensor &wildcardCensor,
- const UString &name, bool include, NRecursedType::EEnum recursedType)
-{
- if (!AddNameToCensor(wildcardCensor, name, include, recursedType))
- throw kIncorrectWildCardInCommandLine;
-}
-
-static void AddToCensorFromNonSwitchesStrings(
- int startIndex,
- NWildcard::CCensor &wildcardCensor,
- const UStringVector &nonSwitchStrings, NRecursedType::EEnum type,
- bool thereAreSwitchIncludes, UINT codePage)
-{
- if(nonSwitchStrings.Size() == startIndex && (!thereAreSwitchIncludes))
- AddCommandLineWildCardToCensr(wildcardCensor, kUniversalWildcard, true, type);
- for(int i = startIndex; i < nonSwitchStrings.Size(); i++)
- {
- const UString &s = nonSwitchStrings[i];
- if (s[0] == kFileListID)
- AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type, codePage);
- else
- AddCommandLineWildCardToCensr(wildcardCensor, s, true, type);
- }
-}
-
-#ifdef _WIN32
-static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
- const UString &switchParam, bool include,
- NRecursedType::EEnum commonRecursedType)
-{
- int splitPos = switchParam.Find(L':');
- if (splitPos < 0)
- ThrowUserErrorException();
- UString mappingName = switchParam.Left(splitPos);
-
- UString switchParam2 = switchParam.Mid(splitPos + 1);
- splitPos = switchParam2.Find(L':');
- if (splitPos < 0)
- ThrowUserErrorException();
-
- UString mappingSize = switchParam2.Left(splitPos);
- UString eventName = switchParam2.Mid(splitPos + 1);
-
- UInt64 dataSize64 = ConvertStringToUInt64(mappingSize, NULL);
- UInt32 dataSize = (UInt32)dataSize64;
- {
- CFileMapping fileMapping;
- if (!fileMapping.Open(FILE_MAP_READ, false, GetSystemString(mappingName)))
- ThrowException("Can not open mapping");
- LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_READ, 0, dataSize);
- if (data == NULL)
- ThrowException("MapViewOfFile error");
- try
- {
- const wchar_t *curData = (const wchar_t *)data;
- if (*curData != 0)
- ThrowException("Incorrect mapping data");
- UInt32 numChars = dataSize / sizeof(wchar_t);
- UString name;
- for (UInt32 i = 1; i < numChars; i++)
- {
- wchar_t c = curData[i];
- if (c == L'\0')
- {
- AddCommandLineWildCardToCensr(wildcardCensor,
- name, include, commonRecursedType);
- name.Empty();
- }
- else
- name += c;
- }
- if (!name.IsEmpty())
- ThrowException("data error");
- }
- catch(...)
- {
- UnmapViewOfFile(data);
- throw;
- }
- UnmapViewOfFile(data);
- }
-
- {
- NSynchronization::CEvent event;
- event.Open(EVENT_MODIFY_STATE, false, GetSystemString(eventName));
- event.Set();
- }
-}
-#endif
-
-static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
- const UStringVector &strings, bool include,
- NRecursedType::EEnum commonRecursedType, UINT codePage)
-{
- for(int i = 0; i < strings.Size(); i++)
- {
- const UString &name = strings[i];
- NRecursedType::EEnum recursedType;
- int pos = 0;
- if (name.Length() < kSomeCludePostStringMinSize)
- ThrowUserErrorException();
- if (::MyCharUpper(name[pos]) == kRecursedIDChar)
- {
- pos++;
- int index = UString(kRecursedPostCharSet).Find(name[pos]);
- recursedType = GetRecursedTypeFromIndex(index);
- if (index >= 0)
- pos++;
- }
- else
- recursedType = commonRecursedType;
- if (name.Length() < pos + kSomeCludeAfterRecursedPostStringMinSize)
- ThrowUserErrorException();
- UString tail = name.Mid(pos + 1);
- if (name[pos] == kImmediateNameID)
- AddCommandLineWildCardToCensr(wildcardCensor, tail, include, recursedType);
- else if (name[pos] == kFileListID)
- AddToCensorFromListFile(wildcardCensor, tail, include, recursedType, codePage);
- #ifdef _WIN32
- else if (name[pos] == kMapNameID)
- ParseMapWithPaths(wildcardCensor, tail, include, recursedType);
- #endif
- else
- ThrowUserErrorException();
- }
-}
-
-#ifdef _WIN32
-
-// This code converts all short file names to long file names.
-
-static void ConvertToLongName(const UString &prefix, UString &name)
-{
- if (name.IsEmpty() || DoesNameContainWildCard(name))
- return;
- NFind::CFileInfoW fileInfo;
- if (NFind::FindFile(prefix + name, fileInfo))
- name = fileInfo.Name;
-}
-
-static void ConvertToLongNames(const UString &prefix, CObjectVector<NWildcard::CItem> &items)
-{
- for (int i = 0; i < items.Size(); i++)
- {
- NWildcard::CItem &item = items[i];
- if (item.Recursive || item.PathParts.Size() != 1)
- continue;
- ConvertToLongName(prefix, item.PathParts.Front());
- }
-}
-
-static void ConvertToLongNames(const UString &prefix, NWildcard::CCensorNode &node)
-{
- ConvertToLongNames(prefix, node.IncludeItems);
- ConvertToLongNames(prefix, node.ExcludeItems);
- int i;
- for (i = 0; i < node.SubNodes.Size(); i++)
- ConvertToLongName(prefix, node.SubNodes[i].Name);
- // mix folders with same name
- for (i = 0; i < node.SubNodes.Size(); i++)
- {
- NWildcard::CCensorNode &nextNode1 = node.SubNodes[i];
- for (int j = i + 1; j < node.SubNodes.Size();)
- {
- const NWildcard::CCensorNode &nextNode2 = node.SubNodes[j];
- if (nextNode1.Name.CompareNoCase(nextNode2.Name) == 0)
- {
- nextNode1.IncludeItems += nextNode2.IncludeItems;
- nextNode1.ExcludeItems += nextNode2.ExcludeItems;
- node.SubNodes.Delete(j);
- }
- else
- j++;
- }
- }
- for (i = 0; i < node.SubNodes.Size(); i++)
- {
- NWildcard::CCensorNode &nextNode = node.SubNodes[i];
- ConvertToLongNames(prefix + nextNode.Name + wchar_t(NFile::NName::kDirDelimiter), nextNode);
- }
-}
-
-static void ConvertToLongNames(NWildcard::CCensor &censor)
-{
- for (int i = 0; i < censor.Pairs.Size(); i++)
- {
- NWildcard::CPair &pair = censor.Pairs[i];
- ConvertToLongNames(pair.Prefix, pair.Head);
- }
-}
-
-#endif
-
-static NUpdateArchive::NPairAction::EEnum GetUpdatePairActionType(int i)
-{
- switch(i)
- {
- case NUpdateArchive::NPairAction::kIgnore: return NUpdateArchive::NPairAction::kIgnore;
- case NUpdateArchive::NPairAction::kCopy: return NUpdateArchive::NPairAction::kCopy;
- case NUpdateArchive::NPairAction::kCompress: return NUpdateArchive::NPairAction::kCompress;
- case NUpdateArchive::NPairAction::kCompressAsAnti: return NUpdateArchive::NPairAction::kCompressAsAnti;
- }
- throw 98111603;
-}
-
-const UString kUpdatePairStateIDSet = L"PQRXYZW";
-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 = '!';
-
-
-static bool ParseUpdateCommandString2(const UString &command,
- NUpdateArchive::CActionSet &actionSet, UString &postString)
-{
- for(int i = 0; i < command.Length();)
- {
- wchar_t c = MyCharUpper(command[i]);
- int statePos = kUpdatePairStateIDSet.Find(c);
- if (statePos < 0)
- {
- postString = command.Mid(i);
- return true;
- }
- i++;
- if (i >= command.Length())
- return false;
- int actionPos = kUpdatePairActionIDSet.Find(::MyCharUpper(command[i]));
- if (actionPos < 0)
- return false;
- actionSet.StateActions[statePos] = GetUpdatePairActionType(actionPos);
- if (kUpdatePairStateNotSupportedActions[statePos] == actionPos)
- return false;
- i++;
- }
- postString.Empty();
- return true;
-}
-
-static void ParseUpdateCommandString(CUpdateOptions &options,
- const UStringVector &updatePostStrings,
- const NUpdateArchive::CActionSet &defaultActionSet)
-{
- for(int i = 0; i < updatePostStrings.Size(); i++)
- {
- const UString &updateString = updatePostStrings[i];
- if(updateString.CompareNoCase(kUpdateIgnoreItselfPostStringID) == 0)
- {
- if(options.UpdateArchiveItself)
- {
- options.UpdateArchiveItself = false;
- options.Commands.Delete(0);
- }
- }
- else
- {
- NUpdateArchive::CActionSet actionSet = defaultActionSet;
-
- UString postString;
- if (!ParseUpdateCommandString2(updateString, actionSet, postString))
- ThrowUserErrorException();
- if(postString.IsEmpty())
- {
- if(options.UpdateArchiveItself)
- options.Commands[0].ActionSet = actionSet;
- }
- else
- {
- if(MyCharUpper(postString[0]) != kUpdateNewArchivePostCharID)
- ThrowUserErrorException();
- CUpdateArchiveCommand uc;
- UString archivePath = postString.Mid(1);
- if (archivePath.IsEmpty())
- ThrowUserErrorException();
- uc.ArchivePath.BaseExtension = options.ArchivePath.BaseExtension;
- uc.ArchivePath.VolExtension = options.ArchivePath.VolExtension;
- uc.ArchivePath.ParseFromPath(archivePath);
- uc.ActionSet = actionSet;
- options.Commands.Add(uc);
- }
- }
- }
-}
-
-static const char kByteSymbol = 'B';
-static const char kKiloSymbol = 'K';
-static const char kMegaSymbol = 'M';
-static const char kGigaSymbol = 'G';
-
-static bool ParseComplexSize(const UString &src, UInt64 &result)
-{
- UString s = src;
- s.MakeUpper();
-
- const wchar_t *start = s;
- const wchar_t *end;
- UInt64 number = ConvertStringToUInt64(start, &end);
- int numDigits = (int)(end - start);
- if (numDigits == 0 || s.Length() > numDigits + 1)
- return false;
- if (s.Length() == numDigits)
- {
- result = number;
- return true;
- }
- int numBits;
- switch (s[numDigits])
- {
- case kByteSymbol:
- result = number;
- return true;
- case kKiloSymbol:
- numBits = 10;
- break;
- case kMegaSymbol:
- numBits = 20;
- break;
- case kGigaSymbol:
- numBits = 30;
- break;
- default:
- return false;
- }
- if (number >= ((UInt64)1 << (64 - numBits)))
- return false;
- result = number << numBits;
- return true;
-}
-
-static void SetAddCommandOptions(
- NCommandType::EEnum commandType,
- const CParser &parser,
- CUpdateOptions &options)
-{
- NUpdateArchive::CActionSet defaultActionSet;
- switch(commandType)
- {
- case NCommandType::kAdd:
- defaultActionSet = NUpdateArchive::kAddActionSet;
- break;
- case NCommandType::kDelete:
- defaultActionSet = NUpdateArchive::kDeleteActionSet;
- break;
- default:
- defaultActionSet = NUpdateArchive::kUpdateActionSet;
- }
-
- options.UpdateArchiveItself = true;
-
- options.Commands.Clear();
- CUpdateArchiveCommand updateMainCommand;
- updateMainCommand.ActionSet = defaultActionSet;
- options.Commands.Add(updateMainCommand);
- if(parser[NKey::kUpdate].ThereIs)
- ParseUpdateCommandString(options, parser[NKey::kUpdate].PostStrings,
- defaultActionSet);
- if(parser[NKey::kWorkingDir].ThereIs)
- {
- const UString &postString = parser[NKey::kWorkingDir].PostStrings[0];
- if (postString.IsEmpty())
- NDirectory::MyGetTempPath(options.WorkingDir);
- else
- options.WorkingDir = postString;
- }
- options.SfxMode = parser[NKey::kSfx].ThereIs;
- if (options.SfxMode)
- options.SfxModule = parser[NKey::kSfx].PostStrings[0];
-
- if (parser[NKey::kVolume].ThereIs)
- {
- const UStringVector &sv = parser[NKey::kVolume].PostStrings;
- for (int i = 0; i < sv.Size(); i++)
- {
- UInt64 size;
- if (!ParseComplexSize(sv[i], size))
- ThrowException("Incorrect volume size");
- options.VolumesSizes.Add(size);
- }
- }
-}
-
-static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &properties)
-{
- if (parser[NKey::kProperty].ThereIs)
- {
- // options.MethodMode.Properties.Clear();
- for(int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
- {
- CProperty property;
- const UString &postString = parser[NKey::kProperty].PostStrings[i];
- int index = postString.Find(L'=');
- if (index < 0)
- property.Name = postString;
- else
- {
- property.Name = postString.Left(index);
- property.Value = postString.Mid(index + 1);
- }
- properties.Add(property);
- }
- }
-}
-
-
-static void SetArchiveType(const UString &archiveType,
-#ifndef EXCLUDE_COM
- UString &filePath, CLSID &classID,
-#else
- UString &formatName,
-#endif
- UString &archiveExtension)
-{
- CObjectVector<CArchiverInfo> archiverInfoVector;
- ReadArchiverInfoList(archiverInfoVector);
- if (archiverInfoVector.Size() == 0)
- ThrowException("There are no installed archive handlers");
- if (archiveType.IsEmpty())
- ThrowException("Incorrect archive type was assigned");
- for (int i = 0; i < archiverInfoVector.Size(); i++)
- {
- const CArchiverInfo &archiverInfo = archiverInfoVector[i];
- if (archiverInfo.Name.CompareNoCase(archiveType) == 0)
- {
- #ifndef EXCLUDE_COM
- classID = archiverInfo.ClassID;
- filePath = archiverInfo.FilePath;
- #else
- formatName = archiverInfo.Name;
-
- #endif
-
- archiveExtension = archiverInfo.GetMainExtension();
- return;
- }
- }
- ThrowException("Incorrect archive type was assigned");
-}
-
-
-CArchiveCommandLineParser::CArchiveCommandLineParser(): parser(kNumSwitches) {}
-
-void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
- CArchiveCommandLineOptions &options)
-{
- try
- {
- parser.ParseStrings(kSwitchForms, commandStrings);
- }
- catch(...)
- {
- ThrowUserErrorException();
- }
-
- options.IsInTerminal = (_isatty(_fileno(stdin)) != 0);
- options.IsStdOutTerminal = (_isatty(_fileno(stdout)) != 0);
- options.IsStdErrTerminal = (_isatty(_fileno(stderr)) != 0);
- options.StdOutMode = parser[NKey::kStdOut].ThereIs;
- options.EnableHeaders = !parser[NKey::kDisableHeaders].ThereIs;
- options.HelpMode = parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs || parser[NKey::kHelp3].ThereIs;
-
- #ifdef _WIN32
- options.LargePages = false;
- if (parser[NKey::kLargePages].ThereIs)
- {
- const UString &postString = parser[NKey::kLargePages].PostStrings.Front();
- if (postString.IsEmpty())
- options.LargePages = true;
- }
- #endif
-}
-
-struct CCodePagePair
-{
- const wchar_t *Name;
- UINT CodePage;
-};
-
-static CCodePagePair g_CodePagePairs[] =
-{
- { L"UTF-8", CP_UTF8 },
- { L"WIN", CP_ACP },
- { L"DOS", CP_OEMCP }
-};
-
-static const int kNumCodePages = sizeof(g_CodePagePairs) / sizeof(g_CodePagePairs[0]);
-
-void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
-{
- const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
- int numNonSwitchStrings = nonSwitchStrings.Size();
- if(numNonSwitchStrings < kMinNonSwitchWords)
- ThrowUserErrorException();
-
- if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], options.Command))
- ThrowUserErrorException();
-
- options.TechMode = parser[NKey::kTechMode].ThereIs;
-
- NRecursedType::EEnum recursedType;
- if (parser[NKey::kRecursed].ThereIs)
- recursedType = GetRecursedTypeFromIndex(parser[NKey::kRecursed].PostCharIndex);
- else
- recursedType = NRecursedType::kNonRecursed;
-
- UINT codePage = CP_UTF8;
- if (parser[NKey::kCharSet].ThereIs)
- {
- UString name = parser[NKey::kCharSet].PostStrings.Front();
- name.MakeUpper();
- int i;
- for (i = 0; i < kNumCodePages; i++)
- {
- const CCodePagePair &pair = g_CodePagePairs[i];
- if (name.Compare(pair.Name) == 0)
- {
- codePage = pair.CodePage;
- break;
- }
- }
- if (i >= kNumCodePages)
- ThrowUserErrorException();
- }
-
- bool thereAreSwitchIncludes = false;
- if (parser[NKey::kInclude].ThereIs)
- {
- thereAreSwitchIncludes = true;
- AddSwitchWildCardsToCensor(options.WildcardCensor,
- parser[NKey::kInclude].PostStrings, true, recursedType, codePage);
- }
- if (parser[NKey::kExclude].ThereIs)
- AddSwitchWildCardsToCensor(options.WildcardCensor,
- parser[NKey::kExclude].PostStrings, false, recursedType, codePage);
-
- int curCommandIndex = kCommandIndex + 1;
- bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs;
- if (thereIsArchiveName)
- {
- if(curCommandIndex >= numNonSwitchStrings)
- ThrowUserErrorException();
- options.ArchiveName = nonSwitchStrings[curCommandIndex++];
- }
-
- AddToCensorFromNonSwitchesStrings(
- curCommandIndex, options.WildcardCensor,
- nonSwitchStrings, recursedType, thereAreSwitchIncludes, codePage);
-
- options.YesToAll = parser[NKey::kYes].ThereIs;
-
- bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
-
- options.PasswordEnabled = parser[NKey::kPassword].ThereIs;
-
- if(options.PasswordEnabled)
- options.Password = parser[NKey::kPassword].PostStrings[0];
-
- options.StdInMode = parser[NKey::kStdIn].ThereIs;
- options.ShowDialog = parser[NKey::kShowDialog].ThereIs;
-
- if(isExtractGroupCommand || options.Command.CommandType == NCommandType::kList)
- {
- if (options.StdInMode)
- ThrowException("Reading archives from stdin is not implemented");
- if (!options.WildcardCensor.AllAreRelative())
- ThrowException("Cannot use absolute pathnames for this command");
-
- NWildcard::CCensor archiveWildcardCensor;
-
- if (parser[NKey::kArInclude].ThereIs)
- {
- AddSwitchWildCardsToCensor(archiveWildcardCensor,
- parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage);
- }
- if (parser[NKey::kArExclude].ThereIs)
- AddSwitchWildCardsToCensor(archiveWildcardCensor,
- parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage);
-
- if (thereIsArchiveName)
- AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);
-
- #ifdef _WIN32
- ConvertToLongNames(archiveWildcardCensor);
- #endif
-
- 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);
- }
-
- if (archivePaths.Size() == 0)
- throw "there is no such archive";
-
- UStringVector archivePathsFull;
-
- for (i = 0; i < archivePaths.Size(); i++)
- {
- UString fullPath;
- NFile::NDirectory::MyGetFullPathName(archivePaths[i], fullPath);
- archivePathsFull.Add(fullPath);
- }
- CIntVector indices;
- SortStringsToIndices(archivePathsFull, indices);
- options.ArchivePathsSorted.Reserve(indices.Size());
- options.ArchivePathsFullSorted.Reserve(indices.Size());
- for (i = 0; i < indices.Size(); i++)
- {
- options.ArchivePathsSorted.Add(archivePaths[indices[i]]);
- options.ArchivePathsFullSorted.Add(archivePathsFull[indices[i]]);
- }
-
- if(isExtractGroupCommand)
- {
- SetMethodOptions(parser, options.ExtractProperties);
- if (options.StdOutMode && options.IsStdOutTerminal)
- throw kTerminalOutError;
- 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 =
- k_OverwriteModes[parser[NKey::kOverwrite].PostCharIndex];
- else if (options.YesToAll)
- options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
- }
- }
- else if(options.Command.IsFromUpdateGroup())
- {
- CUpdateOptions &updateOptions = options.UpdateOptions;
-
- UString archiveType;
- if(parser[NKey::kArchiveType].ThereIs)
- archiveType = parser[NKey::kArchiveType].PostStrings[0];
- else
- archiveType = kDefaultArchiveType;
-
- UString typeExtension;
- if (!archiveType.IsEmpty())
- {
- #ifndef EXCLUDE_COM
- SetArchiveType(archiveType, updateOptions.MethodMode.FilePath,
- updateOptions.MethodMode.ClassID, typeExtension);
- #else
- SetArchiveType(archiveType, updateOptions.MethodMode.Name, typeExtension);
- #endif
- }
- UString extension = typeExtension;
- if(parser[NKey::kSfx].ThereIs)
- extension = kSFXExtension;
- updateOptions.ArchivePath.BaseExtension = extension;
- updateOptions.ArchivePath.VolExtension = typeExtension;
- updateOptions.ArchivePath.ParseFromPath(options.ArchiveName);
- SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
-
- SetMethodOptions(parser, updateOptions.MethodMode.Properties);
-
- options.EnablePercents = !parser[NKey::kDisablePercents].ThereIs;
-
- if (options.EnablePercents)
- {
- if ((options.StdOutMode && !options.IsStdErrTerminal) ||
- (!options.StdOutMode && !options.IsStdOutTerminal))
- options.EnablePercents = false;
- }
-
- updateOptions.EMailMode = parser[NKey::kEmail].ThereIs;
- if (updateOptions.EMailMode)
- {
- updateOptions.EMailAddress = parser[NKey::kEmail].PostStrings.Front();
- if (updateOptions.EMailAddress.Length() > 0)
- if (updateOptions.EMailAddress[0] == L'.')
- {
- updateOptions.EMailRemoveAfter = true;
- updateOptions.EMailAddress.Delete(0);
- }
- }
-
- updateOptions.StdOutMode = options.StdOutMode;
- updateOptions.StdInMode = options.StdInMode;
-
- if (updateOptions.StdOutMode && updateOptions.EMailMode)
- throw "stdout mode and email mode cannot be combined";
- if (updateOptions.StdOutMode && options.IsStdOutTerminal)
- throw kTerminalOutError;
- if(updateOptions.StdInMode)
- updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();
-
- #ifdef _WIN32
- ConvertToLongNames(options.WildcardCensor);
- #endif
- }
- else
- ThrowUserErrorException();
- options.WildcardCensor.ExtendExclude();
-}
diff --git a/7zip/UI/Common/ArchiveExtractCallback.cpp b/7zip/UI/Common/ArchiveExtractCallback.cpp
deleted file mode 100755
index 48f7bb67..00000000
--- a/7zip/UI/Common/ArchiveExtractCallback.cpp
+++ /dev/null
@@ -1,449 +0,0 @@
-// ArchiveExtractCallback.cpp
-
-#include "StdAfx.h"
-
-#include "ArchiveExtractCallback.h"
-
-#include "Common/Wildcard.h"
-#include "Common/StringConvert.h"
-#include "Common/ComTry.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"
-
-#include "../../Common/FilePathAutoRename.h"
-
-#include "../Common/ExtractingFilePath.h"
-#include "OpenArchive.h"
-
-using namespace NWindows;
-
-static const wchar_t *kCantAutoRename = L"ERROR: Can not create file with auto name";
-static const wchar_t *kCantRenameFile = L"ERROR: Can not rename existing file ";
-static const wchar_t *kCantDeleteOutputFile = L"ERROR: Can not delete output file ";
-
-
-void CArchiveExtractCallback::Init(
- IInArchive *archiveHandler,
- IFolderArchiveExtractCallback *extractCallback2,
- bool stdOutMode,
- const UString &directoryPath,
- NExtract::NPathMode::EEnum pathMode,
- NExtract::NOverwriteMode::EEnum overwriteMode,
- const UStringVector &removePathParts,
- const UString &itemDefaultName,
- const FILETIME &utcLastWriteTimeDefault,
- UInt32 attributesDefault)
-{
- _stdOutMode = stdOutMode;
- _numErrors = 0;
- _extractCallback2 = extractCallback2;
- _itemDefaultName = itemDefaultName;
- _utcLastWriteTimeDefault = utcLastWriteTimeDefault;
- _attributesDefault = attributesDefault;
- _removePathParts = removePathParts;
- _pathMode = pathMode;
- _overwriteMode = overwriteMode;
- _archiveHandler = archiveHandler;
- _directoryPath = directoryPath;
- NFile::NName::NormalizeDirPathPrefix(_directoryPath);
-}
-
-STDMETHODIMP CArchiveExtractCallback::SetTotal(UInt64 size)
-{
- COM_TRY_BEGIN
- return _extractCallback2->SetTotal(size);
- COM_TRY_END
-}
-
-STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 *completeValue)
-{
- COM_TRY_BEGIN
- return _extractCallback2->SetCompleted(completeValue);
- COM_TRY_END
-}
-
-void CArchiveExtractCallback::CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath)
-{
- fullPath = _directoryPath;
- for(int i = 0; i < dirPathParts.Size(); i++)
- {
- if (i > 0)
- fullPath += wchar_t(NFile::NName::kDirDelimiter);
- fullPath += dirPathParts[i];
- NFile::NDirectory::MyCreateDirectory(fullPath);
- }
-}
-
-static UString MakePathNameFromParts(const UStringVector &parts)
-{
- UString result;
- for(int i = 0; i < parts.Size(); i++)
- {
- if(i != 0)
- result += wchar_t(NFile::NName::kDirDelimiter);
- result += parts[i];
- }
- return result;
-}
-
-
-HRESULT CArchiveExtractCallback::GetTime(int index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined)
-{
- filetimeIsDefined = false;
- NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, propID, &prop));
- if (prop.vt == VT_FILETIME)
- {
- filetime = prop.filetime;
- filetimeIsDefined = true;
- }
- else if (prop.vt != VT_EMPTY)
- return E_FAIL;
- return S_OK;
-}
-
-STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)
-{
- COM_TRY_BEGIN
- *outStream = 0;
- _outFileStream.Release();
-
- _encrypted = false;
- _isSplit = false;
-
- UString fullPath;
- {
- NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));
-
- if(prop.vt == VT_EMPTY)
- fullPath = _itemDefaultName;
- else
- {
- if(prop.vt != VT_BSTR)
- return E_FAIL;
- fullPath = prop.bstrVal;
- }
- }
-
- // UString fullPathCorrect = GetCorrectPath(fullPath);
- _filePath = fullPath;
-
- {
- NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidPosition, &prop));
- if (prop.vt != VT_EMPTY)
- {
- if (prop.vt != VT_UI8)
- return E_FAIL;
- _position = prop.uhVal.QuadPart;
- _isSplit = true;
- }
- }
-
- {
- NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidEncrypted, &prop));
- if (prop.vt == VT_BOOL)
- _encrypted = VARIANT_BOOLToBool(prop.boolVal);
- else if (prop.vt != VT_EMPTY)
- return E_FAIL;
- }
-
- if(askExtractMode == NArchive::NExtract::NAskMode::kExtract)
- {
- if (_stdOutMode)
- {
- CMyComPtr<ISequentialOutStream> outStreamLoc = new CStdOutFileStream;
- *outStream = outStreamLoc.Detach();
- return S_OK;
- }
-
- {
- NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidAttributes, &prop));
- if (prop.vt == VT_EMPTY)
- {
- _processedFileInfo.Attributes = _attributesDefault;
- _processedFileInfo.AttributesAreDefined = false;
- }
- else
- {
- if (prop.vt != VT_UI4)
- throw "incorrect item";
- _processedFileInfo.Attributes = prop.ulVal;
- _processedFileInfo.AttributesAreDefined = true;
- }
- }
-
- RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.IsDirectory));
-
- RINOK(GetTime(index, kpidCreationTime, _processedFileInfo.CreationTime,
- _processedFileInfo.IsCreationTimeDefined));
- RINOK(GetTime(index, kpidLastWriteTime, _processedFileInfo.LastWriteTime,
- _processedFileInfo.IsLastWriteTimeDefined));
- RINOK(GetTime(index, kpidLastAccessTime, _processedFileInfo.LastAccessTime,
- _processedFileInfo.IsLastAccessTimeDefined));
-
- bool newFileSizeDefined;
- UInt64 newFileSize;
- {
- NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
- newFileSizeDefined = (prop.vt != VT_EMPTY);
- if (newFileSizeDefined)
- newFileSize = ConvertPropVariantToUInt64(prop);
- }
-
- bool isAnti = false;
- {
- NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidIsAnti, &prop));
- if (prop.vt == VT_BOOL)
- isAnti = VARIANT_BOOLToBool(prop.boolVal);
- }
-
- UStringVector pathParts;
- SplitPathToParts(fullPath, pathParts);
-
- if(pathParts.IsEmpty())
- return E_FAIL;
- UString processedPath;
- switch(_pathMode)
- {
- case NExtract::NPathMode::kFullPathnames:
- {
- processedPath = fullPath;
- break;
- }
- case NExtract::NPathMode::kCurrentPathnames:
- {
- // for incorrect paths: "/dir1/dir2/file"
- int numRemovePathParts = _removePathParts.Size();
- if(pathParts.Size() <= numRemovePathParts)
- return E_FAIL;
- for(int i = 0; i < numRemovePathParts; i++)
- if(_removePathParts[i].CompareNoCase(pathParts[i]) != 0)
- return E_FAIL;
- pathParts.Delete(0, numRemovePathParts);
- processedPath = MakePathNameFromParts(pathParts);
- break;
- }
- case NExtract::NPathMode::kNoPathnames:
- {
- processedPath = pathParts.Back();
- pathParts.Delete(0, pathParts.Size() - 1); // Test it!!
- break;
- }
- }
- processedPath = GetCorrectPath(processedPath);
- if(!_processedFileInfo.IsDirectory)
- pathParts.DeleteBack();
-
- MakeCorrectPath(pathParts);
-
- if (!isAnti)
- {
- if (!pathParts.IsEmpty())
- {
- 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);
- }
- }
-
-
- UString fullProcessedPath = _directoryPath + processedPath;
-
- if(_processedFileInfo.IsDirectory)
- {
- _diskFilePath = fullProcessedPath;
- if (isAnti)
- NFile::NDirectory::MyRemoveDirectory(_diskFilePath);
- return S_OK;
- }
-
- if (!_isSplit)
- {
- NFile::NFind::CFileInfoW fileInfo;
- if(NFile::NFind::FindFile(fullProcessedPath, fileInfo))
- {
- switch(_overwriteMode)
- {
- case NExtract::NOverwriteMode::kSkipExisting:
- return S_OK;
- case NExtract::NOverwriteMode::kAskBefore:
- {
- Int32 overwiteResult;
- RINOK(_extractCallback2->AskOverwrite(
- fullProcessedPath, &fileInfo.LastWriteTime, &fileInfo.Size, fullPath,
- _processedFileInfo.IsLastWriteTimeDefined ? &_processedFileInfo.LastWriteTime : NULL,
- newFileSizeDefined ? &newFileSize : NULL,
- &overwiteResult))
-
- switch(overwiteResult)
- {
- case NOverwriteAnswer::kCancel:
- return E_ABORT;
- case NOverwriteAnswer::kNo:
- return S_OK;
- case NOverwriteAnswer::kNoToAll:
- _overwriteMode = NExtract::NOverwriteMode::kSkipExisting;
- return S_OK;
- case NOverwriteAnswer::kYesToAll:
- _overwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
- break;
- case NOverwriteAnswer::kYes:
- break;
- case NOverwriteAnswer::kAutoRename:
- _overwriteMode = NExtract::NOverwriteMode::kAutoRename;
- break;
- default:
- throw 20413;
- }
- }
- }
- if (_overwriteMode == NExtract::NOverwriteMode::kAutoRename)
- {
- if (!AutoRenamePath(fullProcessedPath))
- {
- UString message = UString(kCantAutoRename) +
- fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
- return E_ABORT;
- }
- }
- else if (_overwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting)
- {
- UString existPath = fullProcessedPath;
- if (!AutoRenamePath(existPath))
- {
- UString message = kCantAutoRename + fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
- return E_ABORT;
- }
- if(!NFile::NDirectory::MyMoveFile(fullProcessedPath, existPath))
- {
- UString message = UString(kCantRenameFile) + fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
- return E_ABORT;
- }
- }
- else
- if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
- {
- UString message = UString(kCantDeleteOutputFile) +
- fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
- return E_ABORT;
- }
- }
- }
- if (!isAnti)
- {
- _outFileStreamSpec = new COutFileStream;
- CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
- if (!_outFileStreamSpec->File.Open(fullProcessedPath,
- _isSplit ? OPEN_ALWAYS: CREATE_ALWAYS))
- {
- // if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit)
- {
- UString message = L"can not open output file " + fullProcessedPath;
- RINOK(_extractCallback2->MessageError(message));
- return S_OK;
- }
- }
- if (_isSplit)
- {
- RINOK(_outFileStreamSpec->Seek(_position, STREAM_SEEK_SET, NULL));
- }
- _outFileStream = outStreamLoc;
- *outStream = outStreamLoc.Detach();
- }
- _diskFilePath = fullProcessedPath;
- }
- else
- {
- *outStream = NULL;
- }
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
-{
- COM_TRY_BEGIN
- _extractMode = false;
- switch (askExtractMode)
- {
- case NArchive::NExtract::NAskMode::kExtract:
- _extractMode = true;
- };
- return _extractCallback2->PrepareOperation(_filePath, askExtractMode, _isSplit ? &_position: 0);
- COM_TRY_END
-}
-
-STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
-{
- COM_TRY_BEGIN
- switch(operationResult)
- {
- case NArchive::NExtract::NOperationResult::kOK:
- case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
- case NArchive::NExtract::NOperationResult::kCRCError:
- case NArchive::NExtract::NOperationResult::kDataError:
- break;
- default:
- _outFileStream.Release();
- return E_FAIL;
- }
- if(_outFileStream != NULL)
- _outFileStreamSpec->File.SetTime(
- (WriteCreated && _processedFileInfo.IsCreationTimeDefined) ? &_processedFileInfo.CreationTime : NULL,
- (WriteAccessed && _processedFileInfo.IsLastAccessTimeDefined) ? &_processedFileInfo.LastAccessTime : NULL,
- (WriteModified && _processedFileInfo.IsLastWriteTimeDefined) ? &_processedFileInfo.LastWriteTime : &_utcLastWriteTimeDefault);
- _outFileStream.Release();
- if (_extractMode && _processedFileInfo.AttributesAreDefined)
- NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attributes);
- RINOK(_extractCallback2->SetOperationResult(operationResult, _encrypted));
- return S_OK;
- COM_TRY_END
-}
-
-/*
-STDMETHODIMP CArchiveExtractCallback::GetInStream(
- const wchar_t *name, ISequentialInStream **inStream)
-{
- COM_TRY_BEGIN
- CInFileStream *inFile = new CInFileStream;
- CMyComPtr<ISequentialInStream> inStreamTemp = inFile;
- if (!inFile->Open(_srcDirectoryPrefix + name))
- return ::GetLastError();
- *inStream = inStreamTemp.Detach();
- return S_OK;
- COM_TRY_END
-}
-*/
-
-STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
-{
- COM_TRY_BEGIN
- if (!_cryptoGetTextPassword)
- {
- RINOK(_extractCallback2.QueryInterface(IID_ICryptoGetTextPassword,
- &_cryptoGetTextPassword));
- }
- return _cryptoGetTextPassword->CryptoGetTextPassword(password);
- COM_TRY_END
-}
-
diff --git a/7zip/UI/Common/ArchiveOpenCallback.h b/7zip/UI/Common/ArchiveOpenCallback.h
deleted file mode 100755
index 5cf95370..00000000
--- a/7zip/UI/Common/ArchiveOpenCallback.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// ArchiveOpenCallback.h
-
-#ifndef __ARCHIVE_OPEN_CALLBACK_H
-#define __ARCHIVE_OPEN_CALLBACK_H
-
-#include "Common/String.h"
-#include "Common/MyCom.h"
-#include "Windows/FileFind.h"
-
-#ifndef _NO_CRYPTO
-#include "../../IPassword.h"
-#endif
-#include "../../Archive/IArchive.h"
-
-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;
- #endif
-};
-
-class COpenCallbackImp:
- public IArchiveOpenCallback,
- public IArchiveOpenVolumeCallback,
- public IArchiveOpenSetSubArchiveName,
- #ifndef _NO_CRYPTO
- public ICryptoGetTextPassword,
- #endif
- public CMyUnknownImp
-{
-public:
- #ifndef _NO_CRYPTO
- MY_UNKNOWN_IMP3(
- IArchiveOpenVolumeCallback,
- ICryptoGetTextPassword,
- IArchiveOpenSetSubArchiveName
- )
- #else
- MY_UNKNOWN_IMP2(
- 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);
-
- #ifndef _NO_CRYPTO
- // ICryptoGetTextPassword
- STDMETHOD(CryptoGetTextPassword)(BSTR *password);
- #endif
-
- STDMETHOD(SetSubArchiveName(const wchar_t *name))
- {
- _subArchiveMode = true;
- _subArchiveName = name;
- return S_OK;
- }
-
-private:
- UString _folderPrefix;
- NWindows::NFile::NFind::CFileInfoW _fileInfo;
- bool _subArchiveMode;
- UString _subArchiveName;
-public:
- UStringVector FileNames;
- IOpenCallbackUI *Callback;
- void Init(const UString &folderPrefix, const UString &fileName)
- {
- _folderPrefix = folderPrefix;
- if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo))
- throw 1;
- FileNames.Clear();
- _subArchiveMode = false;
- }
- int FindName(const UString &name);
-};
-
-#endif
diff --git a/7zip/UI/Common/ArchiverInfo.cpp b/7zip/UI/Common/ArchiverInfo.cpp
deleted file mode 100755
index 115c5d91..00000000
--- a/7zip/UI/Common/ArchiverInfo.cpp
+++ /dev/null
@@ -1,359 +0,0 @@
-// ArchiverInfo.cpp
-
-#include "StdAfx.h"
-
-#include "ArchiverInfo.h"
-
-#ifndef EXCLUDE_COM
-
-#include "Common/StringConvert.h"
-#include "Windows/FileFind.h"
-#include "Windows/FileName.h"
-#include "Windows/DLL.h"
-#ifdef _WIN32
-#include "Windows/Registry.h"
-#endif
-#include "Windows/PropVariant.h"
-#include "../../Archive/IArchive.h"
-
-using namespace NWindows;
-using namespace NFile;
-
-#endif
-
-extern HINSTANCE g_hInstance;
-
-#ifndef EXCLUDE_COM
-
-static void SplitString(const UString &srcString, UStringVector &destStrings)
-{
- destStrings.Clear();
- UString string;
- int len = srcString.Length();
- if (len == 0)
- return;
- for (int i = 0; i < len; i++)
- {
- wchar_t c = srcString[i];
- if (c == L' ')
- {
- if (!string.IsEmpty())
- {
- destStrings.Add(string);
- string.Empty();
- }
- }
- else
- string += c;
- }
- if (!string.IsEmpty())
- destStrings.Add(string);
-}
-
-typedef UInt32 (WINAPI * GetHandlerPropertyFunc)(
- PROPID propID, PROPVARIANT *value);
-
-static UString GetModuleFolderPrefix()
-{
- UString path;
- NDLL::MyGetModuleFileName(g_hInstance, path);
- int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
- return path.Left(pos + 1);
-}
-
-static wchar_t *kFormatFolderName = L"Formats";
-
-#ifdef _WIN32
-static LPCTSTR kRegistryPath = TEXT("Software\\7-zip");
-static LPCWSTR kProgramPathValue = L"Path";
-static bool ReadPathFromRegistry(HKEY baseKey, UString &path)
-{
- NRegistry::CKey key;
- if(key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
- if (key.QueryValue(kProgramPathValue, path) == ERROR_SUCCESS)
- {
- NName::NormalizeDirPathPrefix(path);
- return true;
- }
- return false;
-}
-#endif
-
-static UString GetBaseFolderPrefixFromRegistry()
-{
- UString moduleFolderPrefix = GetModuleFolderPrefix();
- NFind::CFileInfoW fileInfo;
- if (NFind::FindFile(moduleFolderPrefix + kFormatFolderName, fileInfo))
- if (fileInfo.IsDirectory())
- return moduleFolderPrefix;
- UString path;
- #ifdef _WIN32
- if(ReadPathFromRegistry(HKEY_CURRENT_USER, path))
- return path;
- if(ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
- return path;
- #endif
- return moduleFolderPrefix;
-}
-
-typedef UInt32 (WINAPI *CreateObjectPointer)(
- const GUID *clsID,
- const GUID *interfaceID,
- void **outObject);
-
-#endif
-
-#ifndef _SFX
-static inline void SetBuffer(CByteBuffer &bb, const Byte *data, int size)
-{
- bb.SetCapacity(size);
- memmove((Byte *)bb, data, size);
-}
-#endif
-
-void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
-{
- archivers.Clear();
-
- #ifdef EXCLUDE_COM
-
- #ifdef FORMAT_7Z
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.Name = L"7z";
- item.Extensions.Add(CArchiverExtInfo(L"7z"));
- #ifndef _SFX
- const unsigned char kSig[] = {'7' , 'z', 0xBC, 0xAF, 0x27, 0x1C};
- SetBuffer(item.StartSignature, kSig, 6);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_BZIP2
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.KeepName = true;
- item.Name = L"BZip2";
- item.Extensions.Add(CArchiverExtInfo(L"bz2"));
- item.Extensions.Add(CArchiverExtInfo(L"tbz2", L".tar"));
- #ifndef _SFX
- const unsigned char sig[] = {'B' , 'Z', 'h' };
- SetBuffer(item.StartSignature, sig, 3);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_GZIP
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.Name = L"GZip";
- item.Extensions.Add(CArchiverExtInfo(L"gz"));
- item.Extensions.Add(CArchiverExtInfo(L"tgz", L".tar"));
- #ifndef _SFX
- const unsigned char sig[] = { 0x1F, 0x8B };
- SetBuffer(item.StartSignature, sig, 2);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_SPLIT
- {
- CArchiverInfo item;
- item.UpdateEnabled = false;
- item.KeepName = true;
- item.Name = L"Split";
- item.Extensions.Add(CArchiverExtInfo(L"001"));
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_TAR
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.Name = L"Tar";
- item.Extensions.Add(CArchiverExtInfo(L"tar"));
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_ZIP
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.Name = L"Zip";
- item.Extensions.Add(CArchiverExtInfo(L"zip"));
- #ifndef _SFX
- const unsigned char sig[] = { 0x50, 0x4B, 0x03, 0x04 };
- SetBuffer(item.StartSignature, sig, 4);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_CPIO
- {
- CArchiverInfo item;
- item.Name = L"Cpio";
- item.Extensions.Add(CArchiverExtInfo(L"cpio"));
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_RPM
- {
- CArchiverInfo item;
- item.Name = L"Rpm";
- item.Extensions.Add(CArchiverExtInfo(L"rpm", L".cpio.gz"));
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_ARJ
- {
- CArchiverInfo item;
- item.Name = L"Arj";
- item.Extensions.Add(CArchiverExtInfo(L"arj"));
- #ifndef _SFX
- const unsigned char sig[] = { 0x60, 0xEA };
- SetBuffer(item.StartSignature, sig, 2);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_Z
- {
- CArchiverInfo item;
- item.Name = L"Z";
- item.Extensions.Add(CArchiverExtInfo(L"Z"));
- #ifndef _SFX
- const unsigned char sig[] = { 0x1F, 0x9D };
- SetBuffer(item.StartSignature, sig, 2);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #else
-
- UString folderPath = GetBaseFolderPrefixFromRegistry() +
- (UString)kFormatFolderName + (UString)WSTRING_PATH_SEPARATOR;
- NFind::CEnumeratorW enumerator(folderPath + L"*");
- NFind::CFileInfoW fileInfo;
- while (enumerator.Next(fileInfo))
- {
- if (fileInfo.IsDirectory())
- continue;
- UString filePath = folderPath + fileInfo.Name;
- {
- NDLL::CLibrary library;
- if (!library.LoadEx(filePath, LOAD_LIBRARY_AS_DATAFILE))
- continue;
- }
-
- NDLL::CLibrary library;
- if (!library.Load(filePath))
- continue;
- GetHandlerPropertyFunc getHandlerProperty = (GetHandlerPropertyFunc)
- library.GetProcAddress("GetHandlerProperty");
- if (getHandlerProperty == NULL)
- continue;
-
- CArchiverInfo item;
- item.FilePath = filePath;
-
- NWindows::NCOM::CPropVariant prop;
- if (getHandlerProperty(NArchive::kName, &prop) != S_OK)
- continue;
- if (prop.vt != VT_BSTR)
- continue;
- item.Name = prop.bstrVal;
- prop.Clear();
-
- if (getHandlerProperty(NArchive::kClassID, &prop) != S_OK)
- continue;
- if (prop.vt != VT_BSTR)
- continue;
- item.ClassID = *(const GUID *)prop.bstrVal;
- prop.Clear();
-
- if (getHandlerProperty(NArchive::kExtension, &prop) != S_OK)
- continue;
- if (prop.vt != VT_BSTR)
- continue;
-
- UString ext = prop.bstrVal;
- UString addExt;
-
- prop.Clear();
-
- if (getHandlerProperty(NArchive::kAddExtension, &prop) != S_OK)
- continue;
- if (prop.vt == VT_BSTR)
- {
- addExt = prop.bstrVal;
- }
- else if (prop.vt != VT_EMPTY)
- continue;
- prop.Clear();
-
- UStringVector exts, addExts;
- SplitString(ext, exts);
- SplitString(addExt, addExts);
-
- prop.Clear();
- for (int i = 0; i < exts.Size(); i++)
- {
- CArchiverExtInfo extInfo;
- extInfo.Ext = exts[i];
- if (addExts.Size() > 0)
- extInfo.AddExt = addExts[i];
- if (extInfo.AddExt == L"*")
- extInfo.AddExt.Empty();
- item.Extensions.Add(extInfo);
- }
-
- if (getHandlerProperty(NArchive::kUpdate, &prop) == S_OK)
- if (prop.vt == VT_BOOL)
- item.UpdateEnabled = VARIANT_BOOLToBool(prop.boolVal);
- prop.Clear();
-
- if (item.UpdateEnabled)
- {
- if (getHandlerProperty(NArchive::kKeepName, &prop) == S_OK)
- if (prop.vt == VT_BOOL)
- item.KeepName = VARIANT_BOOLToBool(prop.boolVal);
- prop.Clear();
- }
-
- if (getHandlerProperty(NArchive::kStartSignature, &prop) == S_OK)
- {
- if (prop.vt == VT_BSTR)
- {
- UINT len = ::SysStringByteLen(prop.bstrVal);
- item.StartSignature.SetCapacity(len);
- memmove(item.StartSignature, prop.bstrVal, len);
- }
- }
- prop.Clear();
-
- if (getHandlerProperty(NArchive::kAssociate, &prop) == S_OK)
- if (prop.vt == VT_BOOL)
- item.Associate = VARIANT_BOOLToBool(prop.boolVal);
- prop.Clear();
-
-
- archivers.Add(item);
- }
-
- #endif
-}
-
-
diff --git a/7zip/UI/Common/DefaultName.cpp b/7zip/UI/Common/DefaultName.cpp
deleted file mode 100755
index ab75fa2c..00000000
--- a/7zip/UI/Common/DefaultName.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-// DefaultName.cpp
-
-#include "StdAfx.h"
-
-#include "DefaultName.h"
-
-static const wchar_t *kEmptyFileAlias = L"[Content]";
-
-UString GetDefaultName2(const UString &fileName,
- const UString &extension, const UString &addSubExtension)
-{
- int extLength = extension.Length();
- int fileNameLength = fileName.Length();
- if (fileNameLength > extLength + 1)
- {
- int dotPos = fileNameLength - (extLength + 1);
- if (fileName[dotPos] == '.')
- if (extension.CompareNoCase(fileName.Mid(dotPos + 1)) == 0)
- return fileName.Left(dotPos) + addSubExtension;
- }
- return kEmptyFileAlias;
-}
-
diff --git a/7zip/UI/Common/Extract.cpp b/7zip/UI/Common/Extract.cpp
deleted file mode 100755
index 300521ad..00000000
--- a/7zip/UI/Common/Extract.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-// Extract.cpp
-
-#include "StdAfx.h"
-
-#include "Extract.h"
-
-#include "Windows/Defs.h"
-#include "Windows/FileDir.h"
-
-#include "OpenArchive.h"
-#include "SetProperties.h"
-
-#ifndef EXCLUDE_COM
-#include "Windows/DLL.h"
-#endif
-
-using namespace NWindows;
-
-HRESULT DecompressArchive(
- IInArchive *archive,
- const UString &defaultName,
- const NWildcard::CCensorNode &wildcardCensor,
- const CExtractOptions &options,
- IExtractCallbackUI *callback,
- UString &errorMessage)
-{
- CRecordVector<UInt32> realIndices;
- UInt32 numItems;
- RINOK(archive->GetNumberOfItems(&numItems));
-
- for(UInt32 i = 0; i < numItems; i++)
- {
- UString filePath;
- RINOK(GetArchiveItemPath(archive, i, options.DefaultItemName, filePath));
- bool isFolder;
- RINOK(IsArchiveItemFolder(archive, i, isFolder));
- if (!wildcardCensor.CheckPath(filePath, !isFolder))
- continue;
- realIndices.Add(i);
- }
- if (realIndices.Size() == 0)
- {
- callback->ThereAreNoFiles();
- return S_OK;
- }
-
- CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
- CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
-
- UStringVector removePathParts;
-
- UString outDir = options.OutputDir;
- outDir.Replace(L"*", defaultName);
- if(!outDir.IsEmpty())
- if(!NFile::NDirectory::CreateComplexDirectory(outDir))
- {
- HRESULT res = ::GetLastError();
- if (res == S_OK)
- res = E_FAIL;
- errorMessage = ((UString)L"Can not create output directory ") + outDir;
- return res;
- }
-
- extractCallbackSpec->Init(
- archive,
- callback,
- options.StdOutMode,
- outDir,
- options.PathMode,
- options.OverwriteMode,
- removePathParts,
- options.DefaultItemName,
- options.ArchiveFileInfo.LastWriteTime,
- options.ArchiveFileInfo.Attributes);
-
- #ifdef COMPRESS_MT
- RINOK(SetProperties(archive, options.Properties));
- #endif
-
- HRESULT result = archive->Extract(&realIndices.Front(),
- realIndices.Size(), options.TestMode? 1: 0,
- extractCallback);
-
- return callback->ExtractResult(result);
-}
-
-HRESULT DecompressArchives(
- UStringVector &archivePaths, UStringVector &archivePathsFull,
- const NWildcard::CCensorNode &wildcardCensor,
- const CExtractOptions &optionsSpec,
- IOpenCallbackUI *openCallback,
- IExtractCallbackUI *extractCallback,
- UString &errorMessage)
-{
- CExtractOptions options = optionsSpec;
- for (int i = 0; i < archivePaths.Size(); i++)
- {
- const UString &archivePath = archivePaths[i];
- NFile::NFind::CFileInfoW archiveFileInfo;
- if (!NFile::NFind::FindFile(archivePath, archiveFileInfo))
- throw "there is no such archive";
-
- if (archiveFileInfo.IsDirectory())
- throw "there is no such archive";
-
- options.ArchiveFileInfo = archiveFileInfo;
-
- RINOK(extractCallback->BeforeOpen(archivePath));
- CArchiveLink archiveLink;
- HRESULT result = MyOpenArchive(archivePath, archiveLink, openCallback);
- RINOK(extractCallback->OpenResult(archivePath, result));
- if (result != S_OK)
- continue;
-
- for (int v = 0; v < archiveLink.VolumePaths.Size(); v++)
- {
- int index = archivePathsFull.FindInSorted(archiveLink.VolumePaths[v]);
- if (index >= 0 && index > i)
- {
- archivePaths.Delete(index);
- archivePathsFull.Delete(index);
- }
- }
-
- #ifndef _NO_CRYPTO
- UString password;
- RINOK(openCallback->GetPasswordIfAny(password));
- if (!password.IsEmpty())
- {
- RINOK(extractCallback->SetPassword(password));
- }
- #endif
-
- options.DefaultItemName = archiveLink.GetDefaultItemName();
- RINOK(DecompressArchive(
- archiveLink.GetArchive(), archiveLink.GetDefaultItemName(),
- wildcardCensor, options, extractCallback, errorMessage));
- if (!errorMessage.IsEmpty())
- return E_FAIL;
- }
- return S_OK;
-}
diff --git a/7zip/UI/Common/IFileExtractCallback.h b/7zip/UI/Common/IFileExtractCallback.h
deleted file mode 100755
index 7db0af1f..00000000
--- a/7zip/UI/Common/IFileExtractCallback.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// IFileExtractCallback.h
-
-#ifndef __IFILEEXTRACTCALLBACK_H
-#define __IFILEEXTRACTCALLBACK_H
-
-#include "Common/String.h"
-
-namespace NOverwriteAnswer
-{
- enum EEnum
- {
- kYes,
- kYesToAll,
- kNo,
- kNoToAll,
- kAutoRename,
- kCancel,
- };
-}
-
-// {23170F69-40C1-278A-0000-000100070000}
-DEFINE_GUID(IID_IFolderArchiveExtractCallback,
-0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00);
-MIDL_INTERFACE("23170F69-40C1-278A-0000-000100070000")
-IFolderArchiveExtractCallback: public IProgress
-{
-public:
- STDMETHOD(AskOverwrite)(
- const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
- const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
- Int32 *answer) PURE;
- STDMETHOD(PrepareOperation)(const wchar_t *name, Int32 askExtractMode, const UInt64 *position) PURE;
- STDMETHOD(MessageError)(const wchar_t *message) PURE;
- STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted) PURE;
-};
-
-struct IExtractCallbackUI: IFolderArchiveExtractCallback
-{
- virtual HRESULT BeforeOpen(const wchar_t *name) = 0;
- virtual HRESULT OpenResult(const wchar_t *name, HRESULT result) = 0;
- virtual HRESULT ThereAreNoFiles() = 0;
- virtual HRESULT ExtractResult(HRESULT result) = 0;
- virtual HRESULT SetPassword(const UString &password) = 0;
-};
-
-#endif
diff --git a/7zip/UI/Common/OpenArchive.cpp b/7zip/UI/Common/OpenArchive.cpp
deleted file mode 100755
index 89deb434..00000000
--- a/7zip/UI/Common/OpenArchive.cpp
+++ /dev/null
@@ -1,522 +0,0 @@
-// OpenArchive.cpp
-
-#include "StdAfx.h"
-
-#include "OpenArchive.h"
-
-#include "Common/Wildcard.h"
-
-#include "Windows/FileName.h"
-#include "Windows/FileDir.h"
-#include "Windows/Defs.h"
-#include "Windows/PropVariant.h"
-
-#include "../../Common/FileStreams.h"
-#include "../../Common/StreamUtils.h"
-
-#include "Common/StringConvert.h"
-
-#ifdef FORMAT_7Z
-#include "../../Archive/7z/7zHandler.h"
-#endif
-
-#ifdef FORMAT_BZIP2
-#include "../../Archive/BZip2/BZip2Handler.h"
-#endif
-
-#ifdef FORMAT_GZIP
-#include "../../Archive/GZip/GZipHandler.h"
-#endif
-
-#ifdef FORMAT_SPLIT
-#include "../../Archive/Split/SplitHandler.h"
-#endif
-
-#ifdef FORMAT_TAR
-#include "../../Archive/Tar/TarHandler.h"
-#endif
-
-#ifdef FORMAT_ZIP
-#include "../../Archive/Zip/ZipHandler.h"
-#endif
-
-#ifdef FORMAT_Z
-#include "../../Archive/Z/ZHandler.h"
-#endif
-
-#ifndef EXCLUDE_COM
-#include "HandlerLoader.h"
-#endif
-
-#include "DefaultName.h"
-
-using namespace NWindows;
-
-HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, UString &result)
-{
- NCOM::CPropVariant prop;
- RINOK(archive->GetProperty(index, kpidPath, &prop));
- if(prop.vt == VT_BSTR)
- result = prop.bstrVal;
- else if (prop.vt == VT_EMPTY)
- result.Empty();
- else
- return E_FAIL;
- return S_OK;
-}
-
-HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, const UString &defaultName, UString &result)
-{
- RINOK(GetArchiveItemPath(archive, index, result));
- if (result.IsEmpty())
- result = defaultName;
- return S_OK;
-}
-
-HRESULT GetArchiveItemFileTime(IInArchive *archive, UInt32 index,
- const FILETIME &defaultFileTime, FILETIME &fileTime)
-{
- NCOM::CPropVariant prop;
- RINOK(archive->GetProperty(index, kpidLastWriteTime, &prop));
- if (prop.vt == VT_FILETIME)
- fileTime = prop.filetime;
- else if (prop.vt == VT_EMPTY)
- fileTime = defaultFileTime;
- else
- return E_FAIL;
- return S_OK;
-}
-
-static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result)
-{
- NCOM::CPropVariant prop;
- RINOK(archive->GetProperty(index, propID, &prop));
- if(prop.vt == VT_BOOL)
- result = VARIANT_BOOLToBool(prop.boolVal);
- else if (prop.vt == VT_EMPTY)
- result = false;
- else
- return E_FAIL;
- return S_OK;
-}
-
-HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result)
-{
- return IsArchiveItemProp(archive, index, kpidIsFolder, result);
-}
-
-HRESULT IsArchiveItemAnti(IInArchive *archive, UInt32 index, bool &result)
-{
- return IsArchiveItemProp(archive, index, kpidIsAnti, result);
-}
-
-// Static-SFX (for Linux) can be big.
-const UInt64 kMaxCheckStartPosition = 1 << 22;
-
-HRESULT ReOpenArchive(IInArchive *archive, const UString &fileName)
-{
- CInFileStream *inStreamSpec = new CInFileStream;
- CMyComPtr<IInStream> inStream(inStreamSpec);
- inStreamSpec->Open(fileName);
- return archive->Open(inStream, &kMaxCheckStartPosition, NULL);
-}
-
-#ifndef _SFX
-static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size)
-{
- for (size_t i = 0; i < size; i++)
- if (p1[i] != p2[i])
- return false;
- return true;
-}
-#endif
-
-HRESULT OpenArchive(
- IInStream *inStream,
- const UString &fileName,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
- IInArchive **archiveResult,
- CArchiverInfo &archiverInfoResult,
- UString &defaultItemName,
- IArchiveOpenCallback *openArchiveCallback)
-{
- *archiveResult = NULL;
- CObjectVector<CArchiverInfo> archiverInfoList;
- ReadArchiverInfoList(archiverInfoList);
- UString extension;
- {
- int dotPos = fileName.ReverseFind(L'.');
- if (dotPos >= 0)
- extension = fileName.Mid(dotPos + 1);
- }
- CIntVector orderIndices;
- int i;
- bool finded = false;
- for(i = 0; i < archiverInfoList.Size(); i++)
- {
- if (archiverInfoList[i].FindExtension(extension) >= 0)
- {
- orderIndices.Insert(0, i);
- finded = true;
- }
- else
- orderIndices.Add(i);
- }
-
- #ifndef _SFX
- if (!finded)
- {
- CByteBuffer byteBuffer;
- const UInt32 kBufferSize = (200 << 10);
- byteBuffer.SetCapacity(kBufferSize);
- Byte *buffer = byteBuffer;
- RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
- UInt32 processedSize;
- RINOK(ReadStream(inStream, buffer, kBufferSize, &processedSize));
- int numFinded = 0;
- for (int pos = (int)processedSize; pos >= 0 ; pos--)
- {
- for(int i = numFinded; i < orderIndices.Size(); i++)
- {
- int index = orderIndices[i];
- const CArchiverInfo &ai = archiverInfoList[index];
- const CByteBuffer &sig = ai.StartSignature;
- if (sig.GetCapacity() == 0)
- continue;
- if (pos + sig.GetCapacity() > processedSize)
- continue;
- if (TestSignature(buffer + pos, sig, sig.GetCapacity()))
- {
- orderIndices.Delete(i);
- orderIndices.Insert(0, index);
- numFinded++;
- }
- }
- }
- }
- #endif
-
- HRESULT badResult = S_OK;
- for(i = 0; i < orderIndices.Size(); i++)
- {
- inStream->Seek(0, STREAM_SEEK_SET, NULL);
- const CArchiverInfo &archiverInfo = archiverInfoList[orderIndices[i]];
- #ifndef EXCLUDE_COM
- CHandlerLoader loader;
- #endif
- CMyComPtr<IInArchive> archive;
-
- #ifdef FORMAT_7Z
- if (archiverInfo.Name.CompareNoCase(L"7z") == 0)
- archive = new NArchive::N7z::CHandler;
- #endif
-
- #ifdef FORMAT_BZIP2
- if (archiverInfo.Name.CompareNoCase(L"BZip2") == 0)
- archive = new NArchive::NBZip2::CHandler;
- #endif
-
- #ifdef FORMAT_GZIP
- if (archiverInfo.Name.CompareNoCase(L"GZip") == 0)
- archive = new NArchive::NGZip::CHandler;
- #endif
-
- #ifdef FORMAT_SPLIT
- if (archiverInfo.Name.CompareNoCase(L"Split") == 0)
- archive = new NArchive::NSplit::CHandler;
- #endif
-
- #ifdef FORMAT_TAR
- if (archiverInfo.Name.CompareNoCase(L"Tar") == 0)
- archive = new NArchive::NTar::CHandler;
- #endif
-
- #ifdef FORMAT_ZIP
- if (archiverInfo.Name.CompareNoCase(L"Zip") == 0)
- archive = new NArchive::NZip::CHandler;
- #endif
-
- #ifdef FORMAT_Z
- if (archiverInfo.Name.CompareNoCase(L"Z") == 0)
- archive = new NArchive::NZ::CHandler;
- #endif
-
-
- #ifndef EXCLUDE_COM
- if (!archive)
- {
- HRESULT result = loader.CreateHandler(archiverInfo.FilePath,
- archiverInfo.ClassID, (void **)&archive, false);
- if (result != S_OK)
- continue;
- }
- #endif
-
- if (!archive)
- return E_FAIL;
-
- HRESULT result = archive->Open(inStream, &kMaxCheckStartPosition, openArchiveCallback);
- if(result == S_FALSE)
- continue;
- if(result != S_OK)
- {
- badResult = result;
- if(result == E_ABORT)
- break;
- continue;
- }
- *archiveResult = archive.Detach();
- #ifndef EXCLUDE_COM
- *module = loader.Detach();
- #endif
- archiverInfoResult = archiverInfo;
- int subExtIndex = archiverInfo.FindExtension(extension);
- if (subExtIndex < 0)
- subExtIndex = 0;
- defaultItemName = GetDefaultName2(fileName,
- archiverInfo.Extensions[subExtIndex].Ext,
- archiverInfo.Extensions[subExtIndex].AddExt);
-
- return S_OK;
- }
- if (badResult != S_OK)
- return badResult;
- return S_FALSE;
-}
-
-HRESULT OpenArchive(const UString &filePath,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
- IInArchive **archiveResult,
- CArchiverInfo &archiverInfo,
- UString &defaultItemName,
- IArchiveOpenCallback *openArchiveCallback)
-{
- CInFileStream *inStreamSpec = new CInFileStream;
- CMyComPtr<IInStream> inStream(inStreamSpec);
- if (!inStreamSpec->Open(filePath))
- return GetLastError();
- return OpenArchive(inStream, ExtractFileNameFromPath(filePath),
- #ifndef EXCLUDE_COM
- module,
- #endif
- archiveResult, archiverInfo,
- defaultItemName, openArchiveCallback);
-}
-
-static void MakeDefaultName(UString &name)
-{
- int dotPos = name.ReverseFind(L'.');
- if (dotPos < 0)
- return;
- UString ext = name.Mid(dotPos + 1);
- if (ext.IsEmpty())
- return;
- for (int pos = 0; pos < ext.Length(); pos++)
- if (ext[pos] < L'0' || ext[pos] > L'9')
- return;
- name = name.Left(dotPos);
-}
-
-HRESULT OpenArchive(const UString &fileName,
- #ifndef EXCLUDE_COM
- HMODULE *module0,
- HMODULE *module1,
- #endif
- IInArchive **archive0,
- IInArchive **archive1,
- CArchiverInfo &archiverInfo0,
- CArchiverInfo &archiverInfo1,
- UString &defaultItemName0,
- UString &defaultItemName1,
- IArchiveOpenCallback *openArchiveCallback)
-{
- HRESULT result = OpenArchive(fileName,
- #ifndef EXCLUDE_COM
- module0,
- #endif
- archive0, archiverInfo0, defaultItemName0, openArchiveCallback);
- RINOK(result);
- CMyComPtr<IInArchiveGetStream> getStream;
- result = (*archive0)->QueryInterface(IID_IInArchiveGetStream, (void **)&getStream);
- if (result != S_OK || getStream == 0)
- return S_OK;
-
- CMyComPtr<ISequentialInStream> subSeqStream;
- result = getStream->GetStream(0, &subSeqStream);
- if (result != S_OK)
- return S_OK;
-
- CMyComPtr<IInStream> subStream;
- if (subSeqStream.QueryInterface(IID_IInStream, &subStream) != S_OK)
- return S_OK;
- if (!subStream)
- return S_OK;
-
- UInt32 numItems;
- RINOK((*archive0)->GetNumberOfItems(&numItems));
- if (numItems < 1)
- return S_OK;
-
- UString subPath;
- RINOK(GetArchiveItemPath(*archive0, 0, subPath))
- if (subPath.IsEmpty())
- {
- MakeDefaultName(defaultItemName0);
- subPath = defaultItemName0;
- if (archiverInfo0.Name.CompareNoCase(L"7z") == 0)
- {
- if (subPath.Right(3).CompareNoCase(L".7z") != 0)
- subPath += L".7z";
- }
- }
- else
- subPath = ExtractFileNameFromPath(subPath);
-
- CMyComPtr<IArchiveOpenSetSubArchiveName> setSubArchiveName;
- openArchiveCallback->QueryInterface(IID_IArchiveOpenSetSubArchiveName, (void **)&setSubArchiveName);
- if (setSubArchiveName)
- setSubArchiveName->SetSubArchiveName(subPath);
-
- result = OpenArchive(subStream, subPath,
- #ifndef EXCLUDE_COM
- module1,
- #endif
- archive1, archiverInfo1, defaultItemName1, openArchiveCallback);
- return S_OK;
-}
-
-HRESULT MyOpenArchive(const UString &archiveName,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
- IInArchive **archive,
- UString &defaultItemName,
- IOpenCallbackUI *openCallbackUI)
-{
- COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
- CMyComPtr<IArchiveOpenCallback> openCallback = openCallbackSpec;
- openCallbackSpec->Callback = openCallbackUI;
-
- UString fullName;
- int fileNamePartStartIndex;
- NFile::NDirectory::MyGetFullPathName(archiveName, fullName, fileNamePartStartIndex);
- openCallbackSpec->Init(
- fullName.Left(fileNamePartStartIndex),
- fullName.Mid(fileNamePartStartIndex));
-
- CArchiverInfo archiverInfo;
- return OpenArchive(archiveName,
- #ifndef EXCLUDE_COM
- module,
- #endif
- archive,
- archiverInfo,
- defaultItemName,
- openCallback);
-}
-
-HRESULT MyOpenArchive(const UString &archiveName,
- #ifndef EXCLUDE_COM
- HMODULE *module0,
- HMODULE *module1,
- #endif
- IInArchive **archive0,
- IInArchive **archive1,
- UString &defaultItemName0,
- UString &defaultItemName1,
- UStringVector &volumePaths,
- IOpenCallbackUI *openCallbackUI)
-{
- COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
- CMyComPtr<IArchiveOpenCallback> openCallback = openCallbackSpec;
- openCallbackSpec->Callback = openCallbackUI;
-
- UString fullName;
- int fileNamePartStartIndex;
- NFile::NDirectory::MyGetFullPathName(archiveName, fullName, fileNamePartStartIndex);
- UString prefix = fullName.Left(fileNamePartStartIndex);
- UString name = fullName.Mid(fileNamePartStartIndex);
- openCallbackSpec->Init(prefix, name);
-
- CArchiverInfo archiverInfo0, archiverInfo1;
- HRESULT result = OpenArchive(archiveName,
- #ifndef EXCLUDE_COM
- module0,
- module1,
- #endif
- archive0,
- archive1,
- archiverInfo0,
- archiverInfo1,
- defaultItemName0,
- defaultItemName1,
- openCallback);
- RINOK(result);
- volumePaths.Add(prefix + name);
- for (int i = 0; i < openCallbackSpec->FileNames.Size(); i++)
- volumePaths.Add(prefix + openCallbackSpec->FileNames[i]);
- return S_OK;
-}
-
-HRESULT CArchiveLink::Close()
-{
- if (Archive1 != 0)
- RINOK(Archive1->Close());
- if (Archive0 != 0)
- RINOK(Archive0->Close());
- return S_OK;
-}
-
-void CArchiveLink::Release()
-{
- if (Archive1 != 0)
- Archive1.Release();
- if (Archive0 != 0)
- Archive0.Release();
- #ifndef EXCLUDE_COM
- Library1.Free();
- Library0.Free();
- #endif
-}
-
-HRESULT OpenArchive(const UString &archiveName,
- CArchiveLink &archiveLink,
- IArchiveOpenCallback *openCallback)
-{
- return OpenArchive(archiveName,
- #ifndef EXCLUDE_COM
- &archiveLink.Library0, &archiveLink.Library1,
- #endif
- &archiveLink.Archive0, &archiveLink.Archive1,
- archiveLink.ArchiverInfo0, archiveLink.ArchiverInfo1,
- archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
- openCallback);
-}
-
-HRESULT MyOpenArchive(const UString &archiveName,
- CArchiveLink &archiveLink,
- IOpenCallbackUI *openCallbackUI)
-{
- return MyOpenArchive(archiveName,
- #ifndef EXCLUDE_COM
- &archiveLink.Library0, &archiveLink.Library1,
- #endif
- &archiveLink.Archive0, &archiveLink.Archive1,
- archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
- archiveLink.VolumePaths,
- openCallbackUI);
-}
-
-HRESULT ReOpenArchive(CArchiveLink &archiveLink,
- const UString &fileName)
-{
- if (archiveLink.GetNumLevels() > 1)
- return E_NOTIMPL;
- if (archiveLink.GetNumLevels() == 0)
- return MyOpenArchive(fileName, archiveLink, 0);
- return ReOpenArchive(archiveLink.GetArchive(), fileName);
-}
diff --git a/7zip/UI/Common/SortUtils.cpp b/7zip/UI/Common/SortUtils.cpp
deleted file mode 100755
index 8c953750..00000000
--- a/7zip/UI/Common/SortUtils.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// SortUtils.cpp
-
-#include "StdAfx.h"
-
-#include "SortUtils.h"
-
-static int CompareStrings(const int *p1, const int *p2, void *param)
-{
- const UStringVector &strings = *(const UStringVector *)param;
- const UString &s1 = strings[*p1];
- const UString &s2 = strings[*p2];
- return s1.CompareNoCase(s2);
-}
-
-void SortStringsToIndices(const UStringVector &strings, CIntVector &indices)
-{
- indices.Clear();
- int numItems = strings.Size();
- indices.Reserve(numItems);
- for(int i = 0; i < numItems; i++)
- indices.Add(i);
- indices.Sort(CompareStrings, (void *)&strings);
-}
-
-void SortStrings(const UStringVector &src, UStringVector &dest)
-{
- CIntVector indices;
- SortStringsToIndices(src, indices);
- dest.Clear();
- dest.Reserve(indices.Size());
- for (int i = 0; i < indices.Size(); i++)
- dest.Add(src[indices[i]]);
-}
diff --git a/7zip/UI/Console/ExtractCallbackConsole.cpp b/7zip/UI/Console/ExtractCallbackConsole.cpp
deleted file mode 100755
index 13aee7c8..00000000
--- a/7zip/UI/Console/ExtractCallbackConsole.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-// ExtractCallbackConsole.h
-
-#include "StdAfx.h"
-
-#include "ExtractCallbackConsole.h"
-#include "UserInputUtils.h"
-#include "ConsoleClose.h"
-
-#include "Common/Wildcard.h"
-
-#include "Windows/FileDir.h"
-#include "Windows/FileFind.h"
-#include "Windows/Time.h"
-#include "Windows/Defs.h"
-#include "Windows/PropVariant.h"
-#include "Windows/Error.h"
-#include "Windows/PropVariantConversions.h"
-
-#include "../../Common/FilePathAutoRename.h"
-
-#include "../Common/ExtractingFilePath.h"
-
-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 *kCantAutoRename = "can not create file with auto name\n";
-static const char *kCantRenameFile = "can not rename existing file\n";
-static const char *kCantDeleteOutputFile = "can not delete output file ";
-static const char *kError = "ERROR: ";
-static const char *kMemoryExceptionMessage = "Can't allocate required memory!";
-
-static const char *kProcessing = "Processing archive: ";
-static const char *kEverythingIsOk = "Everything is Ok";
-static const char *kNoFiles = "No files to process";
-
-static const char *kUnsupportedMethod = "Unsupported Method";
-static const char *kCrcFailed = "CRC Failed";
-static const char *kCrcFailedEncrypted = "CRC Failed in encrypted file. Wrong password?";
-static const char *kDataError = "Data Error";
-static const char *kDataErrorEncrypted = "Data Error in encrypted file. Wrong password?";
-static const char *kUnknownError = "Unknown Error";
-
-STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64)
-{
- if (NConsoleClose::TestBreakSignal())
- return E_ABORT;
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *)
-{
- if (NConsoleClose::TestBreakSignal())
- return E_ABORT;
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
- const wchar_t *existName, const FILETIME *, const UInt64 *,
- const wchar_t *newName, const FILETIME *, const UInt64 *,
- Int32 *answer)
-{
- (*OutStream) << "file " << existName <<
- "\nalready exists. Overwrite with " << endl;
- (*OutStream) << newName;
-
- NUserAnswerMode::EEnum overwriteAnswer = ScanUserYesNoAllQuit(OutStream);
-
- 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;
- }
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 askExtractMode, const UInt64 *position)
-{
- 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;
- };
- (*OutStream) << name;
- if (position != 0)
- (*OutStream) << " <" << *position << ">";
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
-{
- (*OutStream) << message << endl;
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 operationResult, bool encrypted)
-{
- switch(operationResult)
- {
- case NArchive::NExtract::NOperationResult::kOK:
- break;
- default:
- {
- NumFileErrorsInCurrentArchive++;
- NumFileErrors++;
- (*OutStream) << " ";
- switch(operationResult)
- {
- case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
- (*OutStream) << kUnsupportedMethod;
- break;
- case NArchive::NExtract::NOperationResult::kCRCError:
- (*OutStream) << (encrypted ? kCrcFailedEncrypted: kCrcFailed);
- break;
- case NArchive::NExtract::NOperationResult::kDataError:
- (*OutStream) << (encrypted ? kDataErrorEncrypted : kDataError);
- break;
- default:
- (*OutStream) << kUnknownError;
- }
- }
- }
- (*OutStream) << endl;
- return S_OK;
-}
-
-STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
-{
- if (!PasswordIsDefined)
- {
- Password = GetPassword(OutStream);
- PasswordIsDefined = true;
- }
- CMyComBSTR tempName(Password);
- *password = tempName.Detach();
- return S_OK;
-}
-
-HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name)
-{
- NumArchives++;
- NumFileErrorsInCurrentArchive = 0;
- (*OutStream) << endl << kProcessing << name << endl;
- return S_OK;
-}
-
-HRESULT CExtractCallbackConsole::OpenResult(const wchar_t *name, HRESULT result)
-{
- (*OutStream) << endl;
- if (result != S_OK)
- {
- (*OutStream) << "Error: " << name << " is not supported archive" << endl;
- NumArchiveErrors++;
- }
- return S_OK;
-}
-
-HRESULT CExtractCallbackConsole::ThereAreNoFiles()
-{
- (*OutStream) << endl << kNoFiles << endl;
- return S_OK;
-}
-
-HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
-{
- if (result == S_OK)
- {
- (*OutStream) << endl;
- if (NumFileErrorsInCurrentArchive == 0)
- (*OutStream) << kEverythingIsOk << endl;
- else
- {
- NumArchiveErrors++;
- (*OutStream) << "Sub items Errors: " << NumFileErrorsInCurrentArchive << endl;
- }
- }
- if (result == S_OK)
- return result;
- NumArchiveErrors++;
- if (result == E_ABORT || result == ERROR_DISK_FULL)
- return result;
- (*OutStream) << endl << kError;
- if (result == E_OUTOFMEMORY)
- (*OutStream) << kMemoryExceptionMessage;
- else
- {
- UString message;
- NError::MyFormatMessage(result, message);
- (*OutStream) << message;
- }
- (*OutStream) << endl;
- return S_OK;
-}
-
-HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
-{
- PasswordIsDefined = true;
- Password = password;
- return S_OK;
-}
diff --git a/7zip/UI/Console/ExtractCallbackConsole.h b/7zip/UI/Console/ExtractCallbackConsole.h
deleted file mode 100755
index fdcdfbd9..00000000
--- a/7zip/UI/Console/ExtractCallbackConsole.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// ExtractCallbackConsole.h
-
-#ifndef __EXTRACTCALLBACKCONSOLE_H
-#define __EXTRACTCALLBACKCONSOLE_H
-
-#include "Common/String.h"
-#include "Common/StdOutStream.h"
-#include "../../Common/FileStreams.h"
-#include "../../IPassword.h"
-#include "../../Archive/IArchive.h"
-#include "../Common/ArchiveExtractCallback.h"
-
-class CExtractCallbackConsole:
- public IExtractCallbackUI,
- public ICryptoGetTextPassword,
- public CMyUnknownImp
-{
-public:
- MY_UNKNOWN_IMP2(IFolderArchiveExtractCallback, ICryptoGetTextPassword)
-
- STDMETHOD(SetTotal)(UInt64 total);
- STDMETHOD(SetCompleted)(const UInt64 *completeValue);
-
- // IFolderArchiveExtractCallback
- STDMETHOD(AskOverwrite)(
- const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
- const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
- Int32 *answer);
- STDMETHOD (PrepareOperation)(const wchar_t *name, Int32 askExtractMode, const UInt64 *position);
-
- 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);
- HRESULT ThereAreNoFiles();
- HRESULT ExtractResult(HRESULT result);
-
- HRESULT SetPassword(const UString &password);
-
-public:
- bool PasswordIsDefined;
- UString Password;
-
- UInt64 NumArchives;
- UInt64 NumArchiveErrors;
- UInt64 NumFileErrors;
- UInt64 NumFileErrorsInCurrentArchive;
-
- CStdOutStream *OutStream;
-
- void Init()
- {
- NumArchives = 0;
- NumArchiveErrors = 0;
- NumFileErrors = 0;
- NumFileErrorsInCurrentArchive = 0;
- }
-
-};
-
-#endif
diff --git a/7zip/UI/Console/Main.cpp b/7zip/UI/Console/Main.cpp
deleted file mode 100755
index f844be5a..00000000
--- a/7zip/UI/Console/Main.cpp
+++ /dev/null
@@ -1,369 +0,0 @@
-// Main.cpp
-
-#include "StdAfx.h"
-
-#include <io.h>
-
-#include "Common/MyInitGuid.h"
-#include "Common/CommandLineParser.h"
-#include "Common/StdOutStream.h"
-#include "Common/Wildcard.h"
-#include "Common/ListFileUtils.h"
-#include "Common/StringConvert.h"
-#include "Common/StdInStream.h"
-#include "Common/StringToInt.h"
-#include "Common/Exception.h"
-
-#include "Windows/FileDir.h"
-#include "Windows/FileName.h"
-#include "Windows/Defs.h"
-#include "Windows/Error.h"
-// #include "Windows/System.h"
-#ifdef _WIN32
-#include "Windows/MemoryLock.h"
-#endif
-
-#include "../../IPassword.h"
-#include "../../ICoder.h"
-#include "../../Compress/LZ/IMatchFinder.h"
-#include "../Common/ArchiverInfo.h"
-#include "../Common/UpdateAction.h"
-#include "../Common/Update.h"
-#include "../Common/Extract.h"
-#include "../Common/ArchiveCommandLine.h"
-#include "../Common/ExitCode.h"
-
-#include "List.h"
-#include "OpenCallbackConsole.h"
-#include "ExtractCallbackConsole.h"
-#include "UpdateCallbackConsole.h"
-
-#include "../../MyVersion.h"
-
-#ifndef EXCLUDE_COM
-#include "Windows/DLL.h"
-#endif
-
-using namespace NWindows;
-using namespace NFile;
-using namespace NCommandLineParser;
-
-HINSTANCE g_hInstance = 0;
-extern CStdOutStream *g_StdStream;
-
-static const char *kCopyrightString = "\n7-Zip"
-#ifdef EXCLUDE_COM
-" (A)"
-#endif
-
-#ifdef UNICODE
-" [NT]"
-#endif
-
-" " MY_VERSION_COPYRIGHT_DATE "\n";
-
-static const char *kHelpString =
- "\nUsage: 7z"
-#ifdef _NO_CRYPTO
- "r"
-#elif EXCLUDE_COM
- "a"
-#endif
- " <command> [<switches>...] <archive_name> [<file_names>...]\n"
- " [<@listfiles...>]\n"
- "\n"
- "<Commands>\n"
- " a: Add files to archive\n"
- " d: Delete files from archive\n"
- " e: Extract files from archive (without using directory names)\n"
- " l: List contents of archive\n"
-// " l[a|t][f]: List contents of archive\n"
-// " a - with Additional fields\n"
-// " t - with all fields\n"
-// " f - with Full pathnames\n"
- " t: Test integrity of archive\n"
- " u: Update files to archive\n"
- " x: eXtract files with full paths\n"
- "<Switches>\n"
- " -ai[r[-|0]]{@listfile|!wildcard}: Include archives\n"
- " -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives\n"
- " -bd: Disable percentage indicator\n"
- " -i[r[-|0]]{@listfile|!wildcard}: Include filenames\n"
- " -m{Parameters}: set compression Method\n"
- " -o{Directory}: set Output directory\n"
- " -p{Password}: set Password\n"
- " -r[-|0]: Recurse subdirectories\n"
- " -scs{UTF-8 | WIN | DOS}: set charset for list files\n"
- " -sfx[{name}]: Create SFX archive\n"
- " -si[{name}]: read data from stdin\n"
- " -slt: show technical information for l (List) command\n"
- " -so: write data to stdout\n"
- " -t{Type}: Set type of archive\n"
- " -v{Size}[b|k|m|g]: Create volumes\n"
- " -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options\n"
- " -w[{path}]: assign Work directory. Empty path means a temporary directory\n"
- " -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames\n"
- " -y: assume Yes on all queries\n";
-
-// ---------------------------
-// exception messages
-
-static const char *kProcessArchiveMessage = " archive: ";
-static const char *kEverythingIsOk = "Everything is Ok";
-static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode::kUserError
-
-static const wchar_t *kDefaultSfxModule = L"7zCon.sfx";
-
-static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExitCode::EEnum code)
-{
- s << message << endl;
- throw code;
-}
-
-static void PrintHelpAndExit(CStdOutStream &s) // yyy
-{
- s << kHelpString;
- ShowMessageAndThrowException(s, kUserErrorMessage, NExitCode::kUserError);
-}
-
-#ifndef _WIN32
-static void GetArguments(int numArguments, const char *arguments[], UStringVector &parts)
-{
- parts.Clear();
- for(int i = 0; i < numArguments; i++)
- {
- UString s = MultiByteToUnicodeString(arguments[i]);
- parts.Add(s);
- }
-}
-#endif
-
-static void ShowCopyrightAndHelp(CStdOutStream &s, bool needHelp)
-{
- s << kCopyrightString;
- /*
- UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
- s << "System configuration: " << (UInt64)numCPUs << " CPU";
- if (numCPUs > 1)
- s << "s";
- s << "\n";
- */
- if (needHelp)
- s << kHelpString;
-}
-
-int Main2(
- #ifndef _WIN32
- int numArguments, const char *arguments[]
- #endif
-)
-{
- #ifdef _WIN32
- SetFileApisToOEM();
- #endif
-
- UStringVector commandStrings;
- #ifdef _WIN32
- NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
- #else
- GetArguments(numArguments, arguments, commandStrings);
- #endif
-
- if(commandStrings.Size() == 1)
- {
- ShowCopyrightAndHelp(g_StdOut, true);
- return 0;
- }
- commandStrings.Delete(0);
-
- CArchiveCommandLineOptions options;
-
- CArchiveCommandLineParser parser;
-
- parser.Parse1(commandStrings, options);
-
- if(options.HelpMode)
- {
- ShowCopyrightAndHelp(g_StdOut, true);
- return 0;
- }
-
- #ifdef _WIN32
- if (options.LargePages)
- NSecurity::EnableLockMemoryPrivilege();
- #endif
-
- CStdOutStream &stdStream = options.StdOutMode ? g_StdErr : g_StdOut;
- g_StdStream = &stdStream;
-
- if (options.EnableHeaders)
- ShowCopyrightAndHelp(stdStream, false);
-
- parser.Parse2(options);
-
- bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
- if(isExtractGroupCommand ||
- options.Command.CommandType == NCommandType::kList)
- {
- if(isExtractGroupCommand)
- {
- CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
- CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
-
- ecs->OutStream = &stdStream;
- ecs->PasswordIsDefined = options.PasswordEnabled;
- ecs->Password = options.Password;
- ecs->Init();
-
- COpenCallbackConsole openCallback;
- openCallback.OutStream = &stdStream;
- openCallback.PasswordIsDefined = options.PasswordEnabled;
- openCallback.Password = options.Password;
-
- CExtractOptions eo;
- eo.StdOutMode = options.StdOutMode;
- eo.PathMode = options.Command.GetPathMode();
- eo.TestMode = options.Command.IsTestMode();
- eo.OverwriteMode = options.OverwriteMode;
- eo.OutputDir = options.OutputDir;
- eo.YesToAll = options.YesToAll;
- #ifdef COMPRESS_MT
- eo.Properties = options.ExtractProperties;
- #endif
- UString errorMessage;
- HRESULT result = DecompressArchives(
- options.ArchivePathsSorted,
- options.ArchivePathsFullSorted,
- options.WildcardCensor.Pairs.Front().Head,
- eo, &openCallback, ecs, errorMessage);
- if (!errorMessage.IsEmpty())
- {
- stdStream << endl << "Error: " << errorMessage;
- if (result == S_OK)
- result = E_FAIL;
- }
-
- if (ecs->NumArchives > 1)
- {
- stdStream << endl << endl << "Total:" << endl;
- stdStream << "Archives: " << ecs->NumArchives << endl;
- }
- if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
- {
- if (ecs->NumArchives > 1)
- {
- if (ecs->NumArchiveErrors != 0)
- stdStream << "Archive Errors: " << ecs->NumArchiveErrors << endl;
- if (ecs->NumFileErrors != 0)
- stdStream << "Sub items Errors: " << ecs->NumFileErrors << endl;
- }
- if (result != S_OK)
- throw CSystemException(result);
- return NExitCode::kFatalError;
- }
- if (result != S_OK)
- throw CSystemException(result);
- }
- else
- {
- HRESULT result = ListArchives(
- options.ArchivePathsSorted,
- options.ArchivePathsFullSorted,
- options.WildcardCensor.Pairs.Front().Head,
- options.EnableHeaders,
- options.TechMode,
- options.PasswordEnabled,
- options.Password);
- if (result != S_OK)
- throw CSystemException(result);
- }
- }
- else if(options.Command.IsFromUpdateGroup())
- {
- UString workingDir;
-
- CUpdateOptions &uo = options.UpdateOptions;
- if (uo.SfxMode && uo.SfxModule.IsEmpty())
- uo.SfxModule = kDefaultSfxModule;
-
- bool passwordIsDefined =
- options.PasswordEnabled && !options.Password.IsEmpty();
-
- COpenCallbackConsole openCallback;
- openCallback.OutStream = &stdStream;
- openCallback.PasswordIsDefined = passwordIsDefined;
- openCallback.Password = options.Password;
-
- CUpdateCallbackConsole callback;
- callback.EnablePercents = options.EnablePercents;
- callback.PasswordIsDefined = passwordIsDefined;
- callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
- callback.Password = options.Password;
- callback.StdOutMode = uo.StdOutMode;
- callback.Init(&stdStream);
-
- CUpdateErrorInfo errorInfo;
-
- HRESULT result = UpdateArchive(options.WildcardCensor, uo,
- errorInfo, &openCallback, &callback);
-
- int exitCode = NExitCode::kSuccess;
- if (callback.CantFindFiles.Size() > 0)
- {
- stdStream << endl;
- stdStream << "WARNINGS for files:" << endl << endl;
- int numErrors = callback.CantFindFiles.Size();
- for (int i = 0; i < numErrors; i++)
- {
- stdStream << callback.CantFindFiles[i] << " : ";
- stdStream << NError::MyFormatMessageW(callback.CantFindCodes[i]) << endl;
- }
- stdStream << "----------------" << endl;
- stdStream << "WARNING: Cannot find " << numErrors << " file";
- if (numErrors > 1)
- stdStream << "s";
- stdStream << endl;
- exitCode = NExitCode::kWarning;
- }
-
- if (result != S_OK)
- {
- stdStream << "\nError:\n";
- if (!errorInfo.Message.IsEmpty())
- stdStream << errorInfo.Message << endl;
- if (!errorInfo.FileName.IsEmpty())
- stdStream << errorInfo.FileName << endl;
- if (!errorInfo.FileName2.IsEmpty())
- stdStream << errorInfo.FileName2 << endl;
- if (errorInfo.SystemError != 0)
- stdStream << NError::MyFormatMessageW(errorInfo.SystemError) << endl;
- throw CSystemException(result);
- }
- int numErrors = callback.FailedFiles.Size();
- if (numErrors == 0)
- {
- if (callback.CantFindFiles.Size() == 0)
- stdStream << kEverythingIsOk << endl;
- }
- else
- {
- stdStream << endl;
- stdStream << "WARNINGS for files:" << endl << endl;
- for (int i = 0; i < numErrors; i++)
- {
- stdStream << callback.FailedFiles[i] << " : ";
- stdStream << NError::MyFormatMessageW(callback.FailedCodes[i]) << endl;
- }
- stdStream << "----------------" << endl;
- stdStream << "WARNING: Cannot open " << numErrors << " file";
- if (numErrors > 1)
- stdStream << "s";
- stdStream << endl;
- exitCode = NExitCode::kWarning;
- }
- return exitCode;
- }
- else
- PrintHelpAndExit(stdStream);
- return 0;
-}
diff --git a/7zip/UI/Console/MainAr.cpp b/7zip/UI/Console/MainAr.cpp
deleted file mode 100755
index 35272a35..00000000
--- a/7zip/UI/Console/MainAr.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-// MainAr.cpp
-
-#include "StdAfx.h"
-
-// #include <locale.h>
-
-#include "Windows/Error.h"
-
-#include "Common/StdOutStream.h"
-#include "Common/NewHandler.h"
-#include "Common/Exception.h"
-#include "Common/StringConvert.h"
-#ifdef _WIN32
-#include "Common/Alloc.h"
-#endif
-
-#include "../Common/ExitCode.h"
-#include "../Common/ArchiveCommandLine.h"
-#include "ConsoleClose.h"
-
-using namespace NWindows;
-
-CStdOutStream *g_StdStream = 0;
-
-#ifndef _UNICODE
-bool g_IsNT = false;
-#endif
-
-extern int Main2(
- #ifndef _WIN32
- int numArguments, const char *arguments[]
- #endif
-);
-
-static const char *kExceptionErrorMessage = "\n\nError:\n";
-static const char *kUserBreak = "\nBreak signaled\n";
-
-static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required memory!\n";
-static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n";
-static const char *kInternalExceptionMessage = "\n\nInternal Error #";
-
-static inline bool IsItWindowsNT()
-{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
-}
-
-int
-#ifdef _MSC_VER
-__cdecl
-#endif
-main
-(
-#ifndef _WIN32
-int numArguments, const char *arguments[]
-#endif
-)
-{
- g_StdStream = &g_StdOut;
- #ifdef _UNICODE
- if (!IsItWindowsNT())
- {
- (*g_StdStream) << "This program requires Windows NT/2000/XP/2003";
- return NExitCode::kFatalError;
- }
- #else
- g_IsNT = IsItWindowsNT();
- #endif
-
- #ifdef _WIN32
- SetLargePageSize();
- #endif
-
- // setlocale(LC_COLLATE, ".OCP");
- NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
- int res = 0;
- try
- {
- res = Main2(
-#ifndef _WIN32
- numArguments, arguments
-#endif
- );
- }
- catch(const CNewException &)
- {
- (*g_StdStream) << kMemoryExceptionMessage;
- return (NExitCode::kMemoryError);
- }
- catch(const NConsoleClose::CCtrlBreakException &)
- {
- (*g_StdStream) << endl << kUserBreak;
- return (NExitCode::kUserBreak);
- }
- catch(const CArchiveCommandLineException &e)
- {
- (*g_StdStream) << kExceptionErrorMessage << e << endl;
- return (NExitCode::kUserError);
- }
- catch(const CSystemException &systemError)
- {
- if (systemError.ErrorCode == E_OUTOFMEMORY)
- {
- (*g_StdStream) << kMemoryExceptionMessage;
- return (NExitCode::kMemoryError);
- }
- if (systemError.ErrorCode == E_ABORT)
- {
- (*g_StdStream) << endl << kUserBreak;
- return (NExitCode::kUserBreak);
- }
- UString message;
- NError::MyFormatMessage(systemError.ErrorCode, message);
- (*g_StdStream) << endl << endl << "System error:" << endl <<
- message << endl;
- return (NExitCode::kFatalError);
- }
- catch(NExitCode::EEnum &exitCode)
- {
- (*g_StdStream) << kInternalExceptionMessage << exitCode << endl;
- return (exitCode);
- }
- /*
- catch(const NExitCode::CMultipleErrors &multipleErrors)
- {
- (*g_StdStream) << endl << multipleErrors.NumErrors << " errors" << endl;
- return (NExitCode::kFatalError);
- }
- */
- catch(const UString &s)
- {
- (*g_StdStream) << kExceptionErrorMessage << s << endl;
- return (NExitCode::kFatalError);
- }
- catch(const AString &s)
- {
- (*g_StdStream) << kExceptionErrorMessage << s << endl;
- return (NExitCode::kFatalError);
- }
- catch(const char *s)
- {
- (*g_StdStream) << kExceptionErrorMessage << s << endl;
- return (NExitCode::kFatalError);
- }
- catch(int t)
- {
- (*g_StdStream) << kInternalExceptionMessage << t << endl;
- return (NExitCode::kFatalError);
- }
- catch(...)
- {
- (*g_StdStream) << kUnknownExceptionMessage;
- return (NExitCode::kFatalError);
- }
- return res;
-}
diff --git a/7zip/UI/Console/OpenCallbackConsole.cpp b/7zip/UI/Console/OpenCallbackConsole.cpp
deleted file mode 100755
index 21c5391c..00000000
--- a/7zip/UI/Console/OpenCallbackConsole.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-// OpenCallbackConsole.cpp
-
-#include "StdAfx.h"
-
-#include "OpenCallbackConsole.h"
-
-#include "ConsoleClose.h"
-#include "UserInputUtils.h"
-
-HRESULT COpenCallbackConsole::CheckBreak()
-{
- if (NConsoleClose::TestBreakSignal())
- return E_ABORT;
- return S_OK;
-}
-
-HRESULT COpenCallbackConsole::SetTotal(const UInt64 *, const UInt64 *)
-{
- return CheckBreak();
-}
-
-HRESULT COpenCallbackConsole::SetCompleted(const UInt64 *, const UInt64 *)
-{
- return CheckBreak();
-}
-
-HRESULT COpenCallbackConsole::CryptoGetTextPassword(BSTR *password)
-{
- RINOK(CheckBreak());
- if (!PasswordIsDefined)
- {
- Password = GetPassword(OutStream);
- PasswordIsDefined = true;
- }
- CMyComBSTR temp(Password);
- *password = temp.Detach();
- return S_OK;
-}
-
-HRESULT COpenCallbackConsole::GetPasswordIfAny(UString &password)
-{
- if (PasswordIsDefined)
- password = Password;
- return S_OK;
-}
-
-
diff --git a/7zip/UI/Console/OpenCallbackConsole.h b/7zip/UI/Console/OpenCallbackConsole.h
deleted file mode 100755
index b01d4d88..00000000
--- a/7zip/UI/Console/OpenCallbackConsole.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// OpenCallbackConsole.h
-
-#ifndef __OPENCALLBACKCONSOLE_H
-#define __OPENCALLBACKCONSOLE_H
-
-#include "Common/StdOutStream.h"
-#include "../Common/ArchiveOpenCallback.h"
-
-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);
-
- CStdOutStream *OutStream;
- bool PasswordIsDefined;
- UString Password;
- COpenCallbackConsole(): PasswordIsDefined(false) {}
-};
-
-#endif
diff --git a/7zip/UI/Console/PercentPrinter.cpp b/7zip/UI/Console/PercentPrinter.cpp
deleted file mode 100755
index 34e48143..00000000
--- a/7zip/UI/Console/PercentPrinter.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-// PercentPrinter.cpp
-
-#include "StdAfx.h"
-
-#include "Common/IntToString.h"
-#include "Common/String.h"
-
-#include "PercentPrinter.h"
-
-static const char *kPrepareString = " ";
-static const char *kCloseString = "\b\b\b\b \b\b\b\b";
-// static const char *kPercentFormatString = "\b\b\b\b%3I64u%%";
-static const char *kPercentFormatString1 = "\b\b\b\b";
-static const int kNumDigits = 3;
-
-CPercentPrinter::CPercentPrinter(UInt64 minStepSize):
- m_MinStepSize(minStepSize),
- m_PrevValue(0),
- m_CurValue(0),
- m_Total(1),
- m_ScreenPos(0),
- m_StringIsPrinted(false)
-{
- for (int i = 0; i < kNumPercentSpaces; i++)
- m_Spaces[i] = ' ';
- m_Spaces[kNumPercentSpaces] = '\0';
-}
-
-void CPercentPrinter::PreparePrint()
-{
- if (m_ScreenPos < kNumPercentSpaces)
- (*OutStream) << (m_Spaces + m_ScreenPos);
- m_ScreenPos = kNumPercentSpaces;
- (*OutStream) << kPrepareString;
-}
-
-void CPercentPrinter::ClosePrint()
-{
- (*OutStream) << kCloseString;
- m_StringIsPrinted = false;
-}
-
-void CPercentPrinter::PrintString(const char *s)
-{
- m_ScreenPos += MyStringLen(s);
- (*OutStream) << s;
-}
-
-void CPercentPrinter::PrintString(const wchar_t *s)
-{
- m_ScreenPos += MyStringLen(s);
- (*OutStream) << s;
-}
-
-void CPercentPrinter::PrintNewLine()
-{
- m_ScreenPos = 0;
- (*OutStream) << "\n";
- m_StringIsPrinted = false;
-}
-
-void CPercentPrinter::SetRatio(UInt64 doneValue)
- { m_CurValue = doneValue; }
-
-void CPercentPrinter::RePrintRatio()
-{
- if (m_Total == 0)
- return;
- UInt64 ratio = m_CurValue * 100 / m_Total;
- char temp[32 + kNumDigits] = " "; // for 4 digits;
- ConvertUInt64ToString(ratio, temp + kNumDigits);
- int len = (int)strlen(temp + kNumDigits);
- temp[kNumDigits + len] = '%';
- temp[kNumDigits + len + 1] = '\0';
- int pos = (len > kNumDigits)? kNumDigits : len;
- (*OutStream) << kPercentFormatString1;
- (*OutStream) << (temp + pos);
- OutStream->Flush();
- m_PrevValue = m_CurValue;
- m_StringIsPrinted = true;
-}
-
-void CPercentPrinter::PrintRatio()
-{
- if (m_CurValue < m_PrevValue + m_MinStepSize || !m_StringIsPrinted)
- return;
- RePrintRatio();
-}
diff --git a/7zip/UI/Console/PercentPrinter.h b/7zip/UI/Console/PercentPrinter.h
deleted file mode 100755
index 0260cad2..00000000
--- a/7zip/UI/Console/PercentPrinter.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// PercentPrinter.h
-
-#ifndef __PERCENTPRINTER_H
-#define __PERCENTPRINTER_H
-
-#include "Common/Defs.h"
-#include "Common/Types.h"
-#include "Common/StdOutStream.h"
-
-const int kNumPercentSpaces = 70;
-class CPercentPrinter
-{
- UInt64 m_MinStepSize;
- UInt64 m_PrevValue;
- UInt64 m_CurValue;
- UInt64 m_Total;
- UInt32 m_ScreenPos;
- char m_Spaces[kNumPercentSpaces + 1];
- bool m_StringIsPrinted;
-public:
- CStdOutStream *OutStream;
-
- CPercentPrinter(UInt64 minStepSize = 1);
- void SetTotal(UInt64 total)
- {
- m_Total = total;
- m_PrevValue = 0;
- m_StringIsPrinted = false;
- }
- void PrintString(const char *s);
- void PrintString(const wchar_t *s);
- void PrintNewLine();
- void PreparePrint();
- void ClosePrint();
- void SetRatio(UInt64 doneValue);
- void RePrintRatio();
- void PrintRatio();
-};
-
-#endif
diff --git a/7zip/UI/Console/UpdateCallbackConsole.cpp b/7zip/UI/Console/UpdateCallbackConsole.cpp
deleted file mode 100755
index 51b96524..00000000
--- a/7zip/UI/Console/UpdateCallbackConsole.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-// UpdateCallbackConsole.cpp
-
-#include "StdAfx.h"
-
-#include "UpdateCallbackConsole.h"
-
-#include "Windows/Error.h"
-// #include "Windows/Synchronization.h"
-
-#include "ConsoleClose.h"
-#include "UserInputUtils.h"
-
-using namespace NWindows;
-
-static const wchar_t *kEmptyFileAlias = L"[Content]";
-
-static const char *kCreatingArchiveMessage = "Creating archive ";
-static const char *kUpdatingArchiveMessage = "Updating archive ";
-static const char *kScanningMessage = "Scanning";
-static const char *kNoFilesScannedMessage = "No files scanned";
-static const char *kTotalFilesAddedMessage = "Total files added to archive: ";
-
-// static NSynchronization::CCriticalSection g_CriticalSection;
-
-HRESULT CUpdateCallbackConsole::OpenResult(const wchar_t *name, HRESULT result)
-{
- (*OutStream) << endl;
- if (result != S_OK)
- (*OutStream) << "Error: " << name << " is not supported archive" << endl;
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::StartScanning()
-{
- (*OutStream) << kScanningMessage;
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::CanNotFindError(const wchar_t *name, DWORD systemError)
-{
- CantFindFiles.Add(name);
- CantFindCodes.Add(systemError);
- // m_PercentPrinter.ClosePrint();
- if (!m_WarningsMode)
- {
- (*OutStream) << endl << endl;
- m_PercentPrinter.PrintNewLine();
- m_WarningsMode = true;
- }
- m_PercentPrinter.PrintString(name);
- m_PercentPrinter.PrintString(": WARNING: ");
- m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
- m_PercentPrinter.PrintNewLine();
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::FinishScanning()
-{
- (*OutStream) << endl << endl;
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::StartArchive(const wchar_t *name, bool updating)
-{
- if(updating)
- (*OutStream) << kUpdatingArchiveMessage;
- else
- (*OutStream) << kCreatingArchiveMessage;
- if (name != 0)
- (*OutStream) << name;
- else
- (*OutStream) << "StdOut";
- (*OutStream) << endl << endl;
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::FinishArchive()
-{
- (*OutStream) << endl;
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::CheckBreak()
-{
- if (NConsoleClose::TestBreakSignal())
- return E_ABORT;
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::Finilize()
-{
- // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- if (m_NeedBeClosed)
- {
- if (EnablePercents)
- {
- m_PercentPrinter.ClosePrint();
- m_PercentCanBePrint = false;
- }
- if (!StdOutMode)
- m_PercentPrinter.PrintNewLine();
- m_NeedBeClosed = false;
- }
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::SetTotal(UInt64 size)
-{
- // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- if (EnablePercents)
- m_PercentPrinter.SetTotal(size);
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::SetCompleted(const UInt64 *completeValue)
-{
- // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- if (completeValue != NULL)
- {
- if (EnablePercents)
- {
- m_PercentPrinter.SetRatio(*completeValue);
- if (m_PercentCanBePrint)
- m_PercentPrinter.PrintRatio();
- }
- }
- if (NConsoleClose::TestBreakSignal())
- return E_ABORT;
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool isAnti)
-{
- // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- if (StdOutMode)
- return S_OK;
- if(isAnti)
- m_PercentPrinter.PrintString("Anti item ");
- else
- m_PercentPrinter.PrintString("Compressing ");
- if (name[0] == 0)
- name = kEmptyFileAlias;
- m_PercentPrinter.PrintString(name);
- if (EnablePercents)
- {
- m_PercentCanBePrint = true;
- m_PercentPrinter.PreparePrint();
- m_PercentPrinter.RePrintRatio();
- }
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::OpenFileError(const wchar_t *name, DWORD systemError)
-{
- // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- FailedCodes.Add(systemError);
- FailedFiles.Add(name);
- // if (systemError == ERROR_SHARING_VIOLATION)
- {
- m_PercentPrinter.ClosePrint();
- m_PercentPrinter.PrintNewLine();
- m_PercentPrinter.PrintString("WARNING: ");
- m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
- return S_FALSE;
- }
- // return systemError;
-}
-
-HRESULT CUpdateCallbackConsole::SetOperationResult(Int32 )
-{
- m_NeedBeClosed = true;
- return S_OK;
-}
-
-HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
-{
- if (!PasswordIsDefined)
- {
- if (AskPassword)
- {
- Password = GetPassword(OutStream);
- PasswordIsDefined = true;
- }
- }
- *passwordIsDefined = BoolToInt(PasswordIsDefined);
- CMyComBSTR tempName(Password);
- *password = tempName.Detach();
- return S_OK;
-}
diff --git a/7zip/UI/Console/UpdateCallbackConsole.h b/7zip/UI/Console/UpdateCallbackConsole.h
deleted file mode 100755
index 242469ca..00000000
--- a/7zip/UI/Console/UpdateCallbackConsole.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// UpdateCallbackConsole.h
-
-#ifndef __UPDATECALLBACKCONSOLE_H
-#define __UPDATECALLBACKCONSOLE_H
-
-#include "Common/String.h"
-#include "Common/StdOutStream.h"
-#include "PercentPrinter.h"
-#include "../Common/Update.h"
-
-class CUpdateCallbackConsole: public IUpdateCallbackUI2
-{
- CPercentPrinter m_PercentPrinter;
- bool m_PercentCanBePrint;
- bool m_NeedBeClosed;
-
- bool m_WarningsMode;
-
- CStdOutStream *OutStream;
-public:
- bool EnablePercents;
- bool StdOutMode;
-
- bool PasswordIsDefined;
- UString Password;
- bool AskPassword;
-
-
- CUpdateCallbackConsole():
- m_PercentPrinter(1 << 16),
- PasswordIsDefined(false),
- AskPassword(false),
- StdOutMode(false),
- EnablePercents(true),
- m_WarningsMode(false)
- {}
-
- ~CUpdateCallbackConsole() { Finilize(); }
- void Init(CStdOutStream *outStream)
- {
- m_PercentCanBePrint = false;
- m_NeedBeClosed = false;
- FailedFiles.Clear();
- FailedCodes.Clear();
- OutStream = outStream;
- m_PercentPrinter.OutStream = outStream;
- }
-
- HRESULT OpenResult(const wchar_t *name, HRESULT result);
-
- HRESULT StartScanning();
- HRESULT CanNotFindError(const wchar_t *name, DWORD systemError);
- HRESULT FinishScanning();
-
- HRESULT StartArchive(const wchar_t *name, bool updating);
- HRESULT FinishArchive();
-
- HRESULT CheckBreak();
- HRESULT Finilize();
- HRESULT SetTotal(UInt64 size);
- HRESULT SetCompleted(const UInt64 *completeValue);
-
- HRESULT GetStream(const wchar_t *name, bool isAnti);
- HRESULT OpenFileError(const wchar_t *name, DWORD systemError);
- HRESULT SetOperationResult(Int32 operationResult);
- HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password);
-
- UStringVector FailedFiles;
- CRecordVector<HRESULT> FailedCodes;
-
- UStringVector CantFindFiles;
- CRecordVector<HRESULT> CantFindCodes;
-};
-
-#endif
diff --git a/7zip/UI/Console/makefile b/7zip/UI/Console/makefile
deleted file mode 100755
index 3e5dd8f6..00000000
--- a/7zip/UI/Console/makefile
+++ /dev/null
@@ -1,93 +0,0 @@
-PROG = 7z.exe
-LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib
-CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
-
-CONSOLE_OBJS = \
- $O\ConsoleClose.obj \
- $O\ExtractCallbackConsole.obj \
- $O\List.obj \
- $O\Main.obj \
- $O\MainAr.obj \
- $O\OpenCallbackConsole.obj \
- $O\PercentPrinter.obj \
- $O\UpdateCallbackConsole.obj \
- $O\UserInputUtils.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CommandLineParser.obj \
- $O\IntToString.obj \
- $O\ListFileUtils.obj \
- $O\NewHandler.obj \
- $O\StdInStream.obj \
- $O\StdOutStream.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\UTFConvert.obj \
- $O\Vector.obj \
- $O\Wildcard.obj \
-
-WIN_OBJS = \
- $O\DLL.obj \
- $O\Error.obj \
- $O\FileDir.obj \
- $O\FileFind.obj \
- $O\FileIO.obj \
- $O\FileName.obj \
- $O\MemoryLock.obj \
- $O\PropVariant.obj \
- $O\PropVariantConversions.obj \
- $O\Registry.obj \
-
-7ZIP_COMMON_OBJS = \
- $O\FilePathAutoRename.obj \
- $O\FileStreams.obj \
- $O\StreamUtils.obj \
-
-UI_COMMON_OBJS = \
- $O\ArchiveCommandLine.obj \
- $O\ArchiveExtractCallback.obj \
- $O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
- $O\DefaultName.obj \
- $O\EnumDirItems.obj \
- $O\Extract.obj \
- $O\ExtractingFilePath.obj \
- $O\OpenArchive.obj \
- $O\PropIDUtils.obj \
- $O\SetProperties.obj \
- $O\SortUtils.obj \
- $O\TempFiles.obj \
- $O\Update.obj \
- $O\UpdateAction.obj \
- $O\UpdateCallback.obj \
- $O\UpdatePair.obj \
- $O\UpdateProduce.obj \
- $O\WorkDir.obj \
-
-
-OBJS = \
- $O\StdAfx.obj \
- $(CONSOLE_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(UI_COMMON_OBJS) \
- $O\CopyCoder.obj \
- $O\resource.res
-
-!include "../../../Build.mak"
-
-$(CONSOLE_OBJS): $(*B).cpp
- $(COMPL)
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(UI_COMMON_OBJS): ../Common/$(*B).cpp
- $(COMPL)
-$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
- $(COMPL)
diff --git a/7zip/UI/Explorer/Explorer.dsp b/7zip/UI/Explorer/Explorer.dsp
deleted file mode 100755
index 7689cd83..00000000
--- a/7zip/UI/Explorer/Explorer.dsp
+++ /dev/null
@@ -1,805 +0,0 @@
-# Microsoft Developer Studio Project File - Name="Explorer" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=Explorer - Win32 DebugU
-!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 "Explorer.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 "Explorer.mak" CFG="Explorer - Win32 DebugU"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Explorer - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "Explorer - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "Explorer - Win32 ReleaseU" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "Explorer - Win32 DebugU" (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)" == "Explorer - 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 "EXPLORER_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /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 comctl32.lib htmlhelp.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "Explorer - 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 "EXPLORER_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /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 comctl32.lib htmlhelp.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "Explorer - Win32 ReleaseU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ReleaseU"
-# PROP BASE Intermediate_Dir "ReleaseU"
-# PROP BASE Ignore_Export_Lib 1
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ReleaseU"
-# PROP Intermediate_Dir "ReleaseU"
-# PROP Ignore_Export_Lib 1
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "_MBCS" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /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 comctl32.lib htmlhelp.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /opt:NOWIN98
-# SUBTRACT BASE LINK32 /pdb:none
-# 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 comctl32.lib htmlhelp.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zipn.dll" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "Explorer - Win32 DebugU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "DebugU"
-# PROP BASE Intermediate_Dir "DebugU"
-# PROP BASE Ignore_Export_Lib 1
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "DebugU"
-# PROP Intermediate_Dir "DebugU"
-# PROP Ignore_Export_Lib 1
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /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 comctl32.lib htmlhelp.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /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 comctl32.lib htmlhelp.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "Explorer - Win32 Release"
-# Name "Explorer - Win32 Debug"
-# Name "Explorer - Win32 ReleaseU"
-# Name "Explorer - Win32 DebugU"
-# Begin Group "Spec"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\DllExports.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Explorer.def
-# End Source File
-# Begin Source File
-
-SOURCE=.\resource.h
-# 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 "UI Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Common\ArchiveExtractCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveExtractCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveName.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveOpenCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveOpenCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiverInfo.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiverInfo.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\CompressCall.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\CompressCall.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\DefaultName.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\DefaultName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\EnumDirItems.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\EnumDirItems.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ExtractingFilePath.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ExtractingFilePath.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\HandlerLoader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\OpenArchive.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\OpenArchive.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\PropIDUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\PropIDUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\SortUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\SortUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateAction.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateAction.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdatePair.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdatePair.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateProduce.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateProduce.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\WorkDir.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\WorkDir.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ZipRegistry.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ZipRegistry.h
-# End Source File
-# End Group
-# Begin Group "Engine"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ContextMenu.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ContextMenu.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\MyMessages.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\MyMessages.h
-# End Source File
-# End Group
-# Begin Group "Dialogs"
-
-# PROP Default_Filter ""
-# Begin Group "Options"
-
-# PROP Default_Filter ""
-# Begin Group "SystemPage"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\SystemPage\SystemPage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\SystemPage\SystemPage.h
-# End Source File
-# End Group
-# Begin Group "FoldersPage"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\FoldersPage\FoldersPage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FoldersPage\FoldersPage.h
-# End Source File
-# End Group
-# End Group
-# End Group
-# Begin Group "Agent"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Agent\Agent.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\Agent.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\AgentOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\AgentProxy.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\AgentProxy.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\ArchiveFolder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\ArchiveFolderOpen.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\ArchiveFolderOut.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\IFileExtractCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\IFolderArchive.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\UpdateCallbackAgent.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Agent\UpdateCallbackAgent.h
-# End Source File
-# End Group
-# Begin Group "FileManager"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\FileManager\FormatUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\FormatUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\HelpUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\HelpUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\IFolder.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\LangUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\LangUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\ProgramLocation.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\ProgramLocation.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\RegistryUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\RegistryUtils.h
-# End Source File
-# End Group
-# Begin Group "SDK"
-
-# PROP Default_Filter ""
-# Begin Group "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.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\Lang.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Lang.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\MyCom.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\Random.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Random.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdInStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdInStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.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
-# Begin Source File
-
-SOURCE=..\..\..\Common\TextConfig.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\TextConfig.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Types.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\UTFConvert.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\UTFConvert.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.h
-# End Source File
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# Begin Group "Control"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Control\Dialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Control\Dialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Control\PropertyPage.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Control\PropertyPage.h
-# End Source File
-# End Group
-# 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\Error.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Error.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\FileMapping.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\FileName.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\FileName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Memory.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Memory.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Menu.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Menu.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\PropVariantConversions.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\PropVariantConversions.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Registry.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Registry.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\ResourceString.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\ResourceString.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Shell.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Shell.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Synchronization.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Window.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Window.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "7-zip common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.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 "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 Source File
-
-SOURCE=".\7-zip.dll.manifest"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ContextMenuFlags.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\OptionsDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\OptionsDialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\RegistryContextMenu.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\RegistryContextMenu.h
-# End Source File
-# End Target
-# End Project
diff --git a/7zip/UI/Explorer/makefile b/7zip/UI/Explorer/makefile
deleted file mode 100755
index 1539428d..00000000
--- a/7zip/UI/Explorer/makefile
+++ /dev/null
@@ -1,130 +0,0 @@
-PROG = 7-zip.dll
-DEF_FILE = Explorer.def
-LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib htmlhelp.lib shell32.lib comctl32.lib ole32.lib comdlg32.lib
-CFLAGS = $(CFLAGS) -I ../../../ \
- -DLANG \
- -DNEW_FOLDER_INTERFACE
-
-EXPLORER_OBJS = \
- $O\DllExports.obj \
- $O\ContextMenu.obj \
- $O\MyMessages.obj \
- $O\OptionsDialog.obj \
- $O\RegistryContextMenu.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\IntToString.obj \
- $O\Lang.obj \
- $O\ListFileUtils.obj \
- $O\NewHandler.obj \
- $O\Random.obj \
- $O\StdInStream.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\TextConfig.obj \
- $O\UTFConvert.obj \
- $O\Vector.obj \
- $O\Wildcard.obj \
-
-WIN_OBJS = \
- $O\DLL.obj \
- $O\Error.obj \
- $O\FileDir.obj \
- $O\FileFind.obj \
- $O\FileIO.obj \
- $O\FileName.obj \
- $O\Menu.obj \
- $O\PropVariant.obj \
- $O\PropVariantConversions.obj \
- $O\Registry.obj \
- $O\ResourceString.obj \
- $O\Shell.obj \
- $O\Synchronization.obj \
- $O\Window.obj \
-
-WIN_CTRL_OBJS = \
- $O\Dialog.obj \
- $O\PropertyPage.obj \
-
-7ZIP_COMMON_OBJS = \
- $O\FilePathAutoRename.obj \
- $O\FileStreams.obj \
- $O\StreamUtils.obj \
-
-UI_COMMON_OBJS = \
- $O\ArchiveExtractCallback.obj \
- $O\ArchiveName.obj \
- $O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
- $O\CompressCall.obj \
- $O\DefaultName.obj \
- $O\EnumDirItems.obj \
- $O\ExtractingFilePath.obj \
- $O\OpenArchive.obj \
- $O\PropIDUtils.obj \
- $O\SortUtils.obj \
- $O\UpdateAction.obj \
- $O\UpdateCallback.obj \
- $O\UpdatePair.obj \
- $O\UpdateProduce.obj \
- $O\WorkDir.obj \
- $O\ZipRegistry.obj \
-
-AGENT_OBJS = \
- $O\Agent.obj \
- $O\AgentOut.obj \
- $O\AgentProxy.obj \
- $O\ArchiveFolder.obj \
- $O\ArchiveFolderOpen.obj \
- $O\ArchiveFolderOut.obj \
- $O\UpdateCallbackAgent.obj \
-
-
-FM_COMMON_OBJS = \
- $O\FormatUtils.obj \
- $O\HelpUtils.obj \
- $O\LangUtils.obj \
- $O\ProgramLocation.obj \
- $O\RegistryUtils.obj \
-
-OBJS = \
- $O\StdAfx.obj \
- $(EXPLORER_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(WIN_CTRL_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(UI_COMMON_OBJS) \
- $(AGENT_OBJS) \
- $(FM_COMMON_OBJS)\
- $O\SystemPage.obj \
- $O\FoldersPage.obj \
- $O\CopyCoder.obj \
- $O\resource.res
-
-!include "../../../Build.mak"
-
-$(EXPLORER_OBJS): $(*B).cpp
- $(COMPL)
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(UI_COMMON_OBJS): ../Common/$(*B).cpp
- $(COMPL)
-$(AGENT_OBJS): ../Agent/$(*B).cpp
- $(COMPL)
-$(FM_COMMON_OBJS): ../../FileManager/$(*B).cpp
- $(COMPL)
-$O\SystemPage.obj: SystemPage/$(*B).cpp
- $(COMPL)
-$O\FoldersPage.obj: FoldersPage/$(*B).cpp
- $(COMPL)
-$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
- $(COMPL)
diff --git a/7zip/UI/Far/makefile b/7zip/UI/Far/makefile
deleted file mode 100755
index d5819130..00000000
--- a/7zip/UI/Far/makefile
+++ /dev/null
@@ -1,96 +0,0 @@
-PROG = 7-ZipFar.dll
-DEF_FILE = Far.def
-LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib ole32.lib
-CFLAGS = $(CFLAGS) -I ../../../
-
-FAR_OBJS = \
- $O\CLSIDConst.obj \
- $O\ExtractEngine.obj \
- $O\FarUtils.obj \
- $O\Main.obj \
- $O\OverwriteDialog.obj \
- $O\Plugin.obj \
- $O\PluginCommon.obj \
- $O\PluginDelete.obj \
- $O\PluginRead.obj \
- $O\PluginWrite.obj \
- $O\ProgressBox.obj \
- $O\UpdateCallback100.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\IntToString.obj \
- $O\NewHandler.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\Vector.obj \
- $O\Wildcard.obj \
-
-WIN_OBJS = \
- $O\DLL.obj \
- $O\Error.obj \
- $O\FileDir.obj \
- $O\FileFind.obj \
- $O\FileIO.obj \
- $O\FileName.obj \
- $O\PropVariant.obj \
- $O\PropVariantConversions.obj \
- $O\Registry.obj \
- $O\Synchronization.obj \
-
-7ZIP_COMMON_OBJS = \
- $O\FilePathAutoRename.obj \
- $O\FileStreams.obj \
- $O\StreamUtils.obj \
-
-UI_COMMON_OBJS = \
- $O\ArchiveExtractCallback.obj \
- $O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
- $O\DefaultName.obj \
- $O\EnumDirItems.obj \
- $O\ExtractingFilePath.obj \
- $O\OpenArchive.obj \
- $O\PropIDUtils.obj \
- $O\SortUtils.obj \
- $O\UpdateAction.obj \
- $O\UpdateCallback.obj \
- $O\UpdatePair.obj \
- $O\UpdateProduce.obj \
- $O\WorkDir.obj \
- $O\ZipRegistry.obj \
-
-AGENT_OBJS = \
- $O\Agent.obj \
- $O\AgentOut.obj \
- $O\AgentProxy.obj \
- $O\UpdateCallbackAgent.obj \
-
-OBJS = \
- $O\StdAfx.obj \
- $(FAR_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(UI_COMMON_OBJS) \
- $(AGENT_OBJS) \
- $O\CopyCoder.obj \
- $O\resource.res
-
-!include "../../../Build.mak"
-
-$(FAR_OBJS): $(*B).cpp
- $(COMPL)
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(UI_COMMON_OBJS): ../Common/$(*B).cpp
- $(COMPL)
-$(AGENT_OBJS): ../Agent/$(*B).cpp
- $(COMPL)
-$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
- $(COMPL)
diff --git a/7zip/UI/GUI/CompressDialog.cpp b/7zip/UI/GUI/CompressDialog.cpp
deleted file mode 100755
index edaee789..00000000
--- a/7zip/UI/GUI/CompressDialog.cpp
+++ /dev/null
@@ -1,1357 +0,0 @@
-// CompressDialog.cpp
-
-#include "StdAfx.h"
-
-#include "resource.h"
-#include "Common/Defs.h"
-#include "Common/StringConvert.h"
-#include "Common/IntToString.h"
-#include "Windows/CommonDialog.h"
-#include "Windows/FileDir.h"
-#include "Windows/FileName.h"
-#include "Windows/ResourceString.h"
-#include "Windows/System.h"
-
-#include "../../FileManager/HelpUtils.h"
-#include "../../FileManager/SplitUtils.h"
-#include "../Explorer/MyMessages.h"
-
-#include "../Common/ZipRegistry.h"
-
-#include "CompressDialog.h"
-
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-#ifdef LANG
-#include "../../FileManager/LangUtils.h"
-#endif
-
-#include "../Resource/CompressDialog/resource.h"
-
-#define MY_SIZE_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDC_STATIC_COMPRESS_ARCHIVE, 0x02000D01 },
- { IDC_STATIC_COMPRESS_FORMAT, 0x02000D03 },
- { IDC_STATIC_COMPRESS_LEVEL, 0x02000D0B },
- { IDC_STATIC_COMPRESS_METHOD, 0x02000D04 },
- { IDC_STATIC_COMPRESS_DICTIONARY, 0x02000D0C },
- { IDC_STATIC_COMPRESS_ORDER, 0x02000D0D },
- { IDC_STATIC_COMPRESS_MEMORY, 0x02000D0E },
- { IDC_STATIC_COMPRESS_MEMORY_DE, 0x02000D0F },
- { IDC_COMPRESS_SOLID, 0x02000D05 },
- { IDC_COMPRESS_MULTI_THREAD, 0x02000D09 },
- { IDC_STATIC_COMPRESS_VOLUME, 0x02000D40 },
- { IDC_STATIC_COMPRESS_PARAMETERS, 0x02000D06 },
-
- { IDC_STATIC_COMPRESS_UPDATE_MODE, 0x02000D02 },
- { IDC_STATIC_COMPRESS_OPTIONS, 0x02000D07 },
- { IDC_COMPRESS_SFX, 0x02000D08 },
-
- { IDC_COMPRESS_ENCRYPTION, 0x02000D10 },
- { IDC_STATIC_COMPRESS_PASSWORD1, 0x02000B01 },
- { IDC_STATIC_COMPRESS_PASSWORD2, 0x02000B03 },
- { IDC_COMPRESS_CHECK_SHOW_PASSWORD, 0x02000B02 },
- { IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, 0x02000D11 },
- { IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, 0x02000D0A },
-
- { IDOK, 0x02000702 },
- { IDCANCEL, 0x02000710 },
- { IDHELP, 0x02000720 }
-};
-#endif
-
-using namespace NWindows;
-using namespace NFile;
-using namespace NName;
-using namespace NDirectory;
-
-static const int kHistorySize = 8;
-
-static LPCWSTR kExeExt = L".exe";
-static LPCWSTR k7zFormat = L"7z";
-
-struct CLevelInfo
-{
- UInt32 ResourceID;
- UInt32 LangID;
-};
-
-enum ELevel
-{
- kStore = 0,
- kFastest = 1,
- kFast = 3,
- kNormal = 5,
- kMaximum = 7,
- kUltra = 9
-};
-
-static const CLevelInfo g_Levels[] =
-{
- { IDS_METHOD_STORE, 0x02000D81 },
- { IDS_METHOD_FASTEST, 0x02000D85 },
- { 0, 0 },
- { IDS_METHOD_FAST, 0x02000D84 },
- { 0, 0 },
- { IDS_METHOD_NORMAL, 0x02000D82 },
- { 0, 0 },
- { IDS_METHOD_MAXIMUM, 0x02000D83 },
- { 0, 0 },
- { IDS_METHOD_ULTRA, 0x02000D86 }
-};
-
-enum EMethodID
-{
- kCopy,
- kLZMA,
- kPPMd,
- kBZip2,
- kDeflate,
- kDeflate64
-};
-
-static const LPCWSTR kMethodsNames[] =
-{
- L"Copy",
- L"LZMA",
- L"PPMd",
- L"BZip2",
- L"Deflate",
- L"Deflate64"
-};
-
-static const EMethodID g_7zMethods[] =
-{
- kLZMA,
- kPPMd,
- kBZip2
-};
-
-static const EMethodID g_7zSfxMethods[] =
-{
- kCopy,
- kLZMA,
- kPPMd
-};
-
-static EMethodID g_ZipMethods[] =
-{
- kDeflate,
- kDeflate64,
- kBZip2
-};
-
-static EMethodID g_GZipMethods[] =
-{
- kDeflate
-};
-
-static EMethodID g_BZip2Methods[] =
-{
- kBZip2
-};
-
-struct CFormatInfo
-{
- LPCWSTR Name;
- UInt32 LevelsMask;
- const EMethodID *MathodIDs;
- int NumMethods;
- bool Filter;
- bool Solid;
- bool MultiThread;
- bool SFX;
- bool Encrypt;
- bool EncryptFileNames;
-};
-
-static const CFormatInfo g_Formats[] =
-{
- {
- 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),
- 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),
- g_ZipMethods, MY_SIZE_OF_ARRAY(g_ZipMethods) ,
- false, false, true, false, true, false
- },
- {
- L"GZip",
- (1 << 5) | (1 << 7) | (1 << 9),
- g_GZipMethods, MY_SIZE_OF_ARRAY(g_GZipMethods),
- false, false, false, false, false, false
- },
- {
- L"BZip2",
- (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
- g_BZip2Methods,
- MY_SIZE_OF_ARRAY(g_BZip2Methods),
- false, false, true, false, false
- },
- {
- L"Tar",
- (1 << 0),
- 0, 0,
- false, false, false, false, false, false
- }
-};
-
-static bool IsMethodSupportedBySfx(int methodID)
-{
- for (int i = 0; i < MY_SIZE_OF_ARRAY(g_7zSfxMethods); i++)
- if (methodID == g_7zSfxMethods[i])
- return true;
- return false;
-};
-
-#ifndef _WIN64
-typedef BOOL (WINAPI *GlobalMemoryStatusExP)(LPMEMORYSTATUSEX lpBuffer);
-#endif
-
-static UInt64 GetPhysicalRamSize()
-{
- MEMORYSTATUSEX stat;
- stat.dwLength = sizeof(stat);
- // return (128 << 20);
- #ifdef _WIN64
- if (!::GlobalMemoryStatusEx(&stat))
- return 0;
- return stat.ullTotalPhys;
- #else
- GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
- ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
- "GlobalMemoryStatusEx");
- if (globalMemoryStatusEx != 0)
- if (globalMemoryStatusEx(&stat))
- return stat.ullTotalPhys;
- {
- MEMORYSTATUS stat;
- stat.dwLength = sizeof(stat);
- GlobalMemoryStatus(&stat);
- return stat.dwTotalPhys;
- }
- #endif
-}
-
-static UInt64 GetMaxRamSizeForProgram()
-{
- UInt64 physSize = GetPhysicalRamSize();
- const UInt64 kMinSysSize = (1 << 24);
- if (physSize <= kMinSysSize)
- physSize = 0;
- else
- physSize -= kMinSysSize;
- const UInt64 kMinUseSize = (1 << 25);
- if (physSize < kMinUseSize)
- physSize = kMinUseSize;
- return physSize;
-}
-
-bool CCompressDialog::OnInit()
-{
- #ifdef LANG
- LangSetWindowText(HWND(*this), 0x02000D00);
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, MY_SIZE_OF_ARRAY(kIDLangPairs) );
- #endif
- _password1Control.Attach(GetItem(IDC_COMPRESS_EDIT_PASSWORD1));
- _password2Control.Attach(GetItem(IDC_COMPRESS_EDIT_PASSWORD2));
- _password1Control.SetText(Info.Password);
- _password2Control.SetText(Info.Password);
- _encryptionMethod.Attach(GetItem(IDC_COMPRESS_COMBO_ENCRYPTION_METHOD));
-
- m_ArchivePath.Attach(GetItem(IDC_COMPRESS_COMBO_ARCHIVE));
- m_Format.Attach(GetItem(IDC_COMPRESS_COMBO_FORMAT));
- m_Level.Attach(GetItem(IDC_COMPRESS_COMBO_LEVEL));
- m_Method.Attach(GetItem(IDC_COMPRESS_COMBO_METHOD));
- m_Dictionary.Attach(GetItem(IDC_COMPRESS_COMBO_DICTIONARY));
- m_Order.Attach(GetItem(IDC_COMPRESS_COMBO_ORDER));
-
- m_UpdateMode.Attach(GetItem(IDC_COMPRESS_COMBO_UPDATE_MODE));
- m_Volume.Attach(GetItem(IDC_COMPRESS_COMBO_VOLUME));
- m_Params.Attach(GetItem(IDC_COMPRESS_EDIT_PARAMETERS));
-
- AddVolumeItems(m_Volume);
-
- ReadCompressionInfo(m_RegistryInfo);
- CheckButton(IDC_COMPRESS_CHECK_SHOW_PASSWORD, m_RegistryInfo.ShowPassword);
- CheckButton(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, m_RegistryInfo.EncryptHeaders);
-
- UpdatePasswordControl();
-
- Info.ArchiverInfoIndex = 0;
- int i;
- for(i = 0; i < m_ArchiverInfoList.Size(); i++)
- {
- const CArchiverInfo &ai = m_ArchiverInfoList[i];
- m_Format.AddString(ai.Name);
- if (ai.Name.CompareNoCase(m_RegistryInfo.ArchiveType) == 0)
- Info.ArchiverInfoIndex = i;
- }
- m_Format.SetCurSel(Info.ArchiverInfoIndex);
-
- SetArchiveName(Info.ArchiveName);
- SetLevel();
- SetParams();
-
- for(i = 0; i < m_RegistryInfo.HistoryArchives.Size() && i < kHistorySize; i++)
- m_ArchivePath.AddString(m_RegistryInfo.HistoryArchives[i]);
-
- m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_ADD, 0x02000DA1));
- m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_UPDATE, 0x02000DA2));
- m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_FRESH, 0x02000DA3));
- m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE, 0x02000DA4));
-
- m_UpdateMode.SetCurSel(0);
-
- Info.Solid = m_RegistryInfo.Solid;
- Info.MultiThread = m_RegistryInfo.MultiThread;
-
- CheckButton(IDC_COMPRESS_SOLID, Info.Solid);
- CheckButton(IDC_COMPRESS_MULTI_THREAD, Info.MultiThread);
- CheckButton(IDC_COMPRESS_SFX, Info.SFXMode);
-
- CheckControlsEnable();
-
- OnButtonSFX();
-
- SetEncryptionMethod();
- return CModalDialog::OnInit();
-}
-
-namespace NCompressDialog
-{
- bool CInfo::GetFullPathName(UString &result) const
- {
- NDirectory::MySetCurrentDirectory(CurrentDirPrefix);
- return MyGetFullPathName(ArchiveName, result);
- }
-}
-
-void CCompressDialog::UpdatePasswordControl()
-{
- bool showPassword = IsShowPasswordChecked();
- TCHAR c = showPassword ? 0: TEXT('*');
- _password1Control.SetPasswordChar(c);
- _password2Control.SetPasswordChar(c);
- UString password;
- _password1Control.GetText(password);
- _password1Control.SetText(password);
- _password2Control.GetText(password);
- _password2Control.SetText(password);
-
- int cmdShow = showPassword ? SW_HIDE : SW_SHOW;
- ShowItem(IDC_STATIC_COMPRESS_PASSWORD2, cmdShow);
- _password2Control.Show(cmdShow);
-}
-
-bool CCompressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
- switch(buttonID)
- {
- case IDC_COMPRESS_BUTTON_SET_ARCHIVE:
- {
- OnButtonSetArchive();
- return true;
- }
- case IDC_COMPRESS_SFX:
- {
- OnButtonSFX();
- return true;
- }
- case IDC_COMPRESS_CHECK_SHOW_PASSWORD:
- {
- UpdatePasswordControl();
- return true;
- }
- case IDC_COMPRESS_MULTI_THREAD:
- {
- SetMemoryUsage();
- return true;
- }
- }
- return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
-}
-
-static bool IsMultiProcessor()
-{
- return NSystem::GetNumberOfProcessors() > 1;
-}
-
-void CCompressDialog::CheckSFXControlsEnable()
-{
- const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- bool enable = fi.SFX;
- if (enable)
- {
- int methodID = GetMethodID();
- enable = (methodID == -1 || IsMethodSupportedBySfx(methodID));
- }
- if (!enable)
- CheckButton(IDC_COMPRESS_SFX, false);
- EnableItem(IDC_COMPRESS_SFX, enable);
-}
-
-void CCompressDialog::CheckVolumeEnable()
-{
- bool isSFX = IsSFX();
- m_Volume.Enable(!isSFX);
- if (isSFX)
- m_Volume.SetText(TEXT(""));
-}
-
-void CCompressDialog::CheckControlsEnable()
-{
- const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- Info.SolidIsAllowed = fi.Solid;
- bool multiThreadEnable = fi.MultiThread & IsMultiProcessor();
- Info.MultiThreadIsAllowed = multiThreadEnable;
- Info.EncryptHeadersIsAllowed = fi.EncryptFileNames;
-
- EnableItem(IDC_COMPRESS_SOLID, fi.Solid);
- EnableItem(IDC_COMPRESS_MULTI_THREAD, multiThreadEnable);
- CheckSFXControlsEnable();
- CheckVolumeEnable();
-
- EnableItem(IDC_COMPRESS_ENCRYPTION, fi.Encrypt);
-
- EnableItem(IDC_STATIC_COMPRESS_PASSWORD1, fi.Encrypt);
- EnableItem(IDC_STATIC_COMPRESS_PASSWORD2, fi.Encrypt);
- EnableItem(IDC_COMPRESS_EDIT_PASSWORD1, fi.Encrypt);
- EnableItem(IDC_COMPRESS_EDIT_PASSWORD2, fi.Encrypt);
- EnableItem(IDC_COMPRESS_CHECK_SHOW_PASSWORD, fi.Encrypt);
-
- EnableItem(IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, fi.Encrypt);
- EnableItem(IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, fi.Encrypt);
- EnableItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames);
-}
-
-bool CCompressDialog::IsSFX()
-{
- CWindow sfxButton = GetItem(IDC_COMPRESS_SFX);
- return sfxButton.IsEnabled() && IsButtonCheckedBool(IDC_COMPRESS_SFX);
-}
-
-void CCompressDialog::OnButtonSFX()
-{
- SetMethod();
-
- UString fileName;
- m_ArchivePath.GetText(fileName);
- int dotPos = fileName.ReverseFind(L'.');
- int slashPos = fileName.ReverseFind(L'\\');
- if (dotPos < 0 || dotPos <= slashPos)
- dotPos = -1;
- bool isSFX = IsSFX();
- if (isSFX)
- {
- if (dotPos >= 0)
- fileName = fileName.Left(dotPos);
- fileName += kExeExt;
- m_ArchivePath.SetText(fileName);
- }
- else
- {
- if (dotPos >= 0)
- {
- UString ext = fileName.Mid(dotPos);
- if (ext.CompareNoCase(kExeExt) == 0)
- {
- fileName = fileName.Left(dotPos);
- m_ArchivePath.SetText(fileName);
- }
- }
- SetArchiveName2(false); // it's for OnInit
- }
-
- CheckVolumeEnable();
-}
-
-void CCompressDialog::OnButtonSetArchive()
-{
- UString fileName;
- m_ArchivePath.GetText(fileName);
- fileName.Trim();
- Info.ArchiveName = fileName;
- UString fullFileName;
- if (!Info.GetFullPathName(fullFileName))
- {
- fullFileName = Info.ArchiveName;
- return;
- }
- UString title = LangString(IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, 0x02000D90);
- UString s = LangString(IDS_OPEN_TYPE_ALL_FILES, 0x02000DB1);
- s += L" (*.*)";
- UString resPath;
- if (!MyGetOpenFileName(HWND(*this), title, fullFileName, s, resPath))
- return;
- m_ArchivePath.SetText(resPath);
-}
-
-// in ExtractDialog.cpp
-extern void AddUniqueString(UStringVector &strings, const UString &srcString);
-
-static bool IsAsciiString(const UString &s)
-{
- for (int i = 0; i < s.Length(); i++)
- {
- wchar_t c = s[i];
- if (c < 0x20 || c > 0x7F)
- return false;
- }
- return true;
-}
-
-void CCompressDialog::OnOK()
-{
- _password1Control.GetText(Info.Password);
- if (IsZipFormat())
- {
- if (!IsAsciiString(Info.Password))
- {
- MyMessageBoxResource(*this, IDS_PASSWORD_USE_ASCII, 0x02000B11);
- return;
- }
- UString method = GetEncryptionMethodSpec();
- method.MakeUpper();
- if (method.Find(L"AES") == 0)
- {
- if (Info.Password.Length() > 99)
- {
- MyMessageBoxResource(*this, IDS_PASSWORD_IS_TOO_LONG, 0x02000B12);
- return;
- }
- }
- }
- if (!IsShowPasswordChecked())
- {
- UString password2;
- _password2Control.GetText(password2);
- if (password2 != Info.Password)
- {
- MyMessageBoxResource(*this, IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH, 0x02000B10);
- return;
- }
- }
-
- SaveOptionsInMem();
- UString s;
- m_ArchivePath.GetText(s);
- s.Trim();
- m_RegistryInfo.HistoryArchives.Clear();
- AddUniqueString(m_RegistryInfo.HistoryArchives, s);
- Info.ArchiveName = s;
- Info.UpdateMode = NCompressDialog::NUpdateMode::EEnum(m_UpdateMode.GetCurSel());
-
- Info.Level = GetLevelSpec();
- Info.Dictionary = GetDictionarySpec();
- Info.Order = GetOrderSpec();
- Info.OrderMode = GetOrderMode();
- Info.Method = GetMethodSpec();
- Info.EncryptionMethod = GetEncryptionMethodSpec();
-
- Info.ArchiverInfoIndex = m_Format.GetCurSel();
-
- Info.SFXMode = IsSFX();
- m_RegistryInfo.Solid = Info.Solid = IsButtonCheckedBool(IDC_COMPRESS_SOLID);
- m_RegistryInfo.MultiThread = Info.MultiThread = IsMultiThread();
- m_RegistryInfo.EncryptHeaders = Info.EncryptHeaders = IsButtonCheckedBool(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES);
-
- m_Params.GetText(Info.Options);
- UString volumeString;
- m_Volume.GetText(volumeString);
- volumeString.Trim();
- Info.VolumeSizes.Clear();
- if (!volumeString.IsEmpty())
- if (!ParseVolumeSizes(volumeString, Info.VolumeSizes))
- {
- MyMessageBoxResource(*this, IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41);
- return;
- }
-
- for(int i = 0; i < m_ArchivePath.GetCount(); i++)
- {
- UString sTemp;
- m_ArchivePath.GetLBText(i, sTemp);
- sTemp.Trim();
- AddUniqueString(m_RegistryInfo.HistoryArchives, sTemp);
- }
- if (m_RegistryInfo.HistoryArchives.Size() > kHistorySize)
- m_RegistryInfo.HistoryArchives.DeleteBack();
-
- ////////////////////
- // Method
-
- m_RegistryInfo.Level = Info.Level;
- m_RegistryInfo.ArchiveType = m_ArchiverInfoList[Info.ArchiverInfoIndex].Name;
-
- m_RegistryInfo.ShowPassword = IsShowPasswordChecked();
-
- SaveCompressionInfo(m_RegistryInfo);
-
- CModalDialog::OnOK();
-}
-
-static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/add.htm";
-
-void CCompressDialog::OnHelp()
-{
- ShowHelpWindow(NULL, kHelpTopic);
-}
-
-bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
-{
- if (code == CBN_SELCHANGE)
- {
- switch(itemID)
- {
- case IDC_COMPRESS_COMBO_FORMAT:
- {
- OnChangeFormat();
- return true;
- }
- case IDC_COMPRESS_COMBO_LEVEL:
- {
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
- int index = FindRegistryFormatAlways(ai.Name);
- NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- fo.ResetForLevelChange();
- SetMethod();
- CheckSFXNameChange();
- return true;
- }
- case IDC_COMPRESS_COMBO_METHOD:
- {
- SetDictionary();
- SetOrder();
- CheckSFXNameChange();
- return true;
- }
- case IDC_COMPRESS_COMBO_DICTIONARY:
- case IDC_COMPRESS_COMBO_ORDER:
- {
- SetMemoryUsage();
- return true;
- }
- }
- }
- return CModalDialog::OnCommand(code, itemID, lParam);
-}
-
-void CCompressDialog::CheckSFXNameChange()
-{
- bool isSFX = IsSFX();
- CheckSFXControlsEnable();
- if (isSFX != IsSFX())
- SetArchiveName2(isSFX);
-}
-
-void CCompressDialog::SetArchiveName2(bool prevWasSFX)
-{
- UString fileName;
- m_ArchivePath.GetText(fileName);
- const CArchiverInfo &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat];
- if (prevArchiverInfo.KeepName || Info.KeepName)
- {
- UString prevExtension = prevArchiverInfo.GetMainExtension();
- if (prevWasSFX)
- prevExtension = kExeExt;
- else
- prevExtension = UString('.') + prevExtension;
- const int prevExtensionLen = prevExtension.Length();
- if (fileName.Length() >= prevExtensionLen)
- if (fileName.Right(prevExtensionLen).CompareNoCase(prevExtension) == 0)
- fileName = fileName.Left(fileName.Length() - prevExtensionLen);
- }
- SetArchiveName(fileName);
-}
-
-void CCompressDialog::OnChangeFormat()
-{
- bool isSFX = IsSFX();
- SaveOptionsInMem();
- SetLevel();
- SetParams();
- CheckControlsEnable();
- SetArchiveName2(isSFX);
- SetEncryptionMethod();
-}
-
-// if type.KeepName then use OriginalFileName
-// else if !KeepName remove extension
-// add new extension
-
-void CCompressDialog::SetArchiveName(const UString &name)
-{
- UString fileName = name;
- Info.ArchiverInfoIndex = m_Format.GetCurSel();
- const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
- m_PrevFormat = Info.ArchiverInfoIndex;
- if (ai.KeepName)
- {
- fileName = OriginalFileName;
- }
- else
- {
- if (!Info.KeepName)
- {
- int dotPos = fileName.ReverseFind('.');
- int slashPos = MyMax(fileName.ReverseFind('\\'), fileName.ReverseFind('/'));
- if (dotPos >= 0 && dotPos > slashPos + 1)
- fileName = fileName.Left(dotPos);
- }
- }
-
- if (IsSFX())
- fileName += kExeExt;
- else
- {
- fileName += L'.';
- fileName += ai.GetMainExtension();
- }
- m_ArchivePath.SetText(fileName);
-}
-
-int CCompressDialog::FindRegistryFormat(const UString &name)
-{
- for (int i = 0; i < m_RegistryInfo.FormatOptionsVector.Size(); i++)
- {
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[i];
- if (GetUnicodeString(fo.FormatID) == name)
- return i;
- }
- return -1;
-}
-
-int CCompressDialog::FindRegistryFormatAlways(const UString &name)
-{
- int index = FindRegistryFormat(name);
- if (index < 0)
- {
- NCompression::CFormatOptions fo;
- fo.FormatID = GetSystemString(name);
- index = m_RegistryInfo.FormatOptionsVector.Add(fo);
- }
- return index;
-}
-
-int CCompressDialog::GetStaticFormatIndex()
-{
- int formatIndex = m_Format.GetCurSel();
- const CArchiverInfo &ai = m_ArchiverInfoList[formatIndex];
- for (int i = 0; i < MY_SIZE_OF_ARRAY(g_Formats); i++)
- if (ai.Name.CompareNoCase(g_Formats[i].Name) == 0)
- return i;
- return 0; // -1;
-}
-
-void CCompressDialog::SetNearestSelectComboBox(
- NControl::CComboBox &comboBox, UInt32 value)
-{
- for (int i = comboBox.GetCount() - 1; i >= 0; i--)
- if ((UInt32)comboBox.GetItemData(i) <= value)
- {
- comboBox.SetCurSel(i);
- return;
- }
- if (comboBox.GetCount() > 0)
- comboBox.SetCurSel(0);
-}
-
-void CCompressDialog::SetLevel()
-{
- m_Level.ResetContent();
- const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
- int index = FindRegistryFormat(ai.Name);
- UInt32 level = kNormal;
- if (index >= 0)
- {
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- if (fo.Level <= kUltra)
- level = fo.Level;
- else
- level = kUltra;
- }
- int i;
- for (i = 0; i <= kUltra; i++)
- {
- if ((fi.LevelsMask & (1 << i)) != 0)
- {
- const CLevelInfo &levelInfo = g_Levels[i];
- int index = (int)m_Level.AddString(LangString(levelInfo.ResourceID, levelInfo.LangID));
- m_Level.SetItemData(index, i);
- }
- }
- SetNearestSelectComboBox(m_Level, level);
- SetMethod();
-}
-
-int CCompressDialog::GetLevel()
-{
- if (m_Level.GetCount() <= 0)
- return -1;
- return (int)m_Level.GetItemData(m_Level.GetCurSel());
-}
-
-int CCompressDialog::GetLevelSpec()
-{
- if (m_Level.GetCount() <= 1)
- return -1;
- return GetLevel();
-}
-
-int CCompressDialog::GetLevel2()
-{
- int level = GetLevel();
- if (level < 0)
- level = 5;
- return level;
-}
-
-bool CCompressDialog::IsMultiThread()
-{
- /*
- const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- bool multiThreadEnable = fi.MultiThread & IsMultiProcessor();
- if (!multiThreadEnable)
- return false;
- */
- return IsButtonCheckedBool(IDC_COMPRESS_MULTI_THREAD);
-}
-
-void CCompressDialog::SetMethod()
-{
- m_Method.ResetContent();
- if (GetLevel() <= 0)
- {
- SetDictionary();
- SetOrder();
- return;
- }
- const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
- int index = FindRegistryFormat(ai.Name);
- UString defaultMethod;
- if (index >= 0)
- {
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- defaultMethod = fo.Method;
- }
- bool isSfx = IsSFX();
- for(int m = 0; m < fi.NumMethods; m++)
- {
- EMethodID methodID = fi.MathodIDs[m];
- if (isSfx)
- if (!IsMethodSupportedBySfx(methodID))
- continue;
- const LPCWSTR method = kMethodsNames[methodID];
- int itemIndex = (int)m_Method.AddString(GetSystemString(method));
- if (defaultMethod.CompareNoCase(method) == 0 || m == 0)
- m_Method.SetCurSel(itemIndex);
- }
- SetDictionary();
- SetOrder();
-}
-
-bool CCompressDialog::IsZipFormat()
-{
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
- return (ai.Name.CompareNoCase(L"zip") == 0);
-}
-
-void CCompressDialog::SetEncryptionMethod()
-{
- _encryptionMethod.ResetContent();
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
- if (ai.Name.CompareNoCase(L"7z") == 0)
- {
- _encryptionMethod.AddString(TEXT("AES-256"));
- _encryptionMethod.SetCurSel(0);
- }
- else if (ai.Name.CompareNoCase(L"zip") == 0)
- {
- int index = FindRegistryFormat(ai.Name);
- UString encryptionMethod;
- if (index >= 0)
- {
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- encryptionMethod = fo.EncryptionMethod;
- }
- _encryptionMethod.AddString(TEXT("ZipCrypto"));
- _encryptionMethod.AddString(TEXT("AES-256"));
- _encryptionMethod.SetCurSel(encryptionMethod.Find(L"AES") == 0 ? 1 : 0);
- }
-}
-
-int CCompressDialog::GetMethodID()
-{
- UString methodName;
- m_Method.GetText(methodName);
- for (int i = 0; i < MY_SIZE_OF_ARRAY(kMethodsNames); i++)
- if (methodName.CompareNoCase(kMethodsNames[i]) == 0)
- return i;
- return -1;
-}
-
-UString CCompressDialog::GetMethodSpec()
-{
- if (m_Method.GetCount() <= 1)
- return UString();
- UString result;
- m_Method.GetText(result);
- return result;
-}
-
-UString CCompressDialog::GetEncryptionMethodSpec()
-{
- if (m_Method.GetCount() <= 1)
- return UString();
- if (_encryptionMethod.GetCurSel() <= 0)
- return UString();
- UString result;
- _encryptionMethod.GetText(result);
- result.Replace(L"-", L"");
- return result;
-}
-
-int CCompressDialog::AddDictionarySize(UInt32 size, bool kilo, bool maga)
-{
- UInt32 sizePrint = size;
- if (kilo)
- sizePrint >>= 10;
- else if (maga)
- sizePrint >>= 20;
- TCHAR s[40];
- ConvertUInt64ToString(sizePrint, s);
- if (kilo)
- lstrcat(s, TEXT(" K"));
- else if (maga)
- lstrcat(s, TEXT(" M"));
- else
- lstrcat(s, TEXT(" "));
- lstrcat(s, TEXT("B"));
- int index = (int)m_Dictionary.AddString(s);
- m_Dictionary.SetItemData(index, size);
- return index;
-}
-
-int CCompressDialog::AddDictionarySize(UInt32 size)
-{
- if (size > 0)
- {
- if ((size & 0xFFFFF) == 0)
- return AddDictionarySize(size, false, true);
- if ((size & 0x3FF) == 0)
- return AddDictionarySize(size, true, false);
- }
- return AddDictionarySize(size, false, false);
-}
-
-void CCompressDialog::SetDictionary()
-{
- m_Dictionary.ResetContent();
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
- int index = FindRegistryFormat(ai.Name);
- UInt32 defaultDictionary = UInt32(-1);
- if (index >= 0)
- {
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
- defaultDictionary = fo.Dictionary;
- }
- int methodID = GetMethodID();
- int level = GetLevel2();
- if (methodID < 0)
- {
- SetMemoryUsage();
- return;
- }
- const UInt64 maxRamSize = GetMaxRamSizeForProgram();
- switch (methodID)
- {
- case kLZMA:
- {
- static const UInt32 kMinDicSize = (1 << 16);
- if (defaultDictionary == UInt32(-1))
- {
- if (level >= 9)
- defaultDictionary = (1 << 26);
- else if (level >= 7)
- defaultDictionary = (1 << 24);
- else if (level >= 5)
- defaultDictionary = (1 << 22);
- else if (level >= 3)
- defaultDictionary = (1 << 20);
- else
- defaultDictionary = (kMinDicSize);
- }
- int i;
- AddDictionarySize(kMinDicSize);
- m_Dictionary.SetCurSel(0);
- for (i = 20; i <= 30; i++)
- for (int j = 0; j < 2; j++)
- {
- if (i == 20 && j > 0)
- continue;
- UInt32 dictionary = (1 << i) + (j << (i - 1));
- if (dictionary >
- #ifdef _WIN64
- (1 << 30)
- #else
- (1 << 27)
- #endif
- )
- continue;
- AddDictionarySize(dictionary);
- UInt64 decomprSize;
- UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
- if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize)
- m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
- }
-
- // SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
- break;
- }
- case kPPMd:
- {
- if (defaultDictionary == UInt32(-1))
- {
- if (level >= 9)
- defaultDictionary = (192 << 20);
- else if (level >= 7)
- defaultDictionary = (64 << 20);
- else if (level >= 5)
- defaultDictionary = (16 << 20);
- else
- defaultDictionary = (4 << 20);
- }
- int i;
- for (i = 20; i < 31; i++)
- for (int j = 0; j < 2; j++)
- {
- if (i == 20 && j > 0)
- continue;
- UInt32 dictionary = (1 << i) + (j << (i - 1));
- if (dictionary >= (1 << 31))
- continue;
- AddDictionarySize(dictionary);
- UInt64 decomprSize;
- UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
- if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
- m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
- }
- SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
- break;
- }
- case kDeflate:
- {
- AddDictionarySize(32 << 10);
- m_Dictionary.SetCurSel(0);
- break;
- }
- case kDeflate64:
- {
- AddDictionarySize(64 << 10);
- m_Dictionary.SetCurSel(0);
- break;
- }
- case kBZip2:
- {
- UInt32 defaultDictionary;
- if (level >= 5)
- defaultDictionary = (900 << 10);
- else if (level >= 3)
- defaultDictionary = (500 << 10);
- else
- defaultDictionary = (100 << 10);
- for (int i = 1; i <= 9; i++)
- {
- UInt32 dictionary = (i * 100) << 10;
- AddDictionarySize(dictionary);
- if (dictionary <= defaultDictionary || m_Dictionary.GetCount() == 0)
- m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
- }
- break;
- }
- }
- SetMemoryUsage();
-}
-
-UInt32 CCompressDialog::GetDictionary()
-{
- if (m_Dictionary.GetCount() <= 0)
- return (UInt32)-1;
- return (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
-}
-
-UInt32 CCompressDialog::GetDictionarySpec()
-{
- if (m_Dictionary.GetCount() <= 1)
- return (UInt32)-1;
- return GetDictionary();
-}
-
-int CCompressDialog::AddOrder(UInt32 size)
-{
- TCHAR s[40];
- ConvertUInt64ToString(size, s);
- int index = (int)m_Order.AddString(s);
- m_Order.SetItemData(index, size);
- return index;
-}
-
-void CCompressDialog::SetOrder()
-{
- m_Order.ResetContent();
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
- int index = FindRegistryFormat(ai.Name);
- UInt32 defaultOrder = UInt32(-1);
- if (index >= 0)
- {
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
- defaultOrder = fo.Order;
- }
- int methodID = GetMethodID();
- int level = GetLevel2();
- if (methodID < 0)
- {
- SetMemoryUsage();
- return;
- }
- switch (methodID)
- {
- case kLZMA:
- {
- if (defaultOrder == UInt32(-1))
- defaultOrder = (level >= 7) ? 64 : 32;
- for (int i = 3; i <= 8; i++)
- for (int j = 0; j < 2; j++)
- {
- UInt32 order = (1 << i) + (j << (i - 1));
- if (order <= 256)
- AddOrder(order);
- }
- AddOrder(273);
- SetNearestSelectComboBox(m_Order, defaultOrder);
- break;
- }
- case kPPMd:
- {
- if (defaultOrder == UInt32(-1))
- {
- if (level >= 9)
- defaultOrder = 32;
- else if (level >= 7)
- defaultOrder = 16;
- else if (level >= 5)
- defaultOrder = 6;
- else
- defaultOrder = 4;
- }
- int i;
- AddOrder(2);
- AddOrder(3);
- for (i = 2; i < 8; i++)
- for (int j = 0; j < 4; j++)
- {
- UInt32 order = (1 << i) + (j << (i - 2));
- if (order < 32)
- AddOrder(order);
- }
- AddOrder(32);
- SetNearestSelectComboBox(m_Order, defaultOrder);
- break;
- }
- case kDeflate:
- case kDeflate64:
- {
- if (defaultOrder == UInt32(-1))
- {
- if (level >= 9)
- defaultOrder = 128;
- else if (level >= 7)
- defaultOrder = 64;
- else
- defaultOrder = 32;
- }
- int i;
- for (i = 3; i <= 8; i++)
- for (int j = 0; j < 2; j++)
- {
- UInt32 order = (1 << i) + (j << (i - 1));
- if (order <= 256)
- AddOrder(order);
- }
- AddOrder(methodID == kDeflate64 ? 257 : 258);
- SetNearestSelectComboBox(m_Order, defaultOrder);
- break;
- }
- case kBZip2:
- {
- break;
- }
- }
- SetMemoryUsage();
-}
-
-bool CCompressDialog::GetOrderMode()
-{
- switch (GetMethodID())
- {
- case kPPMd:
- return true;
- }
- return false;
-}
-
-UInt32 CCompressDialog::GetOrder()
-{
- if (m_Order.GetCount() <= 0)
- return (UInt32)-1;
- return (UInt32)m_Order.GetItemData(m_Order.GetCurSel());
-}
-
-UInt32 CCompressDialog::GetOrderSpec()
-{
- if (m_Order.GetCount() <= 1)
- return (UInt32)-1;
- return GetOrder();
-}
-
-UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory)
-{
- decompressMemory = UInt64(Int64(-1));
- int level = GetLevel2();
- if (level == 0)
- {
- decompressMemory = (1 << 20);
- return decompressMemory;
- }
- UInt64 size = 0;
-
- const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- if (fi.Filter && level >= 9)
- size += (12 << 20) * 2 + (5 << 20);
- switch (GetMethodID())
- {
- case kLZMA:
- {
- UInt32 hs = dictionary - 1;
- hs |= (hs >> 1);
- hs |= (hs >> 2);
- hs |= (hs >> 4);
- hs |= (hs >> 8);
- hs >>= 1;
- hs |= 0xFFFF;
- if (hs > (1 << 24))
- hs >>= 1;
- hs++;
- size += hs * 4;
- size += (UInt64)dictionary * 11 / 2;
- if (level >= 5)
- size += dictionary * 4;
- size += (2 << 20);
- if (isMultiThread && level >= 5)
- size += (2 << 20) + (4 << 20);
-
- decompressMemory = dictionary + (2 << 20);
- return size;
- }
- case kPPMd:
- {
- decompressMemory = dictionary + (2 << 20);
- return size + decompressMemory;
- }
- case kDeflate:
- case kDeflate64:
- {
- UInt32 order = GetOrder();
- if (order == UInt32(-1))
- order = 32;
- if (level >= 7)
- size += (1 << 20);
- size += 3 << 20;
- decompressMemory = (2 << 20);
- return size;
- }
- case kBZip2:
- {
- decompressMemory = (7 << 20);
- UInt64 memForOneThread = (10 << 20);
- if (isMultiThread)
- memForOneThread *= NSystem::GetNumberOfProcessors();
- return size + (10 << 20);
- }
- }
- return UInt64(Int64(-1));
-}
-
-UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
-{
- return GetMemoryUsage(GetDictionary(), IsMultiThread(), decompressMemory);
-}
-
-void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
-{
- if (value == (UInt64)Int64(-1))
- {
- SetItemText(res, TEXT("?"));
- return;
- }
- value = (value + (1 << 20) - 1) >> 20;
- TCHAR s[40];
- ConvertUInt64ToString(value, s);
- lstrcat(s, TEXT(" MB"));
- SetItemText(res, s);
-}
-
-void CCompressDialog::SetMemoryUsage()
-{
- UInt64 decompressMem;
- UInt64 memUsage = GetMemoryUsage(decompressMem);
- PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_VALUE, memUsage);
- PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, decompressMem);
-}
-
-void CCompressDialog::SetParams()
-{
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
- m_Params.SetText(TEXT(""));
- int index = FindRegistryFormat(ai.Name);
- if (index >= 0)
- {
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- m_Params.SetText(fo.Options);
- }
-}
-
-void CCompressDialog::SaveOptionsInMem()
-{
- const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
- int index = FindRegistryFormatAlways(ai.Name);
- m_Params.GetText(Info.Options);
- Info.Options.Trim();
- NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- fo.Options = Info.Options;
- fo.Level = GetLevelSpec();
- fo.Dictionary = GetDictionarySpec();
- fo.Order = GetOrderSpec();
- fo.Method = GetMethodSpec();
- fo.EncryptionMethod = GetEncryptionMethodSpec();
-}
diff --git a/7zip/UI/GUI/CompressDialog.h b/7zip/UI/GUI/CompressDialog.h
deleted file mode 100755
index fc73b557..00000000
--- a/7zip/UI/GUI/CompressDialog.h
+++ /dev/null
@@ -1,172 +0,0 @@
-// CompressDialog.h
-
-#ifndef __COMPRESSDIALOG_H
-#define __COMPRESSDIALOG_H
-
-#include "../Common/ZipRegistry.h"
-#include "../Common/ArchiverInfo.h"
-#include "../Resource/CompressDialog/resource.h"
-
-#include "Windows/Control/Dialog.h"
-#include "Windows/Control/Edit.h"
-#include "Windows/Control/ComboBox.h"
-
-namespace NCompressDialog
-{
- namespace NUpdateMode
- {
- enum EEnum
- {
- kAdd,
- kUpdate,
- kFresh,
- kSynchronize,
- };
- }
- struct CInfo
- {
- NUpdateMode::EEnum UpdateMode;
- bool SolidIsAllowed;
- bool Solid;
-
- bool MultiThreadIsAllowed;
- bool MultiThread;
-
- CRecordVector<UInt64> VolumeSizes;
-
- UInt32 Level;
- UString Method;
- UInt32 Dictionary;
- bool OrderMode;
- UInt32 Order;
- UString Options;
-
- UString EncryptionMethod;
-
- bool SFXMode;
-
- UString ArchiveName; // in: Relative for ; out: abs
- UString CurrentDirPrefix;
- bool KeepName;
-
- bool GetFullPathName(UString &result) const;
-
- int ArchiverInfoIndex;
-
- UString Password;
- bool EncryptHeadersIsAllowed;
- bool EncryptHeaders;
-
- void Init()
- {
- Level = Dictionary = Order = UInt32(-1);
- OrderMode = false;
- Method.Empty();
- Options.Empty();
- EncryptionMethod.Empty();
- }
- CInfo()
- {
- Init();
- }
- };
-}
-
-class CCompressDialog: public NWindows::NControl::CModalDialog
-{
- NWindows::NControl::CComboBox m_ArchivePath;
- NWindows::NControl::CComboBox m_Format;
- NWindows::NControl::CComboBox m_Level;
- NWindows::NControl::CComboBox m_Method;
- NWindows::NControl::CComboBox m_Dictionary;
- NWindows::NControl::CComboBox m_Order;
- NWindows::NControl::CComboBox m_UpdateMode;
- NWindows::NControl::CComboBox m_Volume;
- NWindows::NControl::CDialogChildControl m_Params;
-
- NWindows::NControl::CEdit _password1Control;
- NWindows::NControl::CEdit _password2Control;
- NWindows::NControl::CComboBox _encryptionMethod;
-
- NCompression::CInfo m_RegistryInfo;
-
- int m_PrevFormat;
- void SetArchiveName(const UString &name);
- int FindRegistryFormat(const UString &name);
- int FindRegistryFormatAlways(const UString &name);
-
- void OnChangeFormat();
- void CheckSFXNameChange();
- void SetArchiveName2(bool prevWasSFX);
-
- int GetStaticFormatIndex();
-
- void SetNearestSelectComboBox(
- NWindows::NControl::CComboBox &comboBox, UInt32 value);
-
- void SetLevel();
- int GetLevel();
- int GetLevelSpec();
- int GetLevel2();
- bool IsMultiThread();
-
- void SetMethod();
- int GetMethodID();
- UString GetMethodSpec();
- UString GetEncryptionMethodSpec();
-
- bool IsZipFormat();
-
- void SetEncryptionMethod();
-
- int AddDictionarySize(UInt32 size, bool kilo, bool maga);
- int AddDictionarySize(UInt32 size);
-
- void SetDictionary();
- UInt32 GetDictionary();
- UInt32 GetDictionarySpec();
-
- int AddOrder(UInt32 size);
- void SetOrder();
- bool GetOrderMode();
- UInt32 GetOrder();
- UInt32 GetOrderSpec();
-
- UInt64 GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory);
- UInt64 GetMemoryUsage(UInt64 &decompressMemory);
- void PrintMemUsage(UINT res, UInt64 value);
- void SetMemoryUsage();
- void SetParams();
- void SaveOptionsInMem();
-
- void UpdatePasswordControl();
- bool IsShowPasswordChecked() const
- { return IsButtonChecked(IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED; }
-public:
- CObjectVector<CArchiverInfo> m_ArchiverInfoList;
-
- NCompressDialog::CInfo Info;
- UString OriginalFileName; // for bzip2, gzip2
-
- INT_PTR Create(HWND wndParent = 0)
- { return CModalDialog::Create(IDD_DIALOG_COMPRESS, wndParent); }
-
-protected:
-
- void CheckSFXControlsEnable();
- void CheckVolumeEnable();
- void CheckControlsEnable();
-
- void OnButtonSetArchive();
- bool IsSFX();
- void OnButtonSFX();
-
- virtual bool OnInit();
- virtual bool OnCommand(int code, int itemID, LPARAM lParam);
- virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
- virtual void OnOK();
- virtual void OnHelp();
-
-};
-
-#endif
diff --git a/7zip/UI/GUI/ExtractDialog.h b/7zip/UI/GUI/ExtractDialog.h
deleted file mode 100755
index f52498d2..00000000
--- a/7zip/UI/GUI/ExtractDialog.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// ExtractDialog.h
-
-#ifndef __EXTRACTDIALOG_H
-#define __EXTRACTDIALOG_H
-
-#include "resource.h"
-
-#include "Windows/Control/Dialog.h"
-#include "Windows/Control/Edit.h"
-#include "Windows/Control/ComboBox.h"
-
-#ifndef NO_REGISTRY
-#include "../Common/ZipRegistry.h"
-#endif
-#include "../Common/ExtractMode.h"
-
-namespace NExtractionDialog
-{
- /*
- namespace NFilesMode
- {
- enum EEnum
- {
- kSelected,
- kAll,
- kSpecified
- };
- }
- */
-}
-
-class CExtractDialog: public NWindows::NControl::CModalDialog
-{
- #ifdef NO_REGISTRY
- NWindows::NControl::CDialogChildControl _path;
- #else
- NWindows::NControl::CComboBox _path;
- #endif
-
- #ifndef _SFX
- NWindows::NControl::CEdit _passwordControl;
- #endif
-
- #ifndef _SFX
- void GetPathMode();
- void SetPathMode();
- void GetOverwriteMode();
- void SetOverwriteMode();
- // int GetFilesMode() const;
- void UpdatePasswordControl();
- #endif
-
- void OnButtonSetPath();
-
- virtual bool OnInit();
- virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
- virtual void OnOK();
- #ifndef NO_REGISTRY
- virtual void OnHelp();
- #endif
-public:
- // bool _enableSelectedFilesButton;
- // bool _enableFilesButton;
- // NExtractionDialog::NFilesMode::EEnum FilesMode;
-
- UString DirectoryPath;
- #ifndef _SFX
- UString Password;
- #endif
- NExtract::NPathMode::EEnum PathMode;
- NExtract::NOverwriteMode::EEnum OverwriteMode;
-
- INT_PTR Create(HWND aWndParent = 0)
- { return CModalDialog::Create(IDD_DIALOG_EXTRACT, aWndParent); }
-};
-
-#endif
diff --git a/7zip/UI/GUI/GUI.dsp b/7zip/UI/GUI/GUI.dsp
deleted file mode 100755
index ef9aba16..00000000
--- a/7zip/UI/GUI/GUI.dsp
+++ /dev/null
@@ -1,904 +0,0 @@
-# Microsoft Developer Studio Project File - Name="GUI" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=GUI - Win32 DebugU
-!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 "GUI.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 "GUI.mak" CFG="GUI - Win32 DebugU"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "GUI - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "GUI - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE "GUI - Win32 ReleaseU" (based on "Win32 (x86) Application")
-!MESSAGE "GUI - Win32 DebugU" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "GUI - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /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 /subsystem:windows /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 comctl32.lib htmlhelp.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-Zip\7zg.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "GUI - 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 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /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 /subsystem:windows /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 comctl32.lib htmlhelp.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-Zip\7zg.exe" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "GUI - Win32 ReleaseU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ReleaseU"
-# PROP BASE Intermediate_Dir "ReleaseU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ReleaseU"
-# PROP Intermediate_Dir "ReleaseU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /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 /subsystem:windows /machine:I386 /out:"C:\UTIL\7zg.exe"
-# 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 comctl32.lib htmlhelp.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-Zip\7zgn.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "GUI - Win32 DebugU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "DebugU"
-# PROP BASE Intermediate_Dir "DebugU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "DebugU"
-# PROP Intermediate_Dir "DebugU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /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 /subsystem:windows /debug /machine:I386 /out:"C:\UTIL\7zg.exe" /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 comctl32.lib htmlhelp.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-Zip\7zgn.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "GUI - Win32 Release"
-# Name "GUI - Win32 Debug"
-# Name "GUI - Win32 ReleaseU"
-# Name "GUI - Win32 DebugU"
-# Begin Group "Spec"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\7zG.exe.manifest
-# End Source File
-# Begin Source File
-
-SOURCE=.\FM.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\resource.h
-# 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 "SDK"
-
-# PROP Default_Filter ""
-# Begin Group "Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CommandLineParser.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\CommandLineParser.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\Lang.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Lang.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\ListFileUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\ListFileUtils.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\StdInStream.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\StdInStream.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\String.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
-# Begin Source File
-
-SOURCE=..\..\..\Common\TextConfig.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\TextConfig.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\UTFConvert.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\UTFConvert.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Vector.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Wildcard.h
-# End Source File
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# Begin Group "Control"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Control\ComboBox.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Control\ComboBox.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Control\Dialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Control\Dialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Control\Edit.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\ProgressBar.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\..\..\Windows\CommonDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\CommonDialog.h
-# End Source File
-# 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\Error.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Error.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.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\FileName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\MemoryLock.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\MemoryLock.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\PropVariantConversions.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\PropVariantConversions.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Registry.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Registry.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\ResourceString.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\ResourceString.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Shell.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Shell.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\Window.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Windows\Window.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "UI Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Common\ArchiveCommandLine.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveCommandLine.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveExtractCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveExtractCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveOpenCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiveOpenCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiverInfo.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiverInfo.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\DefaultName.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\DefaultName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\DirItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\EnumDirItems.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\EnumDirItems.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ExitCode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\Extract.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\Extract.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ExtractingFilePath.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ExtractingFilePath.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ExtractMode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\HandlerLoader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\IFileExtractCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\OpenArchive.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\OpenArchive.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\Property.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\PropIDUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\PropIDUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\SetProperties.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\SetProperties.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\SortUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\SortUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\TempFiles.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\TempFiles.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\Update.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\Update.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateAction.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateAction.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdatePair.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdatePair.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateProduce.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\UpdateProduce.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\WorkDir.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\WorkDir.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ZipRegistry.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ZipRegistry.h
-# End Source File
-# End Group
-# Begin Group "Explorer"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\Explorer\MyMessages.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Explorer\MyMessages.h
-# End Source File
-# End Group
-# Begin Group "Dialogs"
-
-# PROP Default_Filter ""
-# Begin Group "Progress"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\FileManager\Resource\ProgressDialog2\ProgressDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\Resource\ProgressDialog2\ProgressDialog.h
-# End Source File
-# End Group
-# Begin Group "Messages"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\FileManager\Resource\MessagesDialog\MessagesDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\Resource\MessagesDialog\MessagesDialog.h
-# End Source File
-# End Group
-# Begin Group "Overwtite"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\FileManager\Resource\OverwriteDialog\OverwriteDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\Resource\OverwriteDialog\OverwriteDialog.h
-# End Source File
-# End Group
-# Begin Group "Password"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\FileManager\Resource\PasswordDialog\PasswordDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\Resource\PasswordDialog\PasswordDialog.h
-# End Source File
-# End Group
-# Begin Group "Compress Dialog"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\CompressDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\CompressDialog.h
-# End Source File
-# End Group
-# Begin Group "Extract Dialog"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ExtractDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ExtractDialog.h
-# End Source File
-# End Group
-# End Group
-# Begin Group "FM Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\FileManager\ExtractCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\ExtractCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\FolderInterface.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\FormatUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\FormatUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\HelpUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\HelpUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\LangUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\LangUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\OpenCallback.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\OpenCallback.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\ProgramLocation.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\ProgramLocation.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\RegistryUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\RegistryUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\SplitUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\SplitUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\StringUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\StringUtils.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\UpdateCallback100.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\FileManager\UpdateCallback100.h
-# End Source File
-# End Group
-# Begin Group "Engine"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ExtractGUI.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ExtractGUI.h
-# End Source File
-# Begin Source File
-
-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
-
-SOURCE=.\UpdateCallbackGUI.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\UpdateGUI.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\UpdateGUI.h
-# End Source File
-# End Group
-# Begin Group "7-zip Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.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 "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
-# End Target
-# End Project
diff --git a/7zip/UI/GUI/OpenCallbackGUI.cpp b/7zip/UI/GUI/OpenCallbackGUI.cpp
deleted file mode 100755
index 6634c0b3..00000000
--- a/7zip/UI/GUI/OpenCallbackGUI.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// OpenCallbackGUI.cpp
-
-#include "StdAfx.h"
-
-#include "OpenCallbackGUI.h"
-
-#include "Common/StdOutStream.h"
-#include "Common/StdInStream.h"
-#include "Common/StringConvert.h"
-
-#ifndef _NO_CRYPTO
-#include "../../FileManager/Resource/PasswordDialog/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)
-{
- 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;
-}
-#endif
-
diff --git a/7zip/UI/GUI/OpenCallbackGUI.h b/7zip/UI/GUI/OpenCallbackGUI.h
deleted file mode 100755
index eb593abe..00000000
--- a/7zip/UI/GUI/OpenCallbackGUI.h
+++ /dev/null
@@ -1,30 +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 PasswordIsDefined;
- UString Password;
- #endif
-
- HWND ParentWindow;
-
- COpenCallbackGUI():
- #ifndef _NO_CRYPTO
- PasswordIsDefined(false),
- #endif
- ParentWindow(0) {}
-};
-
-#endif
diff --git a/7zip/UI/GUI/StdAfx.cpp b/7zip/UI/GUI/StdAfx.cpp
deleted file mode 100755
index e9cf4cfb..00000000
--- a/7zip/UI/GUI/StdAfx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : source file that includes just the standard includes
-// GUI.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
diff --git a/7zip/UI/GUI/makefile b/7zip/UI/GUI/makefile
deleted file mode 100755
index a0c3e988..00000000
--- a/7zip/UI/GUI/makefile
+++ /dev/null
@@ -1,135 +0,0 @@
-PROG = 7zG.exe
-LIBS = $(LIBS) user32.lib advapi32.lib oleaut32.lib shell32.lib comctl32.lib htmlhelp.lib ole32.lib comdlg32.lib
-CFLAGS = $(CFLAGS) -I ../../../ -DLANG -DCOMPRESS_MT
-
-GUI_OBJS = \
- $O\CompressDialog.obj \
- $O\ExtractDialog.obj \
- $O\ExtractGUI.obj \
- $O\GUI.obj \
- $O\OpenCallbackGUI.obj \
- $O\UpdateCallbackGUI.obj \
- $O\UpdateGUI.obj \
-
-COMMON_OBJS = \
- $O\Alloc.obj \
- $O\CommandLineParser.obj \
- $O\IntToString.obj \
- $O\Lang.obj \
- $O\ListFileUtils.obj \
- $O\NewHandler.obj \
- $O\StdInStream.obj \
- $O\String.obj \
- $O\StringConvert.obj \
- $O\StringToInt.obj \
- $O\TextConfig.obj \
- $O\UTFConvert.obj \
- $O\Vector.obj \
- $O\Wildcard.obj \
-
-WIN_OBJS = \
- $O\CommonDialog.obj \
- $O\DLL.obj \
- $O\Error.obj \
- $O\FileDir.obj \
- $O\FileFind.obj \
- $O\FileIO.obj \
- $O\FileName.obj \
- $O\MemoryLock.obj \
- $O\PropVariant.obj \
- $O\PropVariantConversions.obj \
- $O\Registry.obj \
- $O\ResourceString.obj \
- $O\Shell.obj \
- $O\Synchronization.obj \
- $O\Window.obj \
-
-WIN_CTRL_OBJS = \
- $O\ComboBox.obj \
- $O\Dialog.obj \
- $O\ListView.obj \
-
-7ZIP_COMMON_OBJS = \
- $O\FilePathAutoRename.obj \
- $O\FileStreams.obj \
- $O\StreamUtils.obj \
-
-UI_COMMON_OBJS = \
- $O\ArchiveCommandLine.obj \
- $O\ArchiveExtractCallback.obj \
- $O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
- $O\DefaultName.obj \
- $O\EnumDirItems.obj \
- $O\Extract.obj \
- $O\ExtractingFilePath.obj \
- $O\OpenArchive.obj \
- $O\PropIDUtils.obj \
- $O\SetProperties.obj \
- $O\SortUtils.obj \
- $O\TempFiles.obj \
- $O\Update.obj \
- $O\UpdateAction.obj \
- $O\UpdateCallback.obj \
- $O\UpdatePair.obj \
- $O\UpdateProduce.obj \
- $O\WorkDir.obj \
- $O\ZipRegistry.obj \
-
-FM_OBJS = \
- $O\ExtractCallback.obj \
- $O\FormatUtils.obj \
- $O\HelpUtils.obj \
- $O\LangUtils.obj \
- $O\OpenCallback.obj \
- $O\ProgramLocation.obj \
- $O\RegistryUtils.obj \
- $O\SplitUtils.obj \
- $O\StringUtils.obj \
- $O\UpdateCallback100.obj \
-
-OBJS = \
- $O\StdAfx.obj \
- $(GUI_OBJS) \
- $(COMMON_OBJS) \
- $(WIN_OBJS) \
- $(WIN_CTRL_OBJS) \
- $(7ZIP_COMMON_OBJS) \
- $(UI_COMMON_OBJS) \
- $(FM_OBJS)\
- $O\MyMessages.obj \
- $O\MessagesDialog.obj \
- $O\OverwriteDialog.obj \
- $O\PasswordDialog.obj \
- $O\ProgressDialog.obj \
- $O\CopyCoder.obj \
- $O\resource.res
-
-!include "../../../Build.mak"
-
-$(GUI_OBJS): $(*B).cpp
- $(COMPL)
-$(COMMON_OBJS): ../../../Common/$(*B).cpp
- $(COMPL)
-$(WIN_OBJS): ../../../Windows/$(*B).cpp
- $(COMPL)
-$(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp
- $(COMPL)
-$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
- $(COMPL)
-$(UI_COMMON_OBJS): ../Common/$(*B).cpp
- $(COMPL)
-$(FM_OBJS): ../../FileManager/$(*B).cpp
- $(COMPL)
-$O\MyMessages.obj: ../Explorer/MyMessages.cpp
- $(COMPL)
-$O\MessagesDialog.obj: ../../FileManager/Resource/MessagesDialog/$(*B).cpp
- $(COMPL)
-$O\OverwriteDialog.obj: ../../FileManager/Resource/OverwriteDialog./$(*B).cpp
- $(COMPL)
-$O\PasswordDialog.obj: ../../FileManager/Resource/PasswordDialog/$(*B).cpp
- $(COMPL)
-$O\ProgressDialog.obj: ../../FileManager/Resource/ProgressDialog2/$(*B).cpp
- $(COMPL)
-$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
- $(COMPL)
diff --git a/7zip/UI/GUI/resource.h b/7zip/UI/GUI/resource.h
deleted file mode 100755
index af4fdc0b..00000000
--- a/7zip/UI/GUI/resource.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#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_OPEN_TYPE_ALL_FILES 80
-
-#define IDS_METHOD_STORE 81
-#define IDS_METHOD_NORMAL 82
-#define IDS_METHOD_MAXIMUM 83
-#define IDS_METHOD_FAST 84
-#define IDS_METHOD_FASTEST 85
-#define IDS_METHOD_ULTRA 86
-
-#define IDS_COMPRESS_UPDATE_MODE_ADD 90
-#define IDS_COMPRESS_UPDATE_MODE_UPDATE 91
-#define IDS_COMPRESS_UPDATE_MODE_FRESH 92
-#define IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE 93
-
-#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95
-
-#define IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE 96
-#define IDS_CANT_UPDATE_ARCHIVE 97
-
-#define IDS_PROGRESS_COMPRESSING 98
-#define IDS_PROGRESS_TESTING 99
-#define IDS_ERROR 100
-#define IDS_MESSAGE_NO_ERRORS 101
-#define IDS_CONFIG_DIALOG_CAPTION 102
-
-#define IDS_PASSWORD_USE_ASCII 110
-#define IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH 111
-#define IDS_PASSWORD_IS_TOO_LONG 112
-
-#define IDD_DIALOG_EXTRACT 137
-#define IDB_DELETE 149
-#define IDC_LIST1 1067
-#define IDC_COLUMN_EDIT_WIDTH 1068
-
diff --git a/7zip/UI/GUI/resource.rc b/7zip/UI/GUI/resource.rc
deleted file mode 100755
index ace71177..00000000
--- a/7zip/UI/GUI/resource.rc
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "../../MyVersionInfo.rc"
-#include <winnt.h>
-#include "resource.h"
-
-MY_VERSION_INFO_APP("7-Zip GUI", "7zg")
-
-IDI_ICON1 ICON "FM.ico"
-
-1 24 MOVEABLE PURE "7zG.exe.manifest"
-
-STRINGTABLE
-BEGIN
- IDS_CONTEXT_EXTRACT "Extract files..."
- IDS_CONTEXT_EXTRACT_HELP "Extracts files from the selected archive."
- IDS_CONTEXT_COMPRESS "Add to archive..."
- IDS_CONTEXT_COMPRESS_HELP "Adds the selected items to archive."
- IDS_CONTEXT_OPEN "Open"
- IDS_CONTEXT_OPEN_HELP "Opens the selected archive."
- IDS_CONTEXT_TEST "Test archive"
- IDS_CONTEXT_TEST_HELP "Tests integrity of the selected archive."
- IDS_CONTEXT_CAPTION_HELP "7-Zip commands"
- IDS_CONTEXT_POPUP_CAPTION "7-Zip"
- IDS_OPEN_TYPE_ALL_FILES "All Files"
- IDS_METHOD_STORE "Store"
- IDS_METHOD_NORMAL "Normal"
- IDS_METHOD_MAXIMUM "Maximum"
- IDS_METHOD_FAST "Fast"
- IDS_METHOD_FASTEST "Fastest"
- IDS_METHOD_ULTRA "Ultra"
- IDS_COMPRESS_UPDATE_MODE_ADD "Add and replace files"
- IDS_COMPRESS_UPDATE_MODE_UPDATE "Update and add files"
- IDS_COMPRESS_UPDATE_MODE_FRESH "Freshen existing files"
- IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE "Synchronize files"
- IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE "Browse"
- IDS_COMPRESS_INCORRECT_VOLUME_SIZE "Incorrect volume size"
-
- IDS_PASSWORD_USE_ASCII "Use only English letters, numbers and special characters (!, #, $, ...) for password."
- IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH "Passwords do not match"
- IDS_PASSWORD_IS_TOO_LONG "Password is too long"
-
- IDS_CANT_UPDATE_ARCHIVE "Can not update archive '{0}'"
- IDS_PROGRESS_COMPRESSING "Compressing"
- IDS_PROGRESS_TESTING "Testing"
- IDS_ERROR "Error"
- IDS_MESSAGE_NO_ERRORS "There are no errors"
- IDS_CONFIG_DIALOG_CAPTION "7-Zip Options"
-END
-
-#include "../../FileManager/Resource/PropertyName/resource.rc"
-#include "../../FileManager/Resource/OverwriteDialog/resource.rc"
-#include "../../FileManager/Resource/PasswordDialog/resource.rc"
-#include "../../FileManager/Resource/MessagesDialog/resource.rc"
-#include "../../FileManager/Resource/ProgressDialog2/resource.rc"
-#include "../Resource/Extract/resource.rc"
-#include "../Resource/ExtractDialog/resource.rc"
-#include "../Resource/CompressDialog/resource.rc"
diff --git a/7zip/UI/Resource/Extract/resource.h b/7zip/UI/Resource/Extract/resource.h
deleted file mode 100755
index 4cee4183..00000000
--- a/7zip/UI/Resource/Extract/resource.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#define IDS_CANNOT_CREATE_FOLDER 200
-#define IDS_OPEN_IS_NOT_SUPORTED_ARCHIVE 201
-
-#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC 202
-#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR 203
-#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD 204
-#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED 205
-#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED 206
-
-#define IDS_EXTRACT_SET_FOLDER 207
-#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CANNOT_OPEN_FILE 208
-#define IDS_PROGRESS_EXTRACTING 209
diff --git a/7zip/UI/Resource/Extract/resource.rc b/7zip/UI/Resource/Extract/resource.rc
deleted file mode 100755
index f4cf5a1f..00000000
--- a/7zip/UI/Resource/Extract/resource.rc
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "resource.h"
-
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-
-STRINGTABLE DISCARDABLE
-BEGIN
- 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."
- IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR "Data error in '{0}'. File is broken"
- IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED "CRC failed in encrypted file '{0}'. Wrong password?"
- IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED "Data error in encrypted file '{0}'. Wrong password?"
- IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD "Unsupported compression method for '{0}'."
- IDS_EXTRACT_SET_FOLDER "Specify a location for extracted files."
- IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CANNOT_OPEN_FILE "Can not open output file '{0}'."
- IDS_PROGRESS_EXTRACTING "Extracting"
-END
diff --git a/7zip/UI/Resource/ExtractDialog/resource.rc b/7zip/UI/Resource/ExtractDialog/resource.rc
deleted file mode 100755
index 1c3f1319..00000000
--- a/7zip/UI/Resource/ExtractDialog/resource.rc
+++ /dev/null
@@ -1,80 +0,0 @@
-#include "resource.h"
-#include "../../../GuiCommon.rc"
-
-#define xSize2 285
-#define ySize2 204
-
-#define xSize (xSize2 + marg + marg)
-#define ySize (ySize2 + marg + marg)
-
-#undef g1XSize
-#undef g1XSize2
-#undef g1XPos2
-#undef g2XPos
-#undef g2XPos2
-#undef g2XSize
-#undef g2XSize2
-
-#define bYPos (ySize - marg - bYSize)
-
-#define g1XSize 127
-#define g1XSize2 (g1XSize - 13)
-#define g1XPos2 (marg + 7)
-
-#define gSpace 14
-#define g2XPos (marg + g1XSize + gSpace)
-#define g2XPos2 (g2XPos + 7)
-#define g2XSize (xSize2 - g1XSize - gSpace)
-#define g2XSize2 (g2XSize - 14)
-
-#define bXPos1 (xSize - marg - bXSize)
-#define bXPos2 (bXPos1 - 10 - bXSize)
-#define bXPos3 (bXPos2 - 10 - bXSize)
-
-IDD_DIALOG_EXTRACT DIALOG DISCARDABLE 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
-CAPTION "Extract"
-MY_FONT
-BEGIN
- LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, marg, marg, xSize2, 8
-
- COMBOBOX IDC_EXTRACT_COMBO_PATH, marg, 21, xSize2 - bDotsSize - 13, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
-
- PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xSize - marg - bDotsSize, 20, bDotsSize, bYSize, WS_GROUP
-
- GROUPBOX "Path mode",IDC_EXTRACT_PATH_MODE, marg, 44, g1XSize, 57
- CONTROL "Full pathnames", IDC_EXTRACT_RADIO_FULL_PATHNAMES,"Button", BS_AUTORADIOBUTTON | WS_GROUP,
- g1XPos2, 57, g1XSize2, 10
- CONTROL "Current pathnames",IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, "Button", BS_AUTORADIOBUTTON,
- g1XPos2, 71, g1XSize2, 10
- CONTROL "No pathnames", IDC_EXTRACT_RADIO_NO_PATHNAMES, "Button", BS_AUTORADIOBUTTON,
- g1XPos2, 85, g1XSize2, 10
-
- GROUPBOX "Overwrite mode",IDC_EXTRACT_OVERWRITE_MODE, g2XPos, 44, g2XSize, 88, WS_GROUP
- CONTROL "Ask before overwrite", IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, "Button", BS_AUTORADIOBUTTON | WS_GROUP,
- g2XPos2, 57, g2XSize2, 10
- CONTROL "Overwrite without prompt", IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, "Button", BS_AUTORADIOBUTTON,
- g2XPos2, 71, g2XSize2, 10
- CONTROL "Skip existing files", IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, "Button", BS_AUTORADIOBUTTON,
- g2XPos2, 85, g2XSize2, 10
- CONTROL "Auto rename", IDC_EXTRACT_RADIO_AUTO_RENAME, "Button", BS_AUTORADIOBUTTON,
- g2XPos2, 99, g2XSize2, 10
- CONTROL "Auto rename existing files", IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, "Button", BS_AUTORADIOBUTTON,
- g2XPos2,113, g2XSize2, 10
-
- GROUPBOX "Files",IDC_EXTRACT_FILES, marg, 140, 127, 48, NOT WS_VISIBLE | WS_DISABLED | WS_GROUP
- CONTROL "&Selected files",IDC_EXTRACT_RADIO_SELECTED_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_GROUP,
- g1XPos2, 153, g1XSize2, 10
- CONTROL "&All files",IDC_EXTRACT_RADIO_ALL_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED,
- g1XPos2, 166, g1XSize2, 10
-
- GROUPBOX "Password",IDC_EXTRACT_PASSWORD, g2XPos, 142, g2XSize, 46
- EDITTEXT IDC_EXTRACT_EDIT_PASSWORD,154,153,130,14, ES_PASSWORD | ES_AUTOHSCROLL
- CONTROL "Show Password",IDC_EXTRACT_CHECK_SHOW_PASSWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
- g2XPos2, 172, g2XSize2, 10
-
- DEFPUSHBUTTON "OK", IDOK, bXPos3, bYPos, bXSize, bYSize, WS_GROUP
- PUSHBUTTON "Cancel", IDCANCEL, bXPos2, bYPos, bXSize, bYSize
- PUSHBUTTON "Help", IDHELP, bXPos1, bYPos, bXSize, bYSize
-END
-
-
diff --git a/C/7zCrc.c b/C/7zCrc.c
new file mode 100755
index 00000000..136ac2e0
--- /dev/null
+++ b/C/7zCrc.c
@@ -0,0 +1,137 @@
+/* 7zCrc.c */
+
+#include "7zCrc.h"
+
+#define kCrcPoly 0xEDB88320
+
+UInt32 g_CrcTable[256]
+
+#ifdef CRC_GENERATE_TABLE
+;
+void CrcGenerateTable()
+{
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ {
+ UInt32 r = i;
+ int j;
+ for (j = 0; j < 8; j++)
+ if (r & 1)
+ r = (r >> 1) ^ kCrcPoly;
+ else
+ r >>= 1;
+ g_CrcTable[i] = r;
+ }
+}
+
+#else
+
+= {
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+ 0x2d02ef8dL
+};
+
+#endif
+
+void CrcInit(UInt32 *crc) { *crc = 0xFFFFFFFF; }
+UInt32 CrcGetDigest(UInt32 *crc) { return *crc ^ 0xFFFFFFFF; }
+
+void CrcUpdateByte(UInt32 *crc, Byte b)
+{
+ *crc = g_CrcTable[((Byte)(*crc)) ^ b] ^ (*crc >> 8);
+}
+
+void CrcUpdateUInt16(UInt32 *crc, UInt16 v)
+{
+ CrcUpdateByte(crc, (Byte)v);
+ CrcUpdateByte(crc, (Byte)(v >> 8));
+}
+
+void CrcUpdateUInt32(UInt32 *crc, UInt32 v)
+{
+ int i;
+ for (i = 0; i < 4; i++)
+ CrcUpdateByte(crc, (Byte)(v >> (8 * i)));
+}
+
+void CrcUpdateUInt64(UInt32 *crc, UInt64 v)
+{
+ int i;
+ for (i = 0; i < 8; i++)
+ {
+ CrcUpdateByte(crc, (Byte)(v));
+ v >>= 8;
+ }
+}
+
+void CrcUpdate(UInt32 *crc, const void *data, size_t size)
+{
+ UInt32 v = *crc;
+ const Byte *p = (const Byte *)data;
+ for (; size > 0 ; size--, p++)
+ v = g_CrcTable[((Byte)(v)) ^ *p] ^ (v >> 8);
+ *crc = v;
+}
+
+UInt32 CrcCalculateDigest(const void *data, size_t size)
+{
+ UInt32 crc;
+ CrcInit(&crc);
+ CrcUpdate(&crc, data, size);
+ return CrcGetDigest(&crc);
+}
+
+int CrcVerifyDigest(UInt32 digest, const void *data, size_t size)
+{
+ return (CrcCalculateDigest(data, size) == digest);
+}
diff --git a/C/7zCrc.h b/C/7zCrc.h
new file mode 100755
index 00000000..370b2a0f
--- /dev/null
+++ b/C/7zCrc.h
@@ -0,0 +1,31 @@
+/* 7zCrc.h */
+
+#ifndef __7Z_CRC_H
+#define __7Z_CRC_H
+
+#include <stddef.h>
+
+#include "Types.h"
+
+extern UInt32 g_CrcTable[256];
+
+// #define CRC_GENERATE_TABLE
+
+#ifdef CRC_GENERATE_TABLE
+void CrcGenerateTable();
+#else
+#define CrcGenerateTable()
+#endif
+
+void CrcInit(UInt32 *crc);
+UInt32 CrcGetDigest(UInt32 *crc);
+void CrcUpdateByte(UInt32 *crc, Byte v);
+void CrcUpdateUInt16(UInt32 *crc, UInt16 v);
+void CrcUpdateUInt32(UInt32 *crc, UInt32 v);
+void CrcUpdateUInt64(UInt32 *crc, UInt64 v);
+void CrcUpdate(UInt32 *crc, const void *data, size_t size);
+
+UInt32 CrcCalculateDigest(const void *data, size_t size);
+int CrcVerifyDigest(UInt32 digest, const void *data, size_t size);
+
+#endif
diff --git a/7zip/Archive/7z_C/7zAlloc.c b/C/Archive/7z/7zAlloc.c
index 21bb30c7..21bb30c7 100755
--- a/7zip/Archive/7z_C/7zAlloc.c
+++ b/C/Archive/7z/7zAlloc.c
diff --git a/7zip/Archive/7z_C/7zBuffer.c b/C/Archive/7z/7zBuffer.c
index 3c4b71e8..3c4b71e8 100755
--- a/7zip/Archive/7z_C/7zBuffer.c
+++ b/C/Archive/7z/7zBuffer.c
diff --git a/C/Archive/7z/7zDecode.c b/C/Archive/7z/7zDecode.c
new file mode 100755
index 00000000..fe530384
--- /dev/null
+++ b/C/Archive/7z/7zDecode.c
@@ -0,0 +1,150 @@
+/* 7zDecode.c */
+
+#include "7zDecode.h"
+#ifdef _SZ_ONE_DIRECTORY
+#include "LzmaDecode.h"
+#else
+#include "../../Compress/Lzma/LzmaDecode.h"
+#endif
+
+CMethodID k_Copy = { { 0x0 }, 1 };
+CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
+
+#ifdef _LZMA_IN_CB
+
+typedef struct _CLzmaInCallbackImp
+{
+ ILzmaInCallback InCallback;
+ ISzInStream *InStream;
+ size_t Size;
+} CLzmaInCallbackImp;
+
+int LzmaReadImp(void *object, const unsigned char **buffer, SizeT *size)
+{
+ CLzmaInCallbackImp *cb = (CLzmaInCallbackImp *)object;
+ size_t processedSize;
+ SZ_RESULT res;
+ *size = 0;
+ res = cb->InStream->Read((void *)cb->InStream, (void **)buffer, cb->Size, &processedSize);
+ *size = (SizeT)processedSize;
+ if (processedSize > cb->Size)
+ return (int)SZE_FAIL;
+ cb->Size -= processedSize;
+ if (res == SZ_OK)
+ return 0;
+ return (int)res;
+}
+
+#endif
+
+SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder,
+ #ifdef _LZMA_IN_CB
+ ISzInStream *inStream,
+ #else
+ const Byte *inBuffer,
+ #endif
+ Byte *outBuffer, size_t outSize,
+ size_t *outSizeProcessed, ISzAlloc *allocMain)
+{
+ UInt32 si;
+ size_t inSize = 0;
+ CCoderInfo *coder;
+ if (folder->NumPackStreams != 1)
+ return SZE_NOTIMPL;
+ if (folder->NumCoders != 1)
+ return SZE_NOTIMPL;
+ coder = folder->Coders;
+ *outSizeProcessed = 0;
+
+ for (si = 0; si < folder->NumPackStreams; si++)
+ inSize += (size_t)packSizes[si];
+
+ if (AreMethodsEqual(&coder->MethodID, &k_Copy))
+ {
+ size_t i;
+ if (inSize != outSize)
+ return SZE_DATA_ERROR;
+ #ifdef _LZMA_IN_CB
+ for (i = 0; i < inSize;)
+ {
+ size_t j;
+ void *inBuffer;
+ size_t bufferSize;
+ RINOK(inStream->Read((void *)inStream, (void **)&inBuffer, inSize - i, &bufferSize));
+ if (bufferSize == 0)
+ return SZE_DATA_ERROR;
+ if (bufferSize > inSize - i)
+ return SZE_FAIL;
+ *outSizeProcessed += bufferSize;
+ for (j = 0; j < bufferSize && i < inSize; j++, i++)
+ outBuffer[i] = ((const Byte *)inBuffer)[j];
+ }
+ #else
+ for (i = 0; i < inSize; i++)
+ outBuffer[i] = inBuffer[i];
+ *outSizeProcessed = inSize;
+ #endif
+ return SZ_OK;
+ }
+
+ if (AreMethodsEqual(&coder->MethodID, &k_LZMA))
+ {
+ #ifdef _LZMA_IN_CB
+ CLzmaInCallbackImp lzmaCallback;
+ #else
+ SizeT inProcessed;
+ #endif
+
+ CLzmaDecoderState state; /* it's about 24-80 bytes structure, if int is 32-bit */
+ int result;
+ SizeT outSizeProcessedLoc;
+
+ #ifdef _LZMA_IN_CB
+ lzmaCallback.Size = inSize;
+ lzmaCallback.InStream = inStream;
+ lzmaCallback.InCallback.Read = LzmaReadImp;
+ #endif
+
+ if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items,
+ coder->Properties.Capacity) != LZMA_RESULT_OK)
+ return SZE_FAIL;
+
+ state.Probs = (CProb *)allocMain->Alloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
+ if (state.Probs == 0)
+ return SZE_OUTOFMEMORY;
+
+ #ifdef _LZMA_OUT_READ
+ if (state.Properties.DictionarySize == 0)
+ state.Dictionary = 0;
+ else
+ {
+ state.Dictionary = (unsigned char *)allocMain->Alloc(state.Properties.DictionarySize);
+ if (state.Dictionary == 0)
+ {
+ allocMain->Free(state.Probs);
+ return SZE_OUTOFMEMORY;
+ }
+ }
+ LzmaDecoderInit(&state);
+ #endif
+
+ result = LzmaDecode(&state,
+ #ifdef _LZMA_IN_CB
+ &lzmaCallback.InCallback,
+ #else
+ inBuffer, (SizeT)inSize, &inProcessed,
+ #endif
+ outBuffer, (SizeT)outSize, &outSizeProcessedLoc);
+ *outSizeProcessed = (size_t)outSizeProcessedLoc;
+ allocMain->Free(state.Probs);
+ #ifdef _LZMA_OUT_READ
+ allocMain->Free(state.Dictionary);
+ #endif
+ if (result == LZMA_RESULT_DATA_ERROR)
+ return SZE_DATA_ERROR;
+ if (result != LZMA_RESULT_OK)
+ return SZE_FAIL;
+ return SZ_OK;
+ }
+ return SZE_NOTIMPL;
+}
diff --git a/C/Archive/7z/7zExtract.c b/C/Archive/7z/7zExtract.c
new file mode 100755
index 00000000..748591a5
--- /dev/null
+++ b/C/Archive/7z/7zExtract.c
@@ -0,0 +1,118 @@
+/* 7zExtract.c */
+
+#include "7zExtract.h"
+#include "7zDecode.h"
+#include "../../7zCrc.h"
+
+SZ_RESULT SzExtract(
+ ISzInStream *inStream,
+ CArchiveDatabaseEx *db,
+ UInt32 fileIndex,
+ UInt32 *blockIndex,
+ Byte **outBuffer,
+ size_t *outBufferSize,
+ size_t *offset,
+ size_t *outSizeProcessed,
+ ISzAlloc *allocMain,
+ ISzAlloc *allocTemp)
+{
+ UInt32 folderIndex = db->FileIndexToFolderIndexMap[fileIndex];
+ SZ_RESULT res = SZ_OK;
+ *offset = 0;
+ *outSizeProcessed = 0;
+ if (folderIndex == (UInt32)-1)
+ {
+ allocMain->Free(*outBuffer);
+ *blockIndex = folderIndex;
+ *outBuffer = 0;
+ *outBufferSize = 0;
+ return SZ_OK;
+ }
+
+ if (*outBuffer == 0 || *blockIndex != folderIndex)
+ {
+ CFolder *folder = db->Database.Folders + folderIndex;
+ CFileSize unPackSize = SzFolderGetUnPackSize(folder);
+ #ifndef _LZMA_IN_CB
+ CFileSize packSize = SzArDbGetFolderFullPackSize(db, folderIndex);
+ Byte *inBuffer = 0;
+ size_t processedSize;
+ #endif
+ if (unPackSize != (size_t)unPackSize)
+ return SZE_OUTOFMEMORY;
+ *blockIndex = folderIndex;
+ allocMain->Free(*outBuffer);
+ *outBuffer = 0;
+
+ RINOK(inStream->Seek(inStream, SzArDbGetFolderStreamPos(db, folderIndex, 0)));
+
+ #ifndef _LZMA_IN_CB
+ if (packSize != 0)
+ {
+ inBuffer = (Byte *)allocTemp->Alloc((size_t)packSize);
+ if (inBuffer == 0)
+ return SZE_OUTOFMEMORY;
+ }
+ res = inStream->Read(inStream, inBuffer, (size_t)packSize, &processedSize);
+ if (res == SZ_OK && processedSize != (size_t)packSize)
+ res = SZE_FAIL;
+ #endif
+ if (res == SZ_OK)
+ {
+ *outBufferSize = (size_t)unPackSize;
+ if (unPackSize != 0)
+ {
+ *outBuffer = (Byte *)allocMain->Alloc((size_t)unPackSize);
+ if (*outBuffer == 0)
+ res = SZE_OUTOFMEMORY;
+ }
+ if (res == SZ_OK)
+ {
+ size_t outRealSize;
+ res = SzDecode(db->Database.PackSizes +
+ db->FolderStartPackStreamIndex[folderIndex], folder,
+ #ifdef _LZMA_IN_CB
+ inStream,
+ #else
+ inBuffer,
+ #endif
+ *outBuffer, (size_t)unPackSize, &outRealSize, allocTemp);
+ if (res == SZ_OK)
+ {
+ if (outRealSize == (size_t)unPackSize)
+ {
+ if (folder->UnPackCRCDefined)
+ {
+ if (!CrcVerifyDigest(folder->UnPackCRC, *outBuffer, (size_t)unPackSize))
+ res = SZE_FAIL;
+ }
+ }
+ else
+ res = SZE_FAIL;
+ }
+ }
+ }
+ #ifndef _LZMA_IN_CB
+ allocTemp->Free(inBuffer);
+ #endif
+ }
+ if (res == SZ_OK)
+ {
+ UInt32 i;
+ CFileItem *fileItem = db->Database.Files + fileIndex;
+ *offset = 0;
+ for(i = db->FolderStartFileIndex[folderIndex]; i < fileIndex; i++)
+ *offset += (UInt32)db->Database.Files[i].Size;
+ *outSizeProcessed = (size_t)fileItem->Size;
+ if (*offset + *outSizeProcessed > *outBufferSize)
+ return SZE_FAIL;
+ {
+ if (fileItem->IsFileCRCDefined)
+ {
+ if (!CrcVerifyDigest(fileItem->FileCRC, *outBuffer + *offset, *outSizeProcessed))
+ res = SZE_FAIL;
+ }
+ }
+ }
+ return res;
+}
diff --git a/7zip/Archive/7z_C/7zHeader.c b/C/Archive/7z/7zHeader.c
index 3be4bc27..3be4bc27 100755
--- a/7zip/Archive/7z_C/7zHeader.c
+++ b/C/Archive/7z/7zHeader.c
diff --git a/C/Archive/7z/7zIn.c b/C/Archive/7z/7zIn.c
new file mode 100755
index 00000000..8f3d7cae
--- /dev/null
+++ b/C/Archive/7z/7zIn.c
@@ -0,0 +1,1284 @@
+/* 7zIn.c */
+
+#include "7zIn.h"
+#include "7zDecode.h"
+#include "../../7zCrc.h"
+
+#define RINOM(x) { if((x) == 0) return SZE_OUTOFMEMORY; }
+
+void SzArDbExInit(CArchiveDatabaseEx *db)
+{
+ SzArchiveDatabaseInit(&db->Database);
+ db->FolderStartPackStreamIndex = 0;
+ db->PackStreamStartPositions = 0;
+ db->FolderStartFileIndex = 0;
+ db->FileIndexToFolderIndexMap = 0;
+}
+
+void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *))
+{
+ freeFunc(db->FolderStartPackStreamIndex);
+ freeFunc(db->PackStreamStartPositions);
+ freeFunc(db->FolderStartFileIndex);
+ freeFunc(db->FileIndexToFolderIndexMap);
+ SzArchiveDatabaseFree(&db->Database, freeFunc);
+ SzArDbExInit(db);
+}
+
+/*
+CFileSize GetFolderPackStreamSize(int folderIndex, int streamIndex) const
+{
+ return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex];
+}
+
+CFileSize GetFilePackSize(int fileIndex) const
+{
+ int folderIndex = FileIndexToFolderIndexMap[fileIndex];
+ if (folderIndex >= 0)
+ {
+ const CFolder &folderInfo = Folders[folderIndex];
+ if (FolderStartFileIndex[folderIndex] == fileIndex)
+ return GetFolderFullPackSize(folderIndex);
+ }
+ return 0;
+}
+*/
+
+#define MY_ALLOC(T, p, size, allocFunc) { if ((size) == 0) p = 0; else \
+ if ((p = (T *)allocFunc((size) * sizeof(T))) == 0) return SZE_OUTOFMEMORY; }
+
+SZ_RESULT SzArDbExFill(CArchiveDatabaseEx *db, void * (*allocFunc)(size_t size))
+{
+ UInt32 startPos = 0;
+ CFileSize startPosSize = 0;
+ UInt32 i;
+ UInt32 folderIndex = 0;
+ UInt32 indexInFolder = 0;
+ MY_ALLOC(UInt32, db->FolderStartPackStreamIndex, db->Database.NumFolders, allocFunc);
+ for(i = 0; i < db->Database.NumFolders; i++)
+ {
+ db->FolderStartPackStreamIndex[i] = startPos;
+ startPos += db->Database.Folders[i].NumPackStreams;
+ }
+
+ MY_ALLOC(CFileSize, db->PackStreamStartPositions, db->Database.NumPackStreams, allocFunc);
+
+ for(i = 0; i < db->Database.NumPackStreams; i++)
+ {
+ db->PackStreamStartPositions[i] = startPosSize;
+ startPosSize += db->Database.PackSizes[i];
+ }
+
+ MY_ALLOC(UInt32, db->FolderStartFileIndex, db->Database.NumFolders, allocFunc);
+ MY_ALLOC(UInt32, db->FileIndexToFolderIndexMap, db->Database.NumFiles, allocFunc);
+
+ for (i = 0; i < db->Database.NumFiles; i++)
+ {
+ CFileItem *file = db->Database.Files + i;
+ int emptyStream = !file->HasStream;
+ if (emptyStream && indexInFolder == 0)
+ {
+ db->FileIndexToFolderIndexMap[i] = (UInt32)-1;
+ continue;
+ }
+ if (indexInFolder == 0)
+ {
+ /*
+ v3.13 incorrectly worked with empty folders
+ v4.07: Loop for skipping empty folders
+ */
+ for (;;)
+ {
+ if (folderIndex >= db->Database.NumFolders)
+ return SZE_ARCHIVE_ERROR;
+ db->FolderStartFileIndex[folderIndex] = i;
+ if (db->Database.Folders[folderIndex].NumUnPackStreams != 0)
+ break;
+ folderIndex++;
+ }
+ }
+ db->FileIndexToFolderIndexMap[i] = folderIndex;
+ if (emptyStream)
+ continue;
+ indexInFolder++;
+ if (indexInFolder >= db->Database.Folders[folderIndex].NumUnPackStreams)
+ {
+ folderIndex++;
+ indexInFolder = 0;
+ }
+ }
+ return SZ_OK;
+}
+
+
+CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder)
+{
+ return db->ArchiveInfo.DataStartPosition +
+ db->PackStreamStartPositions[db->FolderStartPackStreamIndex[folderIndex] + indexInFolder];
+}
+
+CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex)
+{
+ UInt32 packStreamIndex = db->FolderStartPackStreamIndex[folderIndex];
+ CFolder *folder = db->Database.Folders + folderIndex;
+ CFileSize size = 0;
+ UInt32 i;
+ for (i = 0; i < folder->NumPackStreams; i++)
+ size += db->Database.PackSizes[packStreamIndex + i];
+ return size;
+}
+
+
+/*
+SZ_RESULT SzReadTime(const CObjectVector<CSzByteBuffer> &dataVector,
+ CObjectVector<CFileItem> &files, UInt64 type)
+{
+ CBoolVector boolVector;
+ RINOK(ReadBoolVector2(files.Size(), boolVector))
+
+ CStreamSwitch streamSwitch;
+ RINOK(streamSwitch.Set(this, &dataVector));
+
+ for(int i = 0; i < files.Size(); i++)
+ {
+ CFileItem &file = files[i];
+ CArchiveFileTime fileTime;
+ bool defined = boolVector[i];
+ if (defined)
+ {
+ UInt32 low, high;
+ RINOK(SzReadUInt32(low));
+ RINOK(SzReadUInt32(high));
+ fileTime.dwLowDateTime = low;
+ fileTime.dwHighDateTime = high;
+ }
+ switch(type)
+ {
+ case k7zIdCreationTime:
+ file.IsCreationTimeDefined = defined;
+ if (defined)
+ file.CreationTime = fileTime;
+ break;
+ case k7zIdLastWriteTime:
+ file.IsLastWriteTimeDefined = defined;
+ if (defined)
+ file.LastWriteTime = fileTime;
+ break;
+ case k7zIdLastAccessTime:
+ file.IsLastAccessTimeDefined = defined;
+ if (defined)
+ file.LastAccessTime = fileTime;
+ break;
+ }
+ }
+ return SZ_OK;
+}
+*/
+
+SZ_RESULT SafeReadDirect(ISzInStream *inStream, Byte *data, size_t size)
+{
+ #ifdef _LZMA_IN_CB
+ while (size > 0)
+ {
+ void *inBufferSpec;
+ size_t processedSize;
+ const Byte *inBuffer;
+ RINOK(inStream->Read(inStream, (void **)&inBufferSpec, size, &processedSize));
+ inBuffer = (const Byte *)inBufferSpec;
+ if (processedSize == 0 || processedSize > size)
+ return SZE_FAIL;
+ size -= processedSize;
+ do
+ {
+ *data++ = *inBuffer++;
+ }
+ while (--processedSize != 0);
+ }
+ #else
+ size_t processedSize;
+ RINOK(inStream->Read(inStream, data, size, &processedSize));
+ if (processedSize != size)
+ return SZE_FAIL;
+ #endif
+ return SZ_OK;
+}
+
+SZ_RESULT SafeReadDirectByte(ISzInStream *inStream, Byte *data)
+{
+ return SafeReadDirect(inStream, data, 1);
+}
+
+SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value)
+{
+ int i;
+ *value = 0;
+ for (i = 0; i < 4; i++)
+ {
+ Byte b;
+ RINOK(SafeReadDirectByte(inStream, &b));
+ *value |= ((UInt32)b << (8 * i));
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value)
+{
+ int i;
+ *value = 0;
+ for (i = 0; i < 8; i++)
+ {
+ Byte b;
+ RINOK(SafeReadDirectByte(inStream, &b));
+ *value |= ((UInt64)b << (8 * i));
+ }
+ return SZ_OK;
+}
+
+int TestSignatureCandidate(Byte *testBytes)
+{
+ size_t i;
+ for (i = 0; i < k7zSignatureSize; i++)
+ if (testBytes[i] != k7zSignature[i])
+ return 0;
+ return 1;
+}
+
+typedef struct _CSzState
+{
+ Byte *Data;
+ size_t Size;
+}CSzData;
+
+SZ_RESULT SzReadByte(CSzData *sd, Byte *b)
+{
+ if (sd->Size == 0)
+ return SZE_ARCHIVE_ERROR;
+ sd->Size--;
+ *b = *sd->Data++;
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadBytes(CSzData *sd, Byte *data, size_t size)
+{
+ size_t i;
+ for (i = 0; i < size; i++)
+ {
+ RINOK(SzReadByte(sd, data + i));
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadUInt32(CSzData *sd, UInt32 *value)
+{
+ int i;
+ *value = 0;
+ for (i = 0; i < 4; i++)
+ {
+ Byte b;
+ RINOK(SzReadByte(sd, &b));
+ *value |= ((UInt32)(b) << (8 * i));
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadNumber(CSzData *sd, UInt64 *value)
+{
+ Byte firstByte;
+ Byte mask = 0x80;
+ int i;
+ RINOK(SzReadByte(sd, &firstByte));
+ *value = 0;
+ for (i = 0; i < 8; i++)
+ {
+ Byte b;
+ if ((firstByte & mask) == 0)
+ {
+ UInt64 highPart = firstByte & (mask - 1);
+ *value += (highPart << (8 * i));
+ return SZ_OK;
+ }
+ RINOK(SzReadByte(sd, &b));
+ *value |= ((UInt64)b << (8 * i));
+ mask >>= 1;
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadSize(CSzData *sd, CFileSize *value)
+{
+ UInt64 value64;
+ RINOK(SzReadNumber(sd, &value64));
+ *value = (CFileSize)value64;
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadNumber32(CSzData *sd, UInt32 *value)
+{
+ UInt64 value64;
+ RINOK(SzReadNumber(sd, &value64));
+ if (value64 >= 0x80000000)
+ return SZE_NOTIMPL;
+ if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 2)))
+ return SZE_NOTIMPL;
+ *value = (UInt32)value64;
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadID(CSzData *sd, UInt64 *value)
+{
+ return SzReadNumber(sd, value);
+}
+
+SZ_RESULT SzSkeepDataSize(CSzData *sd, UInt64 size)
+{
+ if (size > sd->Size)
+ return SZE_ARCHIVE_ERROR;
+ sd->Size -= (size_t)size;
+ sd->Data += (size_t)size;
+ return SZ_OK;
+}
+
+SZ_RESULT SzSkeepData(CSzData *sd)
+{
+ UInt64 size;
+ RINOK(SzReadNumber(sd, &size));
+ return SzSkeepDataSize(sd, size);
+}
+
+SZ_RESULT SzReadArchiveProperties(CSzData *sd)
+{
+ for (;;)
+ {
+ UInt64 type;
+ RINOK(SzReadID(sd, &type));
+ if (type == k7zIdEnd)
+ break;
+ SzSkeepData(sd);
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SzWaitAttribute(CSzData *sd, UInt64 attribute)
+{
+ for (;;)
+ {
+ UInt64 type;
+ RINOK(SzReadID(sd, &type));
+ if (type == attribute)
+ return SZ_OK;
+ if (type == k7zIdEnd)
+ return SZE_ARCHIVE_ERROR;
+ RINOK(SzSkeepData(sd));
+ }
+}
+
+SZ_RESULT SzReadBoolVector(CSzData *sd, size_t numItems, Byte **v, void * (*allocFunc)(size_t size))
+{
+ Byte b = 0;
+ Byte mask = 0;
+ size_t i;
+ MY_ALLOC(Byte, *v, numItems, allocFunc);
+ for (i = 0; i < numItems; i++)
+ {
+ if (mask == 0)
+ {
+ RINOK(SzReadByte(sd, &b));
+ mask = 0x80;
+ }
+ (*v)[i] = (Byte)(((b & mask) != 0) ? 1 : 0);
+ mask >>= 1;
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadBoolVector2(CSzData *sd, size_t numItems, Byte **v, void * (*allocFunc)(size_t size))
+{
+ Byte allAreDefined;
+ size_t i;
+ RINOK(SzReadByte(sd, &allAreDefined));
+ if (allAreDefined == 0)
+ return SzReadBoolVector(sd, numItems, v, allocFunc);
+ MY_ALLOC(Byte, *v, numItems, allocFunc);
+ for(i = 0; i < numItems; i++)
+ (*v)[i] = 1;
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadHashDigests(
+ CSzData *sd,
+ size_t numItems,
+ Byte **digestsDefined,
+ UInt32 **digests,
+ void * (*allocFunc)(size_t size))
+{
+ size_t i;
+ RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, allocFunc));
+ MY_ALLOC(UInt32, *digests, numItems, allocFunc);
+ for(i = 0; i < numItems; i++)
+ if ((*digestsDefined)[i])
+ {
+ RINOK(SzReadUInt32(sd, (*digests) + i));
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadPackInfo(
+ CSzData *sd,
+ CFileSize *dataOffset,
+ UInt32 *numPackStreams,
+ CFileSize **packSizes,
+ Byte **packCRCsDefined,
+ UInt32 **packCRCs,
+ void * (*allocFunc)(size_t size))
+{
+ UInt32 i;
+ RINOK(SzReadSize(sd, dataOffset));
+ RINOK(SzReadNumber32(sd, numPackStreams));
+
+ RINOK(SzWaitAttribute(sd, k7zIdSize));
+
+ MY_ALLOC(CFileSize, *packSizes, (size_t)*numPackStreams, allocFunc);
+
+ for(i = 0; i < *numPackStreams; i++)
+ {
+ RINOK(SzReadSize(sd, (*packSizes) + i));
+ }
+
+ for (;;)
+ {
+ UInt64 type;
+ RINOK(SzReadID(sd, &type));
+ if (type == k7zIdEnd)
+ break;
+ if (type == k7zIdCRC)
+ {
+ RINOK(SzReadHashDigests(sd, (size_t)*numPackStreams, packCRCsDefined, packCRCs, allocFunc));
+ continue;
+ }
+ RINOK(SzSkeepData(sd));
+ }
+ if (*packCRCsDefined == 0)
+ {
+ MY_ALLOC(Byte, *packCRCsDefined, (size_t)*numPackStreams, allocFunc);
+ MY_ALLOC(UInt32, *packCRCs, (size_t)*numPackStreams, allocFunc);
+ for(i = 0; i < *numPackStreams; i++)
+ {
+ (*packCRCsDefined)[i] = 0;
+ (*packCRCs)[i] = 0;
+ }
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadSwitch(CSzData *sd)
+{
+ Byte external;
+ RINOK(SzReadByte(sd, &external));
+ return (external == 0) ? SZ_OK: SZE_ARCHIVE_ERROR;
+}
+
+SZ_RESULT SzGetNextFolderItem(CSzData *sd, CFolder *folder, void * (*allocFunc)(size_t size))
+{
+ UInt32 numCoders;
+ UInt32 numBindPairs;
+ UInt32 numPackedStreams;
+ UInt32 i;
+ UInt32 numInStreams = 0;
+ UInt32 numOutStreams = 0;
+ RINOK(SzReadNumber32(sd, &numCoders));
+ folder->NumCoders = numCoders;
+
+ MY_ALLOC(CCoderInfo, folder->Coders, (size_t)numCoders, allocFunc);
+
+ for (i = 0; i < numCoders; i++)
+ SzCoderInfoInit(folder->Coders + i);
+
+ for (i = 0; i < numCoders; i++)
+ {
+ Byte mainByte;
+ CCoderInfo *coder = folder->Coders + i;
+ {
+ RINOK(SzReadByte(sd, &mainByte));
+ coder->MethodID.IDSize = (Byte)(mainByte & 0xF);
+ RINOK(SzReadBytes(sd, coder->MethodID.ID, coder->MethodID.IDSize));
+ if ((mainByte & 0x10) != 0)
+ {
+ RINOK(SzReadNumber32(sd, &coder->NumInStreams));
+ RINOK(SzReadNumber32(sd, &coder->NumOutStreams));
+ }
+ else
+ {
+ coder->NumInStreams = 1;
+ coder->NumOutStreams = 1;
+ }
+ if ((mainByte & 0x20) != 0)
+ {
+ UInt64 propertiesSize = 0;
+ RINOK(SzReadNumber(sd, &propertiesSize));
+ if (!SzByteBufferCreate(&coder->Properties, (size_t)propertiesSize, allocFunc))
+ return SZE_OUTOFMEMORY;
+ RINOK(SzReadBytes(sd, coder->Properties.Items, (size_t)propertiesSize));
+ }
+ }
+ while ((mainByte & 0x80) != 0)
+ {
+ RINOK(SzReadByte(sd, &mainByte));
+ RINOK(SzSkeepDataSize(sd, (mainByte & 0xF)));
+ if ((mainByte & 0x10) != 0)
+ {
+ UInt32 n;
+ RINOK(SzReadNumber32(sd, &n));
+ RINOK(SzReadNumber32(sd, &n));
+ }
+ if ((mainByte & 0x20) != 0)
+ {
+ UInt64 propertiesSize = 0;
+ RINOK(SzReadNumber(sd, &propertiesSize));
+ RINOK(SzSkeepDataSize(sd, propertiesSize));
+ }
+ }
+ numInStreams += (UInt32)coder->NumInStreams;
+ numOutStreams += (UInt32)coder->NumOutStreams;
+ }
+
+ numBindPairs = numOutStreams - 1;
+ folder->NumBindPairs = numBindPairs;
+
+
+ MY_ALLOC(CBindPair, folder->BindPairs, (size_t)numBindPairs, allocFunc);
+
+ for (i = 0; i < numBindPairs; i++)
+ {
+ CBindPair *bindPair = folder->BindPairs + i;;
+ RINOK(SzReadNumber32(sd, &bindPair->InIndex));
+ RINOK(SzReadNumber32(sd, &bindPair->OutIndex));
+ }
+
+ numPackedStreams = numInStreams - (UInt32)numBindPairs;
+
+ folder->NumPackStreams = numPackedStreams;
+ MY_ALLOC(UInt32, folder->PackStreams, (size_t)numPackedStreams, allocFunc);
+
+ if (numPackedStreams == 1)
+ {
+ UInt32 j;
+ UInt32 pi = 0;
+ for (j = 0; j < numInStreams; j++)
+ if (SzFolderFindBindPairForInStream(folder, j) < 0)
+ {
+ folder->PackStreams[pi++] = j;
+ break;
+ }
+ }
+ else
+ for(i = 0; i < numPackedStreams; i++)
+ {
+ RINOK(SzReadNumber32(sd, folder->PackStreams + i));
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadUnPackInfo(
+ CSzData *sd,
+ UInt32 *numFolders,
+ CFolder **folders, /* for allocFunc */
+ void * (*allocFunc)(size_t size),
+ ISzAlloc *allocTemp)
+{
+ UInt32 i;
+ RINOK(SzWaitAttribute(sd, k7zIdFolder));
+ RINOK(SzReadNumber32(sd, numFolders));
+ {
+ RINOK(SzReadSwitch(sd));
+
+ MY_ALLOC(CFolder, *folders, (size_t)*numFolders, allocFunc);
+
+ for(i = 0; i < *numFolders; i++)
+ SzFolderInit((*folders) + i);
+
+ for(i = 0; i < *numFolders; i++)
+ {
+ RINOK(SzGetNextFolderItem(sd, (*folders) + i, allocFunc));
+ }
+ }
+
+ RINOK(SzWaitAttribute(sd, k7zIdCodersUnPackSize));
+
+ for(i = 0; i < *numFolders; i++)
+ {
+ UInt32 j;
+ CFolder *folder = (*folders) + i;
+ UInt32 numOutStreams = SzFolderGetNumOutStreams(folder);
+
+ MY_ALLOC(CFileSize, folder->UnPackSizes, (size_t)numOutStreams, allocFunc);
+
+ for(j = 0; j < numOutStreams; j++)
+ {
+ RINOK(SzReadSize(sd, folder->UnPackSizes + j));
+ }
+ }
+
+ for (;;)
+ {
+ UInt64 type;
+ RINOK(SzReadID(sd, &type));
+ if (type == k7zIdEnd)
+ return SZ_OK;
+ if (type == k7zIdCRC)
+ {
+ SZ_RESULT res;
+ Byte *crcsDefined = 0;
+ UInt32 *crcs = 0;
+ res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp->Alloc);
+ if (res == SZ_OK)
+ {
+ for(i = 0; i < *numFolders; i++)
+ {
+ CFolder *folder = (*folders) + i;
+ folder->UnPackCRCDefined = crcsDefined[i];
+ folder->UnPackCRC = crcs[i];
+ }
+ }
+ allocTemp->Free(crcs);
+ allocTemp->Free(crcsDefined);
+ RINOK(res);
+ continue;
+ }
+ RINOK(SzSkeepData(sd));
+ }
+}
+
+SZ_RESULT SzReadSubStreamsInfo(
+ CSzData *sd,
+ UInt32 numFolders,
+ CFolder *folders,
+ UInt32 *numUnPackStreams,
+ CFileSize **unPackSizes,
+ Byte **digestsDefined,
+ UInt32 **digests,
+ ISzAlloc *allocTemp)
+{
+ UInt64 type = 0;
+ UInt32 i;
+ UInt32 si = 0;
+ UInt32 numDigests = 0;
+
+ for(i = 0; i < numFolders; i++)
+ folders[i].NumUnPackStreams = 1;
+ *numUnPackStreams = numFolders;
+
+ for (;;)
+ {
+ RINOK(SzReadID(sd, &type));
+ if (type == k7zIdNumUnPackStream)
+ {
+ *numUnPackStreams = 0;
+ for(i = 0; i < numFolders; i++)
+ {
+ UInt32 numStreams;
+ RINOK(SzReadNumber32(sd, &numStreams));
+ folders[i].NumUnPackStreams = numStreams;
+ *numUnPackStreams += numStreams;
+ }
+ continue;
+ }
+ if (type == k7zIdCRC || type == k7zIdSize)
+ break;
+ if (type == k7zIdEnd)
+ break;
+ RINOK(SzSkeepData(sd));
+ }
+
+ if (*numUnPackStreams == 0)
+ {
+ *unPackSizes = 0;
+ *digestsDefined = 0;
+ *digests = 0;
+ }
+ else
+ {
+ *unPackSizes = (CFileSize *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(CFileSize));
+ RINOM(*unPackSizes);
+ *digestsDefined = (Byte *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(Byte));
+ RINOM(*digestsDefined);
+ *digests = (UInt32 *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(UInt32));
+ RINOM(*digests);
+ }
+
+ for(i = 0; i < numFolders; i++)
+ {
+ /*
+ v3.13 incorrectly worked with empty folders
+ v4.07: we check that folder is empty
+ */
+ CFileSize sum = 0;
+ UInt32 j;
+ UInt32 numSubstreams = folders[i].NumUnPackStreams;
+ if (numSubstreams == 0)
+ continue;
+ if (type == k7zIdSize)
+ for (j = 1; j < numSubstreams; j++)
+ {
+ CFileSize size;
+ RINOK(SzReadSize(sd, &size));
+ (*unPackSizes)[si++] = size;
+ sum += size;
+ }
+ (*unPackSizes)[si++] = SzFolderGetUnPackSize(folders + i) - sum;
+ }
+ if (type == k7zIdSize)
+ {
+ RINOK(SzReadID(sd, &type));
+ }
+
+ for(i = 0; i < *numUnPackStreams; i++)
+ {
+ (*digestsDefined)[i] = 0;
+ (*digests)[i] = 0;
+ }
+
+
+ for(i = 0; i < numFolders; i++)
+ {
+ UInt32 numSubstreams = folders[i].NumUnPackStreams;
+ if (numSubstreams != 1 || !folders[i].UnPackCRCDefined)
+ numDigests += numSubstreams;
+ }
+
+
+ si = 0;
+ for (;;)
+ {
+ if (type == k7zIdCRC)
+ {
+ int digestIndex = 0;
+ Byte *digestsDefined2 = 0;
+ UInt32 *digests2 = 0;
+ SZ_RESULT res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp->Alloc);
+ if (res == SZ_OK)
+ {
+ for (i = 0; i < numFolders; i++)
+ {
+ CFolder *folder = folders + i;
+ UInt32 numSubstreams = folder->NumUnPackStreams;
+ if (numSubstreams == 1 && folder->UnPackCRCDefined)
+ {
+ (*digestsDefined)[si] = 1;
+ (*digests)[si] = folder->UnPackCRC;
+ si++;
+ }
+ else
+ {
+ UInt32 j;
+ for (j = 0; j < numSubstreams; j++, digestIndex++)
+ {
+ (*digestsDefined)[si] = digestsDefined2[digestIndex];
+ (*digests)[si] = digests2[digestIndex];
+ si++;
+ }
+ }
+ }
+ }
+ allocTemp->Free(digestsDefined2);
+ allocTemp->Free(digests2);
+ RINOK(res);
+ }
+ else if (type == k7zIdEnd)
+ return SZ_OK;
+ else
+ {
+ RINOK(SzSkeepData(sd));
+ }
+ RINOK(SzReadID(sd, &type));
+ }
+}
+
+
+SZ_RESULT SzReadStreamsInfo(
+ CSzData *sd,
+ CFileSize *dataOffset,
+ CArchiveDatabase *db,
+ UInt32 *numUnPackStreams,
+ CFileSize **unPackSizes, /* allocTemp */
+ Byte **digestsDefined, /* allocTemp */
+ UInt32 **digests, /* allocTemp */
+ void * (*allocFunc)(size_t size),
+ ISzAlloc *allocTemp)
+{
+ for (;;)
+ {
+ UInt64 type;
+ RINOK(SzReadID(sd, &type));
+ if ((UInt64)(int)type != type)
+ return SZE_FAIL;
+ switch((int)type)
+ {
+ case k7zIdEnd:
+ return SZ_OK;
+ case k7zIdPackInfo:
+ {
+ RINOK(SzReadPackInfo(sd, dataOffset, &db->NumPackStreams,
+ &db->PackSizes, &db->PackCRCsDefined, &db->PackCRCs, allocFunc));
+ break;
+ }
+ case k7zIdUnPackInfo:
+ {
+ RINOK(SzReadUnPackInfo(sd, &db->NumFolders, &db->Folders, allocFunc, allocTemp));
+ break;
+ }
+ case k7zIdSubStreamsInfo:
+ {
+ RINOK(SzReadSubStreamsInfo(sd, db->NumFolders, db->Folders,
+ numUnPackStreams, unPackSizes, digestsDefined, digests, allocTemp));
+ break;
+ }
+ default:
+ return SZE_FAIL;
+ }
+ }
+}
+
+Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+
+SZ_RESULT SzReadFileNames(CSzData *sd, UInt32 numFiles, CFileItem *files,
+ void * (*allocFunc)(size_t size))
+{
+ UInt32 i;
+ for(i = 0; i < numFiles; i++)
+ {
+ UInt32 len = 0;
+ UInt32 pos = 0;
+ CFileItem *file = files + i;
+ while(pos + 2 <= sd->Size)
+ {
+ int numAdds;
+ UInt32 value = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8));
+ pos += 2;
+ len++;
+ if (value == 0)
+ break;
+ if (value < 0x80)
+ continue;
+ if (value >= 0xD800 && value < 0xE000)
+ {
+ UInt32 c2;
+ if (value >= 0xDC00)
+ return SZE_ARCHIVE_ERROR;
+ if (pos + 2 > sd->Size)
+ return SZE_ARCHIVE_ERROR;
+ c2 = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8));
+ pos += 2;
+ if (c2 < 0xDC00 || c2 >= 0xE000)
+ return SZE_ARCHIVE_ERROR;
+ value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
+ }
+ for (numAdds = 1; numAdds < 5; numAdds++)
+ if (value < (((UInt32)1) << (numAdds * 5 + 6)))
+ break;
+ len += numAdds;
+ }
+
+ MY_ALLOC(char, file->Name, (size_t)len, allocFunc);
+
+ len = 0;
+ while(2 <= sd->Size)
+ {
+ int numAdds;
+ UInt32 value = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8));
+ SzSkeepDataSize(sd, 2);
+ if (value < 0x80)
+ {
+ file->Name[len++] = (char)value;
+ if (value == 0)
+ break;
+ continue;
+ }
+ if (value >= 0xD800 && value < 0xE000)
+ {
+ UInt32 c2 = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8));
+ SzSkeepDataSize(sd, 2);
+ value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
+ }
+ for (numAdds = 1; numAdds < 5; numAdds++)
+ if (value < (((UInt32)1) << (numAdds * 5 + 6)))
+ break;
+ file->Name[len++] = (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds)));
+ do
+ {
+ numAdds--;
+ file->Name[len++] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F));
+ }
+ while(numAdds > 0);
+
+ len += numAdds;
+ }
+ }
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadHeader2(
+ CSzData *sd,
+ CArchiveDatabaseEx *db, /* allocMain */
+ CFileSize **unPackSizes, /* allocTemp */
+ Byte **digestsDefined, /* allocTemp */
+ UInt32 **digests, /* allocTemp */
+ Byte **emptyStreamVector, /* allocTemp */
+ Byte **emptyFileVector, /* allocTemp */
+ ISzAlloc *allocMain,
+ ISzAlloc *allocTemp)
+{
+ UInt64 type;
+ UInt32 numUnPackStreams = 0;
+ UInt32 numFiles = 0;
+ CFileItem *files = 0;
+ UInt32 numEmptyStreams = 0;
+ UInt32 i;
+
+ RINOK(SzReadID(sd, &type));
+
+ if (type == k7zIdArchiveProperties)
+ {
+ RINOK(SzReadArchiveProperties(sd));
+ RINOK(SzReadID(sd, &type));
+ }
+
+
+ if (type == k7zIdMainStreamsInfo)
+ {
+ RINOK(SzReadStreamsInfo(sd,
+ &db->ArchiveInfo.DataStartPosition,
+ &db->Database,
+ &numUnPackStreams,
+ unPackSizes,
+ digestsDefined,
+ digests, allocMain->Alloc, allocTemp));
+ db->ArchiveInfo.DataStartPosition += db->ArchiveInfo.StartPositionAfterHeader;
+ RINOK(SzReadID(sd, &type));
+ }
+
+ if (type == k7zIdEnd)
+ return SZ_OK;
+ if (type != k7zIdFilesInfo)
+ return SZE_ARCHIVE_ERROR;
+
+ RINOK(SzReadNumber32(sd, &numFiles));
+ db->Database.NumFiles = numFiles;
+
+ MY_ALLOC(CFileItem, files, (size_t)numFiles, allocMain->Alloc);
+
+ db->Database.Files = files;
+ for(i = 0; i < numFiles; i++)
+ SzFileInit(files + i);
+
+ for (;;)
+ {
+ UInt64 type;
+ UInt64 size;
+ RINOK(SzReadID(sd, &type));
+ if (type == k7zIdEnd)
+ break;
+ RINOK(SzReadNumber(sd, &size));
+
+ if ((UInt64)(int)type != type)
+ {
+ RINOK(SzSkeepDataSize(sd, size));
+ }
+ else
+ switch((int)type)
+ {
+ case k7zIdName:
+ {
+ RINOK(SzReadSwitch(sd));
+ RINOK(SzReadFileNames(sd, numFiles, files, allocMain->Alloc))
+ break;
+ }
+ case k7zIdEmptyStream:
+ {
+ RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp->Alloc));
+ numEmptyStreams = 0;
+ for (i = 0; i < numFiles; i++)
+ if ((*emptyStreamVector)[i])
+ numEmptyStreams++;
+ break;
+ }
+ case k7zIdEmptyFile:
+ {
+ RINOK(SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp->Alloc));
+ break;
+ }
+ default:
+ {
+ RINOK(SzSkeepDataSize(sd, size));
+ }
+ }
+ }
+
+ {
+ UInt32 emptyFileIndex = 0;
+ UInt32 sizeIndex = 0;
+ for(i = 0; i < numFiles; i++)
+ {
+ CFileItem *file = files + i;
+ file->IsAnti = 0;
+ if (*emptyStreamVector == 0)
+ file->HasStream = 1;
+ else
+ file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1);
+ if(file->HasStream)
+ {
+ file->IsDirectory = 0;
+ file->Size = (*unPackSizes)[sizeIndex];
+ file->FileCRC = (*digests)[sizeIndex];
+ file->IsFileCRCDefined = (Byte)(*digestsDefined)[sizeIndex];
+ sizeIndex++;
+ }
+ else
+ {
+ if (*emptyFileVector == 0)
+ file->IsDirectory = 1;
+ else
+ file->IsDirectory = (Byte)((*emptyFileVector)[emptyFileIndex] ? 0 : 1);
+ emptyFileIndex++;
+ file->Size = 0;
+ file->IsFileCRCDefined = 0;
+ }
+ }
+ }
+ return SzArDbExFill(db, allocMain->Alloc);
+}
+
+SZ_RESULT SzReadHeader(
+ CSzData *sd,
+ CArchiveDatabaseEx *db,
+ ISzAlloc *allocMain,
+ ISzAlloc *allocTemp)
+{
+ CFileSize *unPackSizes = 0;
+ Byte *digestsDefined = 0;
+ UInt32 *digests = 0;
+ Byte *emptyStreamVector = 0;
+ Byte *emptyFileVector = 0;
+ SZ_RESULT res = SzReadHeader2(sd, db,
+ &unPackSizes, &digestsDefined, &digests,
+ &emptyStreamVector, &emptyFileVector,
+ allocMain, allocTemp);
+ allocTemp->Free(unPackSizes);
+ allocTemp->Free(digestsDefined);
+ allocTemp->Free(digests);
+ allocTemp->Free(emptyStreamVector);
+ allocTemp->Free(emptyFileVector);
+ return res;
+}
+
+SZ_RESULT SzReadAndDecodePackedStreams2(
+ ISzInStream *inStream,
+ CSzData *sd,
+ CSzByteBuffer *outBuffer,
+ CFileSize baseOffset,
+ CArchiveDatabase *db,
+ CFileSize **unPackSizes,
+ Byte **digestsDefined,
+ UInt32 **digests,
+ #ifndef _LZMA_IN_CB
+ Byte **inBuffer,
+ #endif
+ ISzAlloc *allocTemp)
+{
+
+ UInt32 numUnPackStreams = 0;
+ CFileSize dataStartPos;
+ CFolder *folder;
+ #ifndef _LZMA_IN_CB
+ CFileSize packSize = 0;
+ UInt32 i = 0;
+ #endif
+ CFileSize unPackSize;
+ size_t outRealSize;
+ SZ_RESULT res;
+
+ RINOK(SzReadStreamsInfo(sd, &dataStartPos, db,
+ &numUnPackStreams, unPackSizes, digestsDefined, digests,
+ allocTemp->Alloc, allocTemp));
+
+ dataStartPos += baseOffset;
+ if (db->NumFolders != 1)
+ return SZE_ARCHIVE_ERROR;
+
+ folder = db->Folders;
+ unPackSize = SzFolderGetUnPackSize(folder);
+
+ RINOK(inStream->Seek(inStream, dataStartPos));
+
+ #ifndef _LZMA_IN_CB
+ for (i = 0; i < db->NumPackStreams; i++)
+ packSize += db->PackSizes[i];
+
+ MY_ALLOC(Byte, *inBuffer, (size_t)packSize, allocTemp->Alloc);
+
+ RINOK(SafeReadDirect(inStream, *inBuffer, (size_t)packSize));
+ #endif
+
+ if (!SzByteBufferCreate(outBuffer, (size_t)unPackSize, allocTemp->Alloc))
+ return SZE_OUTOFMEMORY;
+
+ res = SzDecode(db->PackSizes, folder,
+ #ifdef _LZMA_IN_CB
+ inStream,
+ #else
+ *inBuffer,
+ #endif
+ outBuffer->Items, (size_t)unPackSize,
+ &outRealSize, allocTemp);
+ RINOK(res)
+ if (outRealSize != (UInt32)unPackSize)
+ return SZE_FAIL;
+ if (folder->UnPackCRCDefined)
+ if (!CrcVerifyDigest(folder->UnPackCRC, outBuffer->Items, (size_t)unPackSize))
+ return SZE_FAIL;
+ return SZ_OK;
+}
+
+SZ_RESULT SzReadAndDecodePackedStreams(
+ ISzInStream *inStream,
+ CSzData *sd,
+ CSzByteBuffer *outBuffer,
+ CFileSize baseOffset,
+ ISzAlloc *allocTemp)
+{
+ CArchiveDatabase db;
+ CFileSize *unPackSizes = 0;
+ Byte *digestsDefined = 0;
+ UInt32 *digests = 0;
+ #ifndef _LZMA_IN_CB
+ Byte *inBuffer = 0;
+ #endif
+ SZ_RESULT res;
+ SzArchiveDatabaseInit(&db);
+ res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset,
+ &db, &unPackSizes, &digestsDefined, &digests,
+ #ifndef _LZMA_IN_CB
+ &inBuffer,
+ #endif
+ allocTemp);
+ SzArchiveDatabaseFree(&db, allocTemp->Free);
+ allocTemp->Free(unPackSizes);
+ allocTemp->Free(digestsDefined);
+ allocTemp->Free(digests);
+ #ifndef _LZMA_IN_CB
+ allocTemp->Free(inBuffer);
+ #endif
+ return res;
+}
+
+SZ_RESULT SzArchiveOpen2(
+ ISzInStream *inStream,
+ CArchiveDatabaseEx *db,
+ ISzAlloc *allocMain,
+ ISzAlloc *allocTemp)
+{
+ Byte signature[k7zSignatureSize];
+ Byte version;
+ UInt32 crcFromArchive;
+ UInt64 nextHeaderOffset;
+ UInt64 nextHeaderSize;
+ UInt32 nextHeaderCRC;
+ UInt32 crc;
+ CFileSize pos = 0;
+ CSzByteBuffer buffer;
+ CSzData sd;
+ SZ_RESULT res;
+
+ RINOK(SafeReadDirect(inStream, signature, k7zSignatureSize));
+
+ if (!TestSignatureCandidate(signature))
+ return SZE_ARCHIVE_ERROR;
+
+ /*
+ db.Clear();
+ db.ArchiveInfo.StartPosition = _arhiveBeginStreamPosition;
+ */
+ RINOK(SafeReadDirectByte(inStream, &version));
+ if (version != k7zMajorVersion)
+ return SZE_ARCHIVE_ERROR;
+ RINOK(SafeReadDirectByte(inStream, &version));
+
+ RINOK(SafeReadDirectUInt32(inStream, &crcFromArchive));
+
+ CrcInit(&crc);
+ RINOK(SafeReadDirectUInt64(inStream, &nextHeaderOffset));
+ CrcUpdateUInt64(&crc, nextHeaderOffset);
+ RINOK(SafeReadDirectUInt64(inStream, &nextHeaderSize));
+ CrcUpdateUInt64(&crc, nextHeaderSize);
+ RINOK(SafeReadDirectUInt32(inStream, &nextHeaderCRC));
+ CrcUpdateUInt32(&crc, nextHeaderCRC);
+
+ pos = k7zStartHeaderSize;
+ db->ArchiveInfo.StartPositionAfterHeader = pos;
+
+ if (CrcGetDigest(&crc) != crcFromArchive)
+ return SZE_ARCHIVE_ERROR;
+
+ if (nextHeaderSize == 0)
+ return SZ_OK;
+
+ RINOK(inStream->Seek(inStream, (CFileSize)(pos + nextHeaderOffset)));
+
+ if (!SzByteBufferCreate(&buffer, (size_t)nextHeaderSize, allocTemp->Alloc))
+ return SZE_OUTOFMEMORY;
+
+ res = SafeReadDirect(inStream, buffer.Items, (size_t)nextHeaderSize);
+ if (res == SZ_OK)
+ {
+ res = SZE_ARCHIVE_ERROR;
+ if (CrcVerifyDigest(nextHeaderCRC, buffer.Items, (UInt32)nextHeaderSize))
+ {
+ for (;;)
+ {
+ UInt64 type;
+ sd.Data = buffer.Items;
+ sd.Size = buffer.Capacity;
+ res = SzReadID(&sd, &type);
+ if (res != SZ_OK)
+ break;
+ if (type == k7zIdHeader)
+ {
+ res = SzReadHeader(&sd, db, allocMain, allocTemp);
+ break;
+ }
+ if (type != k7zIdEncodedHeader)
+ {
+ res = SZE_ARCHIVE_ERROR;
+ break;
+ }
+ {
+ CSzByteBuffer outBuffer;
+ res = SzReadAndDecodePackedStreams(inStream, &sd, &outBuffer,
+ db->ArchiveInfo.StartPositionAfterHeader,
+ allocTemp);
+ if (res != SZ_OK)
+ {
+ SzByteBufferFree(&outBuffer, allocTemp->Free);
+ break;
+ }
+ SzByteBufferFree(&buffer, allocTemp->Free);
+ buffer.Items = outBuffer.Items;
+ buffer.Capacity = outBuffer.Capacity;
+ }
+ }
+ }
+ }
+ SzByteBufferFree(&buffer, allocTemp->Free);
+ return res;
+}
+
+SZ_RESULT SzArchiveOpen(
+ ISzInStream *inStream,
+ CArchiveDatabaseEx *db,
+ ISzAlloc *allocMain,
+ ISzAlloc *allocTemp)
+{
+ SZ_RESULT res = SzArchiveOpen2(inStream, db, allocMain, allocTemp);
+ if (res != SZ_OK)
+ SzArDbExFree(db, allocMain->Free);
+ return res;
+}
diff --git a/7zip/Archive/7z_C/7zItem.c b/C/Archive/7z/7zItem.c
index 2a408050..2a408050 100755
--- a/7zip/Archive/7z_C/7zItem.c
+++ b/C/Archive/7z/7zItem.c
diff --git a/C/Archive/7z/7zMain.c b/C/Archive/7z/7zMain.c
new file mode 100755
index 00000000..0a789639
--- /dev/null
+++ b/C/Archive/7z/7zMain.c
@@ -0,0 +1,358 @@
+/*
+7zMain.c
+Test application for 7z Decoder
+LZMA SDK 4.43 Copyright (c) 1999-2006 Igor Pavlov (2006-06-04)
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef _WIN32
+#define USE_WINDOWS_FUNCTIONS
+#endif
+
+#ifdef USE_WINDOWS_FUNCTIONS
+#include <windows.h>
+#endif
+
+#include "7zIn.h"
+#include "7zExtract.h"
+
+#include "../../7zCrc.h"
+
+
+#ifdef USE_WINDOWS_FUNCTIONS
+typedef HANDLE MY_FILE_HANDLE;
+#else
+typedef FILE *MY_FILE_HANDLE;
+#endif
+
+void ConvertNumberToString(CFileSize value, char *s)
+{
+ char temp[32];
+ int pos = 0;
+ do
+ {
+ temp[pos++] = (char)('0' + (int)(value % 10));
+ value /= 10;
+ }
+ while (value != 0);
+ do
+ *s++ = temp[--pos];
+ while(pos > 0);
+ *s = '\0';
+}
+
+
+#ifdef USE_WINDOWS_FUNCTIONS
+// ReadFile and WriteFile functions in Windows have BUG:
+// If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
+// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
+// (Insufficient system resources exist to complete the requested service).
+#define kChunkSizeMax (1 << 24)
+#endif
+
+size_t MyReadFile(MY_FILE_HANDLE file, void *data, size_t size)
+{
+ if (size == 0)
+ return 0;
+ #ifdef USE_WINDOWS_FUNCTIONS
+ {
+ size_t processedSize = 0;
+ do
+ {
+ DWORD curSize = (size > kChunkSizeMax) ? kChunkSizeMax : (DWORD)size;
+ DWORD processedLoc = 0;
+ BOOL res = ReadFile(file, data, curSize, &processedLoc, NULL);
+ data = (void *)((unsigned char *)data + processedLoc);
+ size -= processedLoc;
+ processedSize += processedLoc;
+ if (!res || processedLoc == 0)
+ break;
+ }
+ while (size > 0);
+ return processedSize;
+ }
+ #else
+ return fread(data, 1, size, file);
+ #endif
+}
+
+size_t MyWriteFile(MY_FILE_HANDLE file, void *data, size_t size)
+{
+ if (size == 0)
+ return 0;
+ #ifdef USE_WINDOWS_FUNCTIONS
+ {
+ size_t processedSize = 0;
+ do
+ {
+ DWORD curSize = (size > kChunkSizeMax) ? kChunkSizeMax : (DWORD)size;
+ DWORD processedLoc = 0;
+ BOOL res = WriteFile(file, data, curSize, &processedLoc, NULL);
+ data = (void *)((unsigned char *)data + processedLoc);
+ size -= processedLoc;
+ processedSize += processedLoc;
+ if (!res)
+ break;
+ }
+ while (size > 0);
+ return processedSize;
+ }
+ #else
+ return fwrite(data, 1, size, file);
+ #endif
+}
+
+int MyCloseFile(MY_FILE_HANDLE file)
+{
+ #ifdef USE_WINDOWS_FUNCTIONS
+ return (CloseHandle(file) != FALSE) ? 0 : 1;
+ #else
+ return fclose(file);
+ #endif
+}
+
+typedef struct _CFileInStream
+{
+ ISzInStream InStream;
+ MY_FILE_HANDLE File;
+} CFileInStream;
+
+#ifdef _LZMA_IN_CB
+
+#define kBufferSize (1 << 12)
+Byte g_Buffer[kBufferSize];
+
+SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxRequiredSize, size_t *processedSize)
+{
+ CFileInStream *s = (CFileInStream *)object;
+ size_t processedSizeLoc;
+ if (maxRequiredSize > kBufferSize)
+ maxRequiredSize = kBufferSize;
+ processedSizeLoc = MyReadFile(s->File, g_Buffer, maxRequiredSize);
+ *buffer = g_Buffer;
+ if (processedSize != 0)
+ *processedSize = processedSizeLoc;
+ return SZ_OK;
+}
+
+#else
+
+SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size, size_t *processedSize)
+{
+ CFileInStream *s = (CFileInStream *)object;
+ size_t processedSizeLoc = MyReadFile(s->File, buffer, size);
+ if (processedSize != 0)
+ *processedSize = processedSizeLoc;
+ return SZ_OK;
+}
+
+#endif
+
+SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
+{
+ CFileInStream *s = (CFileInStream *)object;
+
+ #ifdef USE_WINDOWS_FUNCTIONS
+ {
+ LARGE_INTEGER value;
+ value.LowPart = (DWORD)pos;
+ value.HighPart = (LONG)(pos >> 32);
+ value.LowPart = SetFilePointer(s->File, value.LowPart, &value.HighPart, FILE_BEGIN);
+ if (value.LowPart == 0xFFFFFFFF)
+ if(GetLastError() != NO_ERROR)
+ return SZE_FAIL;
+ return SZ_OK;
+ }
+ #else
+ int res = fseek(s->File, (long)pos, SEEK_SET);
+ if (res == 0)
+ return SZ_OK;
+ return SZE_FAIL;
+ #endif
+}
+
+void PrintError(char *sz)
+{
+ printf("\nERROR: %s\n", sz);
+}
+
+int main(int numargs, char *args[])
+{
+ CFileInStream archiveStream;
+ CArchiveDatabaseEx db;
+ SZ_RESULT res;
+ ISzAlloc allocImp;
+ ISzAlloc allocTempImp;
+
+ printf("\n7z ANSI-C Decoder 4.44 Copyright (c) 1999-2006 Igor Pavlov 2006-08-27\n");
+ if (numargs == 1)
+ {
+ printf(
+ "\nUsage: 7zDec <command> <archive_name>\n\n"
+ "<Commands>\n"
+ " e: Extract files from archive\n"
+ " l: List contents of archive\n"
+ " t: Test integrity of archive\n");
+ return 0;
+ }
+ if (numargs < 3)
+ {
+ PrintError("incorrect command");
+ return 1;
+ }
+
+ archiveStream.File =
+ #ifdef USE_WINDOWS_FUNCTIONS
+ CreateFile(args[2], GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (archiveStream.File == INVALID_HANDLE_VALUE)
+ #else
+ archiveStream.File = fopen(args[2], "rb");
+ if (archiveStream.File == 0)
+ #endif
+ {
+ PrintError("can not open input file");
+ return 1;
+ }
+
+ archiveStream.InStream.Read = SzFileReadImp;
+ archiveStream.InStream.Seek = SzFileSeekImp;
+
+ allocImp.Alloc = SzAlloc;
+ allocImp.Free = SzFree;
+
+ allocTempImp.Alloc = SzAllocTemp;
+ allocTempImp.Free = SzFreeTemp;
+
+ CrcGenerateTable();
+
+ SzArDbExInit(&db);
+ res = SzArchiveOpen(&archiveStream.InStream, &db, &allocImp, &allocTempImp);
+ if (res == SZ_OK)
+ {
+ char *command = args[1];
+ int listCommand = 0;
+ int testCommand = 0;
+ int extractCommand = 0;
+ if (strcmp(command, "l") == 0)
+ listCommand = 1;
+ if (strcmp(command, "t") == 0)
+ testCommand = 1;
+ else if (strcmp(command, "e") == 0)
+ extractCommand = 1;
+
+ if (listCommand)
+ {
+ UInt32 i;
+ for (i = 0; i < db.Database.NumFiles; i++)
+ {
+ CFileItem *f = db.Database.Files + i;
+ char s[32];
+ ConvertNumberToString(f->Size, s);
+ printf("%10s %s\n", s, f->Name);
+ }
+ }
+ else if (testCommand || extractCommand)
+ {
+ UInt32 i;
+
+ /*
+ if you need cache, use these 3 variables.
+ if you use external function, you can make these variable as static.
+ */
+ UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
+ Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
+ size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
+
+ printf("\n");
+ for (i = 0; i < db.Database.NumFiles; i++)
+ {
+ size_t offset;
+ size_t outSizeProcessed;
+ CFileItem *f = db.Database.Files + i;
+ if (f->IsDirectory)
+ printf("Directory ");
+ else
+ printf(testCommand ?
+ "Testing ":
+ "Extracting");
+ printf(" %s", f->Name);
+ if (f->IsDirectory)
+ {
+ printf("\n");
+ continue;
+ }
+ res = SzExtract(&archiveStream.InStream, &db, i,
+ &blockIndex, &outBuffer, &outBufferSize,
+ &offset, &outSizeProcessed,
+ &allocImp, &allocTempImp);
+ if (res != SZ_OK)
+ break;
+ if (!testCommand)
+ {
+ MY_FILE_HANDLE outputHandle;
+ UInt32 processedSize;
+ char *fileName = f->Name;
+ size_t nameLen = strlen(f->Name);
+ for (; nameLen > 0; nameLen--)
+ if (f->Name[nameLen - 1] == '/')
+ {
+ fileName = f->Name + nameLen;
+ break;
+ }
+
+ outputHandle =
+ #ifdef USE_WINDOWS_FUNCTIONS
+ CreateFile(fileName, GENERIC_WRITE, FILE_SHARE_READ,
+ NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (outputHandle == INVALID_HANDLE_VALUE)
+ #else
+ fopen(fileName, "wb+");
+ if (outputHandle == 0)
+ #endif
+ {
+ PrintError("can not open output file");
+ res = SZE_FAIL;
+ break;
+ }
+ processedSize = MyWriteFile(outputHandle, outBuffer + offset, outSizeProcessed);
+ if (processedSize != outSizeProcessed)
+ {
+ PrintError("can not write output file");
+ res = SZE_FAIL;
+ break;
+ }
+ if (MyCloseFile(outputHandle))
+ {
+ PrintError("can not close output file");
+ res = SZE_FAIL;
+ break;
+ }
+ }
+ printf("\n");
+ }
+ allocImp.Free(outBuffer);
+ }
+ else
+ {
+ PrintError("incorrect command");
+ res = SZE_FAIL;
+ }
+ }
+ SzArDbExFree(&db, allocImp.Free);
+
+ MyCloseFile(archiveStream.File);
+ if (res == SZ_OK)
+ {
+ printf("\nEverything is Ok\n");
+ return 0;
+ }
+ if (res == SZE_OUTOFMEMORY)
+ PrintError("can not allocate memory");
+ else
+ printf("\nERROR #%d\n", res);
+ return 1;
+}
diff --git a/7zip/Archive/7z_C/7zMethodID.c b/C/Archive/7z/7zMethodID.c
index 5047359f..5047359f 100755
--- a/7zip/Archive/7z_C/7zMethodID.c
+++ b/C/Archive/7z/7zMethodID.c
diff --git a/C/Archive/7z/7z_C.dsp b/C/Archive/7z/7z_C.dsp
new file mode 100755
index 00000000..699384ef
--- /dev/null
+++ b/C/Archive/7z/7z_C.dsp
@@ -0,0 +1,186 @@
+# Microsoft Developer Studio Project File - Name="7z_C" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=7z_C - 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_C.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_C.mak" CFG="7z_C - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "7z_C - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "7z_C - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "7z_C - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /D "_SZ_FILE_SIZE_64" /YX /FD /c
+# 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 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 /subsystem:console /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 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 /subsystem:console /machine:I386 /out:"Release/7zDec.exe"
+
+!ELSEIF "$(CFG)" == "7z_C - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /D "_SZ_FILE_SIZE_64" /YX /FD /GZ /c
+# 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 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 /subsystem:console /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 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 /subsystem:console /debug /machine:I386 /out:"Debug/7zDec.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "7z_C - Win32 Release"
+# Name "7z_C - Win32 Debug"
+# Begin Group "LZMA"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Lzma\LzmaDecode.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Lzma\LzmaDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Lzma\LzmaTypes.h
+# End Source File
+# End Group
+# Begin Group "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\7zCrc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\7zCrc.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\7zAlloc.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zAlloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zBuffer.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zDecode.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zExtract.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zExtract.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zHeader.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zHeader.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zIn.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zItem.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zItem.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zMain.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zMethodID.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zMethodID.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zTypes.h
+# End Source File
+# End Target
+# End Project
diff --git a/7zip/Archive/7z_C/7z_C.dsw b/C/Archive/7z/7z_C.dsw
index 6fd39621..6fd39621 100755
--- a/7zip/Archive/7z_C/7z_C.dsw
+++ b/C/Archive/7z/7z_C.dsw
diff --git a/7zip/Archive/7z_C/makefile b/C/Archive/7z/makefile
index 9ce2c346..9ce2c346 100755
--- a/7zip/Archive/7z_C/makefile
+++ b/C/Archive/7z/makefile
diff --git a/7zip/Archive/7z_C/makefile.gcc b/C/Archive/7z/makefile.gcc
index 21b7df47..21b7df47 100755
--- a/7zip/Archive/7z_C/makefile.gcc
+++ b/C/Archive/7z/makefile.gcc
diff --git a/7zip/Compress/Branch/BranchARM.c b/C/Compress/Branch/BranchARM.c
index 6d4e3672..6d4e3672 100755
--- a/7zip/Compress/Branch/BranchARM.c
+++ b/C/Compress/Branch/BranchARM.c
diff --git a/7zip/Compress/Branch/BranchARM.h b/C/Compress/Branch/BranchARM.h
index 02eb1b47..02eb1b47 100755
--- a/7zip/Compress/Branch/BranchARM.h
+++ b/C/Compress/Branch/BranchARM.h
diff --git a/7zip/Compress/Branch/BranchARMThumb.c b/C/Compress/Branch/BranchARMThumb.c
index aab9c7a1..aab9c7a1 100755
--- a/7zip/Compress/Branch/BranchARMThumb.c
+++ b/C/Compress/Branch/BranchARMThumb.c
diff --git a/7zip/Compress/Branch/BranchARMThumb.h b/C/Compress/Branch/BranchARMThumb.h
index d67e6e5a..d67e6e5a 100755
--- a/7zip/Compress/Branch/BranchARMThumb.h
+++ b/C/Compress/Branch/BranchARMThumb.h
diff --git a/7zip/Compress/Branch/BranchIA64.c b/C/Compress/Branch/BranchIA64.c
index e7775564..e7775564 100755
--- a/7zip/Compress/Branch/BranchIA64.c
+++ b/C/Compress/Branch/BranchIA64.c
diff --git a/7zip/Compress/Branch/BranchIA64.h b/C/Compress/Branch/BranchIA64.h
index b7757fe9..b7757fe9 100755
--- a/7zip/Compress/Branch/BranchIA64.h
+++ b/C/Compress/Branch/BranchIA64.h
diff --git a/7zip/Compress/Branch/BranchPPC.c b/C/Compress/Branch/BranchPPC.c
index b3e5703f..b3e5703f 100755
--- a/7zip/Compress/Branch/BranchPPC.c
+++ b/C/Compress/Branch/BranchPPC.c
diff --git a/7zip/Compress/Branch/BranchPPC.h b/C/Compress/Branch/BranchPPC.h
index c02bba19..c02bba19 100755
--- a/7zip/Compress/Branch/BranchPPC.h
+++ b/C/Compress/Branch/BranchPPC.h
diff --git a/7zip/Compress/Branch/BranchSPARC.c b/C/Compress/Branch/BranchSPARC.c
index c175875b..c175875b 100755
--- a/7zip/Compress/Branch/BranchSPARC.c
+++ b/C/Compress/Branch/BranchSPARC.c
diff --git a/7zip/Compress/Branch/BranchSPARC.h b/C/Compress/Branch/BranchSPARC.h
index fbe9e673..fbe9e673 100755
--- a/7zip/Compress/Branch/BranchSPARC.h
+++ b/C/Compress/Branch/BranchSPARC.h
diff --git a/7zip/Compress/Branch/BranchTypes.h b/C/Compress/Branch/BranchTypes.h
index f7ad3abc..f7ad3abc 100755
--- a/7zip/Compress/Branch/BranchTypes.h
+++ b/C/Compress/Branch/BranchTypes.h
diff --git a/7zip/Compress/Branch/BranchX86.c b/C/Compress/Branch/BranchX86.c
index c3f455b8..c3f455b8 100755
--- a/7zip/Compress/Branch/BranchX86.c
+++ b/C/Compress/Branch/BranchX86.c
diff --git a/7zip/Compress/Branch/BranchX86.h b/C/Compress/Branch/BranchX86.h
index 25c1ae51..25c1ae51 100755
--- a/7zip/Compress/Branch/BranchX86.h
+++ b/C/Compress/Branch/BranchX86.h
diff --git a/C/Compress/Huffman/HuffmanEncode.c b/C/Compress/Huffman/HuffmanEncode.c
new file mode 100755
index 00000000..3168db2d
--- /dev/null
+++ b/C/Compress/Huffman/HuffmanEncode.c
@@ -0,0 +1,146 @@
+// Compression/HuffmanEncode.c
+
+#include "HuffmanEncode.h"
+#include "../../Sort.h"
+
+#define kMaxLen 16
+#define NUM_BITS 10
+#define MASK ((1 << NUM_BITS) - 1)
+
+#define NUM_COUNTERS 64
+
+// use BLOCK_SORT_EXTERNAL_FLAGS if blockSize > 1M
+#define HUFFMAN_SPEED_OPT
+
+void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymbols, UInt32 maxLen)
+{
+ UInt32 num = 0;
+ // if (maxLen > 10) maxLen = 10;
+ {
+ UInt32 i;
+
+ #ifdef HUFFMAN_SPEED_OPT
+
+ UInt32 counters[NUM_COUNTERS];
+ for (i = 0; i < NUM_COUNTERS; i++)
+ counters[i] = 0;
+ for (i = 0; i < numSymbols; i++)
+ {
+ UInt32 freq = freqs[i];
+ counters[(freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1]++;
+ }
+
+ for (i = 1; i < NUM_COUNTERS; i++)
+ {
+ UInt32 temp = counters[i];
+ counters[i] = num;
+ num += temp;
+ }
+
+ for (i = 0; i < numSymbols; i++)
+ {
+ UInt32 freq = freqs[i];
+ if (freq == 0)
+ lens[i] = 0;
+ else
+ p[counters[((freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1)]++] = i | (freq << NUM_BITS);
+ }
+ counters[0] = 0;
+ HeapSort(p + counters[NUM_COUNTERS - 2], counters[NUM_COUNTERS - 1] - counters[NUM_COUNTERS - 2]);
+
+ #else
+
+ for (i = 0; i < numSymbols; i++)
+ {
+ UInt32 freq = freqs[i];
+ if (freq == 0)
+ lens[i] = 0;
+ else
+ p[num++] = i | (freq << NUM_BITS);
+ }
+ HeapSort(p, num);
+
+ #endif
+ }
+
+ if (num < 2)
+ {
+ int minCode = 0;
+ int maxCode = 1;
+ if (num == 1)
+ {
+ maxCode = p[0] & MASK;
+ if (maxCode == 0)
+ maxCode++;
+ }
+ p[minCode] = 0;
+ p[maxCode] = 1;
+ lens[minCode] = lens[maxCode] = 1;
+ return;
+ }
+
+ {
+ UInt32 b, e, i;
+
+ i = b = e = 0;
+ do
+ {
+ UInt32 n, m, freq;
+ n = (i != num && (b == e || (p[i] >> NUM_BITS) <= (p[b] >> NUM_BITS))) ? i++ : b++;
+ freq = (p[n] & ~MASK);
+ p[n] = (p[n] & MASK) | (e << NUM_BITS);
+ m = (i != num && (b == e || (p[i] >> NUM_BITS) <= (p[b] >> NUM_BITS))) ? i++ : b++;
+ freq += (p[m] & ~MASK);
+ p[m] = (p[m] & MASK) | (e << NUM_BITS);
+ p[e] = (p[e] & MASK) | freq;
+ e++;
+ }
+ while (num - e > 1);
+
+ {
+ UInt32 lenCounters[kMaxLen + 1];
+ for (i = 0; i <= kMaxLen; i++)
+ lenCounters[i] = 0;
+
+ p[--e] &= MASK;
+ lenCounters[1] = 2;
+ while (e > 0)
+ {
+ UInt32 len = (p[p[--e] >> NUM_BITS] >> NUM_BITS) + 1;
+ p[e] = (p[e] & MASK) | (len << NUM_BITS);
+ if (len >= maxLen)
+ for (len = maxLen - 1; lenCounters[len] == 0; len--);
+ lenCounters[len]--;
+ lenCounters[len + 1] += 2;
+ }
+
+ {
+ UInt32 len;
+ i = 0;
+ for (len = maxLen; len != 0; len--)
+ {
+ UInt32 num;
+ for (num = lenCounters[len]; num != 0; num--)
+ lens[p[i++] & MASK] = (Byte)len;
+ }
+ }
+
+ {
+ UInt32 nextCodes[kMaxLen + 1];
+ {
+ UInt32 code = 0;
+ UInt32 len;
+ for (len = 1; len <= kMaxLen; len++)
+ nextCodes[len] = code = (code + lenCounters[len - 1]) << 1;
+ }
+ // if (code + lenCounters[kMaxLen] - 1 != (1 << kMaxLen) - 1) throw 1;
+
+ {
+ UInt32 i;
+ for (i = 0; i < numSymbols; i++)
+ p[i] = nextCodes[lens[i]]++;
+ }
+ }
+ }
+ }
+}
diff --git a/C/Compress/Huffman/HuffmanEncode.h b/C/Compress/Huffman/HuffmanEncode.h
new file mode 100755
index 00000000..dfd2f0ab
--- /dev/null
+++ b/C/Compress/Huffman/HuffmanEncode.h
@@ -0,0 +1,20 @@
+// Compress/HuffmanEncode.h
+
+#ifndef __COMPRESS_HUFFMANENCODE_H
+#define __COMPRESS_HUFFMANENCODE_H
+
+#include "../../Types.h"
+
+#define HUFFMAN_TEMP_SIZE(num) (num * 2)
+
+/*
+Conditions:
+ num <= 1024 = 2 ^ NUM_BITS
+ Sum(freqs) < 4M = 2 ^ (32 - NUM_BITS)
+ maxLen <= 16 = kMaxLen
+ Num_Items(p) >= HUFFMAN_TEMP_SIZE(num)
+*/
+
+void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen);
+
+#endif
diff --git a/C/Compress/Lz/LzHash.h b/C/Compress/Lz/LzHash.h
new file mode 100755
index 00000000..87c28365
--- /dev/null
+++ b/C/Compress/Lz/LzHash.h
@@ -0,0 +1,53 @@
+/* LzHash.h */
+
+#ifndef __C_LZHASH_H
+#define __C_LZHASH_H
+
+#define kHash2Size (1 << 10)
+#define kHash3Size (1 << 16)
+#define kHash4Size (1 << 20)
+
+#define kFix3HashSize (kHash2Size)
+#define kFix4HashSize (kHash2Size + kHash3Size)
+#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
+
+#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
+
+#define HASH3_CALC { \
+ UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
+
+#define HASH4_CALC { \
+ UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
+ hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (g_CrcTable[cur[3]] << 5)) & p->hashMask; }
+
+#define HASH5_CALC { \
+ UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
+ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (g_CrcTable[cur[3]] << 5)); \
+ hashValue = (hash4Value ^ (g_CrcTable[cur[4]] << 3)) & p->hashMask; \
+ hash4Value &= (kHash4Size - 1); }
+
+/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ g_CrcTable[cur[2]]) & 0xFFFF; */
+#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ g_CrcTable[cur[1]]) & 0xFFFF;
+
+
+#define MT_HASH2_CALC \
+ hash2Value = (g_CrcTable[cur[0]] ^ cur[1]) & (kHash2Size - 1);
+
+#define MT_HASH3_CALC { \
+ UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
+
+#define MT_HASH4_CALC { \
+ UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
+ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (g_CrcTable[cur[3]] << 5)) & (kHash4Size - 1); }
+
+#endif
diff --git a/C/Compress/Lz/MatchFinder.c b/C/Compress/Lz/MatchFinder.c
new file mode 100755
index 00000000..4580c52b
--- /dev/null
+++ b/C/Compress/Lz/MatchFinder.c
@@ -0,0 +1,725 @@
+/* MatchFinder.c */
+/* Please call InitCrcTable before */
+
+#include <string.h>
+
+#include "MatchFinder.h"
+#include "LzHash.h"
+
+#include "../../7zCrc.h"
+
+#define kEmptyHashValue 0
+#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
+#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
+#define kNormalizeMask (~(kNormalizeStepMin - 1))
+#define kMaxHistorySize ((UInt32)3 << 30)
+
+#define kStartMaxLen 3
+
+void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
+{
+ if (!p->directInput)
+ {
+ alloc->Free(p->bufferBase);
+ p->bufferBase = 0;
+ }
+}
+
+/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
+
+int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
+{
+ UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
+ if (p->directInput)
+ {
+ p->blockSize = blockSize;
+ return 1;
+ }
+ if (p->bufferBase == 0 || p->blockSize != blockSize)
+ {
+ LzInWindow_Free(p, alloc);
+ p->blockSize = blockSize;
+ p->bufferBase = (Byte *)alloc->Alloc(blockSize);
+ }
+ return (p->bufferBase != 0);
+}
+
+Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer + p->pos; }
+Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[(size_t)p->pos + index]; }
+
+UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
+
+void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
+{
+ p->buffer += subValue;
+ p->posLimit -= subValue;
+ p->pos -= subValue;
+ p->streamPos -= subValue;
+}
+
+void MatchFinder_ReadBlock(CMatchFinder *p)
+{
+ if (p->streamEndWasReached || p->result != SZ_OK)
+ return;
+ for (;;)
+ {
+ Byte *dest = (p->buffer + p->pos + (p->streamPos - p->pos));
+ UInt32 numReadBytes;
+ UInt32 size = (UInt32)(p->bufferBase + p->blockSize - dest);
+ if (size == 0)
+ return;
+ p->result = p->stream->Read(p->stream, dest, size, &numReadBytes);
+ if (p->result != SZ_OK)
+ return;
+ if (numReadBytes == 0)
+ {
+ p->streamEndWasReached = 1;
+ return;
+ }
+ p->streamPos += numReadBytes;
+ if (p->streamPos - p->pos > p->keepSizeAfter)
+ return;
+ }
+}
+
+void MatchFinder_MoveBlock(CMatchFinder *p)
+{
+ memmove(p->bufferBase,
+ p->buffer + p->pos - p->keepSizeBefore,
+ p->streamPos - p->pos + p->keepSizeBefore);
+ p->buffer = p->bufferBase + p->keepSizeBefore - p->pos;
+}
+
+
+int MatchFinder_NeedMove(CMatchFinder *p)
+{
+ /* if (p->streamEndWasReached) return 0; */
+ return ((size_t)(p->bufferBase + p->blockSize - (p->buffer + p->pos)) <= p->keepSizeAfter);
+}
+
+void MatchFinder_ReadIfRequired(CMatchFinder *p)
+{
+ if (p->streamEndWasReached)
+ return;
+ if (p->keepSizeAfter >= p->streamPos - p->pos)
+ MatchFinder_ReadBlock(p);
+}
+
+void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
+{
+ if (MatchFinder_NeedMove(p))
+ MatchFinder_MoveBlock(p);
+ MatchFinder_ReadBlock(p);
+}
+
+void MatchFinder_SetDefaultSettings(CMatchFinder *p)
+{
+ p->cutValue = 32;
+ p->btMode = 1;
+ p->numHashBytes = 4;
+ /* p->skipModeBits = 0; */
+ p->directInput = 0;
+ p->bigHash = 0;
+}
+
+void MatchFinder_Construct(CMatchFinder *p)
+{
+ p->bufferBase = 0;
+ p->directInput = 0;
+ p->hash = 0;
+ MatchFinder_SetDefaultSettings(p);
+}
+
+void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)
+{
+ alloc->Free(p->hash);
+ p->hash = 0;
+}
+
+void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)
+{
+ MatchFinder_FreeThisClassMemory(p, alloc);
+ LzInWindow_Free(p, alloc);
+}
+
+CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc)
+{
+ size_t sizeInBytes = (size_t)num * sizeof(CLzRef);
+ if (sizeInBytes / sizeof(CLzRef) != num)
+ return 0;
+ return (CLzRef *)alloc->Alloc(sizeInBytes);
+}
+
+int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
+ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
+ ISzAlloc *alloc)
+{
+ UInt32 sizeReserv;
+ if (historySize > kMaxHistorySize)
+ {
+ MatchFinder_Free(p, alloc);
+ return 0;
+ }
+ sizeReserv = historySize >> 1;
+ if (historySize > ((UInt32)2 << 30))
+ sizeReserv = historySize >> 2;
+ sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 12);
+
+ p->keepSizeBefore = historySize + keepAddBufferBefore + 1;
+ p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
+ /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */
+ if (LzInWindow_Create(p, sizeReserv, alloc))
+ {
+ UInt32 newCyclicBufferSize = (historySize /* >> p->skipModeBits */) + 1;
+ UInt32 hs;
+ p->matchMaxLen = matchMaxLen;
+ {
+ p->fixedHashSize = 0;
+ if (p->numHashBytes == 2)
+ hs = (1 << 16) - 1;
+ else
+ {
+ hs = historySize - 1;
+ hs |= (hs >> 1);
+ hs |= (hs >> 2);
+ hs |= (hs >> 4);
+ hs |= (hs >> 8);
+ hs >>= 1;
+ /* hs >>= p->skipModeBits; */
+ hs |= 0xFFFF; /* don't change it! It's required for Deflate */
+ if (hs > (1 << 24))
+ {
+ if (p->numHashBytes == 3)
+ hs = (1 << 24) - 1;
+ else
+ hs >>= 1;
+ }
+ }
+ p->hashMask = hs;
+ hs++;
+ if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size;
+ if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size;
+ if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size;
+ hs += p->fixedHashSize;
+ }
+
+ {
+ UInt32 prevSize = p->hashSizeSum + p->numSons;
+ UInt32 newSize;
+ p->historySize = historySize;
+ p->hashSizeSum = hs;
+ p->cyclicBufferSize = newCyclicBufferSize;
+ p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize);
+ newSize = p->hashSizeSum + p->numSons;
+ if (p->hash != 0 && prevSize == newSize)
+ return 1;
+ MatchFinder_FreeThisClassMemory(p, alloc);
+ p->hash = AllocRefs(newSize, alloc);
+ if (p->hash != 0)
+ {
+ p->son = p->hash + p->hashSizeSum;
+ return 1;
+ }
+ }
+ }
+ MatchFinder_Free(p, alloc);
+ return 0;
+}
+
+void MatchFinder_SetLimits(CMatchFinder *p)
+{
+ UInt32 limit = kMaxValForNormalize - p->pos;
+ UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
+ if (limit2 < limit)
+ limit = limit2;
+ limit2 = p->streamPos - p->pos;
+ if (limit2 <= p->keepSizeAfter)
+ {
+ if (limit2 > 0)
+ limit2 = 1;
+ }
+ else
+ limit2 -= p->keepSizeAfter;
+ if (limit2 < limit)
+ limit = limit2;
+ {
+ UInt32 lenLimit = p->streamPos - p->pos;
+ if (lenLimit > p->matchMaxLen)
+ lenLimit = p->matchMaxLen;
+ p->lenLimit = lenLimit;
+ }
+ p->posLimit = p->pos + limit;
+}
+
+void MatchFinder_Init(CMatchFinder *p)
+{
+ UInt32 i;
+ for(i = 0; i < p->hashSizeSum; i++)
+ p->hash[i] = kEmptyHashValue;
+ p->cyclicBufferPos = 0;
+ p->buffer = p->bufferBase - p->cyclicBufferSize;
+ p->pos = p->streamPos = p->cyclicBufferSize;
+ p->result = SZ_OK;
+ p->streamEndWasReached = 0;
+ MatchFinder_ReadBlock(p);
+ MatchFinder_SetLimits(p);
+}
+
+UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
+{
+ return (p->pos - p->historySize - 1) & kNormalizeMask;
+}
+
+void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
+{
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ UInt32 value = items[i];
+ if (value <= subValue)
+ value = kEmptyHashValue;
+ else
+ value -= subValue;
+ items[i] = value;
+ }
+}
+
+void MatchFinder_Normalize(CMatchFinder *p)
+{
+ UInt32 subValue = MatchFinder_GetSubValue(p);
+ MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons);
+ MatchFinder_ReduceOffsets(p, subValue);
+}
+
+void MatchFinder_CheckLimits(CMatchFinder *p)
+{
+ if (p->pos == kMaxValForNormalize)
+ MatchFinder_Normalize(p);
+ if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos)
+ MatchFinder_CheckAndMoveAndRead(p);
+ if (p->cyclicBufferPos == p->cyclicBufferSize)
+ p->cyclicBufferPos = 0;
+ MatchFinder_SetLimits(p);
+}
+
+UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
+ UInt32 *distances, UInt32 maxLen)
+{
+ son[_cyclicBufferPos] = curMatch;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ return distances;
+ {
+ const Byte *pb = buffer + curMatch;
+ const Byte *cur = buffer + pos;
+ curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
+ if (pb[maxLen] == cur[maxLen] && *pb == *cur)
+ {
+ UInt32 len = 0;
+ while(++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ if (maxLen < len)
+ {
+ *distances++ = maxLen = len;
+ *distances++ = delta - 1;
+ if (len == lenLimit)
+ return distances;
+ }
+ }
+ }
+ }
+}
+
+UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
+ UInt32 *distances, UInt32 maxLen)
+{
+ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
+ UInt32 len0 = 0, len1 = 0;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ {
+ *ptr0 = *ptr1 = kEmptyHashValue;
+ return distances;
+ }
+ {
+ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = buffer + curMatch;
+ const Byte *cur = buffer + pos;
+ UInt32 len = (len0 < len1 ? len0 : len1);
+ if (pb[len] == cur[len])
+ {
+ if (++len != lenLimit && pb[len] == cur[len])
+ while(++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ if (maxLen < len)
+ {
+ *distances++ = maxLen = len;
+ *distances++ = delta - 1;
+ if (len == lenLimit)
+ {
+ *ptr1 = pair[0];
+ *ptr0 = pair[1];
+ return distances;
+ }
+ }
+ }
+ if (pb[len] < cur[len])
+ {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
+ curMatch = *ptr1;
+ len1 = len;
+ }
+ else
+ {
+ *ptr0 = curMatch;
+ ptr0 = pair;
+ curMatch = *ptr0;
+ len0 = len;
+ }
+ }
+ }
+}
+
+void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
+{
+ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
+ UInt32 len0 = 0, len1 = 0;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ {
+ *ptr0 = *ptr1 = kEmptyHashValue;
+ return;
+ }
+ {
+ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = buffer + curMatch;
+ const Byte *cur = buffer + pos;
+ UInt32 len = (len0 < len1 ? len0 : len1);
+ if (pb[len] == cur[len])
+ {
+ while(++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ {
+ if (len == lenLimit)
+ {
+ *ptr1 = pair[0];
+ *ptr0 = pair[1];
+ return;
+ }
+ }
+ }
+ if (pb[len] < cur[len])
+ {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
+ curMatch = *ptr1;
+ len1 = len;
+ }
+ else
+ {
+ *ptr0 = curMatch;
+ ptr0 = pair;
+ curMatch = *ptr0;
+ len0 = len;
+ }
+ }
+ }
+}
+
+#define MOVE_POS \
+ ++p->cyclicBufferPos; \
+ if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
+
+#define MOVE_POS_RET MOVE_POS return offset;
+
+void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
+
+#define GET_MATCHES_HEADER2(minLen, ret_op) \
+ UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
+ lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
+ cur = p->buffer + p->pos;
+
+#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
+#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue)
+
+#define GET_MATCHES_FOOTER(offset, maxLen) \
+ offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, p->pos, p->buffer, p->son, p->cyclicBufferPos, \
+ p->cyclicBufferSize, p->cutValue, distances + offset, maxLen) - distances); MOVE_POS_RET;
+
+#define SKIP_FOOTER \
+ SkipMatchesSpec(lenLimit, curMatch, p->pos, p->buffer, p->son, \
+ p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue); MOVE_POS;
+
+UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 offset;
+ GET_MATCHES_HEADER(2)
+ HASH2_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ offset = 0;
+ GET_MATCHES_FOOTER(offset, 1)
+}
+
+UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 offset;
+ GET_MATCHES_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ offset = 0;
+ GET_MATCHES_FOOTER(offset, 2)
+}
+
+UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 hash2Value, matchMinPos, curMatch2, maxLen, offset;
+ GET_MATCHES_HEADER(3)
+
+ HASH3_CALC;
+
+ curMatch2 = p->hash[hash2Value];
+ curMatch = p->hash[kFix3HashSize + hashValue];
+
+ p->hash[hash2Value] =
+ p->hash[kFix3HashSize + hashValue] = p->pos;
+
+ matchMinPos = p->pos - p->cyclicBufferSize;
+
+ maxLen = 2;
+ offset = 0;
+ if (curMatch2 > matchMinPos && p->buffer[curMatch2] == cur[0])
+ {
+ for (; maxLen != lenLimit; maxLen++)
+ if (p->buffer[curMatch2 + maxLen] != cur[maxLen])
+ break;
+ distances[0] = maxLen;
+ distances[1] = p->pos - curMatch2 - 1;
+ offset = 2;
+ if (maxLen == lenLimit)
+ {
+ SkipMatchesSpec(lenLimit, curMatch, p->pos, p->buffer, p->son,
+ p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue);
+ MOVE_POS_RET;
+ }
+ }
+ GET_MATCHES_FOOTER(offset, maxLen)
+}
+
+UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, matchMinPos, curMatch2, curMatch3, maxLen, offset;
+ GET_MATCHES_HEADER(4)
+
+ HASH4_CALC;
+
+ curMatch2 = p->hash[ hash2Value];
+ curMatch3 = p->hash[kFix3HashSize + hash3Value];
+ curMatch = p->hash[kFix4HashSize + hashValue];
+
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] =
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+
+ matchMinPos = p->pos - p->cyclicBufferSize;
+ maxLen = 1;
+ offset = 0;
+ if (curMatch2 > matchMinPos && p->buffer[curMatch2] == cur[0])
+ {
+ distances[0] = maxLen = 2;
+ distances[1] = p->pos - curMatch2 - 1;
+ offset = 2;
+ }
+ if (curMatch2 != curMatch3 && curMatch3 > matchMinPos && p->buffer[curMatch3] == cur[0])
+ {
+ maxLen = 3;
+ distances[offset + 1] = p->pos - curMatch3 - 1;
+ offset += 2;
+ curMatch2 = curMatch3;
+ }
+ if (offset != 0)
+ {
+ for (; maxLen != lenLimit; maxLen++)
+ if (p->buffer[curMatch2 + maxLen] != cur[maxLen])
+ break;
+ distances[offset - 2] = maxLen;
+ if (maxLen == lenLimit)
+ {
+ SkipMatchesSpec(lenLimit, curMatch, p->pos, p->buffer, p->son,
+ p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue);
+ MOVE_POS_RET;
+ }
+ }
+ if (maxLen < 3)
+ maxLen = 3;
+ GET_MATCHES_FOOTER(offset, maxLen)
+}
+
+UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, matchMinPos, curMatch2, curMatch3, maxLen, offset;
+ GET_MATCHES_HEADER(4)
+
+ HASH4_CALC;
+
+ curMatch2 = p->hash[ hash2Value];
+ curMatch3 = p->hash[kFix3HashSize + hash3Value];
+ curMatch = p->hash[kFix4HashSize + hashValue];
+
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] =
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+
+ matchMinPos = p->pos - p->cyclicBufferSize;
+ maxLen = 1;
+ offset = 0;
+ if (curMatch2 > matchMinPos && p->buffer[curMatch2] == cur[0])
+ {
+ distances[0] = maxLen = 2;
+ distances[1] = p->pos - curMatch2 - 1;
+ offset = 2;
+ }
+ if (curMatch2 != curMatch3 && curMatch3 > matchMinPos && p->buffer[curMatch3] == cur[0])
+ {
+ maxLen = 3;
+ distances[offset + 1] = p->pos - curMatch3 - 1;
+ offset += 2;
+ curMatch2 = curMatch3;
+ }
+ if (offset != 0)
+ {
+ for (; maxLen != lenLimit; maxLen++)
+ if (p->buffer[curMatch2 + maxLen] != cur[maxLen])
+ break;
+ distances[offset - 2] = maxLen;
+ if (maxLen == lenLimit)
+ {
+ p->son[p->cyclicBufferPos] = curMatch;
+ MOVE_POS_RET;
+ }
+ }
+ if (maxLen < 3)
+ maxLen = 3;
+ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, p->pos, p->buffer, p->son,
+ p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
+ distances + offset, maxLen) - (distances));
+ MOVE_POS_RET
+}
+
+void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ SKIP_HEADER(2)
+ HASH2_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ SKIP_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ UInt32 hash2Value;
+ SKIP_HEADER(3)
+ HASH3_CALC;
+ curMatch = p->hash[kFix3HashSize + hashValue];
+ p->hash[hash2Value] =
+ p->hash[kFix3HashSize + hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ UInt32 hash2Value, hash3Value;
+ SKIP_HEADER(4)
+ HASH4_CALC;
+ curMatch = p->hash[kFix4HashSize + hashValue];
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] = p->pos;
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ UInt32 hash2Value, hash3Value;
+ SKIP_HEADER(4)
+ HASH4_CALC;
+ curMatch = p->hash[kFix4HashSize + hashValue];
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] =
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+ p->son[p->cyclicBufferPos] = curMatch;
+ MOVE_POS
+ }
+ while (--num != 0);
+}
+
+void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
+{
+ vTable->Init = (Mf_Init_Func)MatchFinder_Init;
+ vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
+ vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
+ vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
+ if (!p->btMode)
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
+ }
+ else if (p->numHashBytes == 2)
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
+ }
+ else if (p->numHashBytes == 3)
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
+ }
+ else
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
+ }
+}
diff --git a/C/Compress/Lz/MatchFinder.h b/C/Compress/Lz/MatchFinder.h
new file mode 100755
index 00000000..43906312
--- /dev/null
+++ b/C/Compress/Lz/MatchFinder.h
@@ -0,0 +1,103 @@
+/* MatchFinder.h */
+
+#ifndef __MATCHFINDER_H
+#define __MATCHFINDER_H
+
+#include "../../IStream.h"
+
+typedef UInt32 CLzRef;
+
+typedef struct _CMatchFinder
+{
+ Byte *buffer;
+ UInt32 pos;
+ UInt32 posLimit;
+ UInt32 streamPos;
+ UInt32 lenLimit;
+
+ UInt32 cyclicBufferPos;
+ UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
+
+ UInt32 matchMaxLen;
+ CLzRef *hash;
+ CLzRef *son;
+ UInt32 hashMask;
+ UInt32 cutValue;
+
+ Byte *bufferBase;
+ ISeqInStream *stream;
+ int streamEndWasReached;
+
+ UInt32 blockSize;
+ UInt32 keepSizeBefore;
+ UInt32 keepSizeAfter;
+
+ UInt32 numHashBytes;
+ int directInput;
+ int btMode;
+ /* int skipModeBits; */
+ int bigHash;
+ UInt32 historySize;
+ UInt32 fixedHashSize;
+ UInt32 hashSizeSum;
+ UInt32 numSons;
+
+ HRes result;
+} CMatchFinder;
+
+#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer + (p)->pos)
+#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(size_t)(p)->pos + (Int32)(index)])
+#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
+
+int MatchFinder_NeedMove(CMatchFinder *p);
+Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
+void MatchFinder_MoveBlock(CMatchFinder *p);
+void MatchFinder_ReadIfRequired(CMatchFinder *p);
+
+void MatchFinder_Construct(CMatchFinder *p);
+
+/* Conditions:
+ historySize <= 3 GB
+ keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
+*/
+int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
+ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
+ ISzAlloc *alloc);
+void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
+void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
+void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
+
+UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
+ UInt32 *distances, UInt32 maxLen);
+
+/*
+Conditions:
+ Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
+ Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
+*/
+
+typedef void (*Mf_Init_Func)(void *object);
+typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
+typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
+typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
+typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
+typedef void (*Mf_Skip_Func)(void *object, UInt32);
+
+typedef struct _IMatchFinder
+{
+ Mf_Init_Func Init;
+ Mf_GetIndexByte_Func GetIndexByte;
+ Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
+ Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
+ Mf_GetMatches_Func GetMatches;
+ Mf_Skip_Func Skip;
+} IMatchFinder;
+
+void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
+
+void MatchFinder_Init(CMatchFinder *p);
+UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
+void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+
+#endif
diff --git a/C/Compress/Lz/MatchFinderMt.c b/C/Compress/Lz/MatchFinderMt.c
new file mode 100755
index 00000000..4ab90d9a
--- /dev/null
+++ b/C/Compress/Lz/MatchFinderMt.c
@@ -0,0 +1,792 @@
+/* MatchFinderMt.c */
+
+#include <stdio.h>
+#include "../../7zCrc.h"
+#include "LzHash.h"
+
+#include "MatchFinderMt.h"
+
+void MtSync_Construct(CMtSync *p)
+{
+ p->wasCreated = False;
+ p->csWasInitialized = False;
+ p->csWasEntered = False;
+ Thread_Construct(&p->thread);
+ Event_Construct(&p->canStart);
+ Event_Construct(&p->wasStarted);
+ Event_Construct(&p->wasStopped);
+ Semaphore_Construct(&p->freeSemaphore);
+ Semaphore_Construct(&p->filledSemaphore);
+}
+
+void MtSync_GetNextBlock(CMtSync *p)
+{
+ if (p->needStart)
+ {
+ p->numProcessedBlocks = 1;
+ p->needStart = False;
+ p->stopWriting = False;
+ p->exit = False;
+ Event_Reset(&p->wasStarted);
+ Event_Reset(&p->wasStopped);
+
+ Event_Set(&p->canStart);
+ Event_Wait(&p->wasStarted);
+ }
+ else
+ {
+ CriticalSection_Leave(&p->cs);
+ p->csWasEntered = False;
+ p->numProcessedBlocks++;
+ Semaphore_Release1(&p->freeSemaphore);
+ }
+ Semaphore_Wait(&p->filledSemaphore);
+ CriticalSection_Enter(&p->cs);
+ p->csWasEntered = True;
+}
+
+/* MtSync_StopWriting must be called if Writing was started */
+
+void MtSync_StopWriting(CMtSync *p)
+{
+ UInt32 myNumBlocks = p->numProcessedBlocks;
+ if (!Thread_WasCreated(&p->thread) || p->needStart)
+ return;
+ p->stopWriting = True;
+ if (p->csWasEntered)
+ {
+ CriticalSection_Leave(&p->cs);
+ p->csWasEntered = False;
+ }
+ Semaphore_Release1(&p->freeSemaphore);
+
+ Event_Wait(&p->wasStopped);
+
+ while (myNumBlocks++ != p->numProcessedBlocks)
+ {
+ Semaphore_Wait(&p->filledSemaphore);
+ Semaphore_Release1(&p->freeSemaphore);
+ }
+ p->needStart = True;
+}
+
+void MtSync_Destruct(CMtSync *p)
+{
+ if (Thread_WasCreated(&p->thread))
+ {
+ MtSync_StopWriting(p);
+ p->exit = True;
+ if (p->needStart)
+ Event_Set(&p->canStart);
+ Thread_Wait(&p->thread);
+ Thread_Close(&p->thread);
+ }
+ if (p->csWasInitialized)
+ {
+ CriticalSection_Delete(&p->cs);
+ p->csWasInitialized = False;
+ }
+
+ Event_Close(&p->canStart);
+ Event_Close(&p->wasStarted);
+ Event_Close(&p->wasStopped);
+ Semaphore_Close(&p->freeSemaphore);
+ Semaphore_Close(&p->filledSemaphore);
+
+ p->wasCreated = False;
+}
+
+HRes MtSync_Create2(CMtSync *p, unsigned (StdCall *startAddress)(void *), void *obj, UInt32 numBlocks)
+{
+ if (p->wasCreated)
+ return SZ_OK;
+
+ RINOK(CriticalSection_Init(&p->cs));
+ p->csWasInitialized = True;
+
+ RINOK(AutoResetEvent_CreateNotSignaled(&p->canStart));
+ RINOK(AutoResetEvent_CreateNotSignaled(&p->wasStarted));
+ RINOK(AutoResetEvent_CreateNotSignaled(&p->wasStopped));
+
+ RINOK(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks));
+ RINOK(Semaphore_Create(&p->filledSemaphore, 0, numBlocks));
+
+ p->needStart = True;
+
+ RINOK(Thread_Create(&p->thread, startAddress, obj));
+ p->wasCreated = True;
+ return SZ_OK;
+}
+
+HRes MtSync_Create(CMtSync *p, unsigned (StdCall *startAddress)(void *), void *obj, UInt32 numBlocks)
+{
+ HRes res = MtSync_Create2(p, startAddress, obj, numBlocks);
+ if (res != SZ_OK)
+ MtSync_Destruct(p);
+ return res;
+}
+
+
+void MtSync_Init(CMtSync *p) { p->needStart = True; }
+
+#define kMtMaxValForNormalize 0xFFFFFFFF
+
+/*
+Notes:
+instead of "size_t pos" we can use "UInt32 pos".
+But MSVC++ compilers have BUG:
+sometimes they use signed extending: (size_t)pos was compiled to "movsxd r10, edx"
+*/
+
+#define DEF_GetHeads(name, v) \
+static void GetHeads ## name(const Byte *buffer, size_t pos, \
+UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads) { \
+for (; numHeads != 0; numHeads--) { const Byte *p = buffer + (size_t)pos; \
+const UInt32 value = (v); *heads++ = (UInt32)pos - hash[value]; hash[value] = (UInt32)(pos++); } }
+
+DEF_GetHeads(2, (p[0] | ((UInt32)p[1] << 8)) & hashMask)
+DEF_GetHeads(3, (g_CrcTable[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8)) & hashMask)
+DEF_GetHeads(4, (g_CrcTable[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (g_CrcTable[p[3]] << 5)) & hashMask)
+DEF_GetHeads(4b, (g_CrcTable[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ ((UInt32)p[3] << 16)) & hashMask)
+DEF_GetHeads(5, (g_CrcTable[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (g_CrcTable[p[3]] << 5) ^ (g_CrcTable[p[4]] << 3)) & hashMask)
+
+void HashThreadFunc(CMatchFinderMt *mt)
+{
+ CMtSync *p = &mt->hashSync;
+ for (;;)
+ {
+ UInt32 numProcessedBlocks = 0;
+ Event_Wait(&p->canStart);
+ Event_Set(&p->wasStarted);
+ for (;;)
+ {
+ if (p->exit)
+ return;
+ if (p->stopWriting)
+ {
+ p->numProcessedBlocks = numProcessedBlocks;
+ Event_Set(&p->wasStopped);
+ break;
+ }
+
+ {
+ CMatchFinder *mf = mt->MatchFinder;
+ if (MatchFinder_NeedMove(mf))
+ {
+ CriticalSection_Enter(&mt->btSync.cs);
+ CriticalSection_Enter(&mt->hashSync.cs);
+ {
+ const Byte *beforePtr = MatchFinder_GetPointerToCurrentPos(mf);
+ const Byte *afterPtr;
+ MatchFinder_MoveBlock(mf);
+ afterPtr = MatchFinder_GetPointerToCurrentPos(mf);
+ mt->pointerToCurPos -= beforePtr - afterPtr;
+ mt->buffer -= beforePtr - afterPtr;
+ }
+ CriticalSection_Leave(&mt->btSync.cs);
+ CriticalSection_Leave(&mt->hashSync.cs);
+ continue;
+ }
+
+ Semaphore_Wait(&p->freeSemaphore);
+
+ MatchFinder_ReadIfRequired(mf);
+ if (mf->pos > (kMtMaxValForNormalize - kMtHashBlockSize))
+ {
+ UInt32 subValue = (mf->pos - mf->historySize - 1);
+ MatchFinder_ReduceOffsets(mf, subValue);
+ MatchFinder_Normalize3(subValue, mf->hash + mf->fixedHashSize, mf->hashMask + 1);
+ }
+ {
+ UInt32 *heads = mt->hashBuf + ((numProcessedBlocks++) & kMtHashNumBlocksMask) * kMtHashBlockSize;
+ UInt32 num = mf->streamPos - mf->pos;
+ heads[0] = 2;
+ heads[1] = num;
+ if (num >= mf->numHashBytes)
+ {
+ num = num - mf->numHashBytes + 1;
+ if (num > kMtHashBlockSize - 2)
+ num = kMtHashBlockSize - 2;
+ mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num);
+ heads[0] += num;
+ }
+ mf->pos += num;
+ }
+ }
+
+ Semaphore_Release1(&p->filledSemaphore);
+ }
+ }
+}
+
+void MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p)
+{
+ MtSync_GetNextBlock(&p->hashSync);
+ p->hashBufPosLimit = p->hashBufPos = ((p->hashSync.numProcessedBlocks - 1) & kMtHashNumBlocksMask) * kMtHashBlockSize;
+ p->hashBufPosLimit += p->hashBuf[p->hashBufPos++];
+ p->hashNumAvail = p->hashBuf[p->hashBufPos++];
+}
+
+#define kEmptyHashValue 0
+
+/* #define MFMT_GM_INLINE */
+
+#ifdef MFMT_GM_INLINE
+
+#if _MSC_VER >= 1300
+#define NO_INLINE __declspec(noinline) __fastcall
+#else
+#ifdef _MSC_VER
+#define NO_INLINE __fastcall
+#endif
+#endif
+
+Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *buffer, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
+ UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 limit, UInt32 size, UInt32 *posRes)
+{
+ do
+ {
+ UInt32 *distances = _distances + 1;
+ UInt32 curMatch = pos - *hash++;
+
+ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
+ UInt32 len0 = 0, len1 = 0;
+ UInt32 cutValue = _cutValue;
+ UInt32 maxLen = _maxLen;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ {
+ *ptr0 = *ptr1 = kEmptyHashValue;
+ break;
+ }
+ {
+ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = buffer + curMatch;
+ const Byte *cur = buffer + pos;
+ UInt32 len = (len0 < len1 ? len0 : len1);
+ if (pb[len] == cur[len])
+ {
+ while(++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ if (maxLen < len)
+ {
+ *distances++ = maxLen = len;
+ *distances++ = delta - 1;
+ if (len == lenLimit)
+ {
+ *ptr1 = pair[0];
+ *ptr0 = pair[1];
+ break;
+ }
+ }
+ }
+ if (pb[len] < cur[len])
+ {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
+ curMatch = *ptr1;
+ len1 = len;
+ }
+ else
+ {
+ *ptr0 = curMatch;
+ ptr0 = pair;
+ curMatch = *ptr0;
+ len0 = len;
+ }
+ }
+ }
+ pos++;
+ _cyclicBufferPos++;
+ {
+ UInt32 num = (UInt32)(distances - _distances);
+ *_distances = num - 1;
+ _distances += num;
+ limit -= num;
+ }
+ }
+ while (limit > 0 && --size != 0);
+ *posRes = pos;
+ return limit;
+}
+
+#endif
+
+void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
+{
+ UInt32 numProcessed = 0;
+ UInt32 curPos = 2;
+ UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2);
+ distances[1] = p->hashNumAvail;
+ while (curPos < limit)
+ {
+ if (p->hashBufPos == p->hashBufPosLimit)
+ {
+ MatchFinderMt_GetNextBlock_Hash(p);
+ distances[1] = numProcessed + p->hashNumAvail;
+ if (p->hashNumAvail >= p->numHashBytes)
+ continue;
+ for (; p->hashNumAvail != 0; p->hashNumAvail--)
+ distances[curPos++] = 0;
+ break;
+ }
+ {
+ UInt32 size = p->hashBufPosLimit - p->hashBufPos;
+ UInt32 lenLimit = p->matchMaxLen;
+ UInt32 pos = p->pos;
+ UInt32 cyclicBufferPos = p->cyclicBufferPos;
+ if (lenLimit >= p->hashNumAvail)
+ lenLimit = p->hashNumAvail;
+ {
+ UInt32 size2 = p->hashNumAvail - lenLimit + 1;
+ if (size2 < size)
+ size = size2;
+ size2 = p->cyclicBufferSize - cyclicBufferPos;
+ if (size2 < size)
+ size = size2;
+ }
+ #ifndef MFMT_GM_INLINE
+ while (curPos < limit && size-- != 0)
+ {
+ UInt32 *startDistances = distances + curPos;
+ UInt32 num = (UInt32)(GetMatchesSpec1(lenLimit, pos - p->hashBuf[p->hashBufPos++],
+ pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
+ startDistances + 1, p->numHashBytes - 1) - startDistances);
+ *startDistances = num - 1;
+ curPos += num;
+ cyclicBufferPos++;
+ pos++;
+ }
+ #else
+ {
+ UInt32 posRes;
+ curPos = limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
+ distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos, (Int32)(limit - curPos) , size, &posRes);
+ p->hashBufPos += posRes - pos;
+ cyclicBufferPos += posRes - pos;
+ pos = posRes;
+ }
+ #endif
+
+ numProcessed += pos - p->pos;
+ p->hashNumAvail -= pos - p->pos;
+ p->pos = pos;
+ if (cyclicBufferPos == p->cyclicBufferSize)
+ cyclicBufferPos = 0;
+ p->cyclicBufferPos = cyclicBufferPos;
+ }
+ }
+ distances[0] = curPos;
+}
+
+void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex)
+{
+ CMtSync *sync = &p->hashSync;
+ if (!sync->needStart)
+ {
+ CriticalSection_Enter(&sync->cs);
+ sync->csWasEntered = True;
+ }
+
+ BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize);
+
+ if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize)
+ {
+ UInt32 subValue = p->pos - p->cyclicBufferSize;
+ MatchFinder_Normalize3(subValue, p->son, p->cyclicBufferSize * 2);
+ p->pos -= subValue;
+ p->buffer += subValue;
+ }
+
+ if (!sync->needStart)
+ {
+ CriticalSection_Leave(&sync->cs);
+ sync->csWasEntered = False;
+ }
+}
+
+void BtThreadFunc(CMatchFinderMt *mt)
+{
+ CMtSync *p = &mt->btSync;
+ for (;;)
+ {
+ UInt32 blockIndex = 0;
+ Event_Wait(&p->canStart);
+ Event_Set(&p->wasStarted);
+ for (;;)
+ {
+ if (p->exit)
+ return;
+ if (p->stopWriting)
+ {
+ p->numProcessedBlocks = blockIndex;
+ MtSync_StopWriting(&mt->hashSync);
+ Event_Set(&p->wasStopped);
+ break;
+ }
+ Semaphore_Wait(&p->freeSemaphore);
+ BtFillBlock(mt, blockIndex++);
+ Semaphore_Release1(&p->filledSemaphore);
+ }
+ }
+}
+
+void MatchFinderMt_Construct(CMatchFinderMt *p)
+{
+ p->hashBuf = 0;
+ MtSync_Construct(&p->hashSync);
+ MtSync_Construct(&p->btSync);
+}
+
+void MatchFinderMt_FreeMem(CMatchFinderMt *p, ISzAlloc *alloc)
+{
+ alloc->Free(p->hashBuf);
+ p->hashBuf = 0;
+}
+
+void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc)
+{
+ MtSync_Destruct(&p->hashSync);
+ MtSync_Destruct(&p->btSync);
+ MatchFinderMt_FreeMem(p, alloc);
+}
+
+#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks)
+#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)
+
+static unsigned StdCall HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
+static unsigned StdCall BtThreadFunc2(void *p) { BtThreadFunc((CMatchFinderMt *)p); return 0; }
+
+HRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
+ UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc)
+{
+ CMatchFinder *mf = p->MatchFinder;
+ p->historySize = historySize;
+ if (kMtBtBlockSize <= matchMaxLen * 4)
+ return E_INVALIDARG;
+ if (p->hashBuf == 0)
+ {
+ p->hashBuf = (UInt32 *)alloc->Alloc((kHashBufferSize + kBtBufferSize) * sizeof(UInt32));
+ if (p->hashBuf == 0)
+ return SZE_OUTOFMEMORY;
+ p->btBuf = p->hashBuf + kHashBufferSize;
+ }
+ keepAddBufferBefore += (kHashBufferSize + kBtBufferSize);
+ keepAddBufferAfter += kMtHashBlockSize;
+ if (!MatchFinder_Create(mf, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter, alloc))
+ return SZE_OUTOFMEMORY;
+
+ RINOK(MtSync_Create(&p->hashSync, HashThreadFunc2, p, kMtHashNumBlocks));
+ RINOK(MtSync_Create(&p->btSync, BtThreadFunc2, p, kMtBtNumBlocks));
+ return SZ_OK;
+}
+
+/* Call it after ReleaseStream / SetStream */
+void MatchFinderMt_Init(CMatchFinderMt *p)
+{
+ CMatchFinder *mf = p->MatchFinder;
+ p->btBufPos = p->btBufPosLimit = 0;
+ p->hashBufPos = p->hashBufPosLimit = 0;
+ MatchFinder_Init(mf);
+ p->pointerToCurPos = MatchFinder_GetPointerToCurrentPos(mf);
+ p->btNumAvailBytes = 0;
+ p->lzPos = p->historySize + 1;
+
+ p->hash = mf->hash;
+ p->fixedHashSize = mf->fixedHashSize;
+
+ p->son = mf->son;
+ p->matchMaxLen = mf->matchMaxLen;
+ p->numHashBytes = mf->numHashBytes;
+ p->pos = mf->pos;
+ p->buffer = mf->buffer;
+ p->cyclicBufferPos = mf->cyclicBufferPos;
+ p->cyclicBufferSize = mf->cyclicBufferSize;
+ p->cutValue = mf->cutValue;
+}
+
+/* ReleaseStream is required to finish multithreading */
+void MatchFinderMt_ReleaseStream(CMatchFinderMt *p)
+{
+ MtSync_StopWriting(&p->btSync);
+ /* p->MatchFinder->ReleaseStream(); */
+}
+
+void MatchFinderMt_Normalize(CMatchFinderMt *p)
+{
+ MatchFinder_Normalize3(p->lzPos - p->historySize - 1, p->hash, p->fixedHashSize);
+ p->lzPos = p->historySize + 1;
+}
+
+void MatchFinderMt_GetNextBlock_Bt(CMatchFinderMt *p)
+{
+ UInt32 blockIndex;
+ MtSync_GetNextBlock(&p->btSync);
+ blockIndex = ((p->btSync.numProcessedBlocks - 1) & kMtBtNumBlocksMask);
+ p->btBufPosLimit = p->btBufPos = blockIndex * kMtBtBlockSize;
+ p->btBufPosLimit += p->btBuf[p->btBufPos++];
+ p->btNumAvailBytes = p->btBuf[p->btBufPos++];
+ if (p->lzPos >= kMtMaxValForNormalize - kMtBtBlockSize)
+ MatchFinderMt_Normalize(p);
+}
+
+const Byte * MatchFinderMt_GetPointerToCurrentPos(CMatchFinderMt *p)
+{
+ return p->pointerToCurPos;
+}
+
+#define GET_NEXT_BLOCK_IF_REQUIRED if (p->btBufPos == p->btBufPosLimit) MatchFinderMt_GetNextBlock_Bt(p);
+
+UInt32 MatchFinderMt_GetNumAvailableBytes(CMatchFinderMt *p)
+{
+ GET_NEXT_BLOCK_IF_REQUIRED;
+ return p->btNumAvailBytes;
+}
+
+Byte MatchFinderMt_GetIndexByte(CMatchFinderMt *p, Int32 index)
+{
+ return p->pointerToCurPos[index];
+}
+
+UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
+{
+ UInt32 hash2Value, curMatch2;
+ UInt32 *hash = p->hash;
+ const Byte *cur = p->pointerToCurPos;
+ UInt32 lzPos = p->lzPos;
+ MT_HASH2_CALC
+
+ curMatch2 = hash[hash2Value];
+ hash[hash2Value] = lzPos;
+
+ if (curMatch2 >= matchMinPos)
+ if (cur[(size_t)curMatch2 - lzPos] == cur[0])
+ {
+ *distances++ = 2;
+ *distances++ = lzPos - curMatch2 - 1;
+ }
+ return distances;
+}
+
+UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, curMatch2, curMatch3;
+ UInt32 *hash = p->hash;
+ const Byte *cur = p->pointerToCurPos;
+ UInt32 lzPos = p->lzPos;
+ MT_HASH3_CALC
+
+ curMatch2 = hash[ hash2Value];
+ curMatch3 = hash[kFix3HashSize + hash3Value];
+
+ hash[ hash2Value] =
+ hash[kFix3HashSize + hash3Value] =
+ lzPos;
+
+ if (curMatch2 >= matchMinPos && cur[(size_t)curMatch2 - lzPos] == cur[0])
+ {
+ distances[1] = lzPos - curMatch2 - 1;
+ if (cur[(size_t)curMatch2 - lzPos + 2] == cur[2])
+ {
+ distances[0] = 3;
+ return distances + 2;
+ }
+ distances[0] = 2;
+ distances += 2;
+ }
+ if (curMatch3 >= matchMinPos && cur[(size_t)curMatch3 - lzPos] == cur[0])
+ {
+ *distances++ = 3;
+ *distances++ = lzPos - curMatch3 - 1;
+ }
+ return distances;
+}
+
+/*
+UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, hash4Value, curMatch2, curMatch3, curMatch4;
+ UInt32 *hash = p->hash;
+ const Byte *cur = p->pointerToCurPos;
+ UInt32 lzPos = p->lzPos;
+ MT_HASH4_CALC
+
+ curMatch2 = hash[ hash2Value];
+ curMatch3 = hash[kFix3HashSize + hash3Value];
+ curMatch4 = hash[kFix4HashSize + hash4Value];
+
+ hash[ hash2Value] =
+ hash[kFix3HashSize + hash3Value] =
+ hash[kFix4HashSize + hash4Value] =
+ lzPos;
+
+ if (curMatch2 >= matchMinPos && cur[(size_t)curMatch2 - lzPos] == cur[0])
+ {
+ distances[1] = lzPos - curMatch2 - 1;
+ if (cur[(size_t)curMatch2 - lzPos + 2] == cur[2])
+ {
+ distances[0] = (cur[(size_t)curMatch2 - lzPos + 3] == cur[3]) ? 4 : 3;
+ return distances + 2;
+ }
+ distances[0] = 2;
+ distances += 2;
+ }
+ if (curMatch3 >= matchMinPos && cur[(size_t)curMatch3 - lzPos] == cur[0])
+ {
+ distances[1] = lzPos - curMatch3 - 1;
+ if (cur[(size_t)curMatch3 - lzPos + 3] == cur[3])
+ {
+ distances[0] = 4;
+ return distances + 2;
+ }
+ distances[0] = 3;
+ distances += 2;
+ }
+
+ if (curMatch4 >= matchMinPos)
+ if (
+ cur[(size_t)curMatch4 - lzPos] == cur[0] &&
+ cur[(size_t)curMatch4 - lzPos + 3] == cur[3]
+ )
+ {
+ *distances++ = 4;
+ *distances++ = lzPos - curMatch4 - 1;
+ }
+ return distances;
+}
+*/
+
+#define INCREASE_LZ_POS p->lzPos++; p->pointerToCurPos++;
+
+UInt32 MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *distances)
+{
+ const UInt32 *btBuf = p->btBuf + p->btBufPos;
+ UInt32 len = *btBuf++;
+ p->btBufPos += 1 + len;
+ p->btNumAvailBytes--;
+ {
+ UInt32 i;
+ for (i = 0; i < len; i += 2)
+ {
+ *distances++ = *btBuf++;
+ *distances++ = *btBuf++;
+ }
+ }
+ INCREASE_LZ_POS
+ return len;
+}
+
+UInt32 MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *distances)
+{
+ const UInt32 *btBuf = p->btBuf + p->btBufPos;
+ UInt32 len = *btBuf++;
+ p->btBufPos += 1 + len;
+
+ if (len == 0)
+ {
+ if (p->btNumAvailBytes-- >= 4)
+ len = (UInt32)(p->MixMatchesFunc(p, p->lzPos - p->historySize, distances) - (distances));
+ }
+ else
+ {
+ /* Condition: there are matches in btBuf with length < p->numHashBytes */
+ UInt32 *distances2;
+ p->btNumAvailBytes--;
+ distances2 = p->MixMatchesFunc(p, p->lzPos - btBuf[1], distances);
+ do
+ {
+ *distances2++ = *btBuf++;
+ *distances2++ = *btBuf++;
+ }
+ while ((len -= 2) != 0);
+ len = (UInt32)(distances2 - (distances));
+ }
+ INCREASE_LZ_POS
+ return len;
+}
+
+#define SKIP_HEADER2 do { GET_NEXT_BLOCK_IF_REQUIRED
+#define SKIP_HEADER(n) SKIP_HEADER2 if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash;
+#define SKIP_FOOTER } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while(--num != 0);
+
+void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num)
+{
+ SKIP_HEADER2 { p->btNumAvailBytes--;
+ SKIP_FOOTER
+}
+
+void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num)
+{
+ SKIP_HEADER(2)
+ UInt32 hash2Value;
+ MT_HASH2_CALC
+ hash[hash2Value] = p->lzPos;
+ SKIP_FOOTER
+}
+
+void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num)
+{
+ SKIP_HEADER(3)
+ UInt32 hash2Value, hash3Value;
+ MT_HASH3_CALC
+ hash[kFix3HashSize + hash3Value] =
+ hash[ hash2Value] =
+ p->lzPos;
+ SKIP_FOOTER
+}
+
+/*
+void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num)
+{
+ SKIP_HEADER(4)
+ UInt32 hash2Value, hash3Value, hash4Value;
+ MT_HASH4_CALC
+ hash[kFix4HashSize + hash4Value] =
+ hash[kFix3HashSize + hash3Value] =
+ hash[ hash2Value] =
+ p->lzPos;
+ SKIP_FOOTER
+}
+*/
+
+void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable)
+{
+ vTable->Init = (Mf_Init_Func)MatchFinderMt_Init;
+ vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinderMt_GetIndexByte;
+ vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinderMt_GetNumAvailableBytes;
+ vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinderMt_GetPointerToCurrentPos;
+ vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches;
+ switch(p->MatchFinder->numHashBytes)
+ {
+ case 2:
+ p->GetHeadsFunc = GetHeads2;
+ p->MixMatchesFunc = (Mf_Mix_Matches)0;
+ vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip;
+ vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches;
+ break;
+ case 3:
+ p->GetHeadsFunc = GetHeads3;
+ p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches2;
+ vTable->Skip = (Mf_Skip_Func)MatchFinderMt2_Skip;
+ break;
+ default:
+ /* case 4: */
+ p->GetHeadsFunc = p->MatchFinder->bigHash ? GetHeads4b : GetHeads4;
+ /* p->GetHeadsFunc = GetHeads4; */
+ p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches3;
+ vTable->Skip = (Mf_Skip_Func)MatchFinderMt3_Skip;
+ break;
+ /*
+ default:
+ p->GetHeadsFunc = GetHeads5;
+ p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches4;
+ vTable->Skip = (Mf_Skip_Func)MatchFinderMt4_Skip;
+ break;
+ */
+ }
+}
diff --git a/C/Compress/Lz/MatchFinderMt.h b/C/Compress/Lz/MatchFinderMt.h
new file mode 100755
index 00000000..a99cc45f
--- /dev/null
+++ b/C/Compress/Lz/MatchFinderMt.h
@@ -0,0 +1,97 @@
+/* MatchFinderMt.h */
+
+#ifndef __MATCHFINDERMT_H
+#define __MATCHFINDERMT_H
+
+#include "../../Threads.h"
+#include "MatchFinder.h"
+
+#define _LZ_MT
+
+#define kMtHashBlockSize (1 << 13)
+#define kMtHashNumBlocks (1 << 3)
+#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
+
+#define kMtBtBlockSize (1 << 14)
+#define kMtBtNumBlocks (1 << 6)
+#define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)
+
+typedef struct _CMtSync
+{
+ Bool wasCreated;
+ Bool needStart;
+ Bool exit;
+ Bool stopWriting;
+
+ CThread thread;
+ CAutoResetEvent canStart;
+ CAutoResetEvent wasStarted;
+ CAutoResetEvent wasStopped;
+ CSemaphore freeSemaphore;
+ CSemaphore filledSemaphore;
+ Bool csWasInitialized;
+ Bool csWasEntered;
+ CCriticalSection cs;
+ UInt32 numProcessedBlocks;
+} CMtSync;
+
+typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);
+
+/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
+#define kMtCacheLineDummy 128
+
+typedef void (*Mf_GetHeads)(const Byte *buffer, size_t pos,
+ UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads);
+
+typedef struct _CMatchFinderMt
+{
+ /* LZ */
+ const Byte *pointerToCurPos;
+ UInt32 *btBuf;
+ UInt32 btBufPos;
+ UInt32 btBufPosLimit;
+ UInt32 lzPos;
+ UInt32 btNumAvailBytes;
+
+ UInt32 *hash;
+ UInt32 fixedHashSize;
+ UInt32 historySize;
+
+ Mf_Mix_Matches MixMatchesFunc;
+
+ /* LZ + BT */
+ CMtSync btSync;
+ Byte btDummy[kMtCacheLineDummy];
+
+ /* BT */
+ UInt32 *hashBuf;
+ UInt32 hashBufPos;
+ UInt32 hashBufPosLimit;
+ UInt32 hashNumAvail;
+
+ CLzRef *son;
+ UInt32 matchMaxLen;
+ UInt32 numHashBytes;
+ UInt32 pos;
+ Byte *buffer; // Pointer to virtual Buffer begin
+ UInt32 cyclicBufferPos;
+ UInt32 cyclicBufferSize; // it must be historySize + 1
+ UInt32 cutValue;
+
+ /* BT + Hash */
+ CMtSync hashSync;
+ /* Byte hashDummy[kMtCacheLineDummy]; */
+
+ /* Hash */
+ Mf_GetHeads GetHeadsFunc;
+ CMatchFinder *MatchFinder;
+} CMatchFinderMt;
+
+void MatchFinderMt_Construct(CMatchFinderMt *p);
+void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc);
+HRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
+ UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc);
+void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);
+void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);
+
+#endif
diff --git a/7zip/Compress/LZMA_C/LzmaDecode.c b/C/Compress/Lzma/LzmaDecode.c
index cb834537..cb834537 100755
--- a/7zip/Compress/LZMA_C/LzmaDecode.c
+++ b/C/Compress/Lzma/LzmaDecode.c
diff --git a/7zip/Compress/LZMA_C/LzmaDecode.h b/C/Compress/Lzma/LzmaDecode.h
index 2870eeb9..2870eeb9 100755
--- a/7zip/Compress/LZMA_C/LzmaDecode.h
+++ b/C/Compress/Lzma/LzmaDecode.h
diff --git a/7zip/Compress/LZMA_C/LzmaDecodeSize.c b/C/Compress/Lzma/LzmaDecodeSize.c
index a3a5eb9d..a3a5eb9d 100755
--- a/7zip/Compress/LZMA_C/LzmaDecodeSize.c
+++ b/C/Compress/Lzma/LzmaDecodeSize.c
diff --git a/7zip/Compress/LZMA_C/LzmaStateDecode.c b/C/Compress/Lzma/LzmaStateDecode.c
index e50f88b5..e50f88b5 100755
--- a/7zip/Compress/LZMA_C/LzmaStateDecode.c
+++ b/C/Compress/Lzma/LzmaStateDecode.c
diff --git a/7zip/Compress/LZMA_C/LzmaStateDecode.h b/C/Compress/Lzma/LzmaStateDecode.h
index 26490d61..26490d61 100755
--- a/7zip/Compress/LZMA_C/LzmaStateDecode.h
+++ b/C/Compress/Lzma/LzmaStateDecode.h
diff --git a/7zip/Compress/LZMA_C/LzmaStateTest.c b/C/Compress/Lzma/LzmaStateTest.c
index 5df4e438..5df4e438 100755
--- a/7zip/Compress/LZMA_C/LzmaStateTest.c
+++ b/C/Compress/Lzma/LzmaStateTest.c
diff --git a/7zip/Compress/LZMA_C/LzmaTest.c b/C/Compress/Lzma/LzmaTest.c
index f95a753b..f95a753b 100755
--- a/7zip/Compress/LZMA_C/LzmaTest.c
+++ b/C/Compress/Lzma/LzmaTest.c
diff --git a/7zip/Compress/LZMA_C/LzmaTypes.h b/C/Compress/Lzma/LzmaTypes.h
index 288c5e45..288c5e45 100755
--- a/7zip/Compress/LZMA_C/LzmaTypes.h
+++ b/C/Compress/Lzma/LzmaTypes.h
diff --git a/C/IStream.h b/C/IStream.h
new file mode 100755
index 00000000..29c46f5f
--- /dev/null
+++ b/C/IStream.h
@@ -0,0 +1,19 @@
+// IStream.h
+
+#ifndef __C_ISTREAM_H
+#define __C_ISTREAM_H
+
+#include "Types.h"
+
+typedef struct _ISeqInStream
+{
+ HRes (*Read)(void *object, void *data, UInt32 size, UInt32 *processedSize);
+} ISeqInStream;
+
+typedef struct _ISzAlloc
+{
+ void *(*Alloc)(size_t size);
+ void (*Free)(void *address); /* address can be 0 */
+} ISzAlloc;
+
+#endif
diff --git a/C/Sort.c b/C/Sort.c
new file mode 100755
index 00000000..b30cd6ab
--- /dev/null
+++ b/C/Sort.c
@@ -0,0 +1,92 @@
+/* Sort.c */
+
+#include "Sort.h"
+
+#define HeapSortDown(p, k, size, temp) \
+ { for (;;) { \
+ UInt32 s = (k << 1); \
+ if (s > size) break; \
+ if (s < size && p[s + 1] > p[s]) s++; \
+ if (temp >= p[s]) break; \
+ p[k] = p[s]; k = s; \
+ } p[k] = temp; }
+
+void HeapSort(UInt32 *p, UInt32 size)
+{
+ if (size <= 1)
+ return;
+ p--;
+ {
+ UInt32 i = size / 2;
+ do
+ {
+ UInt32 temp = p[i];
+ UInt32 k = i;
+ HeapSortDown(p, k, size, temp)
+ }
+ while(--i != 0);
+ }
+ /*
+ do
+ {
+ UInt32 k = 1;
+ UInt32 temp = p[size];
+ p[size--] = p[1];
+ HeapSortDown(p, k, size, temp)
+ }
+ while (size > 1);
+ */
+ while (size > 3)
+ {
+ UInt32 temp = p[size];
+ UInt32 k = (p[3] > p[2]) ? 3 : 2;
+ p[size--] = p[1];
+ p[1] = p[k];
+ HeapSortDown(p, k, size, temp)
+ }
+ {
+ UInt32 temp = p[size];
+ p[size] = p[1];
+ if (size > 2 && p[2] < temp)
+ {
+ p[1] = p[2];
+ p[2] = temp;
+ }
+ else
+ p[1] = temp;
+ }
+}
+
+/*
+#define HeapSortRefDown(p, vals, n, size, temp) \
+ { UInt32 k = n; UInt32 val = vals[temp]; for (;;) { \
+ UInt32 s = (k << 1); \
+ if (s > size) break; \
+ if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \
+ if (val >= vals[p[s]]) break; \
+ p[k] = p[s]; k = s; \
+ } p[k] = temp; }
+
+void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size)
+{
+ if (size <= 1)
+ return;
+ p--;
+ {
+ UInt32 i = size / 2;
+ do
+ {
+ UInt32 temp = p[i];
+ HeapSortRefDown(p, vals, i, size, temp);
+ }
+ while(--i != 0);
+ }
+ do
+ {
+ UInt32 temp = p[size];
+ p[size--] = p[1];
+ HeapSortRefDown(p, vals, 1, size, temp);
+ }
+ while (size > 1);
+}
+*/ \ No newline at end of file
diff --git a/C/Sort.h b/C/Sort.h
new file mode 100755
index 00000000..896243c1
--- /dev/null
+++ b/C/Sort.h
@@ -0,0 +1,11 @@
+/* Sort.h */
+
+#ifndef __7Z_Sort_H
+#define __7Z_Sort_H
+
+#include "Types.h"
+
+void HeapSort(UInt32 *p, UInt32 size);
+/* void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size); */
+
+#endif
diff --git a/C/Threads.c b/C/Threads.c
new file mode 100755
index 00000000..dcf63dcf
--- /dev/null
+++ b/C/Threads.c
@@ -0,0 +1,97 @@
+/* Threads.c */
+
+#include "Threads.h"
+#include <process.h>
+
+HRes GetError()
+{
+ DWORD res = GetLastError();
+ return (res) ? (HRes)(res) : SZE_FAIL;
+}
+
+HRes BoolToHRes(int v) { return v ? SZ_OK : GetError(); }
+HRes BOOLToHRes(BOOL v) { return v ? SZ_OK : GetError(); }
+
+HRes MyCloseHandle(HANDLE *h)
+{
+ if (*h != NULL)
+ if (!CloseHandle(*h))
+ return GetError();
+ *h = NULL;
+ return SZ_OK;
+}
+
+HRes Thread_Create(CThread *thread, unsigned (StdCall *startAddress)(void *), LPVOID parameter)
+{
+ /* DWORD threadId; */
+ thread->handle =
+ /* CreateThread(0, 0, startAddress, parameter, 0, &threadId); */
+ (HANDLE)_beginthreadex(NULL, 0, startAddress, parameter, 0, NULL);
+ /* maybe we must use errno here, but probably GetLastError() is also OK. */
+ return BoolToHRes(thread->handle != 0);
+}
+
+HRes WaitObject(HANDLE h)
+{
+ return (HRes)WaitForSingleObject(h, INFINITE);
+}
+
+HRes Thread_Wait(CThread *thread)
+{
+ if (thread->handle == NULL)
+ return 1;
+ return WaitObject(thread->handle);
+}
+
+HRes Thread_Close(CThread *thread)
+{
+ return MyCloseHandle(&thread->handle);
+}
+
+HRes AutoResetEvent_Create(CAutoResetEvent *p, int initialSignaled)
+{
+ p->handle = CreateEvent(NULL, FALSE, (initialSignaled ? TRUE : FALSE), NULL);
+ return BoolToHRes(p->handle != 0);
+}
+
+HRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) { return AutoResetEvent_Create(p, 0); }
+HRes Event_Set(CEvent *p) { return BOOLToHRes(SetEvent(p->handle)); }
+HRes Event_Reset(CEvent *p) { return BOOLToHRes(ResetEvent(p->handle)); }
+HRes Event_Wait(CEvent *p) { return WaitObject(p->handle); }
+HRes Event_Close(CEvent *p) { return MyCloseHandle(&p->handle); }
+
+
+HRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount)
+{
+ p->handle = CreateSemaphore(NULL, (LONG)initiallyCount, (LONG)maxCount, NULL);
+ return BoolToHRes(p->handle != 0);
+}
+
+HRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount)
+{
+ return BOOLToHRes(ReleaseSemaphore(p->handle, releaseCount, previousCount));
+}
+HRes Semaphore_ReleaseN(CSemaphore *p, LONG releaseCount)
+{
+ return Semaphore_Release(p, releaseCount, NULL);
+}
+HRes Semaphore_Release1(CSemaphore *p)
+{
+ return Semaphore_ReleaseN(p, 1);
+}
+
+HRes Semaphore_Wait(CSemaphore *p) { return WaitObject(p->handle); }
+HRes Semaphore_Close(CSemaphore *p) { return MyCloseHandle(&p->handle); }
+
+HRes CriticalSection_Init(CCriticalSection *p)
+{
+ /* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */
+ __try
+ {
+ InitializeCriticalSection(p);
+ // InitializeCriticalSectionAndSpinCount(p, 0);
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER) { return SZE_OUTOFMEMORY; }
+ return SZ_OK;
+}
+
diff --git a/C/Threads.h b/C/Threads.h
new file mode 100755
index 00000000..fec9e6d5
--- /dev/null
+++ b/C/Threads.h
@@ -0,0 +1,60 @@
+/* Thresds.h */
+
+#ifndef __7Z_THRESDS_H
+#define __7Z_THRESDS_H
+
+#include <windows.h>
+
+#include "Types.h"
+
+typedef struct _CThread
+{
+ HANDLE handle;
+} CThread;
+
+#define Thread_Construct(thread) (thread)->handle = NULL
+#define Thread_WasCreated(thread) ((thread)->handle != NULL)
+
+HRes Thread_Create(CThread *thread, unsigned (StdCall *startAddress)(void *), LPVOID parameter);
+HRes Thread_Wait(CThread *thread);
+HRes Thread_Close(CThread *thread);
+
+typedef struct _CEvent
+{
+ HANDLE handle;
+} CEvent;
+
+typedef CEvent CAutoResetEvent;
+
+#define Event_Construct(event) (event)->handle = NULL
+
+HRes AutoResetEvent_Create(CAutoResetEvent *event, int initialSignaled);
+HRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *event);
+HRes Event_Set(CEvent *event);
+HRes Event_Reset(CEvent *event);
+HRes Event_Wait(CEvent *event);
+HRes Event_Close(CEvent *event);
+
+
+typedef struct _CSemaphore
+{
+ HANDLE handle;
+} CSemaphore;
+
+#define Semaphore_Construct(p) (p)->handle = NULL
+
+HRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount);
+HRes Semaphore_Release1(CSemaphore *p);
+HRes Semaphore_Wait(CSemaphore *p);
+HRes Semaphore_Close(CSemaphore *p);
+
+
+typedef CRITICAL_SECTION CCriticalSection;
+
+HRes CriticalSection_Init(CCriticalSection *p);
+#define CriticalSection_Delete(p) DeleteCriticalSection(p)
+#define CriticalSection_Enter(p) EnterCriticalSection(p)
+#define CriticalSection_Leave(p) LeaveCriticalSection(p)
+
+#endif
+
diff --git a/C/Types.h b/C/Types.h
new file mode 100755
index 00000000..9052a030
--- /dev/null
+++ b/C/Types.h
@@ -0,0 +1,92 @@
+/* 7zTypes.h */
+
+#ifndef __C_TYPES_H
+#define __C_TYPES_H
+
+#ifndef _7ZIP_BYTE_DEFINED
+#define _7ZIP_BYTE_DEFINED
+typedef unsigned char Byte;
+#endif
+
+#ifndef _7ZIP_UINT16_DEFINED
+#define _7ZIP_UINT16_DEFINED
+typedef unsigned short UInt16;
+#endif
+
+#ifndef _7ZIP_UINT32_DEFINED
+#define _7ZIP_UINT32_DEFINED
+#ifdef _LZMA_UINT32_IS_ULONG
+typedef unsigned long UInt32;
+#else
+typedef unsigned int UInt32;
+#endif
+#endif
+
+#ifndef _7ZIP_INT32_DEFINED
+#define _7ZIP_INT32_DEFINED
+#ifdef _LZMA_INT32_IS_ULONG
+typedef long Int32;
+#else
+typedef int Int32;
+#endif
+#endif
+
+/* #define _SZ_NO_INT_64 */
+/* define it your compiler doesn't support long long int */
+
+#ifndef _7ZIP_UINT64_DEFINED
+#define _7ZIP_UINT64_DEFINED
+#ifdef _SZ_NO_INT_64
+typedef unsigned long UInt64;
+#else
+#ifdef _MSC_VER
+typedef unsigned __int64 UInt64;
+#else
+typedef unsigned long long int UInt64;
+#endif
+#endif
+#endif
+
+
+/* #define _SZ_FILE_SIZE_64 */
+/* Use _SZ_FILE_SIZE_64 if you need support for files larger than 4 GB*/
+
+#ifndef CFileSize
+#ifdef _SZ_FILE_SIZE_64
+typedef UInt64 CFileSize;
+#else
+typedef UInt32 CFileSize;
+#endif
+#endif
+
+#define SZ_RESULT int
+
+typedef int HRes;
+#define RES_OK (0)
+
+#define SZ_OK (0)
+#define SZE_DATA_ERROR (1)
+#define SZE_CRC_ERROR (3)
+#define SZE_ARCHIVE_ERROR (6)
+
+#define SZE_OUTOFMEMORY (0x8007000EL)
+#define SZE_NOTIMPL (0x80004001L)
+#define SZE_FAIL (0x80004005L)
+#define SZE_INVALIDARG (0x80070057L)
+
+
+#ifndef RINOK
+#define RINOK(x) { int __result_ = (x); if(__result_ != 0) return __result_; }
+#endif
+
+typedef int Bool;
+#define True 1
+#define False 0
+
+#ifdef _MSC_VER
+#define StdCall __stdcall
+#else
+#define StdCall
+#endif
+
+#endif
diff --git a/7zip/Archive/7z/7z.dsp b/CPP/7zip/Archive/7z/7z.dsp
index e57115ef..e57115ef 100755
--- a/7zip/Archive/7z/7z.dsp
+++ b/CPP/7zip/Archive/7z/7z.dsp
diff --git a/7zip/Archive/7z/7z.dsw b/CPP/7zip/Archive/7z/7z.dsw
index 702a86c7..702a86c7 100755
--- a/7zip/Archive/7z/7z.dsw
+++ b/CPP/7zip/Archive/7z/7z.dsw
diff --git a/7zip/Archive/7z/7z.ico b/CPP/7zip/Archive/7z/7z.ico
index 319753a1..319753a1 100755
--- a/7zip/Archive/7z/7z.ico
+++ b/CPP/7zip/Archive/7z/7z.ico
Binary files differ
diff --git a/7zip/Archive/7z/7zCompressionMode.cpp b/CPP/7zip/Archive/7z/7zCompressionMode.cpp
index 6774fc48..6774fc48 100755
--- a/7zip/Archive/7z/7zCompressionMode.cpp
+++ b/CPP/7zip/Archive/7z/7zCompressionMode.cpp
diff --git a/7zip/Archive/7z/7zCompressionMode.h b/CPP/7zip/Archive/7z/7zCompressionMode.h
index fe54e8a6..fe54e8a6 100755
--- a/7zip/Archive/7z/7zCompressionMode.h
+++ b/CPP/7zip/Archive/7z/7zCompressionMode.h
diff --git a/7zip/Archive/7z/7zDecode.cpp b/CPP/7zip/Archive/7z/7zDecode.cpp
index 5c58f817..5c58f817 100755
--- a/7zip/Archive/7z/7zDecode.cpp
+++ b/CPP/7zip/Archive/7z/7zDecode.cpp
diff --git a/7zip/Archive/7z/7zDecode.h b/CPP/7zip/Archive/7z/7zDecode.h
index 50f80d4c..50f80d4c 100755
--- a/7zip/Archive/7z/7zDecode.h
+++ b/CPP/7zip/Archive/7z/7zDecode.h
diff --git a/7zip/Archive/7z/7zEncode.cpp b/CPP/7zip/Archive/7z/7zEncode.cpp
index a9fe2d0a..a9fe2d0a 100755
--- a/7zip/Archive/7z/7zEncode.cpp
+++ b/CPP/7zip/Archive/7z/7zEncode.cpp
diff --git a/CPP/7zip/Archive/7z/7zEncode.h b/CPP/7zip/Archive/7z/7zEncode.h
new file mode 100755
index 00000000..efd8bba6
--- /dev/null
+++ b/CPP/7zip/Archive/7z/7zEncode.h
@@ -0,0 +1,58 @@
+// 7zEncode.h
+
+#ifndef __7Z_ENCODE_H
+#define __7Z_ENCODE_H
+
+// #include "../../Common/StreamObjects.h"
+
+#include "7zCompressionMode.h"
+
+#include "../Common/CoderMixer2.h"
+#include "../Common/CoderMixer2MT.h"
+#ifdef _ST_MODE
+#include "../Common/CoderMixer2ST.h"
+#endif
+#ifndef EXCLUDE_COM
+#include "../Common/CoderLoader.h"
+#endif
+#include "7zMethods.h"
+#include "7zItem.h"
+
+namespace NArchive {
+namespace N7z {
+
+class CEncoder
+{
+ #ifndef EXCLUDE_COM
+ // CMethodMap _methodMap;
+ // it must be in top of objects
+ CCoderLibraries _libraries;
+ #endif
+
+ NCoderMixer2::CCoderMixer2MT *_mixerCoderSpec;
+ CMyComPtr<ICompressCoder2> _mixerCoder;
+
+ CObjectVector<CCoderInfo> _codersInfo;
+
+ CCompressionMethodMode _options;
+ NCoderMixer2::CBindInfo _bindInfo;
+ NCoderMixer2::CBindInfo _decompressBindInfo;
+ NCoderMixer2::CBindReverseConverter *_bindReverseConverter;
+ CRecordVector<CMethodID> _decompressionMethods;
+
+ HRESULT CreateMixerCoder(const UInt64 *inSizeForReduce);
+
+public:
+ CEncoder(const CCompressionMethodMode &options);
+ ~CEncoder();
+ HRESULT Encode(ISequentialInStream *inStream,
+ const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
+ CFolder &folderItem,
+ ISequentialOutStream *outStream,
+ CRecordVector<UInt64> &packSizes,
+ ICompressProgressInfo *compressProgress);
+};
+
+}}
+
+#endif
diff --git a/7zip/Archive/7z/7zExtract.cpp b/CPP/7zip/Archive/7z/7zExtract.cpp
index 540241f7..540241f7 100755
--- a/7zip/Archive/7z/7zExtract.cpp
+++ b/CPP/7zip/Archive/7z/7zExtract.cpp
diff --git a/7zip/Archive/7z/7zFolderInStream.cpp b/CPP/7zip/Archive/7z/7zFolderInStream.cpp
index fb1cfd3a..fb1cfd3a 100755
--- a/7zip/Archive/7z/7zFolderInStream.cpp
+++ b/CPP/7zip/Archive/7z/7zFolderInStream.cpp
diff --git a/7zip/Archive/7z/7zFolderInStream.h b/CPP/7zip/Archive/7z/7zFolderInStream.h
index 9a720c8b..9a720c8b 100755
--- a/7zip/Archive/7z/7zFolderInStream.h
+++ b/CPP/7zip/Archive/7z/7zFolderInStream.h
diff --git a/7zip/Archive/7z/7zFolderOutStream.cpp b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
index 93bed3d9..93bed3d9 100755
--- a/7zip/Archive/7z/7zFolderOutStream.cpp
+++ b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
diff --git a/7zip/Archive/7z/7zFolderOutStream.h b/CPP/7zip/Archive/7z/7zFolderOutStream.h
index c132c79a..c132c79a 100755
--- a/7zip/Archive/7z/7zFolderOutStream.h
+++ b/CPP/7zip/Archive/7z/7zFolderOutStream.h
diff --git a/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp
index 3321fd71..3321fd71 100755
--- a/7zip/Archive/7z/7zHandler.cpp
+++ b/CPP/7zip/Archive/7z/7zHandler.cpp
diff --git a/7zip/Archive/7z/7zHandler.h b/CPP/7zip/Archive/7z/7zHandler.h
index 8be9f398..8be9f398 100755
--- a/7zip/Archive/7z/7zHandler.h
+++ b/CPP/7zip/Archive/7z/7zHandler.h
diff --git a/CPP/7zip/Archive/7z/7zHandlerOut.cpp b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
new file mode 100755
index 00000000..8be88c38
--- /dev/null
+++ b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
@@ -0,0 +1,1148 @@
+// 7z/OutHandler.cpp
+
+#include "StdAfx.h"
+
+#include "7zHandler.h"
+#include "7zOut.h"
+#include "7zUpdate.h"
+#include "7zMethods.h"
+
+#include "../../../Windows/PropVariant.h"
+
+#include "../../../Common/ComTry.h"
+#include "../../../Common/StringToInt.h"
+#include "../../IPassword.h"
+#include "../../ICoder.h"
+
+#include "../Common/ItemNameUtils.h"
+#include "../Common/ParseProperties.h"
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace N7z {
+
+#ifdef COMPRESS_LZMA
+static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
+static CMethodID k_LZMA2 = { { 0x3, 0x1, 0x2 }, 3 };
+#endif
+
+#ifdef COMPRESS_PPMD
+static CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
+#endif
+
+#ifdef COMPRESS_BCJ_X86
+static CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
+#endif
+
+#ifdef COMPRESS_BCJ2
+static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
+#endif
+
+#ifdef COMPRESS_COPY
+static CMethodID k_Copy = { { 0x0 }, 1 };
+#endif
+
+#ifdef COMPRESS_DEFLATE
+#ifndef COMPRESS_DEFLATE_ENCODER
+#define COMPRESS_DEFLATE_ENCODER
+#endif
+#endif
+
+#ifdef COMPRESS_DEFLATE_ENCODER
+static CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
+#endif
+
+#ifdef COMPRESS_BZIP2
+#ifndef COMPRESS_BZIP2_ENCODER
+#define COMPRESS_BZIP2_ENCODER
+#endif
+#endif
+
+#ifdef COMPRESS_BZIP2_ENCODER
+static CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
+#endif
+
+const wchar_t *kCopyMethod = L"Copy";
+const wchar_t *kLZMAMethodName = L"LZMA";
+const wchar_t *kLZMA2MethodName = L"LZMA2";
+const wchar_t *kBZip2MethodName = L"BZip2";
+const wchar_t *kPpmdMethodName = L"PPMd";
+const wchar_t *kDeflateMethodName = L"Deflate";
+const wchar_t *kDeflate64MethodName = L"Deflate64";
+
+static const wchar_t *kLzmaMatchFinderX1 = L"HC4";
+static const wchar_t *kLzmaMatchFinderX5 = L"BT4";
+
+static const UInt32 kLzmaAlgorithmX1 = 0;
+static const UInt32 kLzmaAlgorithmX5 = 1;
+
+static const UInt32 kLzmaDicSizeX1 = 1 << 16;
+static const UInt32 kLzmaDicSizeX3 = 1 << 20;
+static const UInt32 kLzmaDicSizeX5 = 1 << 22;
+static const UInt32 kLzmaDicSizeX7 = 1 << 24;
+static const UInt32 kLzmaDicSizeX9 = 1 << 26;
+
+static const UInt32 kLzmaFastBytesX1 = 32;
+static const UInt32 kLzmaFastBytesX7 = 64;
+
+static const UInt32 kPpmdMemSizeX1 = (1 << 22);
+static const UInt32 kPpmdMemSizeX5 = (1 << 24);
+static const UInt32 kPpmdMemSizeX7 = (1 << 26);
+static const UInt32 kPpmdMemSizeX9 = (192 << 20);
+
+static const UInt32 kPpmdOrderX1 = 4;
+static const UInt32 kPpmdOrderX5 = 6;
+static const UInt32 kPpmdOrderX7 = 16;
+static const UInt32 kPpmdOrderX9 = 32;
+
+static const UInt32 kDeflateFastBytesX1 = 32;
+static const UInt32 kDeflateFastBytesX7 = 64;
+static const UInt32 kDeflateFastBytesX9 = 128;
+
+static const UInt32 kDeflatePassesX1 = 1;
+static const UInt32 kDeflatePassesX7 = 3;
+static const UInt32 kDeflatePassesX9 = 10;
+
+static const UInt32 kBZip2NumPassesX1 = 1;
+static const UInt32 kBZip2NumPassesX7 = 2;
+static const UInt32 kBZip2NumPassesX9 = 7;
+
+static const UInt32 kBZip2DicSizeX1 = 100000;
+static const UInt32 kBZip2DicSizeX3 = 500000;
+static const UInt32 kBZip2DicSizeX5 = 900000;
+
+const wchar_t *kDefaultMethodName = kLZMAMethodName;
+
+static const wchar_t *kLzmaMatchFinderForHeaders = L"BT2";
+static const UInt32 kDictionaryForHeaders = 1 << 20;
+static const UInt32 kNumFastBytesForHeaders = 273;
+static const UInt32 kAlgorithmForHeaders = kLzmaAlgorithmX5;
+
+static bool IsCopyMethod(const UString &methodName)
+ { return (methodName.CompareNoCase(kCopyMethod) == 0); }
+
+static bool IsLZMAMethod(const UString &methodName)
+{
+ return
+ (methodName.CompareNoCase(kLZMAMethodName) == 0) ||
+ (methodName.CompareNoCase(kLZMA2MethodName) == 0);
+}
+
+/*
+static bool IsLZMethod(const UString &methodName)
+ { return IsLZMAMethod(methodName); }
+*/
+
+static bool IsBZip2Method(const UString &methodName)
+ { return (methodName.CompareNoCase(kBZip2MethodName) == 0); }
+
+static bool IsPpmdMethod(const UString &methodName)
+ { return (methodName.CompareNoCase(kPpmdMethodName) == 0); }
+
+static bool IsDeflateMethod(const UString &methodName)
+ { return (methodName.CompareNoCase(kDeflateMethodName) == 0) ||
+ (methodName.CompareNoCase(kDeflate64MethodName) == 0); }
+
+STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
+{
+ *type = NFileTimeType::kWindows;
+ return S_OK;
+}
+
+HRESULT CHandler::SetPassword(CCompressionMethodMode &methodMode,
+ IArchiveUpdateCallback *updateCallback)
+{
+ CMyComPtr<ICryptoGetTextPassword2> getTextPassword;
+ if (!getTextPassword)
+ {
+ CMyComPtr<IArchiveUpdateCallback> udateCallback2(updateCallback);
+ udateCallback2.QueryInterface(IID_ICryptoGetTextPassword2, &getTextPassword);
+ }
+
+ if (getTextPassword)
+ {
+ CMyComBSTR password;
+ Int32 passwordIsDefined;
+ RINOK(getTextPassword->CryptoGetTextPassword2(
+ &passwordIsDefined, &password));
+ methodMode.PasswordIsDefined = IntToBool(passwordIsDefined);
+ if (methodMode.PasswordIsDefined)
+ methodMode.Password = password;
+ }
+ else
+ methodMode.PasswordIsDefined = false;
+ return S_OK;
+}
+
+struct CNameToPropID
+{
+ PROPID PropID;
+ VARTYPE VarType;
+ const wchar_t *Name;
+};
+
+CNameToPropID g_NameToPropID[] =
+{
+ { NCoderPropID::kOrder, VT_UI4, L"O" },
+ { NCoderPropID::kPosStateBits, VT_UI4, L"PB" },
+ { NCoderPropID::kLitContextBits, VT_UI4, L"LC" },
+ { NCoderPropID::kLitPosBits, VT_UI4, L"LP" },
+
+ { NCoderPropID::kNumPasses, VT_UI4, L"Pass" },
+ { NCoderPropID::kNumFastBytes, VT_UI4, L"fb" },
+ { NCoderPropID::kMatchFinderCycles, VT_UI4, L"mc" },
+ { NCoderPropID::kAlgorithm, VT_UI4, L"a" },
+ { NCoderPropID::kMatchFinder, VT_BSTR, L"mf" },
+ { NCoderPropID::kNumThreads, VT_UI4, L"mt" }
+};
+
+bool ConvertProperty(PROPVARIANT srcProp, VARTYPE varType,
+ NCOM::CPropVariant &destProp)
+{
+ if (varType == srcProp.vt)
+ {
+ destProp = srcProp;
+ return true;
+ }
+ if (varType == VT_UI1)
+ {
+ if(srcProp.vt == VT_UI4)
+ {
+ UInt32 value = srcProp.ulVal;
+ if (value > 0xFF)
+ return false;
+ destProp = Byte(value);
+ return true;
+ }
+ }
+ return false;
+}
+
+const int kNumNameToPropIDItems = sizeof(g_NameToPropID) / sizeof(g_NameToPropID[0]);
+
+int FindPropIdFromStringName(const UString &name)
+{
+ for (int i = 0; i < kNumNameToPropIDItems; i++)
+ if (name.CompareNoCase(g_NameToPropID[i].Name) == 0)
+ return i;
+ return -1;
+}
+
+HRESULT CHandler::SetCompressionMethod(
+ CCompressionMethodMode &methodMode,
+ CCompressionMethodMode &headerMethod)
+{
+ HRESULT res = SetCompressionMethod(methodMode, _methods
+ #ifdef COMPRESS_MT
+ , _numThreads
+ #endif
+ );
+ RINOK(res);
+ methodMode.Binds = _binds;
+ if (_compressHeadersFull)
+ _compressHeaders = true;
+
+ if (_compressHeaders)
+ {
+ // headerMethod.Methods.Add(methodMode.Methods.Back());
+
+ CObjectVector<COneMethodInfo> headerMethodInfoVector;
+ COneMethodInfo oneMethodInfo;
+ oneMethodInfo.MethodName = kLZMAMethodName;
+ {
+ CProperty property;
+ property.PropID = NCoderPropID::kMatchFinder;
+ property.Value = kLzmaMatchFinderForHeaders;
+ oneMethodInfo.CoderProperties.Add(property);
+ }
+ {
+ CProperty property;
+ property.PropID = NCoderPropID::kAlgorithm;
+ property.Value = kAlgorithmForHeaders;
+ oneMethodInfo.CoderProperties.Add(property);
+ }
+ {
+ CProperty property;
+ property.PropID = NCoderPropID::kNumFastBytes;
+ property.Value = UInt32(kNumFastBytesForHeaders);
+ oneMethodInfo.CoderProperties.Add(property);
+ }
+ {
+ CProperty property;
+ property.PropID = NCoderPropID::kDictionarySize;
+ property.Value = UInt32(kDictionaryForHeaders);
+ oneMethodInfo.CoderProperties.Add(property);
+ }
+ headerMethodInfoVector.Add(oneMethodInfo);
+ HRESULT res = SetCompressionMethod(headerMethod, headerMethodInfoVector
+ #ifdef COMPRESS_MT
+ ,1
+ #endif
+ );
+ RINOK(res);
+ }
+ return S_OK;
+}
+
+static void SetOneMethodProp(COneMethodInfo &oneMethodInfo, PROPID propID,
+ const NWindows::NCOM::CPropVariant &value)
+{
+ int j;
+ for (j = 0; j < oneMethodInfo.CoderProperties.Size(); j++)
+ if (oneMethodInfo.CoderProperties[j].PropID == propID)
+ break;
+ if (j != oneMethodInfo.CoderProperties.Size())
+ return;
+ CProperty property;
+ property.PropID = propID;
+ property.Value = value;
+ oneMethodInfo.CoderProperties.Add(property);
+}
+
+HRESULT CHandler::SetCompressionMethod(
+ CCompressionMethodMode &methodMode,
+ CObjectVector<COneMethodInfo> &methodsInfo
+ #ifdef COMPRESS_MT
+ , UInt32 numThreads
+ #endif
+ )
+{
+ #ifndef EXCLUDE_COM
+ /*
+ CObjectVector<CMethodInfo2> methodInfoVector;
+ if (!NRegistryInfo::EnumerateAllMethods(methodInfoVector))
+ return E_FAIL;
+ */
+ #endif
+
+
+ UInt32 level = _level;
+
+ if (methodsInfo.IsEmpty())
+ {
+ COneMethodInfo oneMethodInfo;
+ oneMethodInfo.MethodName = ((level == 0) ? kCopyMethod : kDefaultMethodName);
+ methodsInfo.Add(oneMethodInfo);
+ }
+
+ bool needSolid = false;
+ for(int i = 0; i < methodsInfo.Size(); i++)
+ {
+ COneMethodInfo &oneMethodInfo = methodsInfo[i];
+ if (oneMethodInfo.MethodName.IsEmpty())
+ oneMethodInfo.MethodName = kDefaultMethodName;
+
+ if (!IsCopyMethod(oneMethodInfo.MethodName))
+ needSolid = true;
+
+ if (IsLZMAMethod(oneMethodInfo.MethodName))
+ {
+ UInt32 dicSize =
+ (level >= 9 ? kLzmaDicSizeX9 :
+ (level >= 7 ? kLzmaDicSizeX7 :
+ (level >= 5 ? kLzmaDicSizeX5 :
+ (level >= 3 ? kLzmaDicSizeX3 :
+ kLzmaDicSizeX1))));
+
+ UInt32 algorithm =
+ (level >= 5 ? kLzmaAlgorithmX5 :
+ kLzmaAlgorithmX1);
+
+ UInt32 fastBytes =
+ (level >= 7 ? kLzmaFastBytesX7 :
+ kLzmaFastBytesX1);
+
+ const wchar_t *matchFinder =
+ (level >= 5 ? kLzmaMatchFinderX5 :
+ kLzmaMatchFinderX1);
+
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algorithm);
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kMatchFinder, matchFinder);
+ #ifdef COMPRESS_MT
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
+ #endif
+ }
+ else if (IsDeflateMethod(oneMethodInfo.MethodName))
+ {
+ UInt32 fastBytes =
+ (level >= 9 ? kDeflateFastBytesX9 :
+ (level >= 7 ? kDeflateFastBytesX7 :
+ kDeflateFastBytesX1));
+
+ UInt32 numPasses =
+ (level >= 9 ? kDeflatePassesX9 :
+ (level >= 7 ? kDeflatePassesX7 :
+ kDeflatePassesX1));
+
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
+ }
+ else if (IsBZip2Method(oneMethodInfo.MethodName))
+ {
+ UInt32 numPasses =
+ (level >= 9 ? kBZip2NumPassesX9 :
+ (level >= 7 ? kBZip2NumPassesX7 :
+ kBZip2NumPassesX1));
+
+ UInt32 dicSize =
+ (level >= 5 ? kBZip2DicSizeX5 :
+ (level >= 3 ? kBZip2DicSizeX3 :
+ kBZip2DicSizeX1));
+
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
+ #ifdef COMPRESS_MT
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
+ #endif
+ }
+ else if (IsPpmdMethod(oneMethodInfo.MethodName))
+ {
+ UInt32 useMemSize =
+ (level >= 9 ? kPpmdMemSizeX9 :
+ (level >= 7 ? kPpmdMemSizeX7 :
+ (level >= 5 ? kPpmdMemSizeX5 :
+ kPpmdMemSizeX1)));
+
+ UInt32 order =
+ (level >= 9 ? kPpmdOrderX9 :
+ (level >= 7 ? kPpmdOrderX7 :
+ (level >= 5 ? kPpmdOrderX5 :
+ kPpmdOrderX1)));
+
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kUsedMemorySize, useMemSize);
+ SetOneMethodProp(oneMethodInfo, NCoderPropID::kOrder, order);
+ }
+
+
+ CMethodFull methodFull;
+ methodFull.NumInStreams = 1;
+ methodFull.NumOutStreams = 1;
+
+ bool defined = false;
+
+ #ifdef COMPRESS_LZMA
+ if (oneMethodInfo.MethodName.CompareNoCase(L"LZMA") == 0)
+ {
+ defined = true;
+ methodFull.MethodID = k_LZMA;
+ }
+ #endif
+
+ #ifdef COMPRESS_PPMD
+ if (oneMethodInfo.MethodName.CompareNoCase(L"PPMD") == 0)
+ {
+ defined = true;
+ methodFull.MethodID = k_PPMD;
+ }
+ #endif
+
+ #ifdef COMPRESS_BCJ_X86
+ if (oneMethodInfo.MethodName.CompareNoCase(L"BCJ") == 0)
+ {
+ defined = true;
+ methodFull.MethodID = k_BCJ_X86;
+ }
+ #endif
+
+ #ifdef COMPRESS_BCJ2
+ if (oneMethodInfo.MethodName.CompareNoCase(L"BCJ2") == 0)
+ {
+ defined = true;
+ methodFull.MethodID = k_BCJ2;
+ methodFull.NumInStreams = 4;
+ methodFull.NumOutStreams = 1;
+ }
+ #endif
+
+ #ifdef COMPRESS_DEFLATE_ENCODER
+ if (oneMethodInfo.MethodName.CompareNoCase(L"Deflate") == 0)
+ {
+ defined = true;
+ methodFull.MethodID = k_Deflate;
+ }
+ #endif
+
+ #ifdef COMPRESS_BZIP2_ENCODER
+ if (oneMethodInfo.MethodName.CompareNoCase(L"BZip2") == 0)
+ {
+ defined = true;
+ methodFull.MethodID = k_BZip2;
+ }
+ #endif
+
+ #ifdef COMPRESS_COPY
+ if (oneMethodInfo.MethodName.CompareNoCase(L"Copy") == 0)
+ {
+ defined = true;
+ methodFull.MethodID = k_Copy;
+ }
+
+ #endif
+
+ #ifndef EXCLUDE_COM
+
+ if (!defined)
+ {
+ CMethodInfo2 methodInfo;
+ if (!GetMethodInfo(oneMethodInfo.MethodName, methodInfo))
+ return E_INVALIDARG;
+ if (!methodInfo.EncoderIsAssigned)
+ return E_INVALIDARG;
+
+ methodFull.MethodID = methodInfo.MethodID;
+ methodFull.NumInStreams = methodInfo.NumInStreams;
+ methodFull.NumOutStreams = methodInfo.NumOutStreams;
+
+ methodFull.EncoderClassID = methodInfo.Encoder;
+ methodFull.FilePath = methodInfo.FilePath;
+ defined = true;
+ }
+
+ #endif
+ if (!defined)
+ return E_INVALIDARG;
+
+ methodFull.CoderProperties = oneMethodInfo.CoderProperties;
+ methodMode.Methods.Add(methodFull);
+
+ if (!_numSolidBytesDefined)
+ {
+ for (int j = 0; j < methodFull.CoderProperties.Size(); j++)
+ {
+ const CProperty &prop = methodFull.CoderProperties[j];
+ if ((prop.PropID == NCoderPropID::kDictionarySize ||
+ prop.PropID == NCoderPropID::kUsedMemorySize) && prop.Value.vt == VT_UI4)
+ {
+ _numSolidBytes = ((UInt64)prop.Value.ulVal) << 7;
+ const UInt64 kMinSize = (1 << 24);
+ if (_numSolidBytes < kMinSize)
+ _numSolidBytes = kMinSize;
+ _numSolidBytesDefined = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!needSolid && !_numSolidBytesDefined)
+ {
+ _numSolidBytesDefined = true;
+ _numSolidBytes = 0;
+ }
+ return S_OK;
+}
+
+static HRESULT GetTime(IArchiveUpdateCallback *updateCallback, int index, PROPID propID, CArchiveFileTime &filetime, bool &filetimeIsDefined)
+{
+ filetimeIsDefined = false;
+ NCOM::CPropVariant propVariant;
+ RINOK(updateCallback->GetProperty(index, propID, &propVariant));
+ if (propVariant.vt == VT_FILETIME)
+ {
+ filetime = propVariant.filetime;
+ filetimeIsDefined = true;
+ }
+ else if (propVariant.vt != VT_EMPTY)
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
+ IArchiveUpdateCallback *updateCallback)
+{
+ COM_TRY_BEGIN
+
+ const CArchiveDatabaseEx *database = 0;
+ #ifdef _7Z_VOL
+ if(_volumes.Size() > 1)
+ return E_FAIL;
+ const CVolume *volume = 0;
+ if (_volumes.Size() == 1)
+ {
+ volume = &_volumes.Front();
+ database = &volume->Database;
+ }
+ #else
+ if (_inStream != 0)
+ database = &_database;
+ #endif
+
+ // CRecordVector<bool> compressStatuses;
+ CObjectVector<CUpdateItem> updateItems;
+ // CRecordVector<UInt32> copyIndices;
+
+ // CMyComPtr<IUpdateCallback2> updateCallback2;
+ // updateCallback->QueryInterface(&updateCallback2);
+
+ 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)
+ {
+ const CFileItem &fileItem = database->Files[updateItem.IndexInArchive];
+ updateItem.Name = fileItem.Name;
+ updateItem.IsDirectory = fileItem.IsDirectory;
+ updateItem.Size = fileItem.UnPackSize;
+ updateItem.IsAnti = fileItem.IsAnti;
+
+ updateItem.CreationTime = fileItem.CreationTime;
+ updateItem.IsCreationTimeDefined = fileItem.IsCreationTimeDefined;
+ updateItem.LastWriteTime = fileItem.LastWriteTime;
+ updateItem.IsLastWriteTimeDefined = fileItem.IsLastWriteTimeDefined;
+ updateItem.LastAccessTime = fileItem.LastAccessTime;
+ updateItem.IsLastAccessTimeDefined = fileItem.IsLastAccessTimeDefined;
+ }
+
+ if (updateItem.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)
+ return E_INVALIDARG;
+ else
+ {
+ updateItem.Attributes = propVariant.ulVal;
+ updateItem.AttributesAreDefined = 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));
+
+ {
+ NCOM::CPropVariant propVariant;
+ RINOK(updateCallback->GetProperty(i, kpidPath, &propVariant));
+ if (propVariant.vt == VT_EMPTY)
+ nameIsDefined = false;
+ else if (propVariant.vt != VT_BSTR)
+ return E_INVALIDARG;
+ else
+ {
+ updateItem.Name = NItemName::MakeLegalName(propVariant.bstrVal);
+ nameIsDefined = true;
+ }
+ }
+ {
+ NCOM::CPropVariant propVariant;
+ RINOK(updateCallback->GetProperty(i, kpidIsFolder, &propVariant));
+ if (propVariant.vt == VT_EMPTY)
+ folderStatusIsDefined = false;
+ else if (propVariant.vt != VT_BOOL)
+ return E_INVALIDARG;
+ else
+ {
+ updateItem.IsDirectory = (propVariant.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)
+ return E_INVALIDARG;
+ else
+ updateItem.IsAnti = (propVariant.boolVal != VARIANT_FALSE);
+ }
+
+ if (updateItem.IsAnti)
+ {
+ updateItem.AttributesAreDefined = false;
+
+ updateItem.IsCreationTimeDefined = false;
+ updateItem.IsLastWriteTimeDefined = false;
+ updateItem.IsLastAccessTimeDefined = false;
+
+ updateItem.Size = 0;
+ }
+
+ if (!folderStatusIsDefined && updateItem.AttributesAreDefined)
+ updateItem.SetDirectoryStatusFromAttributes();
+ }
+
+ if (updateItem.NewData)
+ {
+ NCOM::CPropVariant propVariant;
+ RINOK(updateCallback->GetProperty(i, kpidSize, &propVariant));
+ if (propVariant.vt != VT_UI8)
+ return E_INVALIDARG;
+ updateItem.Size = (UInt64)propVariant.uhVal.QuadPart;
+ if (updateItem.Size != 0 && updateItem.IsAnti)
+ return E_INVALIDARG;
+ }
+ updateItems.Add(updateItem);
+ }
+
+ CCompressionMethodMode methodMode, headerMethod;
+ RINOK(SetCompressionMethod(methodMode, headerMethod));
+ #ifdef COMPRESS_MT
+ methodMode.NumThreads = _numThreads;
+ headerMethod.NumThreads = 1;
+ #endif
+
+ RINOK(SetPassword(methodMode, updateCallback));
+
+ bool useAdditionalHeaderStreams = true;
+ bool compressMainHeader = false;
+
+ if (_compressHeadersFull)
+ {
+ useAdditionalHeaderStreams = false;
+ compressMainHeader = true;
+ }
+ if (methodMode.PasswordIsDefined)
+ {
+ useAdditionalHeaderStreams = false;
+ compressMainHeader = true;
+ if(_encryptHeaders)
+ RINOK(SetPassword(headerMethod, updateCallback));
+ }
+
+ if (numItems < 2)
+ compressMainHeader = false;
+
+ CUpdateOptions options;
+ options.Method = &methodMode;
+ options.HeaderMethod = (_compressHeaders ||
+ (methodMode.PasswordIsDefined && _encryptHeaders)) ?
+ &headerMethod : 0;
+ options.UseFilters = _level != 0 && _autoFilter;
+ options.MaxFilter = _level >= 8;
+
+ options.HeaderOptions.UseAdditionalHeaderStreams = useAdditionalHeaderStreams;
+ options.HeaderOptions.CompressMainHeader = compressMainHeader;
+ options.HeaderOptions.WriteModified = WriteModified;
+ options.HeaderOptions.WriteCreated = WriteCreated;
+ options.HeaderOptions.WriteAccessed = WriteAccessed;
+
+ options.NumSolidFiles = _numSolidFiles;
+ options.NumSolidBytes = _numSolidBytes;
+ options.SolidExtension = _solidExtension;
+ options.RemoveSfxBlock = _removeSfxBlock;
+ options.VolumeMode = _volumeMode;
+ return Update(
+ #ifdef _7Z_VOL
+ volume ? volume->Stream: 0,
+ volume ? database: 0,
+ #else
+ _inStream,
+ database,
+ #endif
+ updateItems, outStream, updateCallback, options);
+ COM_TRY_END
+}
+
+static HRESULT GetBindInfoPart(UString &srcString, UInt32 &coder, UInt32 &stream)
+{
+ stream = 0;
+ int index = ParseStringToUInt32(srcString, coder);
+ if (index == 0)
+ return E_INVALIDARG;
+ srcString.Delete(0, index);
+ if (srcString[0] == 'S')
+ {
+ srcString.Delete(0);
+ int index = ParseStringToUInt32(srcString, stream);
+ if (index == 0)
+ return E_INVALIDARG;
+ srcString.Delete(0, index);
+ }
+ return S_OK;
+}
+
+static HRESULT GetBindInfo(UString &srcString, CBind &bind)
+{
+ RINOK(GetBindInfoPart(srcString, bind.OutCoder, bind.OutStream));
+ if (srcString[0] != ':')
+ return E_INVALIDARG;
+ srcString.Delete(0);
+ RINOK(GetBindInfoPart(srcString, bind.InCoder, bind.InStream));
+ if (!srcString.IsEmpty())
+ return E_INVALIDARG;
+ return S_OK;
+}
+
+static void SplitParams(const UString &srcString, UStringVector &subStrings)
+{
+ subStrings.Clear();
+ UString name;
+ int len = srcString.Length();
+ if (len == 0)
+ return;
+ for (int i = 0; i < len; i++)
+ {
+ wchar_t c = srcString[i];
+ if (c == L':')
+ {
+ subStrings.Add(name);
+ name.Empty();
+ }
+ else
+ name += c;
+ }
+ subStrings.Add(name);
+}
+
+static void SplitParam(const UString &param, UString &name, UString &value)
+{
+ int eqPos = param.Find(L'=');
+ if (eqPos >= 0)
+ {
+ name = param.Left(eqPos);
+ value = param.Mid(eqPos + 1);
+ return;
+ }
+ for(int i = 0; i < param.Length(); i++)
+ {
+ wchar_t c = param[i];
+ if (c >= L'0' && c <= L'9')
+ {
+ name = param.Left(i);
+ value = param.Mid(i);
+ return;
+ }
+ }
+ name = param;
+}
+
+HRESULT CHandler::SetParam(COneMethodInfo &oneMethodInfo, const UString &name, const UString &value)
+{
+ CProperty property;
+ if (name.CompareNoCase(L"D") == 0 || name.CompareNoCase(L"MEM") == 0)
+ {
+ UInt32 dicSize;
+ RINOK(ParsePropDictionaryValue(value, dicSize));
+ if (name.CompareNoCase(L"D") == 0)
+ property.PropID = NCoderPropID::kDictionarySize;
+ else
+ property.PropID = NCoderPropID::kUsedMemorySize;
+ property.Value = dicSize;
+ oneMethodInfo.CoderProperties.Add(property);
+ }
+ else
+ {
+ int index = FindPropIdFromStringName(name);
+ if (index < 0)
+ return E_INVALIDARG;
+
+ const CNameToPropID &nameToPropID = g_NameToPropID[index];
+ property.PropID = nameToPropID.PropID;
+
+ NCOM::CPropVariant propValue;
+
+
+ if (nameToPropID.VarType == VT_BSTR)
+ propValue = value;
+ else
+ {
+ UInt32 number;
+ if (ParseStringToUInt32(value, number) == value.Length())
+ propValue = number;
+ else
+ propValue = value;
+ }
+
+ if (!ConvertProperty(propValue, nameToPropID.VarType, property.Value))
+ return E_INVALIDARG;
+
+ oneMethodInfo.CoderProperties.Add(property);
+ }
+ return S_OK;
+}
+
+HRESULT CHandler::SetParams(COneMethodInfo &oneMethodInfo, const UString &srcString)
+{
+ UStringVector params;
+ SplitParams(srcString, params);
+ if (params.Size() > 0)
+ oneMethodInfo.MethodName = params[0];
+ for (int i = 1; i < params.Size(); i++)
+ {
+ const UString &param = params[i];
+ UString name, value;
+ SplitParam(param, name, value);
+ RINOK(SetParam(oneMethodInfo, name, value));
+ }
+ return S_OK;
+}
+
+HRESULT CHandler::SetSolidSettings(const UString &s)
+{
+ UString s2 = s;
+ s2.MakeUpper();
+ if (s2.IsEmpty() || s2.Compare(L"ON") == 0)
+ {
+ InitSolid();
+ return S_OK;
+ }
+ if (s2.Compare(L"OFF") == 0)
+ {
+ _numSolidFiles = 1;
+ return S_OK;
+ }
+ for (int i = 0; i < s2.Length();)
+ {
+ const wchar_t *start = ((const wchar_t *)s2) + i;
+ const wchar_t *end;
+ UInt64 v = ConvertStringToUInt64(start, &end);
+ if (start == end)
+ {
+ if (s2[i++] != 'E')
+ return E_INVALIDARG;
+ _solidExtension = true;
+ continue;
+ }
+ i += (int)(end - start);
+ if (i == s2.Length())
+ return E_INVALIDARG;
+ wchar_t c = s2[i++];
+ switch(c)
+ {
+ case 'F':
+ if (v < 1)
+ v = 1;
+ _numSolidFiles = v;
+ break;
+ case 'B':
+ _numSolidBytes = v;
+ _numSolidBytesDefined = true;
+ break;
+ case 'K':
+ _numSolidBytes = (v << 10);
+ _numSolidBytesDefined = true;
+ break;
+ case 'M':
+ _numSolidBytes = (v << 20);
+ _numSolidBytesDefined = true;
+ break;
+ case 'G':
+ _numSolidBytes = (v << 30);
+ _numSolidBytesDefined = true;
+ break;
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CHandler::SetSolidSettings(const PROPVARIANT &value)
+{
+ switch(value.vt)
+ {
+ case VT_EMPTY:
+ InitSolid();
+ return S_OK;
+ case VT_BSTR:
+ return SetSolidSettings(value.bstrVal);
+ default:
+ return E_INVALIDARG;
+ }
+}
+
+STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
+{
+ COM_TRY_BEGIN
+ _methods.Clear();
+ _binds.Clear();
+ Init();
+ #ifdef COMPRESS_MT
+ const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
+ #endif
+
+ UInt32 mainDicSize = 0xFFFFFFFF;
+ UInt32 mainDicMethodIndex = 0xFFFFFFFF;
+
+ UInt32 minNumber = 0;
+
+ for (int i = 0; i < numProperties; i++)
+ {
+ UString name = names[i];
+ name.MakeUpper();
+ if (name.IsEmpty())
+ return E_INVALIDARG;
+
+ const PROPVARIANT &value = values[i];
+
+ if (name[0] == 'X')
+ {
+ name.Delete(0);
+ _level = 9;
+ RINOK(ParsePropValue(name, value, _level));
+ continue;
+ }
+
+ if (name[0] == 'B')
+ {
+ name.Delete(0);
+ CBind bind;
+ RINOK(GetBindInfo(name, bind));
+ _binds.Add(bind);
+ continue;
+ }
+
+ if (name[0] == L'S')
+ {
+ name.Delete(0);
+ if (name.IsEmpty())
+ {
+ RINOK(SetSolidSettings(value));
+ }
+ else
+ {
+ RINOK(SetSolidSettings(name));
+ }
+ continue;
+ }
+
+
+ UInt32 number;
+ int index = ParseStringToUInt32(name, number);
+ UString realName = name.Mid(index);
+ if (index == 0)
+ {
+ if(name.Left(2).CompareNoCase(L"MT") == 0)
+ {
+ #ifdef COMPRESS_MT
+ RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
+ #endif
+ continue;
+ }
+ else if (name.CompareNoCase(L"RSFX") == 0)
+ {
+ RINOK(SetBoolProperty(_removeSfxBlock, value));
+ continue;
+ }
+ else if (name.CompareNoCase(L"F") == 0)
+ {
+ RINOK(SetBoolProperty(_autoFilter, value));
+ continue;
+ }
+ else if (name.CompareNoCase(L"HC") == 0)
+ {
+ RINOK(SetBoolProperty(_compressHeaders, value));
+ continue;
+ }
+ else if (name.CompareNoCase(L"HCF") == 0)
+ {
+ RINOK(SetBoolProperty(_compressHeadersFull, value));
+ continue;
+ }
+ else if (name.CompareNoCase(L"HE") == 0)
+ {
+ RINOK(SetBoolProperty(_encryptHeaders, value));
+ continue;
+ }
+ else if (name.CompareNoCase(L"TM") == 0)
+ {
+ RINOK(SetBoolProperty(WriteModified, value));
+ continue;
+ }
+ else if (name.CompareNoCase(L"TC") == 0)
+ {
+ RINOK(SetBoolProperty(WriteCreated, value));
+ continue;
+ }
+ else if (name.CompareNoCase(L"TA") == 0)
+ {
+ RINOK(SetBoolProperty(WriteAccessed, value));
+ continue;
+ }
+ else if (name.CompareNoCase(L"V") == 0)
+ {
+ RINOK(SetBoolProperty(_volumeMode, value));
+ continue;
+ }
+ number = 0;
+ }
+ if (number > 10000)
+ return E_FAIL;
+ if (number < minNumber)
+ return E_INVALIDARG;
+ number -= minNumber;
+ for(int j = _methods.Size(); j <= (int)number; j++)
+ {
+ COneMethodInfo oneMethodInfo;
+ _methods.Add(oneMethodInfo);
+ }
+
+ COneMethodInfo &oneMethodInfo = _methods[number];
+
+ if (realName.Length() == 0)
+ {
+ if (value.vt != VT_BSTR)
+ return E_INVALIDARG;
+
+ // oneMethodInfo.MethodName = UnicodeStringToMultiByte(UString(value.bstrVal));
+ RINOK(SetParams(oneMethodInfo, value.bstrVal));
+ }
+ else
+ {
+ CProperty property;
+ if (realName.Left(1).CompareNoCase(L"D") == 0)
+ {
+ UInt32 dicSize;
+ RINOK(ParsePropDictionaryValue(realName.Mid(1), value, dicSize));
+ property.PropID = NCoderPropID::kDictionarySize;
+ property.Value = dicSize;
+ oneMethodInfo.CoderProperties.Add(property);
+ if (number <= mainDicMethodIndex)
+ mainDicSize = dicSize;
+ }
+ else if (realName.Left(3).CompareNoCase(L"MEM") == 0)
+ {
+ UInt32 dicSize;
+ RINOK(ParsePropDictionaryValue(realName.Mid(3), value, dicSize));
+ property.PropID = NCoderPropID::kUsedMemorySize;
+ property.Value = dicSize;
+ oneMethodInfo.CoderProperties.Add(property);
+ if (number <= mainDicMethodIndex)
+ mainDicSize = dicSize;
+ }
+ else
+ {
+ int index = FindPropIdFromStringName(realName);
+ if (index < 0)
+ return E_INVALIDARG;
+
+ const CNameToPropID &nameToPropID = g_NameToPropID[index];
+ property.PropID = nameToPropID.PropID;
+
+ if (!ConvertProperty(value, nameToPropID.VarType, property.Value))
+ return E_INVALIDARG;
+
+ oneMethodInfo.CoderProperties.Add(property);
+ }
+ }
+ }
+
+ return S_OK;
+ COM_TRY_END
+}
+
+}}
diff --git a/7zip/Archive/7z/7zHeader.cpp b/CPP/7zip/Archive/7z/7zHeader.cpp
index cff4d121..cff4d121 100755
--- a/7zip/Archive/7z/7zHeader.cpp
+++ b/CPP/7zip/Archive/7z/7zHeader.cpp
diff --git a/7zip/Archive/7z/7zHeader.h b/CPP/7zip/Archive/7z/7zHeader.h
index 59bc7fe5..59bc7fe5 100755
--- a/7zip/Archive/7z/7zHeader.h
+++ b/CPP/7zip/Archive/7z/7zHeader.h
diff --git a/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp
index 53d78b1a..53d78b1a 100755
--- a/7zip/Archive/7z/7zIn.cpp
+++ b/CPP/7zip/Archive/7z/7zIn.cpp
diff --git a/7zip/Archive/7z/7zIn.h b/CPP/7zip/Archive/7z/7zIn.h
index 4f27aa75..4f27aa75 100755
--- a/7zip/Archive/7z/7zIn.h
+++ b/CPP/7zip/Archive/7z/7zIn.h
diff --git a/7zip/Archive/7z/7zItem.h b/CPP/7zip/Archive/7z/7zItem.h
index 08ea61f4..08ea61f4 100755
--- a/7zip/Archive/7z/7zItem.h
+++ b/CPP/7zip/Archive/7z/7zItem.h
diff --git a/7zip/Archive/7z/7zMethodID.cpp b/CPP/7zip/Archive/7z/7zMethodID.cpp
index 0d45b732..0d45b732 100755
--- a/7zip/Archive/7z/7zMethodID.cpp
+++ b/CPP/7zip/Archive/7z/7zMethodID.cpp
diff --git a/7zip/Archive/7z/7zMethodID.h b/CPP/7zip/Archive/7z/7zMethodID.h
index 54561054..54561054 100755
--- a/7zip/Archive/7z/7zMethodID.h
+++ b/CPP/7zip/Archive/7z/7zMethodID.h
diff --git a/7zip/Archive/7z/7zMethods.cpp b/CPP/7zip/Archive/7z/7zMethods.cpp
index 19270aa4..19270aa4 100755
--- a/7zip/Archive/7z/7zMethods.cpp
+++ b/CPP/7zip/Archive/7z/7zMethods.cpp
diff --git a/7zip/Archive/7z/7zMethods.h b/CPP/7zip/Archive/7z/7zMethods.h
index 231f3183..231f3183 100755
--- a/7zip/Archive/7z/7zMethods.h
+++ b/CPP/7zip/Archive/7z/7zMethods.h
diff --git a/7zip/Archive/7z/7zOut.cpp b/CPP/7zip/Archive/7z/7zOut.cpp
index 5a81a0d5..5a81a0d5 100755
--- a/7zip/Archive/7z/7zOut.cpp
+++ b/CPP/7zip/Archive/7z/7zOut.cpp
diff --git a/7zip/Archive/7z/7zOut.h b/CPP/7zip/Archive/7z/7zOut.h
index cccc813a..cccc813a 100755
--- a/7zip/Archive/7z/7zOut.h
+++ b/CPP/7zip/Archive/7z/7zOut.h
diff --git a/7zip/Archive/7z/7zProperties.cpp b/CPP/7zip/Archive/7z/7zProperties.cpp
index 316f4f09..316f4f09 100755
--- a/7zip/Archive/7z/7zProperties.cpp
+++ b/CPP/7zip/Archive/7z/7zProperties.cpp
diff --git a/7zip/Archive/7z/7zProperties.h b/CPP/7zip/Archive/7z/7zProperties.h
index a09839bb..a09839bb 100755
--- a/7zip/Archive/7z/7zProperties.h
+++ b/CPP/7zip/Archive/7z/7zProperties.h
diff --git a/7zip/Archive/7z/7zSpecStream.cpp b/CPP/7zip/Archive/7z/7zSpecStream.cpp
index 80d303a4..80d303a4 100755
--- a/7zip/Archive/7z/7zSpecStream.cpp
+++ b/CPP/7zip/Archive/7z/7zSpecStream.cpp
diff --git a/7zip/Archive/7z/7zSpecStream.h b/CPP/7zip/Archive/7z/7zSpecStream.h
index 0253c421..0253c421 100755
--- a/7zip/Archive/7z/7zSpecStream.h
+++ b/CPP/7zip/Archive/7z/7zSpecStream.h
diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp
new file mode 100755
index 00000000..b3d5009a
--- /dev/null
+++ b/CPP/7zip/Archive/7z/7zUpdate.cpp
@@ -0,0 +1,1099 @@
+// UpdateMain.cpp
+
+#include "StdAfx.h"
+
+#include "7zUpdate.h"
+#include "7zFolderInStream.h"
+#include "7zEncode.h"
+#include "7zHandler.h"
+#include "7zOut.h"
+
+#ifndef EXCLUDE_COM
+#include "7zMethods.h"
+#endif
+
+#include "../../Compress/Copy/CopyCoder.h"
+#include "../../Common/ProgressUtils.h"
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/LimitedStreams.h"
+#include "../Common/ItemNameUtils.h"
+
+namespace NArchive {
+namespace N7z {
+
+static const wchar_t *kMatchFinderForBCJ2_LZMA = L"BT2";
+static const UInt32 kDictionaryForBCJ2_LZMA = 1 << 20;
+static const UInt32 kAlgorithmForBCJ2_LZMA = 1;
+static const UInt32 kNumFastBytesForBCJ2_LZMA = 64;
+
+static HRESULT CopyBlock(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, ICompressProgressInfo *progress)
+{
+ CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
+ return copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+}
+
+static HRESULT WriteRange(
+ ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
+ UInt64 size,
+ IProgress *progress,
+ UInt64 &currentComplexity)
+{
+ CLimitedSequentialInStream *streamSpec = new
+ CLimitedSequentialInStream;
+ CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
+ streamSpec->SetStream(inStream);
+ streamSpec->Init(size);
+
+ CLocalProgress *localProgressSpec = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
+ localProgressSpec->Init(progress, true);
+
+ CLocalCompressProgressInfo *localCompressProgressSpec =
+ new CLocalCompressProgressInfo;
+ CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
+
+ localCompressProgressSpec->Init(localProgress, &currentComplexity, &currentComplexity);
+
+ HRESULT result = CopyBlock(inStreamLimited, outStream, compressProgress);
+ currentComplexity += size;
+ return result;
+}
+
+
+static HRESULT WriteRange(IInStream *inStream,
+ ISequentialOutStream *outStream,
+ UInt64 position,
+ UInt64 size,
+ IProgress *progress,
+ UInt64 &currentComplexity)
+{
+ inStream->Seek(position, STREAM_SEEK_SET, 0);
+ return WriteRange(inStream, outStream,
+ size, progress, currentComplexity);
+}
+
+static int GetReverseSlashPos(const UString &name)
+{
+ int slashPos = name.ReverseFind(L'/');
+ #ifdef _WIN32
+ int slash1Pos = name.ReverseFind(L'\\');
+ slashPos = MyMax(slashPos, slash1Pos);
+ #endif
+ return slashPos;
+}
+
+int CUpdateItem::GetExtensionPos() const
+{
+ int slashPos = GetReverseSlashPos(Name);
+ int dotPos = Name.ReverseFind(L'.');
+ if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
+ return Name.Length();
+ return dotPos + 1;
+}
+
+UString CUpdateItem::GetExtension() const
+{
+ return Name.Mid(GetExtensionPos());
+}
+
+/*
+struct CFolderRef
+{
+ const CArchiveDatabaseEx *Database;
+ int FolderIndex;
+};
+*/
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+static int CompareMethodIDs(const CMethodID &a1, const CMethodID &a2)
+{
+ for (int i = 0; i < a1.IDSize && i < a2.IDSize; i++)
+ RINOZ(MyCompare(a1.ID[i], a2.ID[i]));
+ return MyCompare(a1.IDSize, a2.IDSize);
+}
+
+static int CompareBuffers(const CByteBuffer &a1, const CByteBuffer &a2)
+{
+ size_t c1 = a1.GetCapacity();
+ size_t c2 = a2.GetCapacity();
+ RINOZ(MyCompare(c1, c2));
+ for (size_t i = 0; i < c1; i++)
+ RINOZ(MyCompare(a1[i], a2[i]));
+ return 0;
+}
+
+static int CompareAltCoders(const CAltCoderInfo &a1, const CAltCoderInfo &a2)
+{
+ RINOZ(CompareMethodIDs(a1.MethodID, a2.MethodID));
+ return CompareBuffers(a1.Properties, a2.Properties);
+}
+
+static int CompareCoders(const CCoderInfo &c1, const CCoderInfo &c2)
+{
+ RINOZ(MyCompare(c1.NumInStreams, c2.NumInStreams));
+ RINOZ(MyCompare(c1.NumOutStreams, c2.NumOutStreams));
+ int s1 = c1.AltCoders.Size();
+ int s2 = c2.AltCoders.Size();
+ RINOZ(MyCompare(s1, s2));
+ for (int i = 0; i < s1; i++)
+ RINOZ(CompareAltCoders(c1.AltCoders[i], c2.AltCoders[i]));
+ return 0;
+}
+
+static int CompareBindPairs(const CBindPair &b1, const CBindPair &b2)
+{
+ RINOZ(MyCompare(b1.InIndex, b2.InIndex));
+ return MyCompare(b1.OutIndex, b2.OutIndex);
+}
+
+static int CompareFolders(const CFolder &f1, const CFolder &f2)
+{
+ int s1 = f1.Coders.Size();
+ int s2 = f2.Coders.Size();
+ RINOZ(MyCompare(s1, s2));
+ int i;
+ for (i = 0; i < s1; i++)
+ RINOZ(CompareCoders(f1.Coders[i], f2.Coders[i]));
+ s1 = f1.BindPairs.Size();
+ s2 = f2.BindPairs.Size();
+ RINOZ(MyCompare(s1, s2));
+ for (i = 0; i < s1; i++)
+ RINOZ(CompareBindPairs(f1.BindPairs[i], f2.BindPairs[i]));
+ return 0;
+}
+
+static int CompareFiles(const CFileItem &f1, const CFileItem &f2)
+{
+ return MyStringCompareNoCase(f1.Name, f2.Name);
+}
+
+static int CompareFolderRefs(const int *p1, const int *p2, void *param)
+{
+ int i1 = *p1;
+ int i2 = *p2;
+ const CArchiveDatabaseEx &db = *(const CArchiveDatabaseEx *)param;
+ RINOZ(CompareFolders(
+ db.Folders[i1],
+ db.Folders[i2]));
+ RINOZ(MyCompare(
+ db.NumUnPackStreamsVector[i1],
+ db.NumUnPackStreamsVector[i2]));
+ if (db.NumUnPackStreamsVector[i1] == 0)
+ return 0;
+ return CompareFiles(
+ db.Files[db.FolderStartFileIndex[i1]],
+ db.Files[db.FolderStartFileIndex[i2]]);
+}
+
+////////////////////////////////////////////////////////////
+
+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.IsAnti != u2.IsAnti)
+ return (u1.IsAnti ? 1 : -1);
+ int n = MyStringCompareNoCase(u1.Name, u2.Name);
+ return -n;
+ }
+ if (u1.IsAnti != u2.IsAnti)
+ return (u1.IsAnti ? 1 : -1);
+ 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"
+ " 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"
+ " swf "
+ " chm hxi hxs"
+ " gif jpeg jpg jp2 png tiff bmp ico psd psp"
+ " awg ps eps cgm dxf svg vrml wmf emf ai md"
+ " cad dwg pps key sxi"
+ " max 3ds"
+ " 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"
+ " f77 f f90 f95"
+ " asm sql manifest dep "
+ " mak clw csproj vcproj sln dsp dsw "
+ " class "
+ " bat cmd"
+ " xml xsd xsl xslt hxk hxc htm html xhtml xht mht mhtml htw asp aspx css cgi jsp shtml"
+ " awk sed hta js php php3 php4 php5 phptml pl pm py pyo rb sh tcl vbs"
+ " text txt tex ans asc srt reg ini doc docx mcw dot rtf hlp xls xlr xlt xlw ppt pdf"
+ " sxc sxd sxi sxg sxw stc sti stw stm odt ott odg otg odp otp ods ots odf"
+ " abw afp cwk lwp wpd wps wpt wrf wri"
+ " abf afm bdf fon mgf otf pcf pfa snf ttf"
+ " dbf mdb nsf ntf wdb db fdb gdb"
+ " exe dll ocx vbx sfx sys tlb awx com obj lib out o so "
+ " pdb pch idb ncb opt";
+
+int GetExtIndex(const char *ext)
+{
+ int extIndex = 1;
+ const char *p = g_Exts;
+ for (;;)
+ {
+ char c = *p++;
+ if (c == 0)
+ return extIndex;
+ if (c == ' ')
+ continue;
+ int pos = 0;
+ for (;;)
+ {
+ char c2 = ext[pos++];
+ if (c2 == 0 && (c == 0 || c == ' '))
+ return extIndex;
+ if (c != c2)
+ break;
+ c = *p++;
+ }
+ extIndex++;
+ for (;;)
+ {
+ if (c == 0)
+ return extIndex;
+ if (c == ' ')
+ break;
+ c = *p++;
+ }
+ }
+}
+
+struct CRefItem
+{
+ UInt32 Index;
+ const CUpdateItem *UpdateItem;
+ UInt32 ExtensionPos;
+ UInt32 NamePos;
+ int ExtensionIndex;
+ CRefItem(UInt32 index, const CUpdateItem &updateItem, bool sortByType):
+ Index(index),
+ UpdateItem(&updateItem),
+ ExtensionPos(0),
+ NamePos(0),
+ ExtensionIndex(0)
+ {
+ if (sortByType)
+ {
+ int slashPos = GetReverseSlashPos(updateItem.Name);
+ NamePos = ((slashPos >= 0) ? (slashPos + 1) : 0);
+ int dotPos = updateItem.Name.ReverseFind(L'.');
+ if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
+ ExtensionPos = updateItem.Name.Length();
+ else
+ {
+ ExtensionPos = dotPos + 1;
+ UString us = updateItem.Name.Mid(ExtensionPos);
+ if (!us.IsEmpty())
+ {
+ us.MakeLower();
+ int i;
+ AString s;
+ for (i = 0; i < us.Length(); i++)
+ {
+ wchar_t c = us[i];
+ if (c >= 0x80)
+ break;
+ s += (char)c;
+ }
+ if (i == us.Length())
+ ExtensionIndex = GetExtIndex(s);
+ else
+ ExtensionIndex = 0;
+ }
+ }
+ }
+ }
+};
+
+static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *param)
+{
+ const CRefItem &a1 = *p1;
+ const CRefItem &a2 = *p2;
+ 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.IsAnti != u2.IsAnti)
+ return (u1.IsAnti ? 1 : -1);
+ n = MyStringCompareNoCase(u1.Name, u2.Name);
+ return -n;
+ }
+ bool sortByType = *(bool *)param;
+ if (sortByType)
+ {
+ 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));
+ RINOZ(MyCompare(u1.Size, u2.Size))
+ }
+ return MyStringCompareNoCase(u1.Name, u2.Name);
+}
+
+struct CSolidGroup
+{
+ CCompressionMethodMode Method;
+ CRecordVector<UInt32> Indices;
+};
+
+static wchar_t *g_ExeExts[] =
+{
+ L"dll",
+ L"exe",
+ L"ocx",
+ L"sfx",
+ L"sys"
+};
+
+static bool IsExeFile(const UString &ext)
+{
+ for (int i = 0; i < sizeof(g_ExeExts) / sizeof(g_ExeExts[0]); i++)
+ if (ext.CompareNoCase(g_ExeExts[i]) == 0)
+ return true;
+ return false;
+}
+
+static CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
+static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
+static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
+
+static bool GetMethodFull(const CMethodID &methodID,
+ UInt32 numInStreams, CMethodFull &methodResult)
+{
+ methodResult.MethodID = methodID;
+ methodResult.NumInStreams = numInStreams;
+ methodResult.NumOutStreams = 1;
+
+ #ifndef EXCLUDE_COM
+ CMethodInfo methodInfo;
+ if (!GetMethodInfo(methodID, methodInfo))
+ return false;
+ if (!methodInfo.EncoderIsAssigned)
+ return false;
+ methodResult.EncoderClassID = methodInfo.Encoder;
+ methodResult.FilePath = methodInfo.FilePath;
+ if (methodInfo.NumOutStreams != 1 || methodInfo.NumInStreams != numInStreams)
+ return false;
+ #endif
+ return true;
+}
+
+static bool MakeExeMethod(const CCompressionMethodMode &method,
+ bool bcj2Filter, CCompressionMethodMode &exeMethod)
+{
+ exeMethod = method;
+ if (bcj2Filter)
+ {
+ CMethodFull methodFull;
+ if (!GetMethodFull(k_BCJ2, 4, methodFull))
+ return false;
+ exeMethod.Methods.Insert(0, methodFull);
+ if (!GetMethodFull(k_LZMA, 1, methodFull))
+ return false;
+ {
+ CProperty property;
+ property.PropID = NCoderPropID::kAlgorithm;
+ property.Value = kAlgorithmForBCJ2_LZMA;
+ methodFull.CoderProperties.Add(property);
+ }
+ {
+ CProperty property;
+ property.PropID = NCoderPropID::kMatchFinder;
+ property.Value = kMatchFinderForBCJ2_LZMA;
+ methodFull.CoderProperties.Add(property);
+ }
+ {
+ CProperty property;
+ property.PropID = NCoderPropID::kDictionarySize;
+ property.Value = kDictionaryForBCJ2_LZMA;
+ methodFull.CoderProperties.Add(property);
+ }
+ {
+ CProperty property;
+ property.PropID = NCoderPropID::kNumFastBytes;
+ property.Value = kNumFastBytesForBCJ2_LZMA;
+ methodFull.CoderProperties.Add(property);
+ }
+
+ exeMethod.Methods.Add(methodFull);
+ exeMethod.Methods.Add(methodFull);
+ CBind bind;
+
+ bind.OutCoder = 0;
+ bind.InStream = 0;
+
+ bind.InCoder = 1;
+ bind.OutStream = 0;
+ exeMethod.Binds.Add(bind);
+
+ bind.InCoder = 2;
+ bind.OutStream = 1;
+ exeMethod.Binds.Add(bind);
+
+ bind.InCoder = 3;
+ bind.OutStream = 2;
+ exeMethod.Binds.Add(bind);
+ }
+ else
+ {
+ CMethodFull methodFull;
+ if (!GetMethodFull(k_BCJ_X86, 1, methodFull))
+ return false;
+ exeMethod.Methods.Insert(0, methodFull);
+ CBind bind;
+ bind.OutCoder = 0;
+ bind.InStream = 0;
+ bind.InCoder = 1;
+ bind.OutStream = 0;
+ exeMethod.Binds.Add(bind);
+ }
+ return true;
+}
+
+static void SplitFilesToGroups(
+ const CCompressionMethodMode &method,
+ bool useFilters, bool maxFilter,
+ const CObjectVector<CUpdateItem> &updateItems,
+ CObjectVector<CSolidGroup> &groups)
+{
+ if (method.Methods.Size() != 1 || method.Binds.Size() != 0)
+ useFilters = false;
+ groups.Clear();
+ groups.Add(CSolidGroup());
+ groups.Add(CSolidGroup());
+ CSolidGroup &generalGroup = groups[0];
+ CSolidGroup &exeGroup = groups[1];
+ generalGroup.Method = method;
+ int i;
+ for (i = 0; i < updateItems.Size(); i++)
+ {
+ const CUpdateItem &updateItem = updateItems[i];
+ if (!updateItem.NewData)
+ continue;
+ if (!updateItem.HasStream())
+ continue;
+ if (useFilters)
+ {
+ const UString name = updateItem.Name;
+ int dotPos = name.ReverseFind(L'.');
+ if (dotPos >= 0)
+ {
+ UString ext = name.Mid(dotPos + 1);
+ if (IsExeFile(ext))
+ {
+ exeGroup.Indices.Add(i);
+ continue;
+ }
+ }
+ }
+ generalGroup.Indices.Add(i);
+ }
+ if (exeGroup.Indices.Size() > 0)
+ if (!MakeExeMethod(method, maxFilter, exeGroup.Method))
+ exeGroup.Method = method;
+ for (i = 0; i < groups.Size();)
+ if (groups[i].Indices.Size() == 0)
+ groups.Delete(i);
+ else
+ i++;
+}
+
+static void FromUpdateItemToFileItem(const CUpdateItem &updateItem,
+ CFileItem &file)
+{
+ 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.UnPackSize = updateItem.Size;
+ file.IsDirectory = updateItem.IsDirectory;
+ file.IsAnti = updateItem.IsAnti;
+ file.HasStream = updateItem.HasStream();
+}
+
+static HRESULT Update2(
+ IInStream *inStream,
+ const CArchiveDatabaseEx *database,
+ const CObjectVector<CUpdateItem> &updateItems,
+ ISequentialOutStream *seqOutStream,
+ IArchiveUpdateCallback *updateCallback,
+ const CUpdateOptions &options)
+{
+ UInt64 numSolidFiles = options.NumSolidFiles;
+ if (numSolidFiles == 0)
+ numSolidFiles = 1;
+ /*
+ CMyComPtr<IOutStream> outStream;
+ RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream));
+ if (!outStream)
+ return E_NOTIMPL;
+ */
+
+ UInt64 startBlockSize = database != 0 ?
+ database->ArchiveInfo.StartPosition: 0;
+ if (startBlockSize > 0 && !options.RemoveSfxBlock)
+ {
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> limitedStream(streamSpec);
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ streamSpec->SetStream(inStream);
+ streamSpec->Init(startBlockSize);
+ RINOK(CopyBlock(limitedStream, seqOutStream, NULL));
+ }
+
+ CRecordVector<int> fileIndexToUpdateIndexMap;
+ if (database != 0)
+ {
+ fileIndexToUpdateIndexMap.Reserve(database->Files.Size());
+ for (int i = 0; i < database->Files.Size(); i++)
+ fileIndexToUpdateIndexMap.Add(-1);
+ }
+ int i;
+ for(i = 0; i < updateItems.Size(); i++)
+ {
+ int index = updateItems[i].IndexInArchive;
+ if (index != -1)
+ fileIndexToUpdateIndexMap[index] = i;
+ }
+
+ CRecordVector<int> folderRefs;
+ if (database != 0)
+ {
+ for(i = 0; i < database->Folders.Size(); i++)
+ {
+ CNum indexInFolder = 0;
+ CNum numCopyItems = 0;
+ CNum numUnPackStreams = database->NumUnPackStreamsVector[i];
+ for (CNum fileIndex = database->FolderStartFileIndex[i];
+ indexInFolder < numUnPackStreams; fileIndex++)
+ {
+ if (database->Files[fileIndex].HasStream)
+ {
+ indexInFolder++;
+ int updateIndex = fileIndexToUpdateIndexMap[fileIndex];
+ if (updateIndex >= 0)
+ if (!updateItems[updateIndex].NewData)
+ numCopyItems++;
+ }
+ }
+ if (numCopyItems != numUnPackStreams && numCopyItems != 0)
+ return E_NOTIMPL; // It needs repacking !!!
+ if (numCopyItems > 0)
+ folderRefs.Add(i);
+ }
+ folderRefs.Sort(CompareFolderRefs, (void *)database);
+ }
+
+ 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]);
+ UInt64 inSizeForReduce = 0;
+ for(i = 0; i < updateItems.Size(); i++)
+ {
+ const CUpdateItem &updateItem = updateItems[i];
+ if (updateItem.NewData)
+ {
+ complexity += updateItem.Size;
+ if (numSolidFiles == 1)
+ {
+ if (updateItem.Size > inSizeForReduce)
+ inSizeForReduce = updateItem.Size;
+ }
+ else
+ inSizeForReduce += updateItem.Size;
+ }
+ }
+ RINOK(updateCallback->SetTotal(complexity));
+ complexity = 0;
+ RINOK(updateCallback->SetCompleted(&complexity));
+
+ /////////////////////////////////////////
+ // Write Copy Items
+
+ for(i = 0; i < folderRefs.Size(); i++)
+ {
+ int folderIndex = folderRefs[i];
+
+ RINOK(WriteRange(inStream, archive.SeqStream,
+ database->GetFolderStreamPos(folderIndex, 0),
+ database->GetFolderFullPackSize(folderIndex),
+ updateCallback, complexity));
+
+ const CFolder &folder = database->Folders[folderIndex];
+ CNum startIndex = database->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.Folders.Add(folder);
+
+ CNum numUnPackStreams = database->NumUnPackStreamsVector[folderIndex];
+ newDatabase.NumUnPackStreamsVector.Add(numUnPackStreams);
+
+ CNum indexInFolder = 0;
+ for (CNum fi = database->FolderStartFileIndex[folderIndex];
+ indexInFolder < numUnPackStreams; fi++)
+ {
+ CFileItem file = database->Files[fi];
+ if (file.HasStream)
+ {
+ indexInFolder++;
+ int updateIndex = fileIndexToUpdateIndexMap[fi];
+ if (updateIndex >= 0)
+ {
+ const CUpdateItem &updateItem = updateItems[updateIndex];
+ if (updateItem.NewProperties)
+ {
+ CFileItem file2;
+ FromUpdateItemToFileItem(updateItem, file2);
+ file2.UnPackSize = file.UnPackSize;
+ file2.FileCRC = file.FileCRC;
+ file2.IsFileCRCDefined = file.IsFileCRCDefined;
+ file2.HasStream = file.HasStream;
+ file = file2;
+ }
+ }
+ newDatabase.Files.Add(file);
+ }
+ }
+ }
+
+ /////////////////////////////////////////
+ // Compress New Files
+
+ CObjectVector<CSolidGroup> groups;
+ SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter,
+ updateItems, groups);
+
+ const UInt32 kMinReduceSize = (1 << 16);
+ if (inSizeForReduce < kMinReduceSize)
+ inSizeForReduce = kMinReduceSize;
+
+ for (int groupIndex = 0; groupIndex < groups.Size(); groupIndex++)
+ {
+ const CSolidGroup &group = groups[groupIndex];
+ int numFiles = group.Indices.Size();
+ if (numFiles == 0)
+ continue;
+ CRecordVector<CRefItem> refItems;
+ refItems.Reserve(numFiles);
+ bool sortByType = (numSolidFiles > 1);
+ for (i = 0; i < numFiles; i++)
+ refItems.Add(CRefItem(group.Indices[i], updateItems[group.Indices[i]], sortByType));
+ refItems.Sort(CompareUpdateItems, (void *)&sortByType);
+
+ CRecordVector<UInt32> indices;
+ indices.Reserve(numFiles);
+
+ for (i = 0; i < numFiles; i++)
+ {
+ UInt32 index = refItems[i].Index;
+ indices.Add(index);
+ /*
+ const CUpdateItem &updateItem = updateItems[index];
+ CFileItem file;
+ if (updateItem.NewProperties)
+ FromUpdateItemToFileItem(updateItem, file);
+ else
+ file = database.Files[updateItem.IndexInArchive];
+ if (file.IsAnti || file.IsDirectory)
+ return E_FAIL;
+ newDatabase.Files.Add(file);
+ */
+ }
+
+ CEncoder encoder(group.Method);
+
+ for (i = 0; i < numFiles;)
+ {
+ UInt64 totalSize = 0;
+ int numSubFiles;
+ UString prevExtension;
+ for (numSubFiles = 0; i + numSubFiles < numFiles &&
+ numSubFiles < numSolidFiles; numSubFiles++)
+ {
+ const CUpdateItem &updateItem = updateItems[indices[i + numSubFiles]];
+ totalSize += updateItem.Size;
+ if (totalSize > options.NumSolidBytes)
+ break;
+ if (options.SolidExtension)
+ {
+ UString ext = updateItem.GetExtension();
+ if (numSubFiles == 0)
+ prevExtension = ext;
+ else
+ if (ext.CompareNoCase(prevExtension) != 0)
+ break;
+ }
+ }
+ if (numSubFiles < 1)
+ numSubFiles = 1;
+
+ CFolderInStream *inStreamSpec = new CFolderInStream;
+ CMyComPtr<ISequentialInStream> solidInStream(inStreamSpec);
+ inStreamSpec->Init(updateCallback, &indices[i], numSubFiles);
+
+ CFolder folderItem;
+ CLocalProgress *localProgressSpec = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
+ localProgressSpec->Init(updateCallback, true);
+ CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
+ CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
+ localCompressProgressSpec->Init(localProgress, &complexity, NULL);
+
+ RINOK(encoder.Encode(solidInStream, NULL, &inSizeForReduce, folderItem,
+ archive.SeqStream, newDatabase.PackSizes, compressProgress));
+ // for()
+ // newDatabase.PackCRCsDefined.Add(false);
+ // newDatabase.PackCRCs.Add(0);
+
+ newDatabase.Folders.Add(folderItem);
+
+ CNum numUnPackStreams = 0;
+ for (int subIndex = 0; subIndex < numSubFiles; subIndex++)
+ {
+ const CUpdateItem &updateItem = updateItems[indices[i + subIndex]];
+ CFileItem file;
+ if (updateItem.NewProperties)
+ FromUpdateItemToFileItem(updateItem, file);
+ else
+ file = database->Files[updateItem.IndexInArchive];
+ if (file.IsAnti || file.IsDirectory)
+ return E_FAIL;
+
+ /*
+ CFileItem &file = newDatabase.Files[
+ startFileIndexInDatabase + i + subIndex];
+ */
+ if (!inStreamSpec->Processed[subIndex])
+ {
+ continue;
+ // file.Name += L".locked";
+ }
+
+ file.FileCRC = inStreamSpec->CRCs[subIndex];
+ file.UnPackSize = inStreamSpec->Sizes[subIndex];
+ if (file.UnPackSize != 0)
+ {
+ file.IsFileCRCDefined = true;
+ file.HasStream = true;
+ numUnPackStreams++;
+ complexity += file.UnPackSize;
+ }
+ else
+ {
+ file.IsFileCRCDefined = false;
+ file.HasStream = false;
+ }
+ newDatabase.Files.Add(file);
+ }
+ // numUnPackStreams = 0 is very bad case for locked files
+ // v3.13 doesn't understand it.
+ newDatabase.NumUnPackStreamsVector.Add(numUnPackStreams);
+ i += numSubFiles;
+ }
+ }
+
+ {
+ /////////////////////////////////////////
+ // Write Empty Files & Folders
+
+ CRecordVector<int> emptyRefs;
+ for(i = 0; i < updateItems.Size(); i++)
+ {
+ const CUpdateItem &updateItem = updateItems[i];
+ if (updateItem.NewData)
+ {
+ if (updateItem.HasStream())
+ continue;
+ }
+ else
+ if (updateItem.IndexInArchive != -1)
+ if (database->Files[updateItem.IndexInArchive].HasStream)
+ continue;
+ emptyRefs.Add(i);
+ }
+ emptyRefs.Sort(CompareEmptyItems, (void *)&updateItems);
+ for(i = 0; i < emptyRefs.Size(); i++)
+ {
+ const CUpdateItem &updateItem = updateItems[emptyRefs[i]];
+ CFileItem file;
+ if (updateItem.NewProperties)
+ FromUpdateItemToFileItem(updateItem, file);
+ else
+ file = database->Files[updateItem.IndexInArchive];
+ newDatabase.Files.Add(file);
+ }
+ }
+
+ /*
+ if (newDatabase.Files.Size() != updateItems.Size())
+ return E_FAIL;
+ */
+
+ return archive.WriteDatabase(newDatabase, options.HeaderMethod, options.HeaderOptions);
+}
+
+#ifdef _7Z_VOL
+
+static HRESULT WriteVolumeHeader(COutArchive &archive, CFileItem &file, const CUpdateOptions &options)
+{
+ CAltCoderInfo altCoder;
+ altCoder.MethodID.IDSize = 1;
+ altCoder.MethodID.ID[0] = 0;
+ CCoderInfo coder;
+ coder.NumInStreams = coder.NumOutStreams = 1;
+ coder.AltCoders.Add(altCoder);
+
+ 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());
+ }
+ }
+ return S_OK;
+}
+
+#endif
+
+HRESULT Update(
+ IInStream *inStream,
+ const CArchiveDatabaseEx *database,
+ const CObjectVector<CUpdateItem> &updateItems,
+ ISequentialOutStream *seqOutStream,
+ IArchiveUpdateCallback *updateCallback,
+ const CUpdateOptions &options)
+{
+ #ifdef _7Z_VOL
+ if (seqOutStream)
+ #endif
+ return Update2(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
+}
+
+}}
diff --git a/7zip/Archive/7z/7zUpdate.h b/CPP/7zip/Archive/7z/7zUpdate.h
index 385bd942..385bd942 100755
--- a/7zip/Archive/7z/7zUpdate.h
+++ b/CPP/7zip/Archive/7z/7zUpdate.h
diff --git a/CPP/7zip/Archive/7z/DllExports.cpp b/CPP/7zip/Archive/7z/DllExports.cpp
new file mode 100755
index 00000000..2d70d4de
--- /dev/null
+++ b/CPP/7zip/Archive/7z/DllExports.cpp
@@ -0,0 +1,113 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Common/MyInitGuid.h"
+#include "../../../Common/ComTry.h"
+#ifdef _WIN32
+#include "../../../Common/Alloc.h"
+#endif
+
+#include "../../ICoder.h"
+
+#include "7zHandler.h"
+
+#ifndef EXCLUDE_COM
+// {23170F69-40C1-278B-06F1-070100000100}
+DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
+0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00);
+#endif
+
+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
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+ }
+ return TRUE;
+}
+
+
+STDAPI CreateObject(
+ const GUID *classID,
+ const GUID *interfaceID,
+ void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ if (*classID != NArchive::N7z::CLSID_CFormat7z)
+ return CLASS_E_CLASSNOTAVAILABLE;
+ if (*interfaceID == IID_IInArchive)
+ {
+ CMyComPtr<IInArchive> inArchive = new NArchive::N7z::CHandler;
+ *outObject = inArchive.Detach();
+ }
+ #ifndef EXTRACT_ONLY
+ else if (*interfaceID == IID_IOutArchive)
+ {
+ CMyComPtr<IOutArchive> outArchive = new NArchive::N7z::CHandler;
+ *outObject = outArchive.Detach();
+ }
+ #endif
+ else
+ return E_NOINTERFACE;
+ COM_TRY_END
+ return S_OK;
+}
+
+STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant propVariant;
+ switch(propID)
+ {
+ case NArchive::kName:
+ propVariant = L"7z";
+ break;
+ case NArchive::kClassID:
+ {
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&NArchive::N7z::CLSID_CFormat7z, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ case NArchive::kExtension:
+ propVariant = L"7z";
+ break;
+ case NArchive::kUpdate:
+ propVariant = true;
+ break;
+ case NArchive::kKeepName:
+ propVariant = false;
+ break;
+ case NArchive::kStartSignature:
+ {
+ if ((value->bstrVal = ::SysAllocStringByteLen((const char *)NArchive::N7z::kSignature,
+ NArchive::N7z::kSignatureSize)) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ }
+ propVariant.Detach(value);
+ return S_OK;
+}
diff --git a/7zip/Archive/7z/StdAfx.cpp b/CPP/7zip/Archive/7z/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/7z/StdAfx.cpp
+++ b/CPP/7zip/Archive/7z/StdAfx.cpp
diff --git a/7zip/Archive/7z/StdAfx.h b/CPP/7zip/Archive/7z/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Archive/7z/StdAfx.h
+++ b/CPP/7zip/Archive/7z/StdAfx.h
diff --git a/7zip/Archive/7z/makefile b/CPP/7zip/Archive/7z/makefile
index 06bf2f37..06bf2f37 100755
--- a/7zip/Archive/7z/makefile
+++ b/CPP/7zip/Archive/7z/makefile
diff --git a/7zip/Archive/7z/resource.rc b/CPP/7zip/Archive/7z/resource.rc
index 8868173c..8868173c 100755
--- a/7zip/Archive/7z/resource.rc
+++ b/CPP/7zip/Archive/7z/resource.rc
diff --git a/7zip/Archive/Archive.def b/CPP/7zip/Archive/Archive.def
index befc7d83..befc7d83 100755
--- a/7zip/Archive/Archive.def
+++ b/CPP/7zip/Archive/Archive.def
diff --git a/7zip/Archive/Arj/Arj.dsp b/CPP/7zip/Archive/Arj/Arj.dsp
index 3bc6fa91..3bc6fa91 100755
--- a/7zip/Archive/Arj/Arj.dsp
+++ b/CPP/7zip/Archive/Arj/Arj.dsp
diff --git a/7zip/Archive/Arj/Arj.dsw b/CPP/7zip/Archive/Arj/Arj.dsw
index 7ce4bca5..7ce4bca5 100755
--- a/7zip/Archive/Arj/Arj.dsw
+++ b/CPP/7zip/Archive/Arj/Arj.dsw
diff --git a/7zip/Archive/Arj/ArjHandler.cpp b/CPP/7zip/Archive/Arj/ArjHandler.cpp
index a61cc775..a61cc775 100755
--- a/7zip/Archive/Arj/ArjHandler.cpp
+++ b/CPP/7zip/Archive/Arj/ArjHandler.cpp
diff --git a/7zip/Archive/Arj/ArjHandler.h b/CPP/7zip/Archive/Arj/ArjHandler.h
index a1e69ba6..a1e69ba6 100755
--- a/7zip/Archive/Arj/ArjHandler.h
+++ b/CPP/7zip/Archive/Arj/ArjHandler.h
diff --git a/7zip/Archive/Arj/ArjHeader.h b/CPP/7zip/Archive/Arj/ArjHeader.h
index 58ee8c27..58ee8c27 100755
--- a/7zip/Archive/Arj/ArjHeader.h
+++ b/CPP/7zip/Archive/Arj/ArjHeader.h
diff --git a/7zip/Archive/Arj/ArjIn.cpp b/CPP/7zip/Archive/Arj/ArjIn.cpp
index 5d03ea65..5d03ea65 100755
--- a/7zip/Archive/Arj/ArjIn.cpp
+++ b/CPP/7zip/Archive/Arj/ArjIn.cpp
diff --git a/7zip/Archive/Arj/ArjIn.h b/CPP/7zip/Archive/Arj/ArjIn.h
index b73d7dba..b73d7dba 100755
--- a/7zip/Archive/Arj/ArjIn.h
+++ b/CPP/7zip/Archive/Arj/ArjIn.h
diff --git a/7zip/Archive/Arj/ArjItem.h b/CPP/7zip/Archive/Arj/ArjItem.h
index d48fe38d..d48fe38d 100755
--- a/7zip/Archive/Arj/ArjItem.h
+++ b/CPP/7zip/Archive/Arj/ArjItem.h
diff --git a/CPP/7zip/Archive/Arj/DllExports.cpp b/CPP/7zip/Archive/Arj/DllExports.cpp
new file mode 100755
index 00000000..d32ca2d6
--- /dev/null
+++ b/CPP/7zip/Archive/Arj/DllExports.cpp
@@ -0,0 +1,72 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+#include "Common/ComTry.h"
+#include "Windows/PropVariant.h"
+#include "../../ICoder.h"
+#include "ArjHandler.h"
+
+// {23170F69-40C1-278A-1000-000110040000}
+DEFINE_GUID(CLSID_CArjHandler,
+ 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x04, 0x00, 0x00);
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
+{
+ return TRUE;
+}
+
+STDAPI CreateObject(
+ const GUID *classID,
+ const GUID *interfaceID,
+ void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ if (*classID != CLSID_CArjHandler)
+ return CLASS_E_CLASSNOTAVAILABLE;
+ if (*interfaceID != IID_IInArchive)
+ return E_NOINTERFACE;
+ CMyComPtr<IInArchive> inArchive = (IInArchive *)new NArchive::NArj::CHandler;
+ *outObject = inArchive.Detach();
+ COM_TRY_END
+ return S_OK;
+}
+
+STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant propVariant;
+ switch(propID)
+ {
+ case NArchive::kName:
+ propVariant = L"Arj";
+ break;
+ case NArchive::kClassID:
+ {
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CArjHandler, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ case NArchive::kExtension:
+ propVariant = L"arj";
+ break;
+ case NArchive::kUpdate:
+ propVariant = false;
+ break;
+ case NArchive::kKeepName:
+ propVariant = false;
+ break;
+ case NArchive::kStartSignature:
+ {
+ const unsigned char sig[] = { 0x60, 0xEA };
+ if ((value->bstrVal = ::SysAllocStringByteLen((const char *)sig, 2)) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ }
+ propVariant.Detach(value);
+ return S_OK;
+}
diff --git a/7zip/Archive/Arj/StdAfx.cpp b/CPP/7zip/Archive/Arj/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Arj/StdAfx.cpp
+++ b/CPP/7zip/Archive/Arj/StdAfx.cpp
diff --git a/7zip/Archive/Arj/StdAfx.h b/CPP/7zip/Archive/Arj/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/Arj/StdAfx.h
+++ b/CPP/7zip/Archive/Arj/StdAfx.h
diff --git a/7zip/Archive/Arj/arj.ico b/CPP/7zip/Archive/Arj/arj.ico
index c0f8b141..c0f8b141 100755
--- a/7zip/Archive/Arj/arj.ico
+++ b/CPP/7zip/Archive/Arj/arj.ico
Binary files differ
diff --git a/7zip/Archive/Arj/makefile b/CPP/7zip/Archive/Arj/makefile
index 2609998b..2609998b 100755
--- a/7zip/Archive/Arj/makefile
+++ b/CPP/7zip/Archive/Arj/makefile
diff --git a/7zip/Archive/Arj/resource.rc b/CPP/7zip/Archive/Arj/resource.rc
index 5158e405..5158e405 100755
--- a/7zip/Archive/Arj/resource.rc
+++ b/CPP/7zip/Archive/Arj/resource.rc
diff --git a/7zip/Archive/BZip2/BZip2.dsp b/CPP/7zip/Archive/BZip2/BZip2.dsp
index 1d14aedb..1d14aedb 100755
--- a/7zip/Archive/BZip2/BZip2.dsp
+++ b/CPP/7zip/Archive/BZip2/BZip2.dsp
diff --git a/7zip/Archive/BZip2/BZip2.dsw b/CPP/7zip/Archive/BZip2/BZip2.dsw
index 697e5095..697e5095 100755
--- a/7zip/Archive/BZip2/BZip2.dsw
+++ b/CPP/7zip/Archive/BZip2/BZip2.dsw
diff --git a/CPP/7zip/Archive/BZip2/BZip2Handler.cpp b/CPP/7zip/Archive/BZip2/BZip2Handler.cpp
new file mode 100755
index 00000000..169b2597
--- /dev/null
+++ b/CPP/7zip/Archive/BZip2/BZip2Handler.cpp
@@ -0,0 +1,287 @@
+// BZip2Handler.cpp
+
+#include "StdAfx.h"
+
+#include "BZip2Handler.h"
+
+#include "Common/Defs.h"
+
+#include "../../Common/ProgressUtils.h"
+#include "../../Common/StreamUtils.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Defs.h"
+#include "Common/ComTry.h"
+
+#include "../Common/DummyOutStream.h"
+
+#ifdef COMPRESS_BZIP2
+#include "../../Compress/BZip2/BZip2Decoder.h"
+#else
+// {23170F69-40C1-278B-0402-020000000000}
+DEFINE_GUID(CLSID_CCompressBZip2Decoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
+#include "../Common/CoderLoader.h"
+extern CSysString GetBZip2CodecPath();
+#endif
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NBZip2 {
+
+STATPROPSTG kProperties[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ // { NULL, kpidIsFolder, VT_BOOL},
+ // { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackedSize, VT_UI8},
+};
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value)
+{
+ value->vt = VT_EMPTY;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
+{
+ *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
+ return E_INVALIDARG;
+ const STATPROPSTG &srcItem = kProperties[index];
+ *propID = srcItem.propid;
+ *varType = srcItem.vt;
+ *name = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
+{
+ *numProperties = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 /* index */,
+ BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */)
+{
+ return E_INVALIDARG;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant propVariant;
+ if (index != 0)
+ return E_INVALIDARG;
+ switch(propID)
+ {
+ case kpidIsFolder:
+ propVariant = false;
+ break;
+ case kpidPackedSize:
+ propVariant = _item.PackSize;
+ break;
+ }
+ propVariant.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ try
+ {
+ RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_streamStartPosition));
+ const int kSignatureSize = 3;
+ Byte buffer[kSignatureSize];
+ UInt32 processedSize;
+ RINOK(ReadStream(stream, buffer, kSignatureSize, &processedSize));
+ if (processedSize != kSignatureSize)
+ return S_FALSE;
+ if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h')
+ return S_FALSE;
+
+ UInt64 endPosition;
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPosition));
+ _item.PackSize = endPosition - _streamStartPosition;
+
+ _stream = stream;
+ }
+ catch(...)
+ {
+ return S_FALSE;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _stream.Release();
+ return S_OK;
+}
+
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (!allFilesMode)
+ {
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1)
+ return E_INVALIDARG;
+ if (indices[0] != 0)
+ return E_INVALIDARG;
+ }
+
+ bool testMode = (testModeSpec != 0);
+
+ extractCallback->SetTotal(_item.PackSize);
+
+ UInt64 currentTotalPacked = 0, currentTotalUnPacked = 0;
+
+ RINOK(extractCallback->SetCompleted(&currentTotalPacked));
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode;
+ askMode = testMode ? NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+
+ RINOK(extractCallback->GetStream(0, &realOutStream, askMode));
+
+ if(!testMode && !realOutStream)
+ return S_OK;
+
+
+ extractCallback->PrepareOperation(askMode);
+
+ #ifndef COMPRESS_BZIP2
+ CCoderLibrary lib;
+ #endif
+ CMyComPtr<ICompressCoder> decoder;
+ #ifdef COMPRESS_BZIP2
+ decoder = new NCompress::NBZip2::CDecoder;
+ #else
+ HRESULT loadResult = lib.LoadAndCreateCoder(
+ GetBZip2CodecPath(),
+ CLSID_CCompressBZip2Decoder, &decoder);
+ if (loadResult != S_OK)
+ {
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
+ return S_OK;
+ }
+ #endif
+
+ #ifdef COMPRESS_MT
+ {
+ CMyComPtr<ICompressSetCoderMt> setCoderMt;
+ decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
+ if (setCoderMt)
+ {
+ RINOK(setCoderMt->SetNumberOfThreads(_numThreads));
+ }
+ }
+ #endif
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->Init(realOutStream);
+
+ realOutStream.Release();
+
+ CLocalProgress *localProgressSpec = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = localProgressSpec;
+ localProgressSpec->Init(extractCallback, true);
+
+ CLocalCompressProgressInfo *localCompressProgressSpec =
+ new CLocalCompressProgressInfo;
+ CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
+
+ RINOK(_stream->Seek(_streamStartPosition, STREAM_SEEK_SET, NULL));
+
+
+ HRESULT result = S_OK;
+
+ bool firstItem = true;
+ for (;;)
+ {
+ localCompressProgressSpec->Init(progress,
+ &currentTotalPacked,
+ &currentTotalUnPacked);
+
+ const int kSignatureSize = 3;
+ Byte buffer[kSignatureSize];
+ UInt32 processedSize;
+ RINOK(ReadStream(_stream, buffer, kSignatureSize, &processedSize));
+ if (processedSize < kSignatureSize)
+ {
+ if (firstItem)
+ return E_FAIL;
+ break;
+ }
+ if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h')
+ {
+ if (firstItem)
+ return E_FAIL;
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK))
+ return S_OK;
+ }
+ firstItem = false;
+
+ UInt64 dataStartPos;
+ RINOK(_stream->Seek((UInt64)(Int64)(-3), STREAM_SEEK_CUR, &dataStartPos));
+
+ result = decoder->Code(_stream, outStream, NULL, NULL, compressProgress);
+
+ if (result != S_OK)
+ break;
+
+ CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize;
+ decoder.QueryInterface(IID_ICompressGetInStreamProcessedSize,
+ &getInStreamProcessedSize);
+ if (!getInStreamProcessedSize)
+ break;
+
+ UInt64 packSize;
+ RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&packSize));
+ UInt64 pos;
+ RINOK(_stream->Seek(dataStartPos + packSize, STREAM_SEEK_SET, &pos));
+ currentTotalPacked = pos - _streamStartPosition;
+ }
+ outStream.Release();
+
+ int retResult;
+ if (result == S_OK)
+ retResult = NArchive::NExtract::NOperationResult::kOK;
+ else if (result == S_FALSE)
+ retResult = NArchive::NExtract::NOperationResult::kDataError;
+ else
+ return result;
+
+ RINOK(extractCallback->SetOperationResult(retResult));
+
+ return S_OK;
+ COM_TRY_END
+}
+
+}}
diff --git a/7zip/Archive/BZip2/BZip2Handler.h b/CPP/7zip/Archive/BZip2/BZip2Handler.h
index 7977334e..7977334e 100755
--- a/7zip/Archive/BZip2/BZip2Handler.h
+++ b/CPP/7zip/Archive/BZip2/BZip2Handler.h
diff --git a/7zip/Archive/BZip2/BZip2HandlerOut.cpp b/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp
index b5fc72a9..b5fc72a9 100755
--- a/7zip/Archive/BZip2/BZip2HandlerOut.cpp
+++ b/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp
diff --git a/7zip/Archive/BZip2/BZip2Item.h b/CPP/7zip/Archive/BZip2/BZip2Item.h
index d7508ab9..d7508ab9 100755
--- a/7zip/Archive/BZip2/BZip2Item.h
+++ b/CPP/7zip/Archive/BZip2/BZip2Item.h
diff --git a/7zip/Archive/BZip2/BZip2Update.cpp b/CPP/7zip/Archive/BZip2/BZip2Update.cpp
index d9bdf963..d9bdf963 100755
--- a/7zip/Archive/BZip2/BZip2Update.cpp
+++ b/CPP/7zip/Archive/BZip2/BZip2Update.cpp
diff --git a/7zip/Archive/BZip2/BZip2Update.h b/CPP/7zip/Archive/BZip2/BZip2Update.h
index ce20e323..ce20e323 100755
--- a/7zip/Archive/BZip2/BZip2Update.h
+++ b/CPP/7zip/Archive/BZip2/BZip2Update.h
diff --git a/7zip/Archive/BZip2/DllExports.cpp b/CPP/7zip/Archive/BZip2/DllExports.cpp
index 5a861318..5a861318 100755
--- a/7zip/Archive/BZip2/DllExports.cpp
+++ b/CPP/7zip/Archive/BZip2/DllExports.cpp
diff --git a/7zip/Archive/BZip2/StdAfx.cpp b/CPP/7zip/Archive/BZip2/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/BZip2/StdAfx.cpp
+++ b/CPP/7zip/Archive/BZip2/StdAfx.cpp
diff --git a/7zip/Archive/BZip2/StdAfx.h b/CPP/7zip/Archive/BZip2/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/BZip2/StdAfx.h
+++ b/CPP/7zip/Archive/BZip2/StdAfx.h
diff --git a/7zip/Archive/BZip2/bz2.ico b/CPP/7zip/Archive/BZip2/bz2.ico
index 614e3540..614e3540 100755
--- a/7zip/Archive/BZip2/bz2.ico
+++ b/CPP/7zip/Archive/BZip2/bz2.ico
Binary files differ
diff --git a/7zip/Archive/BZip2/makefile b/CPP/7zip/Archive/BZip2/makefile
index 20f20bdb..20f20bdb 100755
--- a/7zip/Archive/BZip2/makefile
+++ b/CPP/7zip/Archive/BZip2/makefile
diff --git a/7zip/Archive/BZip2/resource.rc b/CPP/7zip/Archive/BZip2/resource.rc
index 2d4f27e3..2d4f27e3 100755
--- a/7zip/Archive/BZip2/resource.rc
+++ b/CPP/7zip/Archive/BZip2/resource.rc
diff --git a/7zip/Archive/Cab/Cab.dsp b/CPP/7zip/Archive/Cab/Cab.dsp
index 565661f6..565661f6 100755
--- a/7zip/Archive/Cab/Cab.dsp
+++ b/CPP/7zip/Archive/Cab/Cab.dsp
diff --git a/7zip/Archive/Cab/Cab.dsw b/CPP/7zip/Archive/Cab/Cab.dsw
index 470cb1b3..470cb1b3 100755
--- a/7zip/Archive/Cab/Cab.dsw
+++ b/CPP/7zip/Archive/Cab/Cab.dsw
diff --git a/7zip/Archive/Cab/CabBlockInStream.cpp b/CPP/7zip/Archive/Cab/CabBlockInStream.cpp
index b775c105..b775c105 100755
--- a/7zip/Archive/Cab/CabBlockInStream.cpp
+++ b/CPP/7zip/Archive/Cab/CabBlockInStream.cpp
diff --git a/7zip/Archive/Cab/CabBlockInStream.h b/CPP/7zip/Archive/Cab/CabBlockInStream.h
index 46e15222..46e15222 100755
--- a/7zip/Archive/Cab/CabBlockInStream.h
+++ b/CPP/7zip/Archive/Cab/CabBlockInStream.h
diff --git a/7zip/Archive/Cab/CabHandler.cpp b/CPP/7zip/Archive/Cab/CabHandler.cpp
index cac79b11..cac79b11 100755
--- a/7zip/Archive/Cab/CabHandler.cpp
+++ b/CPP/7zip/Archive/Cab/CabHandler.cpp
diff --git a/7zip/Archive/Cab/CabHandler.h b/CPP/7zip/Archive/Cab/CabHandler.h
index 245586b6..245586b6 100755
--- a/7zip/Archive/Cab/CabHandler.h
+++ b/CPP/7zip/Archive/Cab/CabHandler.h
diff --git a/7zip/Archive/Cab/CabHeader.cpp b/CPP/7zip/Archive/Cab/CabHeader.cpp
index 37533dff..37533dff 100755
--- a/7zip/Archive/Cab/CabHeader.cpp
+++ b/CPP/7zip/Archive/Cab/CabHeader.cpp
diff --git a/7zip/Archive/Cab/CabHeader.h b/CPP/7zip/Archive/Cab/CabHeader.h
index 5c122743..5c122743 100755
--- a/7zip/Archive/Cab/CabHeader.h
+++ b/CPP/7zip/Archive/Cab/CabHeader.h
diff --git a/CPP/7zip/Archive/Cab/CabIn.cpp b/CPP/7zip/Archive/Cab/CabIn.cpp
new file mode 100755
index 00000000..ae774f19
--- /dev/null
+++ b/CPP/7zip/Archive/Cab/CabIn.cpp
@@ -0,0 +1,343 @@
+// Archive/CabIn.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+#include "Common/MyCom.h"
+#include "CabIn.h"
+#include "Windows/Defs.h"
+
+#include "../../Common/StreamUtils.h"
+
+namespace NArchive{
+namespace NCab{
+
+/*
+static HRESULT ReadBytes(IInStream *inStream, void *data, UInt32 size)
+{
+ UInt32 realProcessedSize;
+ RINOK(ReadStream(inStream, data, size, &realProcessedSize));
+ if(realProcessedSize != size)
+ return S_FALSE;
+ return S_OK;
+}
+
+static HRESULT SafeRead(IInStream *inStream, void *data, UInt32 size)
+{
+ UInt32 realProcessedSize;
+ RINOK(ReadStream(inStream, data, size, &realProcessedSize));
+ if(realProcessedSize != size)
+ throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
+ return S_OK;
+}
+
+static void SafeInByteRead(::CInBuffer &inBuffer, void *data, UInt32 size)
+{
+ UInt32 realProcessedSize;
+ inBuffer.ReadBytes(data, size, realProcessedSize);
+ if(realProcessedSize != size)
+ throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
+}
+*/
+
+Byte CInArchive::ReadByte()
+{
+ Byte b;
+ if (!inBuffer.ReadByte(b))
+ throw CInArchiveException(CInArchiveException::kUnsupported);
+ return b;
+}
+
+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;
+}
+
+AString CInArchive::SafeReadName()
+{
+ AString name;
+ for (;;)
+ {
+ Byte b = ReadByte();
+ if (b == 0)
+ return name;
+ name += (char)b;
+ }
+}
+
+void CInArchive::ReadOtherArchive(COtherArchive &oa)
+{
+ oa.FileName = SafeReadName();
+ oa.DiskName = SafeReadName();
+}
+
+void CInArchive::Skeep(size_t size)
+{
+ while (size-- != 0)
+ ReadByte();
+}
+
+HRESULT CInArchive::Open2(IInStream *inStream,
+ const UInt64 *searchHeaderSizeLimit,
+ CDatabase &database)
+{
+ database.Clear();
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &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;
+ }
+
+ CInArchiveInfo &archiveInfo = database.ArchiveInfo;
+
+ archiveInfo.Size = ReadUInt32(); // size of this cabinet file in bytes
+ if (ReadUInt32() != 0)
+ return S_FALSE;
+ archiveInfo.FileHeadersOffset = ReadUInt32(); // offset of the first CFFILE entry
+ if (ReadUInt32() != 0)
+ return S_FALSE;
+
+ archiveInfo.VersionMinor = ReadByte(); // cabinet file format version, minor
+ 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.SetID = ReadUInt16(); // must be the same for all cabinets in a set
+ archiveInfo.CabinetNumber = ReadUInt16(); // number of this cabinet file in a set
+
+ if (archiveInfo.ReserveBlockPresent())
+ {
+ archiveInfo.PerCabinetAreaSize = ReadUInt16(); // (optional) size of per-cabinet reserved area
+ archiveInfo.PerFolderAreaSize = ReadByte(); // (optional) size of per-folder reserved area
+ archiveInfo.PerDataBlockAreaSize = ReadByte(); // (optional) size of per-datablock reserved area
+
+ Skeep(archiveInfo.PerCabinetAreaSize);
+ }
+
+ {
+ if (archiveInfo.IsTherePrev())
+ ReadOtherArchive(archiveInfo.PreviousArchive);
+ if (archiveInfo.IsThereNext())
+ ReadOtherArchive(archiveInfo.NextArchive);
+ }
+
+ int i;
+ for(i = 0; i < archiveInfo.NumFolders; i++)
+ {
+ CFolder folder;
+
+ folder.DataStart = ReadUInt32();
+ folder.NumDataBlocks = ReadUInt16();
+ folder.CompressionTypeMajor = ReadByte();
+ folder.CompressionTypeMinor = ReadByte();
+
+ Skeep(archiveInfo.PerFolderAreaSize);
+ database.Folders.Add(folder);
+ }
+
+ RINOK(inStream->Seek(database.StartPosition + archiveInfo.FileHeadersOffset, STREAM_SEEK_SET, NULL));
+
+ inBuffer.SetStream(inStream);
+ inBuffer.Init();
+ for(i = 0; i < archiveInfo.NumFiles; i++)
+ {
+ CItem item;
+ item.Size = ReadUInt32();
+ item.Offset = ReadUInt32();
+ item.FolderIndex = ReadUInt16();
+ UInt16 pureDate = ReadUInt16();
+ UInt16 pureTime = ReadUInt16();
+ item.Time = ((UInt32(pureDate) << 16)) | pureTime;
+ item.Attributes = ReadUInt16();
+ item.Name = SafeReadName();
+ int folderIndex = item.GetFolderIndex(database.Folders.Size());
+ if (folderIndex >= database.Folders.Size())
+ return S_FALSE;
+ database.Items.Add(item);
+ }
+ return S_OK;
+}
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+HRESULT CInArchive::Open(
+ const UInt64 *searchHeaderSizeLimit,
+ CDatabaseEx &database)
+{
+ return Open2(database.Stream, searchHeaderSizeLimit, database);
+}
+
+
+static int CompareMvItems2(const CMvItem *p1, const CMvItem *p2)
+{
+ RINOZ(MyCompare(p1->VolumeIndex, p2->VolumeIndex));
+ return MyCompare(p1->ItemIndex, p2->ItemIndex);
+}
+
+static int CompareMvItems(const CMvItem *p1, const CMvItem *p2, void *param)
+{
+ const CMvDatabaseEx &mvDb = *(const CMvDatabaseEx *)param;
+ const CDatabaseEx &db1 = mvDb.Volumes[p1->VolumeIndex];
+ 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();
+ if (isDir1 && !isDir2)
+ return -1;
+ if (isDir2 && !isDir1)
+ return 1;
+ int f1 = mvDb.GetFolderIndex(p1);
+ int f2 = mvDb.GetFolderIndex(p2);
+ RINOZ(MyCompare(f1, f2));
+ RINOZ(MyCompare(item1.Offset, item2.Offset));
+ RINOZ(MyCompare(item1.Size, item2.Size));
+ return CompareMvItems2(p1, p2);
+}
+
+bool CMvDatabaseEx::AreItemsEqual(int i1, int i2)
+{
+ const CMvItem *p1 = &Items[i1];
+ const CMvItem *p2 = &Items[i2];
+ const CDatabaseEx &db1 = Volumes[p1->VolumeIndex];
+ const CDatabaseEx &db2 = Volumes[p2->VolumeIndex];
+ const CItem &item1 = db1.Items[p1->ItemIndex];
+ const CItem &item2 = db2.Items[p2->ItemIndex];;
+ int f1 = GetFolderIndex(p1);
+ int f2 = GetFolderIndex(p2);
+ if (f1 != f2)
+ return false;
+ if (item1.Offset != item2.Offset)
+ return false;
+ if (item1.Size != item2.Size)
+ return false;
+
+ return true;
+}
+
+void CMvDatabaseEx::FillSortAndShrink()
+{
+ Items.Clear();
+ StartFolderOfVol.Clear();
+ FolderStartFileIndex.Clear();
+ int offset = 0;
+ for (int v = 0; v < Volumes.Size(); v++)
+ {
+ const CDatabaseEx &db = Volumes[v];
+ int curOffset = offset;
+ if (db.IsTherePrevFolder())
+ curOffset--;
+ StartFolderOfVol.Add(curOffset);
+ offset += db.GetNumberOfNewFolders();
+
+ CMvItem mvItem;
+ mvItem.VolumeIndex = v;
+ for (int i = 0 ; i < db.Items.Size(); i++)
+ {
+ mvItem.ItemIndex = i;
+ Items.Add(mvItem);
+ }
+ }
+
+ Items.Sort(CompareMvItems, (void *)this);
+ int j = 1;
+ int i;
+ for (i = 1; i < Items.Size(); i++)
+ if (!AreItemsEqual(i, i -1))
+ Items[j++] = Items[i];
+ Items.DeleteFrom(j);
+
+ for (i = 0; i < Items.Size(); i++)
+ {
+ const CMvItem &mvItem = Items[i];
+ int folderIndex = GetFolderIndex(&mvItem);
+ if (folderIndex >= FolderStartFileIndex.Size())
+ FolderStartFileIndex.Add(i);
+ }
+}
+
+bool CMvDatabaseEx::Check()
+{
+ for (int v = 1; v < Volumes.Size(); v++)
+ {
+ const CDatabaseEx &db1 = Volumes[v];
+ if (db1.IsTherePrevFolder())
+ {
+ const CDatabaseEx &db0 = Volumes[v - 1];
+ if (db0.Folders.IsEmpty() || db1.Folders.IsEmpty())
+ return false;
+ const CFolder &f0 = db0.Folders.Back();
+ const CFolder &f1 = db1.Folders.Front();
+ if (f0.CompressionTypeMajor != f1.CompressionTypeMajor ||
+ f0.CompressionTypeMinor != f1.CompressionTypeMinor)
+ return false;
+ }
+ }
+ UInt64 maxPos = 0;
+ int prevFolder = -2;
+ for(int i = 0; i < Items.Size(); i++)
+ {
+ const CMvItem &mvItem = Items[i];
+ int fIndex = GetFolderIndex(&mvItem);
+ if (fIndex >= FolderStartFileIndex.Size())
+ return false;
+ const CItem &item = Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
+ if (item.IsDirectory())
+ continue;
+ int folderIndex = GetFolderIndex(&mvItem);
+ if (folderIndex != prevFolder)
+ {
+ prevFolder = folderIndex;
+ maxPos = 0;
+ continue;
+ }
+ if (item.Offset < maxPos)
+ return false;
+ maxPos = item.GetEndOffset();
+ if (maxPos < item.Offset)
+ return false;
+ }
+ return true;
+}
+
+}}
diff --git a/CPP/7zip/Archive/Cab/CabIn.h b/CPP/7zip/Archive/Cab/CabIn.h
new file mode 100755
index 00000000..aa3008f1
--- /dev/null
+++ b/CPP/7zip/Archive/Cab/CabIn.h
@@ -0,0 +1,166 @@
+// Archive/CabIn.h
+
+#ifndef __ARCHIVE_CAB_IN_H
+#define __ARCHIVE_CAB_IN_H
+
+#include "../../IStream.h"
+#include "../../Common/InBuffer.h"
+#include "CabHeader.h"
+#include "CabItem.h"
+
+namespace NArchive {
+namespace NCab {
+
+class CInArchiveException
+{
+public:
+ enum CCauseType
+ {
+ kUnexpectedEndOfArchive = 0,
+ kIncorrectArchive,
+ kUnsupported,
+ } Cause;
+ CInArchiveException(CCauseType cause) : Cause(cause) {}
+};
+
+struct COtherArchive
+{
+ AString FileName;
+ AString DiskName;
+};
+
+struct CArchiveInfo
+{
+ Byte VersionMinor; /* cabinet file format version, minor */
+ Byte VersionMajor; /* cabinet file format version, major */
+ UInt16 NumFolders; /* number of CFFOLDER entries in this cabinet */
+ UInt16 NumFiles; /* number of CFFILE entries in this cabinet */
+ UInt16 Flags; /* cabinet file option indicators */
+ UInt16 SetID; /* must be the same for all cabinets in a set */
+ UInt16 CabinetNumber; /* number of this cabinet file in a set */
+
+ bool ReserveBlockPresent() const { return (Flags & NHeader::NArchive::NFlags::kReservePresent) != 0; }
+
+ bool IsTherePrev() const { return (Flags & NHeader::NArchive::NFlags::kPrevCabinet) != 0; }
+ bool IsThereNext() const { return (Flags & NHeader::NArchive::NFlags::kNextCabinet) != 0; }
+
+ UInt16 PerCabinetAreaSize; // (optional) size of per-cabinet reserved area
+ Byte PerFolderAreaSize; // (optional) size of per-folder reserved area
+ Byte PerDataBlockAreaSize; // (optional) size of per-datablock reserved area
+
+ Byte GetDataBlockReserveSize() const { return (Byte)(ReserveBlockPresent() ? PerDataBlockAreaSize : 0); }
+
+ COtherArchive PreviousArchive;
+ COtherArchive NextArchive;
+
+ CArchiveInfo()
+ {
+ Clear();
+ }
+
+ void Clear()
+ {
+ PerCabinetAreaSize = 0;
+ PerFolderAreaSize = 0;
+ PerDataBlockAreaSize = 0;
+ }
+};
+
+struct CInArchiveInfo: public CArchiveInfo
+{
+ UInt32 Size; /* size of this cabinet file in bytes */
+ UInt32 FileHeadersOffset; // offset of the first CFFILE entry
+};
+
+
+class CDatabase
+{
+public:
+ UInt64 StartPosition;
+ CInArchiveInfo ArchiveInfo;
+ CObjectVector<CFolder> Folders;
+ CObjectVector<CItem> Items;
+ void Clear()
+ {
+ ArchiveInfo.Clear();
+ Folders.Clear();
+ Items.Clear();
+ }
+ bool IsTherePrevFolder() const
+ {
+ for (int i = 0; i < Items.Size(); i++)
+ if (Items[i].ContinuedFromPrev())
+ return true;
+ return false;
+ }
+ int GetNumberOfNewFolders() const
+ {
+ int res = Folders.Size();
+ if (IsTherePrevFolder())
+ res--;
+ return res;
+ }
+ UInt32 GetFileOffset(int index) const { return Items[index].Offset; }
+ UInt32 GetFileSize(int index) const { return Items[index].Size; }
+};
+
+class CDatabaseEx: public CDatabase
+{
+public:
+ CMyComPtr<IInStream> Stream;
+};
+
+struct CMvItem
+{
+ int VolumeIndex;
+ int ItemIndex;
+};
+
+class CMvDatabaseEx
+{
+ bool AreItemsEqual(int i1, int i2);
+public:
+ CObjectVector<CDatabaseEx> Volumes;
+ CRecordVector<CMvItem> Items;
+ CRecordVector<int> StartFolderOfVol;
+ CRecordVector<int> FolderStartFileIndex;
+ int GetFolderIndex(const CMvItem *mvi) const
+ {
+ const CDatabaseEx &db = Volumes[mvi->VolumeIndex];
+ return StartFolderOfVol[mvi->VolumeIndex] +
+ db.Items[mvi->ItemIndex].GetFolderIndex(db.Folders.Size());
+ }
+ void Clear()
+ {
+ Volumes.Clear();
+ Items.Clear();
+ StartFolderOfVol.Clear();
+ FolderStartFileIndex.Clear();
+ }
+ void FillSortAndShrink();
+ bool Check();
+};
+
+class CInArchive
+{
+ CInBuffer inBuffer;
+
+ Byte ReadByte();
+ UInt16 ReadUInt16();
+ UInt32 ReadUInt32();
+ AString SafeReadName();
+ void Skeep(size_t size);
+ void ReadOtherArchive(COtherArchive &oa);
+
+ HRESULT Open2(IInStream *inStream,
+ const UInt64 *searchHeaderSizeLimit,
+ CDatabase &database);
+public:
+ HRESULT Open(
+ const UInt64 *searchHeaderSizeLimit,
+ CDatabaseEx &database);
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Archive/Cab/CabItem.h b/CPP/7zip/Archive/Cab/CabItem.h
new file mode 100755
index 00000000..21327eca
--- /dev/null
+++ b/CPP/7zip/Archive/Cab/CabItem.h
@@ -0,0 +1,62 @@
+// Archive/CabItem.h
+
+#ifndef __ARCHIVE_CAB_ITEM_H
+#define __ARCHIVE_CAB_ITEM_H
+
+#include "Common/Types.h"
+#include "Common/String.h"
+#include "CabHeader.h"
+
+namespace NArchive {
+namespace NCab {
+
+struct CFolder
+{
+ UInt32 DataStart; // offset of the first CFDATA block in this folder
+ UInt16 NumDataBlocks; // number of CFDATA blocks in this folder
+ Byte CompressionTypeMajor;
+ Byte CompressionTypeMinor;
+ Byte GetCompressionMethod() const { return (Byte)(CompressionTypeMajor & 0xF); }
+};
+
+class CItem
+{
+public:
+ AString Name;
+ UInt32 Offset;
+ UInt32 Size;
+ UInt32 Time;
+ 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 ContinuedFromPrev() const
+ {
+ return
+ (FolderIndex == NHeader::NFolderIndex::kContinuedFromPrev) ||
+ (FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext);
+ }
+ bool ContinuedToNext() const
+ {
+ return
+ (FolderIndex == NHeader::NFolderIndex::kContinuedToNext) ||
+ (FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext);
+ }
+
+ int GetFolderIndex(int numFolders) const
+ {
+ if (ContinuedFromPrev())
+ return 0;
+ if (ContinuedToNext())
+ return (numFolders - 1);
+ return FolderIndex;
+ }
+};
+
+}}
+
+#endif
diff --git a/7zip/Archive/Cab/DllExports.cpp b/CPP/7zip/Archive/Cab/DllExports.cpp
index fa17f10b..fa17f10b 100755
--- a/7zip/Archive/Cab/DllExports.cpp
+++ b/CPP/7zip/Archive/Cab/DllExports.cpp
diff --git a/7zip/Archive/Cab/StdAfx.cpp b/CPP/7zip/Archive/Cab/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Cab/StdAfx.cpp
+++ b/CPP/7zip/Archive/Cab/StdAfx.cpp
diff --git a/7zip/Archive/Cab/StdAfx.h b/CPP/7zip/Archive/Cab/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/Cab/StdAfx.h
+++ b/CPP/7zip/Archive/Cab/StdAfx.h
diff --git a/7zip/Archive/Cab/cab.ico b/CPP/7zip/Archive/Cab/cab.ico
index cc2007fc..cc2007fc 100755
--- a/7zip/Archive/Cab/cab.ico
+++ b/CPP/7zip/Archive/Cab/cab.ico
Binary files differ
diff --git a/7zip/Archive/Cab/makefile b/CPP/7zip/Archive/Cab/makefile
index 672afed3..672afed3 100755
--- a/7zip/Archive/Cab/makefile
+++ b/CPP/7zip/Archive/Cab/makefile
diff --git a/7zip/Archive/Cab/resource.rc b/CPP/7zip/Archive/Cab/resource.rc
index fa0792bd..fa0792bd 100755
--- a/7zip/Archive/Cab/resource.rc
+++ b/CPP/7zip/Archive/Cab/resource.rc
diff --git a/7zip/Archive/Chm/Chm.dsp b/CPP/7zip/Archive/Chm/Chm.dsp
index 7e0b7c66..7e0b7c66 100755
--- a/7zip/Archive/Chm/Chm.dsp
+++ b/CPP/7zip/Archive/Chm/Chm.dsp
diff --git a/7zip/Archive/Chm/Chm.dsw b/CPP/7zip/Archive/Chm/Chm.dsw
index 58cb09b2..58cb09b2 100755
--- a/7zip/Archive/Chm/Chm.dsw
+++ b/CPP/7zip/Archive/Chm/Chm.dsw
diff --git a/7zip/Archive/Chm/ChmHandler.cpp b/CPP/7zip/Archive/Chm/ChmHandler.cpp
index 6b37c73e..6b37c73e 100755
--- a/7zip/Archive/Chm/ChmHandler.cpp
+++ b/CPP/7zip/Archive/Chm/ChmHandler.cpp
diff --git a/7zip/Archive/Chm/ChmHandler.h b/CPP/7zip/Archive/Chm/ChmHandler.h
index dd0692ba..dd0692ba 100755
--- a/7zip/Archive/Chm/ChmHandler.h
+++ b/CPP/7zip/Archive/Chm/ChmHandler.h
diff --git a/7zip/Archive/Chm/ChmHeader.cpp b/CPP/7zip/Archive/Chm/ChmHeader.cpp
index 4d485b6c..4d485b6c 100755
--- a/7zip/Archive/Chm/ChmHeader.cpp
+++ b/CPP/7zip/Archive/Chm/ChmHeader.cpp
diff --git a/7zip/Archive/Chm/ChmHeader.h b/CPP/7zip/Archive/Chm/ChmHeader.h
index 9f1bd42b..9f1bd42b 100755
--- a/7zip/Archive/Chm/ChmHeader.h
+++ b/CPP/7zip/Archive/Chm/ChmHeader.h
diff --git a/7zip/Archive/Chm/ChmIn.cpp b/CPP/7zip/Archive/Chm/ChmIn.cpp
index 8c56ec91..8c56ec91 100755
--- a/7zip/Archive/Chm/ChmIn.cpp
+++ b/CPP/7zip/Archive/Chm/ChmIn.cpp
diff --git a/7zip/Archive/Chm/ChmIn.h b/CPP/7zip/Archive/Chm/ChmIn.h
index ebf3c4be..ebf3c4be 100755
--- a/7zip/Archive/Chm/ChmIn.h
+++ b/CPP/7zip/Archive/Chm/ChmIn.h
diff --git a/7zip/Archive/Chm/DllExports.cpp b/CPP/7zip/Archive/Chm/DllExports.cpp
index ad822094..ad822094 100755
--- a/7zip/Archive/Chm/DllExports.cpp
+++ b/CPP/7zip/Archive/Chm/DllExports.cpp
diff --git a/7zip/Archive/Chm/StdAfx.cpp b/CPP/7zip/Archive/Chm/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Chm/StdAfx.cpp
+++ b/CPP/7zip/Archive/Chm/StdAfx.cpp
diff --git a/7zip/Archive/Chm/StdAfx.h b/CPP/7zip/Archive/Chm/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/Chm/StdAfx.h
+++ b/CPP/7zip/Archive/Chm/StdAfx.h
diff --git a/7zip/Archive/Chm/makefile b/CPP/7zip/Archive/Chm/makefile
index 4adce2f5..4adce2f5 100755
--- a/7zip/Archive/Chm/makefile
+++ b/CPP/7zip/Archive/Chm/makefile
diff --git a/7zip/Archive/Chm/resource.rc b/CPP/7zip/Archive/Chm/resource.rc
index fc93ae4f..fc93ae4f 100755
--- a/7zip/Archive/Chm/resource.rc
+++ b/CPP/7zip/Archive/Chm/resource.rc
diff --git a/7zip/Archive/Common/CodecsPath.cpp b/CPP/7zip/Archive/Common/CodecsPath.cpp
index 7ee89875..7ee89875 100755
--- a/7zip/Archive/Common/CodecsPath.cpp
+++ b/CPP/7zip/Archive/Common/CodecsPath.cpp
diff --git a/7zip/Archive/Common/CodecsPath.h b/CPP/7zip/Archive/Common/CodecsPath.h
index 11145a03..11145a03 100755
--- a/7zip/Archive/Common/CodecsPath.h
+++ b/CPP/7zip/Archive/Common/CodecsPath.h
diff --git a/7zip/Archive/Common/CoderLoader.cpp b/CPP/7zip/Archive/Common/CoderLoader.cpp
index bf54f6e0..bf54f6e0 100755
--- a/7zip/Archive/Common/CoderLoader.cpp
+++ b/CPP/7zip/Archive/Common/CoderLoader.cpp
diff --git a/7zip/Archive/Common/CoderLoader.h b/CPP/7zip/Archive/Common/CoderLoader.h
index 02322d8c..02322d8c 100755
--- a/7zip/Archive/Common/CoderLoader.h
+++ b/CPP/7zip/Archive/Common/CoderLoader.h
diff --git a/7zip/Archive/Common/CoderMixer2.cpp b/CPP/7zip/Archive/Common/CoderMixer2.cpp
index 8f46e985..8f46e985 100755
--- a/7zip/Archive/Common/CoderMixer2.cpp
+++ b/CPP/7zip/Archive/Common/CoderMixer2.cpp
diff --git a/7zip/Archive/Common/CoderMixer2.h b/CPP/7zip/Archive/Common/CoderMixer2.h
index 78a3f280..78a3f280 100755
--- a/7zip/Archive/Common/CoderMixer2.h
+++ b/CPP/7zip/Archive/Common/CoderMixer2.h
diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
new file mode 100755
index 00000000..9d7944b1
--- /dev/null
+++ b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
@@ -0,0 +1,359 @@
+// CoderMixer2MT.cpp
+
+#include "StdAfx.h"
+
+#include "CoderMixer2MT.h"
+#include "CrossThreadProgress.h"
+
+using namespace NWindows;
+using namespace NSynchronization;
+
+namespace NCoderMixer2 {
+
+CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams):
+ ExitEvent(NULL),
+ CompressEvent(NULL),
+ CompressionCompletedEvent(NULL),
+ CCoderInfo(numInStreams, numOutStreams)
+{
+ InStreams.Reserve(NumInStreams);
+ InStreamPointers.Reserve(NumInStreams);
+ OutStreams.Reserve(NumOutStreams);
+ OutStreamPointers.Reserve(NumOutStreams);
+}
+
+void CThreadCoderInfo::CreateEvents()
+{
+ CompressEvent = new CAutoResetEvent(false);
+ CompressionCompletedEvent = new CAutoResetEvent(false);
+}
+
+CThreadCoderInfo::~CThreadCoderInfo()
+{
+ if (CompressEvent != NULL)
+ delete CompressEvent;
+ if (CompressionCompletedEvent != NULL)
+ delete CompressionCompletedEvent;
+}
+
+class CCoderInfoFlusher2
+{
+ CThreadCoderInfo *m_CoderInfo;
+public:
+ CCoderInfoFlusher2(CThreadCoderInfo *coderInfo): m_CoderInfo(coderInfo) {}
+ ~CCoderInfoFlusher2()
+ {
+ int i;
+ for (i = 0; i < m_CoderInfo->InStreams.Size(); i++)
+ m_CoderInfo->InStreams[i].Release();
+ for (i = 0; i < m_CoderInfo->OutStreams.Size(); i++)
+ m_CoderInfo->OutStreams[i].Release();
+ m_CoderInfo->CompressionCompletedEvent->Set();
+ }
+};
+
+bool CThreadCoderInfo::WaitAndCode()
+{
+ HANDLE events[2] = { ExitEvent, *CompressEvent };
+ DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
+ if (waitResult == WAIT_OBJECT_0 + 0)
+ return false;
+
+ {
+ InStreamPointers.Clear();
+ OutStreamPointers.Clear();
+ UInt32 i;
+ for (i = 0; i < NumInStreams; i++)
+ {
+ if (InSizePointers[i] != NULL)
+ InSizePointers[i] = &InSizes[i];
+ InStreamPointers.Add(InStreams[i]);
+ }
+ for (i = 0; i < NumOutStreams; i++)
+ {
+ if (OutSizePointers[i] != NULL)
+ OutSizePointers[i] = &OutSizes[i];
+ OutStreamPointers.Add(OutStreams[i]);
+ }
+ CCoderInfoFlusher2 coderInfoFlusher(this);
+ if (Coder)
+ Result = Coder->Code(InStreamPointers[0],
+ OutStreamPointers[0],
+ InSizePointers[0],
+ OutSizePointers[0],
+ Progress);
+ else
+ Result = Coder2->Code(&InStreamPointers.Front(),
+ &InSizePointers.Front(),
+ NumInStreams,
+ &OutStreamPointers.Front(),
+ &OutSizePointers.Front(),
+ NumOutStreams,
+ Progress);
+ }
+ return true;
+}
+
+static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
+ CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems)
+{
+ sizes.Clear();
+ sizePointers.Clear();
+ for(UInt32 i = 0; i < numItems; i++)
+ {
+ if (srcSizes == 0 || srcSizes[i] == NULL)
+ {
+ sizes.Add(0);
+ sizePointers.Add(NULL);
+ }
+ else
+ {
+ sizes.Add(*srcSizes[i]);
+ sizePointers.Add(&sizes.Back());
+ }
+ }
+}
+
+
+void CThreadCoderInfo::SetCoderInfo(const UInt64 **inSizes,
+ const UInt64 **outSizes, ICompressProgressInfo *progress)
+{
+ Progress = progress;
+ SetSizes(inSizes, InSizes, InSizePointers, NumInStreams);
+ SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
+}
+
+static DWORD WINAPI CoderThread(void *threadCoderInfo)
+{
+ for (;;)
+ {
+ if (!((CThreadCoderInfo *)threadCoderInfo)->WaitAndCode())
+ return 0;
+ }
+}
+
+//////////////////////////////////////
+// CCoderMixer2MT
+
+static DWORD WINAPI MainCoderThread(void *threadCoderInfo)
+{
+ for (;;)
+ {
+ if (!((CCoderMixer2MT *)threadCoderInfo)->MyCode())
+ return 0;
+ }
+}
+
+CCoderMixer2MT::CCoderMixer2MT()
+{
+ if (!_mainThread.Create(MainCoderThread, this))
+ throw 271825;
+}
+
+CCoderMixer2MT::~CCoderMixer2MT()
+{
+ _exitEvent.Set();
+ _mainThread.Wait();
+ for(int i = 0; i < _threads.Size(); i++)
+ {
+ _threads[i].Wait();
+ _threads[i].Close();
+ }
+}
+
+void CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
+{
+ _bindInfo = bindInfo;
+ _streamBinders.Clear();
+ for(int i = 0; i < _bindInfo.BindPairs.Size(); i++)
+ {
+ _streamBinders.Add(CStreamBinder());
+ _streamBinders.Back().CreateEvents();
+ }
+}
+
+void CCoderMixer2MT::AddCoderCommon()
+{
+ int index = _coderInfoVector.Size();
+ const CCoderStreamsInfo &CoderStreamsInfo = _bindInfo.Coders[index];
+
+ CThreadCoderInfo threadCoderInfo(CoderStreamsInfo.NumInStreams,
+ CoderStreamsInfo.NumOutStreams);
+ _coderInfoVector.Add(threadCoderInfo);
+ _coderInfoVector.Back().CreateEvents();
+ _coderInfoVector.Back().ExitEvent = _exitEvent;
+ _compressingCompletedEvents.Add(*_coderInfoVector.Back().CompressionCompletedEvent);
+
+ NWindows::CThread newThread;
+ _threads.Add(newThread);
+ if (!_threads.Back().Create(CoderThread, &_coderInfoVector.Back()))
+ throw 271824;
+}
+
+void CCoderMixer2MT::AddCoder(ICompressCoder *coder)
+{
+ AddCoderCommon();
+ _coderInfoVector.Back().Coder = coder;
+}
+
+void CCoderMixer2MT::AddCoder2(ICompressCoder2 *coder)
+{
+ AddCoderCommon();
+ _coderInfoVector.Back().Coder2 = coder;
+}
+
+/*
+void CCoderMixer2MT::FinishAddingCoders()
+{
+ for(int i = 0; i < _coderInfoVector.Size(); i++)
+ {
+ DWORD id;
+ HANDLE newThread = ::CreateThread(NULL, 0, CoderThread,
+ &_coderInfoVector[i], 0, &id);
+ if (newThread == 0)
+ throw 271824;
+ _threads.Add(newThread);
+ }
+}
+*/
+
+void CCoderMixer2MT::ReInit()
+{
+ for(int i = 0; i < _streamBinders.Size(); i++)
+ _streamBinders[i].ReInit();
+}
+
+
+STDMETHODIMP CCoderMixer2MT::Init(ISequentialInStream **inStreams,
+ ISequentialOutStream **outStreams)
+{
+ if (_coderInfoVector.Size() != _bindInfo.Coders.Size())
+ throw 0;
+ int i;
+ for(i = 0; i < _coderInfoVector.Size(); i++)
+ {
+ CThreadCoderInfo &coderInfo = _coderInfoVector[i];
+ const CCoderStreamsInfo &coderStreamsInfo = _bindInfo.Coders[i];
+ coderInfo.InStreams.Clear();
+ UInt32 j;
+ for(j = 0; j < coderStreamsInfo.NumInStreams; j++)
+ coderInfo.InStreams.Add(NULL);
+ coderInfo.OutStreams.Clear();
+ for(j = 0; j < coderStreamsInfo.NumOutStreams; j++)
+ coderInfo.OutStreams.Add(NULL);
+ }
+
+ for(i = 0; i < _bindInfo.BindPairs.Size(); i++)
+ {
+ const CBindPair &bindPair = _bindInfo.BindPairs[i];
+ UInt32 inCoderIndex, inCoderStreamIndex;
+ UInt32 outCoderIndex, outCoderStreamIndex;
+ _bindInfo.FindInStream(bindPair.InIndex, inCoderIndex, inCoderStreamIndex);
+ _bindInfo.FindOutStream(bindPair.OutIndex, outCoderIndex, outCoderStreamIndex);
+
+ _streamBinders[i].CreateStreams(
+ &_coderInfoVector[inCoderIndex].InStreams[inCoderStreamIndex],
+ &_coderInfoVector[outCoderIndex].OutStreams[outCoderStreamIndex]);
+ }
+
+ for(i = 0; i < _bindInfo.InStreams.Size(); i++)
+ {
+ UInt32 inCoderIndex, inCoderStreamIndex;
+ _bindInfo.FindInStream(_bindInfo.InStreams[i], inCoderIndex, inCoderStreamIndex);
+ _coderInfoVector[inCoderIndex].InStreams[inCoderStreamIndex] = inStreams[i];
+ }
+
+ for(i = 0; i < _bindInfo.OutStreams.Size(); i++)
+ {
+ UInt32 outCoderIndex, outCoderStreamIndex;
+ _bindInfo.FindOutStream(_bindInfo.OutStreams[i], outCoderIndex, outCoderStreamIndex);
+ _coderInfoVector[outCoderIndex].OutStreams[outCoderStreamIndex] = outStreams[i];
+ }
+ return S_OK;
+}
+
+
+bool CCoderMixer2MT::MyCode()
+{
+ HANDLE events[2] = { _exitEvent, _startCompressingEvent };
+ DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
+ if (waitResult == WAIT_OBJECT_0 + 0)
+ return false;
+
+ for(int i = 0; i < _coderInfoVector.Size(); i++)
+ _coderInfoVector[i].CompressEvent->Set();
+ /* DWORD result = */ ::WaitForMultipleObjects(_compressingCompletedEvents.Size(),
+ &_compressingCompletedEvents.Front(), TRUE, INFINITE);
+
+ _compressingFinishedEvent.Set();
+
+ return true;
+}
+
+
+STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams,
+ const UInt64 ** /* inSizes */,
+ UInt32 numInStreams,
+ ISequentialOutStream **outStreams,
+ const UInt64 ** /* outSizes */,
+ UInt32 numOutStreams,
+ ICompressProgressInfo *progress)
+{
+ if (numInStreams != (UInt32)_bindInfo.InStreams.Size() ||
+ numOutStreams != (UInt32)_bindInfo.OutStreams.Size())
+ return E_INVALIDARG;
+
+ Init(inStreams, outStreams);
+
+ _compressingFinishedEvent.Reset(); // ?
+
+ CCrossThreadProgress *progressSpec = new CCrossThreadProgress;
+ CMyComPtr<ICompressProgressInfo> crossProgress = progressSpec;
+ progressSpec->Init();
+ _coderInfoVector[_progressCoderIndex].Progress = crossProgress;
+
+ _startCompressingEvent.Set();
+
+
+ for (;;)
+ {
+ HANDLE events[2] = {_compressingFinishedEvent, progressSpec->ProgressEvent };
+ DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
+ if (waitResult == WAIT_OBJECT_0 + 0)
+ break;
+ if (progress != NULL)
+ progressSpec->Result = progress->SetRatioInfo(progressSpec->InSize,
+ progressSpec->OutSize);
+ else
+ progressSpec->Result = S_OK;
+ progressSpec->WaitEvent.Set();
+ }
+
+ int i;
+ for(i = 0; i < _coderInfoVector.Size(); i++)
+ {
+ HRESULT result = _coderInfoVector[i].Result;
+ if (result == S_FALSE)
+ return result;
+ }
+ for(i = 0; i < _coderInfoVector.Size(); i++)
+ {
+ HRESULT result = _coderInfoVector[i].Result;
+ if (result != S_OK && result != E_FAIL)
+ return result;
+ }
+ for(i = 0; i < _coderInfoVector.Size(); i++)
+ {
+ HRESULT result = _coderInfoVector[i].Result;
+ if (result != S_OK)
+ return result;
+ }
+ return S_OK;
+}
+
+UInt64 CCoderMixer2MT::GetWriteProcessedSize(UInt32 binderIndex) const
+{
+ return _streamBinders[binderIndex].ProcessedSize;
+}
+
+}
diff --git a/7zip/Archive/Common/CoderMixer2MT.h b/CPP/7zip/Archive/Common/CoderMixer2MT.h
index 78d752de..78d752de 100755
--- a/7zip/Archive/Common/CoderMixer2MT.h
+++ b/CPP/7zip/Archive/Common/CoderMixer2MT.h
diff --git a/7zip/Archive/Common/CoderMixer2ST.cpp b/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
index c01b776d..c01b776d 100755
--- a/7zip/Archive/Common/CoderMixer2ST.cpp
+++ b/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
diff --git a/7zip/Archive/Common/CoderMixer2ST.h b/CPP/7zip/Archive/Common/CoderMixer2ST.h
index 3144918b..3144918b 100755
--- a/7zip/Archive/Common/CoderMixer2ST.h
+++ b/CPP/7zip/Archive/Common/CoderMixer2ST.h
diff --git a/7zip/Archive/Common/CrossThreadProgress.cpp b/CPP/7zip/Archive/Common/CrossThreadProgress.cpp
index a974b54c..a974b54c 100755
--- a/7zip/Archive/Common/CrossThreadProgress.cpp
+++ b/CPP/7zip/Archive/Common/CrossThreadProgress.cpp
diff --git a/7zip/Archive/Common/CrossThreadProgress.h b/CPP/7zip/Archive/Common/CrossThreadProgress.h
index 5dd339dc..5dd339dc 100755
--- a/7zip/Archive/Common/CrossThreadProgress.h
+++ b/CPP/7zip/Archive/Common/CrossThreadProgress.h
diff --git a/7zip/Archive/Common/DummyOutStream.cpp b/CPP/7zip/Archive/Common/DummyOutStream.cpp
index b1d49913..b1d49913 100755
--- a/7zip/Archive/Common/DummyOutStream.cpp
+++ b/CPP/7zip/Archive/Common/DummyOutStream.cpp
diff --git a/7zip/Archive/Common/DummyOutStream.h b/CPP/7zip/Archive/Common/DummyOutStream.h
index 51690787..51690787 100755
--- a/7zip/Archive/Common/DummyOutStream.h
+++ b/CPP/7zip/Archive/Common/DummyOutStream.h
diff --git a/7zip/Archive/Common/FilterCoder.cpp b/CPP/7zip/Archive/Common/FilterCoder.cpp
index 5e104c84..5e104c84 100755
--- a/7zip/Archive/Common/FilterCoder.cpp
+++ b/CPP/7zip/Archive/Common/FilterCoder.cpp
diff --git a/7zip/Archive/Common/FilterCoder.h b/CPP/7zip/Archive/Common/FilterCoder.h
index 45618172..45618172 100755
--- a/7zip/Archive/Common/FilterCoder.h
+++ b/CPP/7zip/Archive/Common/FilterCoder.h
diff --git a/7zip/Archive/Common/InStreamWithCRC.cpp b/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
index 74dff7e1..74dff7e1 100755
--- a/7zip/Archive/Common/InStreamWithCRC.cpp
+++ b/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
diff --git a/7zip/Archive/Common/InStreamWithCRC.h b/CPP/7zip/Archive/Common/InStreamWithCRC.h
index 770a1437..770a1437 100755
--- a/7zip/Archive/Common/InStreamWithCRC.h
+++ b/CPP/7zip/Archive/Common/InStreamWithCRC.h
diff --git a/7zip/Archive/Common/ItemNameUtils.cpp b/CPP/7zip/Archive/Common/ItemNameUtils.cpp
index f7c3fcd9..f7c3fcd9 100755
--- a/7zip/Archive/Common/ItemNameUtils.cpp
+++ b/CPP/7zip/Archive/Common/ItemNameUtils.cpp
diff --git a/7zip/Archive/Common/ItemNameUtils.h b/CPP/7zip/Archive/Common/ItemNameUtils.h
index 63a01563..63a01563 100755
--- a/7zip/Archive/Common/ItemNameUtils.h
+++ b/CPP/7zip/Archive/Common/ItemNameUtils.h
diff --git a/7zip/Archive/Common/MultiStream.cpp b/CPP/7zip/Archive/Common/MultiStream.cpp
index a8cb333e..a8cb333e 100755
--- a/7zip/Archive/Common/MultiStream.cpp
+++ b/CPP/7zip/Archive/Common/MultiStream.cpp
diff --git a/7zip/Archive/Common/MultiStream.h b/CPP/7zip/Archive/Common/MultiStream.h
index 5a7cc687..5a7cc687 100755
--- a/7zip/Archive/Common/MultiStream.h
+++ b/CPP/7zip/Archive/Common/MultiStream.h
diff --git a/7zip/Archive/Common/OutStreamWithCRC.cpp b/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp
index 7ac3f123..7ac3f123 100755
--- a/7zip/Archive/Common/OutStreamWithCRC.cpp
+++ b/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp
diff --git a/7zip/Archive/Common/OutStreamWithCRC.h b/CPP/7zip/Archive/Common/OutStreamWithCRC.h
index 0feb542b..0feb542b 100755
--- a/7zip/Archive/Common/OutStreamWithCRC.h
+++ b/CPP/7zip/Archive/Common/OutStreamWithCRC.h
diff --git a/7zip/Archive/Common/ParseProperties.cpp b/CPP/7zip/Archive/Common/ParseProperties.cpp
index 9866d900..9866d900 100755
--- a/7zip/Archive/Common/ParseProperties.cpp
+++ b/CPP/7zip/Archive/Common/ParseProperties.cpp
diff --git a/7zip/Archive/Common/ParseProperties.h b/CPP/7zip/Archive/Common/ParseProperties.h
index e6db316b..e6db316b 100755
--- a/7zip/Archive/Common/ParseProperties.h
+++ b/CPP/7zip/Archive/Common/ParseProperties.h
diff --git a/7zip/Archive/Common/StdAfx.h b/CPP/7zip/Archive/Common/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Archive/Common/StdAfx.h
+++ b/CPP/7zip/Archive/Common/StdAfx.h
diff --git a/7zip/Archive/cpio/CpioHandler.cpp b/CPP/7zip/Archive/Cpio/CpioHandler.cpp
index 601afbd6..601afbd6 100755
--- a/7zip/Archive/cpio/CpioHandler.cpp
+++ b/CPP/7zip/Archive/Cpio/CpioHandler.cpp
diff --git a/7zip/Archive/cpio/CpioHandler.h b/CPP/7zip/Archive/Cpio/CpioHandler.h
index 39702541..39702541 100755
--- a/7zip/Archive/cpio/CpioHandler.h
+++ b/CPP/7zip/Archive/Cpio/CpioHandler.h
diff --git a/7zip/Archive/cpio/CpioHeader.cpp b/CPP/7zip/Archive/Cpio/CpioHeader.cpp
index 9e4d99cb..9e4d99cb 100755
--- a/7zip/Archive/cpio/CpioHeader.cpp
+++ b/CPP/7zip/Archive/Cpio/CpioHeader.cpp
diff --git a/7zip/Archive/cpio/CpioHeader.h b/CPP/7zip/Archive/Cpio/CpioHeader.h
index 40a0014a..40a0014a 100755
--- a/7zip/Archive/cpio/CpioHeader.h
+++ b/CPP/7zip/Archive/Cpio/CpioHeader.h
diff --git a/7zip/Archive/cpio/CpioIn.cpp b/CPP/7zip/Archive/Cpio/CpioIn.cpp
index 91399362..91399362 100755
--- a/7zip/Archive/cpio/CpioIn.cpp
+++ b/CPP/7zip/Archive/Cpio/CpioIn.cpp
diff --git a/7zip/Archive/cpio/CpioIn.h b/CPP/7zip/Archive/Cpio/CpioIn.h
index 19e3da10..19e3da10 100755
--- a/7zip/Archive/cpio/CpioIn.h
+++ b/CPP/7zip/Archive/Cpio/CpioIn.h
diff --git a/7zip/Archive/cpio/CpioItem.h b/CPP/7zip/Archive/Cpio/CpioItem.h
index 0eb2a0b4..0eb2a0b4 100755
--- a/7zip/Archive/cpio/CpioItem.h
+++ b/CPP/7zip/Archive/Cpio/CpioItem.h
diff --git a/7zip/Archive/cpio/DllExports.cpp b/CPP/7zip/Archive/Cpio/DllExports.cpp
index 8eb38bfd..8eb38bfd 100755
--- a/7zip/Archive/cpio/DllExports.cpp
+++ b/CPP/7zip/Archive/Cpio/DllExports.cpp
diff --git a/7zip/Archive/Deb/StdAfx.cpp b/CPP/7zip/Archive/Cpio/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Deb/StdAfx.cpp
+++ b/CPP/7zip/Archive/Cpio/StdAfx.cpp
diff --git a/7zip/Archive/Deb/StdAfx.h b/CPP/7zip/Archive/Cpio/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/Deb/StdAfx.h
+++ b/CPP/7zip/Archive/Cpio/StdAfx.h
diff --git a/7zip/Archive/cpio/cpio.dsp b/CPP/7zip/Archive/Cpio/cpio.dsp
index f30c3e63..f30c3e63 100755
--- a/7zip/Archive/cpio/cpio.dsp
+++ b/CPP/7zip/Archive/Cpio/cpio.dsp
diff --git a/7zip/Archive/cpio/cpio.dsw b/CPP/7zip/Archive/Cpio/cpio.dsw
index b1b6d98f..b1b6d98f 100755
--- a/7zip/Archive/cpio/cpio.dsw
+++ b/CPP/7zip/Archive/Cpio/cpio.dsw
diff --git a/7zip/Archive/cpio/cpio.ico b/CPP/7zip/Archive/Cpio/cpio.ico
index 9abaabc7..9abaabc7 100755
--- a/7zip/Archive/cpio/cpio.ico
+++ b/CPP/7zip/Archive/Cpio/cpio.ico
Binary files differ
diff --git a/7zip/Archive/Cpio/makefile b/CPP/7zip/Archive/Cpio/makefile
index d7760281..d7760281 100755
--- a/7zip/Archive/Cpio/makefile
+++ b/CPP/7zip/Archive/Cpio/makefile
diff --git a/7zip/Archive/cpio/resource.rc b/CPP/7zip/Archive/Cpio/resource.rc
index d5456e5a..d5456e5a 100755
--- a/7zip/Archive/cpio/resource.rc
+++ b/CPP/7zip/Archive/Cpio/resource.rc
diff --git a/7zip/Archive/Deb/Deb.dsp b/CPP/7zip/Archive/Deb/Deb.dsp
index 56689305..56689305 100755
--- a/7zip/Archive/Deb/Deb.dsp
+++ b/CPP/7zip/Archive/Deb/Deb.dsp
diff --git a/7zip/Archive/Deb/Deb.dsw b/CPP/7zip/Archive/Deb/Deb.dsw
index c7169534..c7169534 100755
--- a/7zip/Archive/Deb/Deb.dsw
+++ b/CPP/7zip/Archive/Deb/Deb.dsw
diff --git a/7zip/Archive/Deb/DebHandler.cpp b/CPP/7zip/Archive/Deb/DebHandler.cpp
index 8728cec8..8728cec8 100755
--- a/7zip/Archive/Deb/DebHandler.cpp
+++ b/CPP/7zip/Archive/Deb/DebHandler.cpp
diff --git a/7zip/Archive/Deb/DebHandler.h b/CPP/7zip/Archive/Deb/DebHandler.h
index 47de0224..47de0224 100755
--- a/7zip/Archive/Deb/DebHandler.h
+++ b/CPP/7zip/Archive/Deb/DebHandler.h
diff --git a/7zip/Archive/Deb/DebHeader.cpp b/CPP/7zip/Archive/Deb/DebHeader.cpp
index dce00e1b..dce00e1b 100755
--- a/7zip/Archive/Deb/DebHeader.cpp
+++ b/CPP/7zip/Archive/Deb/DebHeader.cpp
diff --git a/7zip/Archive/Deb/DebHeader.h b/CPP/7zip/Archive/Deb/DebHeader.h
index c2884000..c2884000 100755
--- a/7zip/Archive/Deb/DebHeader.h
+++ b/CPP/7zip/Archive/Deb/DebHeader.h
diff --git a/7zip/Archive/Deb/DebIn.cpp b/CPP/7zip/Archive/Deb/DebIn.cpp
index c2221d12..c2221d12 100755
--- a/7zip/Archive/Deb/DebIn.cpp
+++ b/CPP/7zip/Archive/Deb/DebIn.cpp
diff --git a/7zip/Archive/Deb/DebIn.h b/CPP/7zip/Archive/Deb/DebIn.h
index c1b72b6e..c1b72b6e 100755
--- a/7zip/Archive/Deb/DebIn.h
+++ b/CPP/7zip/Archive/Deb/DebIn.h
diff --git a/7zip/Archive/Deb/DebItem.h b/CPP/7zip/Archive/Deb/DebItem.h
index f587f3f5..f587f3f5 100755
--- a/7zip/Archive/Deb/DebItem.h
+++ b/CPP/7zip/Archive/Deb/DebItem.h
diff --git a/7zip/Archive/Deb/DllExports.cpp b/CPP/7zip/Archive/Deb/DllExports.cpp
index fe320531..fe320531 100755
--- a/7zip/Archive/Deb/DllExports.cpp
+++ b/CPP/7zip/Archive/Deb/DllExports.cpp
diff --git a/7zip/Archive/GZip/StdAfx.cpp b/CPP/7zip/Archive/Deb/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/GZip/StdAfx.cpp
+++ b/CPP/7zip/Archive/Deb/StdAfx.cpp
diff --git a/7zip/Archive/GZip/StdAfx.h b/CPP/7zip/Archive/Deb/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/GZip/StdAfx.h
+++ b/CPP/7zip/Archive/Deb/StdAfx.h
diff --git a/7zip/Archive/Deb/deb.ico b/CPP/7zip/Archive/Deb/deb.ico
index 97a08654..97a08654 100755
--- a/7zip/Archive/Deb/deb.ico
+++ b/CPP/7zip/Archive/Deb/deb.ico
Binary files differ
diff --git a/7zip/Archive/Deb/makefile b/CPP/7zip/Archive/Deb/makefile
index a74f33de..a74f33de 100755
--- a/7zip/Archive/Deb/makefile
+++ b/CPP/7zip/Archive/Deb/makefile
diff --git a/7zip/Archive/Deb/resource.rc b/CPP/7zip/Archive/Deb/resource.rc
index a80edced..a80edced 100755
--- a/7zip/Archive/Deb/resource.rc
+++ b/CPP/7zip/Archive/Deb/resource.rc
diff --git a/7zip/Archive/GZip/DllExports.cpp b/CPP/7zip/Archive/GZip/DllExports.cpp
index 3bddcfb9..3bddcfb9 100755
--- a/7zip/Archive/GZip/DllExports.cpp
+++ b/CPP/7zip/Archive/GZip/DllExports.cpp
diff --git a/7zip/Archive/GZip/GZip.dsp b/CPP/7zip/Archive/GZip/GZip.dsp
index 3af06b46..3af06b46 100755
--- a/7zip/Archive/GZip/GZip.dsp
+++ b/CPP/7zip/Archive/GZip/GZip.dsp
diff --git a/7zip/Archive/GZip/GZip.dsw b/CPP/7zip/Archive/GZip/GZip.dsw
index 5ff50d2c..5ff50d2c 100755
--- a/7zip/Archive/GZip/GZip.dsw
+++ b/CPP/7zip/Archive/GZip/GZip.dsw
diff --git a/7zip/Archive/GZip/GZipHandler.cpp b/CPP/7zip/Archive/GZip/GZipHandler.cpp
index ff592324..ff592324 100755
--- a/7zip/Archive/GZip/GZipHandler.cpp
+++ b/CPP/7zip/Archive/GZip/GZipHandler.cpp
diff --git a/7zip/Archive/GZip/GZipHandler.h b/CPP/7zip/Archive/GZip/GZipHandler.h
index 9af7e4a4..9af7e4a4 100755
--- a/7zip/Archive/GZip/GZipHandler.h
+++ b/CPP/7zip/Archive/GZip/GZipHandler.h
diff --git a/7zip/Archive/GZip/GZipHandlerOut.cpp b/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
index cc896016..cc896016 100755
--- a/7zip/Archive/GZip/GZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
diff --git a/7zip/Archive/GZip/GZipHeader.cpp b/CPP/7zip/Archive/GZip/GZipHeader.cpp
index 5e697fa9..5e697fa9 100755
--- a/7zip/Archive/GZip/GZipHeader.cpp
+++ b/CPP/7zip/Archive/GZip/GZipHeader.cpp
diff --git a/7zip/Archive/GZip/GZipHeader.h b/CPP/7zip/Archive/GZip/GZipHeader.h
index e83548eb..e83548eb 100755
--- a/7zip/Archive/GZip/GZipHeader.h
+++ b/CPP/7zip/Archive/GZip/GZipHeader.h
diff --git a/7zip/Archive/GZip/GZipIn.cpp b/CPP/7zip/Archive/GZip/GZipIn.cpp
index 2b16d369..2b16d369 100755
--- a/7zip/Archive/GZip/GZipIn.cpp
+++ b/CPP/7zip/Archive/GZip/GZipIn.cpp
diff --git a/7zip/Archive/GZip/GZipIn.h b/CPP/7zip/Archive/GZip/GZipIn.h
index 998470e0..998470e0 100755
--- a/7zip/Archive/GZip/GZipIn.h
+++ b/CPP/7zip/Archive/GZip/GZipIn.h
diff --git a/7zip/Archive/GZip/GZipItem.h b/CPP/7zip/Archive/GZip/GZipItem.h
index 7006dfb3..7006dfb3 100755
--- a/7zip/Archive/GZip/GZipItem.h
+++ b/CPP/7zip/Archive/GZip/GZipItem.h
diff --git a/7zip/Archive/GZip/GZipOut.cpp b/CPP/7zip/Archive/GZip/GZipOut.cpp
index afa8a931..afa8a931 100755
--- a/7zip/Archive/GZip/GZipOut.cpp
+++ b/CPP/7zip/Archive/GZip/GZipOut.cpp
diff --git a/7zip/Archive/GZip/GZipOut.h b/CPP/7zip/Archive/GZip/GZipOut.h
index a2ba2ebf..a2ba2ebf 100755
--- a/7zip/Archive/GZip/GZipOut.h
+++ b/CPP/7zip/Archive/GZip/GZipOut.h
diff --git a/7zip/Archive/GZip/GZipUpdate.cpp b/CPP/7zip/Archive/GZip/GZipUpdate.cpp
index 45e6e985..45e6e985 100755
--- a/7zip/Archive/GZip/GZipUpdate.cpp
+++ b/CPP/7zip/Archive/GZip/GZipUpdate.cpp
diff --git a/7zip/Archive/GZip/GZipUpdate.h b/CPP/7zip/Archive/GZip/GZipUpdate.h
index c06e8a4c..c06e8a4c 100755
--- a/7zip/Archive/GZip/GZipUpdate.h
+++ b/CPP/7zip/Archive/GZip/GZipUpdate.h
diff --git a/7zip/Archive/Iso/StdAfx.cpp b/CPP/7zip/Archive/GZip/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Iso/StdAfx.cpp
+++ b/CPP/7zip/Archive/GZip/StdAfx.cpp
diff --git a/7zip/Archive/Lzh/StdAfx.h b/CPP/7zip/Archive/GZip/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/Lzh/StdAfx.h
+++ b/CPP/7zip/Archive/GZip/StdAfx.h
diff --git a/7zip/Archive/GZip/gz.ico b/CPP/7zip/Archive/GZip/gz.ico
index f50d8c08..f50d8c08 100755
--- a/7zip/Archive/GZip/gz.ico
+++ b/CPP/7zip/Archive/GZip/gz.ico
Binary files differ
diff --git a/7zip/Archive/GZip/makefile b/CPP/7zip/Archive/GZip/makefile
index abc3f1e4..abc3f1e4 100755
--- a/7zip/Archive/GZip/makefile
+++ b/CPP/7zip/Archive/GZip/makefile
diff --git a/7zip/Archive/GZip/resource.rc b/CPP/7zip/Archive/GZip/resource.rc
index 29fb4825..29fb4825 100755
--- a/7zip/Archive/GZip/resource.rc
+++ b/CPP/7zip/Archive/GZip/resource.rc
diff --git a/7zip/Archive/IArchive.h b/CPP/7zip/Archive/IArchive.h
index d6cbe804..d6cbe804 100755
--- a/7zip/Archive/IArchive.h
+++ b/CPP/7zip/Archive/IArchive.h
diff --git a/7zip/Archive/Iso/DllExports.cpp b/CPP/7zip/Archive/Iso/DllExports.cpp
index f746eea1..f746eea1 100755
--- a/7zip/Archive/Iso/DllExports.cpp
+++ b/CPP/7zip/Archive/Iso/DllExports.cpp
diff --git a/7zip/Archive/Iso/Iso.dsp b/CPP/7zip/Archive/Iso/Iso.dsp
index a204e9cd..a204e9cd 100755
--- a/7zip/Archive/Iso/Iso.dsp
+++ b/CPP/7zip/Archive/Iso/Iso.dsp
diff --git a/7zip/Archive/Iso/Iso.dsw b/CPP/7zip/Archive/Iso/Iso.dsw
index 27728dd2..27728dd2 100755
--- a/7zip/Archive/Iso/Iso.dsw
+++ b/CPP/7zip/Archive/Iso/Iso.dsw
diff --git a/7zip/Archive/Iso/Iso.ico b/CPP/7zip/Archive/Iso/Iso.ico
index 2538e408..2538e408 100755
--- a/7zip/Archive/Iso/Iso.ico
+++ b/CPP/7zip/Archive/Iso/Iso.ico
Binary files differ
diff --git a/7zip/Archive/Iso/IsoHandler.cpp b/CPP/7zip/Archive/Iso/IsoHandler.cpp
index 1831e913..1831e913 100755
--- a/7zip/Archive/Iso/IsoHandler.cpp
+++ b/CPP/7zip/Archive/Iso/IsoHandler.cpp
diff --git a/7zip/Archive/Iso/IsoHandler.h b/CPP/7zip/Archive/Iso/IsoHandler.h
index e545d2a7..e545d2a7 100755
--- a/7zip/Archive/Iso/IsoHandler.h
+++ b/CPP/7zip/Archive/Iso/IsoHandler.h
diff --git a/7zip/Archive/Iso/IsoHeader.cpp b/CPP/7zip/Archive/Iso/IsoHeader.cpp
index 9555e49b..9555e49b 100755
--- a/7zip/Archive/Iso/IsoHeader.cpp
+++ b/CPP/7zip/Archive/Iso/IsoHeader.cpp
diff --git a/7zip/Archive/Iso/IsoHeader.h b/CPP/7zip/Archive/Iso/IsoHeader.h
index 9702d70a..9702d70a 100755
--- a/7zip/Archive/Iso/IsoHeader.h
+++ b/CPP/7zip/Archive/Iso/IsoHeader.h
diff --git a/7zip/Archive/Iso/IsoIn.cpp b/CPP/7zip/Archive/Iso/IsoIn.cpp
index 213b3014..213b3014 100755
--- a/7zip/Archive/Iso/IsoIn.cpp
+++ b/CPP/7zip/Archive/Iso/IsoIn.cpp
diff --git a/7zip/Archive/Iso/IsoIn.h b/CPP/7zip/Archive/Iso/IsoIn.h
index ab850bd9..ab850bd9 100755
--- a/7zip/Archive/Iso/IsoIn.h
+++ b/CPP/7zip/Archive/Iso/IsoIn.h
diff --git a/7zip/Archive/Iso/IsoItem.h b/CPP/7zip/Archive/Iso/IsoItem.h
index 14024d8d..14024d8d 100755
--- a/7zip/Archive/Iso/IsoItem.h
+++ b/CPP/7zip/Archive/Iso/IsoItem.h
diff --git a/7zip/Archive/Lzh/StdAfx.cpp b/CPP/7zip/Archive/Iso/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Lzh/StdAfx.cpp
+++ b/CPP/7zip/Archive/Iso/StdAfx.cpp
diff --git a/7zip/Archive/Iso/StdAfx.h b/CPP/7zip/Archive/Iso/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Archive/Iso/StdAfx.h
+++ b/CPP/7zip/Archive/Iso/StdAfx.h
diff --git a/7zip/Archive/Iso/makefile b/CPP/7zip/Archive/Iso/makefile
index 100a3cd0..100a3cd0 100755
--- a/7zip/Archive/Iso/makefile
+++ b/CPP/7zip/Archive/Iso/makefile
diff --git a/7zip/Archive/Iso/resource.rc b/CPP/7zip/Archive/Iso/resource.rc
index 86929b0e..86929b0e 100755
--- a/7zip/Archive/Iso/resource.rc
+++ b/CPP/7zip/Archive/Iso/resource.rc
diff --git a/7zip/Archive/Lzh/DllExports.cpp b/CPP/7zip/Archive/Lzh/DllExports.cpp
index c2b30945..c2b30945 100755
--- a/7zip/Archive/Lzh/DllExports.cpp
+++ b/CPP/7zip/Archive/Lzh/DllExports.cpp
diff --git a/7zip/Archive/Lzh/Lzh.def b/CPP/7zip/Archive/Lzh/Lzh.def
index e240b3f2..e240b3f2 100755
--- a/7zip/Archive/Lzh/Lzh.def
+++ b/CPP/7zip/Archive/Lzh/Lzh.def
diff --git a/7zip/Archive/Lzh/Lzh.dsp b/CPP/7zip/Archive/Lzh/Lzh.dsp
index ad00699c..ad00699c 100755
--- a/7zip/Archive/Lzh/Lzh.dsp
+++ b/CPP/7zip/Archive/Lzh/Lzh.dsp
diff --git a/7zip/Archive/Lzh/Lzh.dsw b/CPP/7zip/Archive/Lzh/Lzh.dsw
index 41ab2218..41ab2218 100755
--- a/7zip/Archive/Lzh/Lzh.dsw
+++ b/CPP/7zip/Archive/Lzh/Lzh.dsw
diff --git a/7zip/Archive/Lzh/LzhCRC.cpp b/CPP/7zip/Archive/Lzh/LzhCRC.cpp
index ca1235bb..ca1235bb 100755
--- a/7zip/Archive/Lzh/LzhCRC.cpp
+++ b/CPP/7zip/Archive/Lzh/LzhCRC.cpp
diff --git a/CPP/7zip/Archive/Lzh/LzhCRC.h b/CPP/7zip/Archive/Lzh/LzhCRC.h
new file mode 100755
index 00000000..e49d649c
--- /dev/null
+++ b/CPP/7zip/Archive/Lzh/LzhCRC.h
@@ -0,0 +1,27 @@
+// LzhCRC.h
+
+#ifndef __LZH_CRC_H
+#define __LZH_CRC_H
+
+#include <stddef.h>
+#include "Common/Types.h"
+
+namespace NArchive {
+namespace NLzh {
+
+class CCRC
+{
+ UInt16 _value;
+public:
+ static UInt16 Table[256];
+ static void InitTable();
+
+ CCRC(): _value(0){};
+ void Init() { _value = 0; }
+ void Update(const void *data, size_t size);
+ UInt16 GetDigest() const { return _value; }
+};
+
+}}
+
+#endif
diff --git a/7zip/Archive/Lzh/LzhHandler.cpp b/CPP/7zip/Archive/Lzh/LzhHandler.cpp
index 03af11d1..03af11d1 100755
--- a/7zip/Archive/Lzh/LzhHandler.cpp
+++ b/CPP/7zip/Archive/Lzh/LzhHandler.cpp
diff --git a/7zip/Archive/Lzh/LzhHandler.h b/CPP/7zip/Archive/Lzh/LzhHandler.h
index 2dc89494..2dc89494 100755
--- a/7zip/Archive/Lzh/LzhHandler.h
+++ b/CPP/7zip/Archive/Lzh/LzhHandler.h
diff --git a/7zip/Archive/Lzh/LzhHeader.h b/CPP/7zip/Archive/Lzh/LzhHeader.h
index 845b9a21..845b9a21 100755
--- a/7zip/Archive/Lzh/LzhHeader.h
+++ b/CPP/7zip/Archive/Lzh/LzhHeader.h
diff --git a/7zip/Archive/Lzh/LzhIn.cpp b/CPP/7zip/Archive/Lzh/LzhIn.cpp
index 42ef50e4..42ef50e4 100755
--- a/7zip/Archive/Lzh/LzhIn.cpp
+++ b/CPP/7zip/Archive/Lzh/LzhIn.cpp
diff --git a/7zip/Archive/Lzh/LzhIn.h b/CPP/7zip/Archive/Lzh/LzhIn.h
index 344a133f..344a133f 100755
--- a/7zip/Archive/Lzh/LzhIn.h
+++ b/CPP/7zip/Archive/Lzh/LzhIn.h
diff --git a/7zip/Archive/Lzh/LzhItem.h b/CPP/7zip/Archive/Lzh/LzhItem.h
index 66d4ed75..66d4ed75 100755
--- a/7zip/Archive/Lzh/LzhItem.h
+++ b/CPP/7zip/Archive/Lzh/LzhItem.h
diff --git a/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp b/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp
index 2281a884..2281a884 100755
--- a/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp
+++ b/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp
diff --git a/7zip/Archive/Lzh/LzhOutStreamWithCRC.h b/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h
index 31b536b7..31b536b7 100755
--- a/7zip/Archive/Lzh/LzhOutStreamWithCRC.h
+++ b/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h
diff --git a/7zip/Archive/Nsis/StdAfx.cpp b/CPP/7zip/Archive/Lzh/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Nsis/StdAfx.cpp
+++ b/CPP/7zip/Archive/Lzh/StdAfx.cpp
diff --git a/7zip/Archive/RPM/StdAfx.h b/CPP/7zip/Archive/Lzh/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/RPM/StdAfx.h
+++ b/CPP/7zip/Archive/Lzh/StdAfx.h
diff --git a/7zip/Archive/Lzh/lzh.ico b/CPP/7zip/Archive/Lzh/lzh.ico
index 84dab49c..84dab49c 100755
--- a/7zip/Archive/Lzh/lzh.ico
+++ b/CPP/7zip/Archive/Lzh/lzh.ico
Binary files differ
diff --git a/7zip/Archive/Lzh/makefile b/CPP/7zip/Archive/Lzh/makefile
index 6f8fd2a0..6f8fd2a0 100755
--- a/7zip/Archive/Lzh/makefile
+++ b/CPP/7zip/Archive/Lzh/makefile
diff --git a/7zip/Archive/Lzh/resource.rc b/CPP/7zip/Archive/Lzh/resource.rc
index 2870e520..2870e520 100755
--- a/7zip/Archive/Lzh/resource.rc
+++ b/CPP/7zip/Archive/Lzh/resource.rc
diff --git a/7zip/Archive/Nsis/DllExports.cpp b/CPP/7zip/Archive/Nsis/DllExports.cpp
index f10f56ea..f10f56ea 100755
--- a/7zip/Archive/Nsis/DllExports.cpp
+++ b/CPP/7zip/Archive/Nsis/DllExports.cpp
diff --git a/7zip/Archive/Nsis/Nsis.dsp b/CPP/7zip/Archive/Nsis/Nsis.dsp
index 45ce0386..45ce0386 100755
--- a/7zip/Archive/Nsis/Nsis.dsp
+++ b/CPP/7zip/Archive/Nsis/Nsis.dsp
diff --git a/7zip/Archive/Nsis/Nsis.dsw b/CPP/7zip/Archive/Nsis/Nsis.dsw
index d3df6d27..d3df6d27 100755
--- a/7zip/Archive/Nsis/Nsis.dsw
+++ b/CPP/7zip/Archive/Nsis/Nsis.dsw
diff --git a/7zip/Archive/Nsis/NsisDecode.cpp b/CPP/7zip/Archive/Nsis/NsisDecode.cpp
index d49b2312..d49b2312 100755
--- a/7zip/Archive/Nsis/NsisDecode.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisDecode.cpp
diff --git a/7zip/Archive/Nsis/NsisDecode.h b/CPP/7zip/Archive/Nsis/NsisDecode.h
index 1bec178f..1bec178f 100755
--- a/7zip/Archive/Nsis/NsisDecode.h
+++ b/CPP/7zip/Archive/Nsis/NsisDecode.h
diff --git a/7zip/Archive/Nsis/NsisHandler.cpp b/CPP/7zip/Archive/Nsis/NsisHandler.cpp
index 0d840479..0d840479 100755
--- a/7zip/Archive/Nsis/NsisHandler.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisHandler.cpp
diff --git a/7zip/Archive/Nsis/NsisHandler.h b/CPP/7zip/Archive/Nsis/NsisHandler.h
index 1ff8b776..1ff8b776 100755
--- a/7zip/Archive/Nsis/NsisHandler.h
+++ b/CPP/7zip/Archive/Nsis/NsisHandler.h
diff --git a/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp
index 0db6ccfd..0db6ccfd 100755
--- a/7zip/Archive/Nsis/NsisIn.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp
diff --git a/CPP/7zip/Archive/Nsis/NsisIn.h b/CPP/7zip/Archive/Nsis/NsisIn.h
new file mode 100755
index 00000000..d75a9e6e
--- /dev/null
+++ b/CPP/7zip/Archive/Nsis/NsisIn.h
@@ -0,0 +1,166 @@
+// Archive/NsisIn.h
+
+#ifndef __ARCHIVE_NSIS_IN_H
+#define __ARCHIVE_NSIS_IN_H
+
+#include "Common/MyCom.h"
+#include "Common/IntToString.h"
+#include "Common/Buffer.h"
+
+#include "../../IStream.h"
+
+#include "NsisDecode.h"
+
+// #define NSIS_SCRIPT
+
+namespace NArchive {
+namespace NNsis {
+
+const int kSignatureSize = 16;
+extern Byte kSignature[kSignatureSize];
+
+const UInt32 kFlagsMask = 0xF;
+namespace NFlags
+{
+ const UInt32 kUninstall = 1;
+ const UInt32 kSilent = 2;
+ const UInt32 kNoCrc = 4;
+ const UInt32 kForceCrc = 8;
+}
+
+struct CFirstHeader
+{
+ UInt32 Flags;
+ UInt32 HeaderLength;
+
+ UInt32 ArchiveSize;
+
+ bool ThereIsCrc() const
+ {
+ if ((Flags & NFlags::kForceCrc ) != 0)
+ return true;
+ return ((Flags & NFlags::kNoCrc) == 0);
+ }
+
+ UInt32 GetDataSize() const { return ArchiveSize - (ThereIsCrc() ? 4 : 0); }
+};
+
+
+struct CBlockHeader
+{
+ UInt32 Offset;
+ UInt32 Num;
+};
+
+struct CItem
+{
+ AString Prefix;
+ AString Name;
+ UInt32 Pos;
+ bool SizeIsDefined;
+ bool CompressedSizeIsDefined;
+ bool EstimatedSizeIsDefined;
+ UInt32 Size;
+ UInt32 CompressedSize;
+ UInt32 EstimatedSize;
+ FILETIME DateTime;
+ UInt32 DictionarySize;
+ bool IsCompressed;
+ bool UseFilter;
+ CItem(): UseFilter(false), SizeIsDefined(false), EstimatedSizeIsDefined(false),
+ IsCompressed(true), CompressedSizeIsDefined(false), Size(0) {}
+
+ bool IsINSTDIR() const
+ {
+ if (Prefix.Length() < 3)
+ return false;
+ return true;
+ }
+
+ AString GetReducedName() const
+ {
+ AString prefix = Prefix;
+ if (prefix.Length() > 0)
+ if (prefix[prefix.Length() - 1] != '\\')
+ prefix += '\\';
+ AString s2 = prefix + Name;
+ const int len = 9;
+ if (s2.Left(len).CompareNoCase("$INSTDIR\\") == 0)
+ s2 = s2.Mid(len);
+ return s2;
+ }
+
+};
+
+class CInArchive
+{
+ UInt64 _archiveSize;
+ CMyComPtr<IInStream> _stream;
+
+ Byte ReadByte();
+ UInt32 ReadUInt32();
+ HRESULT Open2();
+ void ReadBlockHeader(CBlockHeader &bh);
+ AString ReadString(UInt32 pos);
+ AString ReadString2(UInt32 pos);
+ HRESULT ReadEntries(const CBlockHeader &bh);
+ HRESULT Parse();
+
+ CByteBuffer _data;
+ UInt64 _size;
+
+ size_t _posInData;
+
+ UInt32 _stringsPos;
+
+
+ bool _headerIsCompressed;
+ UInt32 _nonSolidStartOffset;
+public:
+ HRESULT Open(IInStream *inStream, const UInt64 *maxCheckStartPosition);
+ void Clear();
+
+ UInt64 StreamOffset;
+ CDecoder Decoder;
+ CObjectVector<CItem> Items;
+ bool IsSolid;
+ CFirstHeader FirstHeader;
+ NMethodType::EEnum Method;
+ bool UseFilter;
+ UInt32 DictionarySize;
+ bool FilterFlag;
+
+ #ifdef NSIS_SCRIPT
+ AString Script;
+ #endif
+ UInt32 GetOffset() const { return IsSolid ? 4 : 0; }
+ UInt64 GetDataPos(int index)
+ {
+ const CItem &item = Items[index];
+ return GetOffset() + FirstHeader.HeaderLength + item.Pos;
+ }
+
+ UInt64 GetPosOfSolidItem(int index) const
+ {
+ const CItem &item = Items[index];
+ return 4 + FirstHeader.HeaderLength + item.Pos;
+ }
+
+ UInt64 GetPosOfNonSolidItem(int index) const
+ {
+ const CItem &item = Items[index];
+ return StreamOffset + _nonSolidStartOffset + 4 + item.Pos;
+ }
+
+ void Release()
+ {
+ Decoder.Release();
+ }
+
+};
+
+UInt32 GetUInt32FromMemLE(const Byte *p);
+
+}}
+
+#endif
diff --git a/7zip/Archive/RPM/StdAfx.cpp b/CPP/7zip/Archive/Nsis/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/RPM/StdAfx.cpp
+++ b/CPP/7zip/Archive/Nsis/StdAfx.cpp
diff --git a/7zip/Archive/Nsis/StdAfx.h b/CPP/7zip/Archive/Nsis/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Archive/Nsis/StdAfx.h
+++ b/CPP/7zip/Archive/Nsis/StdAfx.h
diff --git a/7zip/Archive/Nsis/makefile b/CPP/7zip/Archive/Nsis/makefile
index 69fcf523..69fcf523 100755
--- a/7zip/Archive/Nsis/makefile
+++ b/CPP/7zip/Archive/Nsis/makefile
diff --git a/7zip/Archive/Nsis/resource.rc b/CPP/7zip/Archive/Nsis/resource.rc
index 487eb4ee..487eb4ee 100755
--- a/7zip/Archive/Nsis/resource.rc
+++ b/CPP/7zip/Archive/Nsis/resource.rc
diff --git a/7zip/Archive/RPM/DllExports.cpp b/CPP/7zip/Archive/RPM/DllExports.cpp
index ed21e64f..ed21e64f 100755
--- a/7zip/Archive/RPM/DllExports.cpp
+++ b/CPP/7zip/Archive/RPM/DllExports.cpp
diff --git a/7zip/Archive/RPM/Rpm.dsp b/CPP/7zip/Archive/RPM/Rpm.dsp
index 085fe137..085fe137 100755
--- a/7zip/Archive/RPM/Rpm.dsp
+++ b/CPP/7zip/Archive/RPM/Rpm.dsp
diff --git a/7zip/Archive/RPM/Rpm.dsw b/CPP/7zip/Archive/RPM/Rpm.dsw
index a67232ed..a67232ed 100755
--- a/7zip/Archive/RPM/Rpm.dsw
+++ b/CPP/7zip/Archive/RPM/Rpm.dsw
diff --git a/7zip/Archive/RPM/RpmHandler.cpp b/CPP/7zip/Archive/RPM/RpmHandler.cpp
index b1a5bf7d..b1a5bf7d 100755
--- a/7zip/Archive/RPM/RpmHandler.cpp
+++ b/CPP/7zip/Archive/RPM/RpmHandler.cpp
diff --git a/7zip/Archive/RPM/RpmHandler.h b/CPP/7zip/Archive/RPM/RpmHandler.h
index 484c6c54..484c6c54 100755
--- a/7zip/Archive/RPM/RpmHandler.h
+++ b/CPP/7zip/Archive/RPM/RpmHandler.h
diff --git a/7zip/Archive/RPM/RpmHeader.h b/CPP/7zip/Archive/RPM/RpmHeader.h
index d76963bd..d76963bd 100755
--- a/7zip/Archive/RPM/RpmHeader.h
+++ b/CPP/7zip/Archive/RPM/RpmHeader.h
diff --git a/7zip/Archive/RPM/RpmIn.cpp b/CPP/7zip/Archive/RPM/RpmIn.cpp
index c1600894..c1600894 100755
--- a/7zip/Archive/RPM/RpmIn.cpp
+++ b/CPP/7zip/Archive/RPM/RpmIn.cpp
diff --git a/7zip/Archive/RPM/RpmIn.h b/CPP/7zip/Archive/RPM/RpmIn.h
index ec798cb8..ec798cb8 100755
--- a/7zip/Archive/RPM/RpmIn.h
+++ b/CPP/7zip/Archive/RPM/RpmIn.h
diff --git a/7zip/Archive/Rar/StdAfx.cpp b/CPP/7zip/Archive/RPM/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Rar/StdAfx.cpp
+++ b/CPP/7zip/Archive/RPM/StdAfx.cpp
diff --git a/7zip/Archive/Rar/StdAfx.h b/CPP/7zip/Archive/RPM/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/Rar/StdAfx.h
+++ b/CPP/7zip/Archive/RPM/StdAfx.h
diff --git a/7zip/Archive/RPM/makefile b/CPP/7zip/Archive/RPM/makefile
index afda1289..afda1289 100755
--- a/7zip/Archive/RPM/makefile
+++ b/CPP/7zip/Archive/RPM/makefile
diff --git a/7zip/Archive/RPM/resource.rc b/CPP/7zip/Archive/RPM/resource.rc
index 926f09aa..926f09aa 100755
--- a/7zip/Archive/RPM/resource.rc
+++ b/CPP/7zip/Archive/RPM/resource.rc
diff --git a/7zip/Archive/RPM/rpm.ico b/CPP/7zip/Archive/RPM/rpm.ico
index cdeb8d1b..cdeb8d1b 100755
--- a/7zip/Archive/RPM/rpm.ico
+++ b/CPP/7zip/Archive/RPM/rpm.ico
Binary files differ
diff --git a/7zip/Archive/Rar/DllExports.cpp b/CPP/7zip/Archive/Rar/DllExports.cpp
index 921bffb2..921bffb2 100755
--- a/7zip/Archive/Rar/DllExports.cpp
+++ b/CPP/7zip/Archive/Rar/DllExports.cpp
diff --git a/7zip/Archive/Rar/Rar.dsp b/CPP/7zip/Archive/Rar/Rar.dsp
index 739024da..739024da 100755
--- a/7zip/Archive/Rar/Rar.dsp
+++ b/CPP/7zip/Archive/Rar/Rar.dsp
diff --git a/7zip/Archive/Rar/Rar.dsw b/CPP/7zip/Archive/Rar/Rar.dsw
index 3dab87aa..3dab87aa 100755
--- a/7zip/Archive/Rar/Rar.dsw
+++ b/CPP/7zip/Archive/Rar/Rar.dsw
diff --git a/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp
index 3389f0e2..3389f0e2 100755
--- a/7zip/Archive/Rar/RarHandler.cpp
+++ b/CPP/7zip/Archive/Rar/RarHandler.cpp
diff --git a/7zip/Archive/Rar/RarHandler.h b/CPP/7zip/Archive/Rar/RarHandler.h
index ea13e01e..ea13e01e 100755
--- a/7zip/Archive/Rar/RarHandler.h
+++ b/CPP/7zip/Archive/Rar/RarHandler.h
diff --git a/7zip/Archive/Rar/RarHeader.cpp b/CPP/7zip/Archive/Rar/RarHeader.cpp
index 94481e02..94481e02 100755
--- a/7zip/Archive/Rar/RarHeader.cpp
+++ b/CPP/7zip/Archive/Rar/RarHeader.cpp
diff --git a/7zip/Archive/Rar/RarHeader.h b/CPP/7zip/Archive/Rar/RarHeader.h
index 832a21c0..832a21c0 100755
--- a/7zip/Archive/Rar/RarHeader.h
+++ b/CPP/7zip/Archive/Rar/RarHeader.h
diff --git a/7zip/Archive/Rar/RarIn.cpp b/CPP/7zip/Archive/Rar/RarIn.cpp
index 9a88feb7..9a88feb7 100755
--- a/7zip/Archive/Rar/RarIn.cpp
+++ b/CPP/7zip/Archive/Rar/RarIn.cpp
diff --git a/7zip/Archive/Rar/RarIn.h b/CPP/7zip/Archive/Rar/RarIn.h
index 22262a74..22262a74 100755
--- a/7zip/Archive/Rar/RarIn.h
+++ b/CPP/7zip/Archive/Rar/RarIn.h
diff --git a/7zip/Archive/Rar/RarItem.cpp b/CPP/7zip/Archive/Rar/RarItem.cpp
index 61a72557..61a72557 100755
--- a/7zip/Archive/Rar/RarItem.cpp
+++ b/CPP/7zip/Archive/Rar/RarItem.cpp
diff --git a/7zip/Archive/Rar/RarItem.h b/CPP/7zip/Archive/Rar/RarItem.h
index 85050a42..85050a42 100755
--- a/7zip/Archive/Rar/RarItem.h
+++ b/CPP/7zip/Archive/Rar/RarItem.h
diff --git a/7zip/Archive/Rar/RarVolumeInStream.cpp b/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp
index 32078e6d..32078e6d 100755
--- a/7zip/Archive/Rar/RarVolumeInStream.cpp
+++ b/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp
diff --git a/7zip/Archive/Rar/RarVolumeInStream.h b/CPP/7zip/Archive/Rar/RarVolumeInStream.h
index 4c9a9e96..4c9a9e96 100755
--- a/7zip/Archive/Rar/RarVolumeInStream.h
+++ b/CPP/7zip/Archive/Rar/RarVolumeInStream.h
diff --git a/7zip/Archive/Split/StdAfx.cpp b/CPP/7zip/Archive/Rar/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Split/StdAfx.cpp
+++ b/CPP/7zip/Archive/Rar/StdAfx.cpp
diff --git a/7zip/Archive/Split/StdAfx.h b/CPP/7zip/Archive/Rar/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/Split/StdAfx.h
+++ b/CPP/7zip/Archive/Rar/StdAfx.h
diff --git a/7zip/Archive/Rar/makefile b/CPP/7zip/Archive/Rar/makefile
index 678dd412..678dd412 100755
--- a/7zip/Archive/Rar/makefile
+++ b/CPP/7zip/Archive/Rar/makefile
diff --git a/7zip/Archive/Rar/rar.ico b/CPP/7zip/Archive/Rar/rar.ico
index 2918d294..2918d294 100755
--- a/7zip/Archive/Rar/rar.ico
+++ b/CPP/7zip/Archive/Rar/rar.ico
Binary files differ
diff --git a/7zip/Archive/Rar/resource.rc b/CPP/7zip/Archive/Rar/resource.rc
index 94b4198b..94b4198b 100755
--- a/7zip/Archive/Rar/resource.rc
+++ b/CPP/7zip/Archive/Rar/resource.rc
diff --git a/7zip/Archive/Split/DllExports.cpp b/CPP/7zip/Archive/Split/DllExports.cpp
index e28f64ce..e28f64ce 100755
--- a/7zip/Archive/Split/DllExports.cpp
+++ b/CPP/7zip/Archive/Split/DllExports.cpp
diff --git a/7zip/Archive/Split/Split.dsp b/CPP/7zip/Archive/Split/Split.dsp
index d6229d98..d6229d98 100755
--- a/7zip/Archive/Split/Split.dsp
+++ b/CPP/7zip/Archive/Split/Split.dsp
diff --git a/7zip/Archive/Split/Split.dsw b/CPP/7zip/Archive/Split/Split.dsw
index 988ca30a..988ca30a 100755
--- a/7zip/Archive/Split/Split.dsw
+++ b/CPP/7zip/Archive/Split/Split.dsw
diff --git a/7zip/Archive/Split/Split.ico b/CPP/7zip/Archive/Split/Split.ico
index 5cb93e84..5cb93e84 100755
--- a/7zip/Archive/Split/Split.ico
+++ b/CPP/7zip/Archive/Split/Split.ico
Binary files differ
diff --git a/7zip/Archive/Split/SplitHandler.cpp b/CPP/7zip/Archive/Split/SplitHandler.cpp
index e919154f..e919154f 100755
--- a/7zip/Archive/Split/SplitHandler.cpp
+++ b/CPP/7zip/Archive/Split/SplitHandler.cpp
diff --git a/7zip/Archive/Split/SplitHandler.h b/CPP/7zip/Archive/Split/SplitHandler.h
index 8b3fcb70..8b3fcb70 100755
--- a/7zip/Archive/Split/SplitHandler.h
+++ b/CPP/7zip/Archive/Split/SplitHandler.h
diff --git a/7zip/Archive/Split/SplitHandlerOut.cpp b/CPP/7zip/Archive/Split/SplitHandlerOut.cpp
index ea86c281..ea86c281 100755
--- a/7zip/Archive/Split/SplitHandlerOut.cpp
+++ b/CPP/7zip/Archive/Split/SplitHandlerOut.cpp
diff --git a/7zip/Archive/Tar/StdAfx.cpp b/CPP/7zip/Archive/Split/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Tar/StdAfx.cpp
+++ b/CPP/7zip/Archive/Split/StdAfx.cpp
diff --git a/7zip/Archive/Z/StdAfx.h b/CPP/7zip/Archive/Split/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/Z/StdAfx.h
+++ b/CPP/7zip/Archive/Split/StdAfx.h
diff --git a/7zip/Archive/Split/makefile b/CPP/7zip/Archive/Split/makefile
index 650c750b..650c750b 100755
--- a/7zip/Archive/Split/makefile
+++ b/CPP/7zip/Archive/Split/makefile
diff --git a/7zip/Archive/Split/resource.rc b/CPP/7zip/Archive/Split/resource.rc
index 3e301754..3e301754 100755
--- a/7zip/Archive/Split/resource.rc
+++ b/CPP/7zip/Archive/Split/resource.rc
diff --git a/7zip/Archive/Tar/DllExports.cpp b/CPP/7zip/Archive/Tar/DllExports.cpp
index afa2fd24..afa2fd24 100755
--- a/7zip/Archive/Tar/DllExports.cpp
+++ b/CPP/7zip/Archive/Tar/DllExports.cpp
diff --git a/7zip/Archive/Z/StdAfx.cpp b/CPP/7zip/Archive/Tar/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Z/StdAfx.cpp
+++ b/CPP/7zip/Archive/Tar/StdAfx.cpp
diff --git a/7zip/Archive/Tar/StdAfx.h b/CPP/7zip/Archive/Tar/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Archive/Tar/StdAfx.h
+++ b/CPP/7zip/Archive/Tar/StdAfx.h
diff --git a/7zip/Archive/Tar/Tar.dsp b/CPP/7zip/Archive/Tar/Tar.dsp
index c01e7383..c01e7383 100755
--- a/7zip/Archive/Tar/Tar.dsp
+++ b/CPP/7zip/Archive/Tar/Tar.dsp
diff --git a/7zip/Archive/Tar/Tar.dsw b/CPP/7zip/Archive/Tar/Tar.dsw
index 318cce1c..318cce1c 100755
--- a/7zip/Archive/Tar/Tar.dsw
+++ b/CPP/7zip/Archive/Tar/Tar.dsw
diff --git a/7zip/Archive/Tar/TarHandler.cpp b/CPP/7zip/Archive/Tar/TarHandler.cpp
index 9c2cd006..9c2cd006 100755
--- a/7zip/Archive/Tar/TarHandler.cpp
+++ b/CPP/7zip/Archive/Tar/TarHandler.cpp
diff --git a/7zip/Archive/Tar/TarHandler.h b/CPP/7zip/Archive/Tar/TarHandler.h
index 7b6e3a40..7b6e3a40 100755
--- a/7zip/Archive/Tar/TarHandler.h
+++ b/CPP/7zip/Archive/Tar/TarHandler.h
diff --git a/7zip/Archive/Tar/TarHandlerOut.cpp b/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
index 110833fb..110833fb 100755
--- a/7zip/Archive/Tar/TarHandlerOut.cpp
+++ b/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
diff --git a/7zip/Archive/Tar/TarHeader.cpp b/CPP/7zip/Archive/Tar/TarHeader.cpp
index 35f0d0cf..35f0d0cf 100755
--- a/7zip/Archive/Tar/TarHeader.cpp
+++ b/CPP/7zip/Archive/Tar/TarHeader.cpp
diff --git a/7zip/Archive/Tar/TarHeader.h b/CPP/7zip/Archive/Tar/TarHeader.h
index 0ab31e52..0ab31e52 100755
--- a/7zip/Archive/Tar/TarHeader.h
+++ b/CPP/7zip/Archive/Tar/TarHeader.h
diff --git a/7zip/Archive/Tar/TarIn.cpp b/CPP/7zip/Archive/Tar/TarIn.cpp
index 86afc482..86afc482 100755
--- a/7zip/Archive/Tar/TarIn.cpp
+++ b/CPP/7zip/Archive/Tar/TarIn.cpp
diff --git a/7zip/Archive/Tar/TarIn.h b/CPP/7zip/Archive/Tar/TarIn.h
index 28781375..28781375 100755
--- a/7zip/Archive/Tar/TarIn.h
+++ b/CPP/7zip/Archive/Tar/TarIn.h
diff --git a/7zip/Archive/Tar/TarItem.h b/CPP/7zip/Archive/Tar/TarItem.h
index 71fff7ba..71fff7ba 100755
--- a/7zip/Archive/Tar/TarItem.h
+++ b/CPP/7zip/Archive/Tar/TarItem.h
diff --git a/7zip/Archive/Tar/TarOut.cpp b/CPP/7zip/Archive/Tar/TarOut.cpp
index e278edda..e278edda 100755
--- a/7zip/Archive/Tar/TarOut.cpp
+++ b/CPP/7zip/Archive/Tar/TarOut.cpp
diff --git a/7zip/Archive/Tar/TarOut.h b/CPP/7zip/Archive/Tar/TarOut.h
index ef837869..ef837869 100755
--- a/7zip/Archive/Tar/TarOut.h
+++ b/CPP/7zip/Archive/Tar/TarOut.h
diff --git a/7zip/Archive/Tar/TarUpdate.cpp b/CPP/7zip/Archive/Tar/TarUpdate.cpp
index 9a6f64e2..9a6f64e2 100755
--- a/7zip/Archive/Tar/TarUpdate.cpp
+++ b/CPP/7zip/Archive/Tar/TarUpdate.cpp
diff --git a/7zip/Archive/Tar/TarUpdate.h b/CPP/7zip/Archive/Tar/TarUpdate.h
index 92f5cebb..92f5cebb 100755
--- a/7zip/Archive/Tar/TarUpdate.h
+++ b/CPP/7zip/Archive/Tar/TarUpdate.h
diff --git a/7zip/Archive/Tar/makefile b/CPP/7zip/Archive/Tar/makefile
index f892c303..f892c303 100755
--- a/7zip/Archive/Tar/makefile
+++ b/CPP/7zip/Archive/Tar/makefile
diff --git a/7zip/Archive/Tar/resource.rc b/CPP/7zip/Archive/Tar/resource.rc
index 3d37f440..3d37f440 100755
--- a/7zip/Archive/Tar/resource.rc
+++ b/CPP/7zip/Archive/Tar/resource.rc
diff --git a/7zip/Archive/Tar/tar.ico b/CPP/7zip/Archive/Tar/tar.ico
index 6835885b..6835885b 100755
--- a/7zip/Archive/Tar/tar.ico
+++ b/CPP/7zip/Archive/Tar/tar.ico
Binary files differ
diff --git a/7zip/Archive/Z/DllExports.cpp b/CPP/7zip/Archive/Z/DllExports.cpp
index b8df85f4..b8df85f4 100755
--- a/7zip/Archive/Z/DllExports.cpp
+++ b/CPP/7zip/Archive/Z/DllExports.cpp
diff --git a/7zip/Archive/Zip/StdAfx.cpp b/CPP/7zip/Archive/Z/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/Zip/StdAfx.cpp
+++ b/CPP/7zip/Archive/Z/StdAfx.cpp
diff --git a/7zip/Archive/Zip/StdAfx.h b/CPP/7zip/Archive/Z/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/Zip/StdAfx.h
+++ b/CPP/7zip/Archive/Z/StdAfx.h
diff --git a/7zip/Archive/Z/Z.dsp b/CPP/7zip/Archive/Z/Z.dsp
index e1f72522..e1f72522 100755
--- a/7zip/Archive/Z/Z.dsp
+++ b/CPP/7zip/Archive/Z/Z.dsp
diff --git a/7zip/Archive/Z/Z.dsw b/CPP/7zip/Archive/Z/Z.dsw
index 1f67186a..1f67186a 100755
--- a/7zip/Archive/Z/Z.dsw
+++ b/CPP/7zip/Archive/Z/Z.dsw
diff --git a/7zip/Archive/Z/Z.ico b/CPP/7zip/Archive/Z/Z.ico
index 2db53583..2db53583 100755
--- a/7zip/Archive/Z/Z.ico
+++ b/CPP/7zip/Archive/Z/Z.ico
Binary files differ
diff --git a/7zip/Archive/Z/ZHandler.cpp b/CPP/7zip/Archive/Z/ZHandler.cpp
index 33887690..33887690 100755
--- a/7zip/Archive/Z/ZHandler.cpp
+++ b/CPP/7zip/Archive/Z/ZHandler.cpp
diff --git a/7zip/Archive/Z/ZHandler.h b/CPP/7zip/Archive/Z/ZHandler.h
index 7abba29f..7abba29f 100755
--- a/7zip/Archive/Z/ZHandler.h
+++ b/CPP/7zip/Archive/Z/ZHandler.h
diff --git a/7zip/Archive/Z/makefile b/CPP/7zip/Archive/Z/makefile
index aff4fc42..aff4fc42 100755
--- a/7zip/Archive/Z/makefile
+++ b/CPP/7zip/Archive/Z/makefile
diff --git a/7zip/Archive/Z/resource.rc b/CPP/7zip/Archive/Z/resource.rc
index 05a81423..05a81423 100755
--- a/7zip/Archive/Z/resource.rc
+++ b/CPP/7zip/Archive/Z/resource.rc
diff --git a/7zip/Archive/Zip/DllExports.cpp b/CPP/7zip/Archive/Zip/DllExports.cpp
index da2a15a4..da2a15a4 100755
--- a/7zip/Archive/Zip/DllExports.cpp
+++ b/CPP/7zip/Archive/Zip/DllExports.cpp
diff --git a/7zip/Archive/cpio/StdAfx.cpp b/CPP/7zip/Archive/Zip/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Archive/cpio/StdAfx.cpp
+++ b/CPP/7zip/Archive/Zip/StdAfx.cpp
diff --git a/7zip/Archive/cpio/StdAfx.h b/CPP/7zip/Archive/Zip/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Archive/cpio/StdAfx.h
+++ b/CPP/7zip/Archive/Zip/StdAfx.h
diff --git a/7zip/Archive/Zip/Zip.dsp b/CPP/7zip/Archive/Zip/Zip.dsp
index 2ac27f4f..2ac27f4f 100755
--- a/7zip/Archive/Zip/Zip.dsp
+++ b/CPP/7zip/Archive/Zip/Zip.dsp
diff --git a/7zip/Archive/Zip/Zip.dsw b/CPP/7zip/Archive/Zip/Zip.dsw
index 0a355329..0a355329 100755
--- a/7zip/Archive/Zip/Zip.dsw
+++ b/CPP/7zip/Archive/Zip/Zip.dsw
diff --git a/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
index 7eb2787f..7eb2787f 100755
--- a/7zip/Archive/Zip/ZipAddCommon.cpp
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
diff --git a/7zip/Archive/Zip/ZipAddCommon.h b/CPP/7zip/Archive/Zip/ZipAddCommon.h
index 26cec643..26cec643 100755
--- a/7zip/Archive/Zip/ZipAddCommon.h
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.h
diff --git a/7zip/Archive/Zip/ZipCompressionMode.h b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
index f1c79918..f1c79918 100755
--- a/7zip/Archive/Zip/ZipCompressionMode.h
+++ b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
diff --git a/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp
index 4672d768..4672d768 100755
--- a/7zip/Archive/Zip/ZipHandler.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp
diff --git a/7zip/Archive/Zip/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h
index ea6becd0..ea6becd0 100755
--- a/7zip/Archive/Zip/ZipHandler.h
+++ b/CPP/7zip/Archive/Zip/ZipHandler.h
diff --git a/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
index e2394172..e2394172 100755
--- a/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
diff --git a/7zip/Archive/Zip/ZipHeader.cpp b/CPP/7zip/Archive/Zip/ZipHeader.cpp
index fd8856bb..fd8856bb 100755
--- a/7zip/Archive/Zip/ZipHeader.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHeader.cpp
diff --git a/7zip/Archive/Zip/ZipHeader.h b/CPP/7zip/Archive/Zip/ZipHeader.h
index ac98ea76..ac98ea76 100755
--- a/7zip/Archive/Zip/ZipHeader.h
+++ b/CPP/7zip/Archive/Zip/ZipHeader.h
diff --git a/7zip/Archive/Zip/ZipIn.cpp b/CPP/7zip/Archive/Zip/ZipIn.cpp
index c9e3a7d1..c9e3a7d1 100755
--- a/7zip/Archive/Zip/ZipIn.cpp
+++ b/CPP/7zip/Archive/Zip/ZipIn.cpp
diff --git a/7zip/Archive/Zip/ZipIn.h b/CPP/7zip/Archive/Zip/ZipIn.h
index 80de2272..80de2272 100755
--- a/7zip/Archive/Zip/ZipIn.h
+++ b/CPP/7zip/Archive/Zip/ZipIn.h
diff --git a/7zip/Archive/Zip/ZipItem.cpp b/CPP/7zip/Archive/Zip/ZipItem.cpp
index 1934c357..1934c357 100755
--- a/7zip/Archive/Zip/ZipItem.cpp
+++ b/CPP/7zip/Archive/Zip/ZipItem.cpp
diff --git a/7zip/Archive/Zip/ZipItem.h b/CPP/7zip/Archive/Zip/ZipItem.h
index 765bfd85..765bfd85 100755
--- a/7zip/Archive/Zip/ZipItem.h
+++ b/CPP/7zip/Archive/Zip/ZipItem.h
diff --git a/7zip/Archive/Zip/ZipItemEx.h b/CPP/7zip/Archive/Zip/ZipItemEx.h
index 3cacc0e7..3cacc0e7 100755
--- a/7zip/Archive/Zip/ZipItemEx.h
+++ b/CPP/7zip/Archive/Zip/ZipItemEx.h
diff --git a/7zip/Archive/Zip/ZipOut.cpp b/CPP/7zip/Archive/Zip/ZipOut.cpp
index 7575d320..7575d320 100755
--- a/7zip/Archive/Zip/ZipOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipOut.cpp
diff --git a/7zip/Archive/Zip/ZipOut.h b/CPP/7zip/Archive/Zip/ZipOut.h
index e08c306e..e08c306e 100755
--- a/7zip/Archive/Zip/ZipOut.h
+++ b/CPP/7zip/Archive/Zip/ZipOut.h
diff --git a/CPP/7zip/Archive/Zip/ZipUpdate.cpp b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
new file mode 100755
index 00000000..f66fcef9
--- /dev/null
+++ b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
@@ -0,0 +1,734 @@
+// ZipUpdate.cpp
+
+#include "StdAfx.h"
+
+#include <stdio.h>
+
+#include "ZipUpdate.h"
+#include "ZipAddCommon.h"
+#include "ZipOut.h"
+
+#include "Common/Defs.h"
+#include "Common/AutoPtr.h"
+#include "Common/StringConvert.h"
+#include "Windows/Defs.h"
+#include "Windows/Thread.h"
+
+#include "../../Common/ProgressUtils.h"
+#ifdef COMPRESS_MT
+#include "../../Common/ProgressMt.h"
+#endif
+#include "../../Common/LimitedStreams.h"
+#include "../../Common/OutMemStream.h"
+
+#include "../../Compress/Copy/CopyCoder.h"
+
+using namespace NWindows;
+using namespace NSynchronization;
+
+namespace NArchive {
+namespace NZip {
+
+class CCriticalSectionLock2
+{
+ CCriticalSection *_object;
+ void Unlock() { if (_object != 0) _object->Leave(); }
+public:
+ CCriticalSectionLock2(): _object(0) {}
+ void Set(CCriticalSection &object) { _object = &object; _object->Enter(); }
+ ~CCriticalSectionLock2() { Unlock(); }
+};
+
+static const Byte kMadeByHostOS = NFileHeader::NHostOS::kFAT;
+static const Byte kExtractHostOS = NFileHeader::NHostOS::kFAT;
+
+static const Byte kMethodForDirectory = NFileHeader::NCompressionMethod::kStored;
+static const Byte kExtractVersionForDirectory = NFileHeader::NCompressionMethod::kStoreExtractVersion;
+
+static HRESULT CopyBlockToArchive(ISequentialInStream *inStream,
+ COutArchive &outArchive, ICompressProgressInfo *progress)
+{
+ CMyComPtr<ISequentialOutStream> outStream;
+ outArchive.CreateStreamForCopying(&outStream);
+ CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
+ return copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+}
+
+static HRESULT WriteRange(IInStream *inStream, COutArchive &outArchive,
+ const CUpdateRange &range, ICompressProgressInfo *progress)
+{
+ UInt64 position;
+ RINOK(inStream->Seek(range.Position, STREAM_SEEK_SET, &position));
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
+ streamSpec->SetStream(inStream);
+ streamSpec->Init(range.Size);
+
+ RINOK(CopyBlockToArchive(inStreamLimited, outArchive, progress));
+ return progress->SetRatioInfo(&range.Size, &range.Size);
+}
+
+static void SetFileHeader(
+ COutArchive &archive,
+ const CCompressionMethodMode &options,
+ const CUpdateItem &updateItem,
+ CItem &item)
+{
+ item.UnPackSize = updateItem.Size;
+ bool isDirectory;
+
+ if (updateItem.NewProperties)
+ {
+ isDirectory = updateItem.IsDirectory;
+ item.Name = updateItem.Name;
+ item.ExternalAttributes = updateItem.Attributes;
+ item.Time = updateItem.Time;
+ }
+ else
+ isDirectory = item.IsDirectory();
+
+ item.LocalHeaderPosition = archive.GetCurrentPosition();
+ item.MadeByVersion.HostOS = kMadeByHostOS;
+ item.MadeByVersion.Version = NFileHeader::NCompressionMethod::kMadeByProgramVersion;
+
+ item.ExtractVersion.HostOS = kExtractHostOS;
+
+ item.InternalAttributes = 0; // test it
+ item.ClearFlags();
+ item.SetEncrypted(!isDirectory && options.PasswordIsDefined);
+ if (isDirectory)
+ {
+ item.ExtractVersion.Version = kExtractVersionForDirectory;
+ item.CompressionMethod = kMethodForDirectory;
+ item.PackSize = 0;
+ item.FileCRC = 0; // test it
+ }
+}
+
+static void SetItemInfoFromCompressingResult(const CCompressingResult &compressingResult,
+ bool isAesMode, Byte aesKeyMode, CItem &item)
+{
+ item.ExtractVersion.Version = compressingResult.ExtractVersion;
+ item.CompressionMethod = compressingResult.Method;
+ item.FileCRC = compressingResult.CRC;
+ item.UnPackSize = compressingResult.UnpackSize;
+ item.PackSize = compressingResult.PackSize;
+
+ item.LocalExtra.Clear();
+ item.CentralExtra.Clear();
+
+ if (isAesMode)
+ {
+ CWzAesExtraField wzAesField;
+ wzAesField.Strength = aesKeyMode;
+ wzAesField.Method = compressingResult.Method;
+ item.CompressionMethod = NFileHeader::NCompressionMethod::kWzAES;
+ item.FileCRC = 0;
+ CExtraSubBlock sb;
+ wzAesField.SetSubBlock(sb);
+ item.LocalExtra.SubBlocks.Add(sb);
+ item.CentralExtra.SubBlocks.Add(sb);
+ }
+}
+
+#ifdef COMPRESS_MT
+
+static DWORD WINAPI CoderThread(void *threadCoderInfo);
+
+struct CThreadInfo
+{
+ NWindows::CThread Thread;
+ CAutoResetEvent *CompressEvent;
+ CAutoResetEvent *CompressionCompletedEvent;
+ bool ExitThread;
+
+ CMtCompressProgress *ProgressSpec;
+ CMyComPtr<ICompressProgressInfo> Progress;
+
+ COutMemStream *OutStreamSpec;
+ CMyComPtr<IOutStream> OutStream;
+ CMyComPtr<ISequentialInStream> InStream;
+
+ CAddCommon Coder;
+ HRESULT Result;
+ CCompressingResult CompressingResult;
+
+ bool IsFree;
+ UInt32 UpdateIndex;
+
+ CThreadInfo(const CCompressionMethodMode &options):
+ CompressEvent(NULL),
+ CompressionCompletedEvent(NULL),
+ ExitThread(false),
+ ProgressSpec(0),
+ OutStreamSpec(0),
+ Coder(options)
+ {}
+
+ void CreateEvents()
+ {
+ CompressEvent = new CAutoResetEvent(false);
+ CompressionCompletedEvent = new CAutoResetEvent(false);
+ }
+ bool CreateThread() { return Thread.Create(CoderThread, this); }
+ ~CThreadInfo();
+
+ void WaitAndCode();
+ void StopWaitClose()
+ {
+ ExitThread = true;
+ if (OutStreamSpec != 0)
+ OutStreamSpec->StopWriting(E_ABORT);
+ if (CompressEvent != NULL)
+ CompressEvent->Set();
+ Thread.Wait();
+ Thread.Close();
+ }
+
+};
+
+CThreadInfo::~CThreadInfo()
+{
+ if (CompressEvent != NULL)
+ delete CompressEvent;
+ if (CompressionCompletedEvent != NULL)
+ delete CompressionCompletedEvent;
+}
+
+void CThreadInfo::WaitAndCode()
+{
+ for (;;)
+ {
+ CompressEvent->Lock();
+ if (ExitThread)
+ return;
+ Result = Coder.Compress(InStream, OutStream, Progress, CompressingResult);
+ if (Result == S_OK && Progress)
+ Result = Progress->SetRatioInfo(&CompressingResult.UnpackSize, &CompressingResult.PackSize);
+ CompressionCompletedEvent->Set();
+ }
+}
+
+static DWORD WINAPI CoderThread(void *threadCoderInfo)
+{
+ ((CThreadInfo *)threadCoderInfo)->WaitAndCode();
+ return 0;
+}
+
+class CThreads
+{
+public:
+ CObjectVector<CThreadInfo> Threads;
+ ~CThreads()
+ {
+ for (int i = 0; i < Threads.Size(); i++)
+ Threads[i].StopWaitClose();
+ }
+};
+
+struct CMemBlocks2: public CMemLockBlocks
+{
+ CCompressingResult CompressingResult;
+ bool Defined;
+ bool Skip;
+ CMemBlocks2(): Defined(false), Skip(false) {}
+};
+
+class CMemRefs
+{
+public:
+ CMemBlockManagerMt *Manager;
+ CObjectVector<CMemBlocks2> Refs;
+ CMemRefs(CMemBlockManagerMt *manager): Manager(manager) {} ;
+ ~CMemRefs()
+ {
+ for (int i = 0; i < Refs.Size(); i++)
+ Refs[i].FreeOpt(Manager);
+ }
+};
+
+#endif
+
+
+static HRESULT UpdateItemOldData(COutArchive &archive,
+ IInStream *inStream,
+ const CUpdateItem &updateItem, CItemEx &item, ICompressProgressInfo *progress,
+ UInt64 &complexity)
+{
+ if (updateItem.NewProperties)
+ {
+ if (item.HasDescriptor())
+ return E_NOTIMPL;
+
+ // use old name size.
+ // CUpdateRange range(item.GetLocalExtraPosition(), item.LocalExtraSize + item.PackSize);
+ CUpdateRange range(item.GetDataPosition(), item.PackSize);
+
+ // item.ExternalAttributes = updateItem.Attributes;
+ // Test it
+ item.Name = updateItem.Name;
+ item.Time = updateItem.Time;
+ item.CentralExtra.RemoveUnknownSubBlocks();
+ item.LocalExtra.RemoveUnknownSubBlocks();
+
+ archive.PrepareWriteCompressedData2((UInt16)item.Name.Length(), item.UnPackSize, item.PackSize, item.LocalExtra.HasWzAesField());
+ item.LocalHeaderPosition = archive.GetCurrentPosition();
+ archive.SeekToPackedDataPosition();
+ RINOK(WriteRange(inStream, archive, range, progress));
+ complexity += range.Size;
+ archive.WriteLocalHeader(item);
+ }
+ else
+ {
+ CUpdateRange range(item.LocalHeaderPosition, item.GetLocalFullSize());
+
+ // set new header position
+ item.LocalHeaderPosition = archive.GetCurrentPosition();
+
+ RINOK(WriteRange(inStream, archive, range, progress));
+ complexity += range.Size;
+ archive.MoveBasePosition(range.Size);
+ }
+ return S_OK;
+}
+
+static HRESULT WriteDirHeader(COutArchive &archive, const CCompressionMethodMode *options,
+ const CUpdateItem &updateItem, CItemEx &item)
+{
+ SetFileHeader(archive, *options, updateItem, item);
+ archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), updateItem.Size, options->IsAesMode);
+ return archive.WriteLocalHeader(item);
+}
+
+static HRESULT Update2St(COutArchive &archive,
+ CInArchive *inArchive,
+ IInStream *inStream,
+ const CObjectVector<CItemEx> &inputItems,
+ const CObjectVector<CUpdateItem> &updateItems,
+ const CCompressionMethodMode *options,
+ const CByteBuffer &comment,
+ IArchiveUpdateCallback *updateCallback)
+{
+ CLocalProgress *localProgressSpec = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
+ localProgressSpec->Init(updateCallback, true);
+
+ CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
+ CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
+
+ CAddCommon compressor(*options);
+
+ CObjectVector<CItem> items;
+ UInt64 complexity = 0;
+
+ for (int itemIndex = 0; itemIndex < updateItems.Size(); itemIndex++)
+ {
+ RINOK(updateCallback->SetCompleted(&complexity));
+ const CUpdateItem &updateItem = updateItems[itemIndex];
+ CItemEx item;
+ if (!updateItem.NewProperties || !updateItem.NewData)
+ {
+ item = inputItems[updateItem.IndexInArchive];
+ if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
+ return E_NOTIMPL;
+ }
+
+ if (updateItem.NewData)
+ {
+ bool isDirectory = ((updateItem.NewProperties) ? updateItem.IsDirectory : item.IsDirectory());
+ if (isDirectory)
+ {
+ RINOK(WriteDirHeader(archive, options, updateItem, item));
+ }
+ else
+ {
+ CMyComPtr<ISequentialInStream> fileInStream;
+ HRESULT res = updateCallback->GetStream(updateItem.IndexInClient, &fileInStream);
+ if (res == S_FALSE)
+ {
+ complexity += updateItem.Size + NFileHeader::kLocalBlockSize;
+ 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);
+ CCompressingResult compressingResult;
+ CMyComPtr<IOutStream> outStream;
+ archive.CreateStreamForCompressing(&outStream);
+ localCompressProgressSpec->Init(localProgress, &complexity, NULL);
+ RINOK(compressor.Compress(fileInStream, outStream, compressProgress, compressingResult));
+ SetItemInfoFromCompressingResult(compressingResult, options->IsAesMode, options->AesKeyMode, item);
+ RINOK(archive.WriteLocalHeader(item));
+ RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ complexity += item.UnPackSize;
+ }
+ }
+ else
+ {
+ localCompressProgressSpec->Init(localProgress, &complexity, NULL);
+ RINOK(UpdateItemOldData(archive, inStream, updateItem, item, compressProgress, complexity));
+ }
+ items.Add(item);
+ complexity += NFileHeader::kLocalBlockSize;
+ }
+ archive.WriteCentralDir(items, comment);
+ return S_OK;
+}
+
+static HRESULT Update2(COutArchive &archive,
+ CInArchive *inArchive,
+ IInStream *inStream,
+ const CObjectVector<CItemEx> &inputItems,
+ const CObjectVector<CUpdateItem> &updateItems,
+ const CCompressionMethodMode *options,
+ const CByteBuffer &comment,
+ IArchiveUpdateCallback *updateCallback)
+{
+ UInt64 complexity = 0;
+ UInt64 numFilesToCompress = 0;
+ UInt64 numBytesToCompress = 0;
+
+ int i;
+ for(i = 0; i < updateItems.Size(); i++)
+ {
+ const CUpdateItem &updateItem = updateItems[i];
+ if (updateItem.NewData)
+ {
+ complexity += updateItem.Size;
+ numBytesToCompress += updateItem.Size;
+ numFilesToCompress++;
+ /*
+ if (updateItem.Commented)
+ complexity += updateItem.CommentRange.Size;
+ */
+ }
+ else
+ {
+ CItemEx inputItem = inputItems[updateItem.IndexInArchive];
+ if (inArchive->ReadLocalItemAfterCdItemFull(inputItem) != S_OK)
+ return E_NOTIMPL;
+ complexity += inputItem.GetLocalFullSize();
+ // complexity += inputItem.GetCentralExtraPlusCommentSize();
+ }
+ complexity += NFileHeader::kLocalBlockSize;
+ complexity += NFileHeader::kCentralBlockSize;
+ }
+
+ if (comment != 0)
+ complexity += comment.GetCapacity();
+ complexity++; // end of central
+ updateCallback->SetTotal(complexity);
+
+ CAddCommon compressor(*options);
+
+ complexity = 0;
+
+ #ifdef COMPRESS_MT
+
+ const size_t kNumMaxThreads = (1 << 10);
+ UInt32 numThreads = options->NumThreads;
+ if (numThreads > kNumMaxThreads)
+ numThreads = kNumMaxThreads;
+
+ const size_t kMemPerThread = (1 << 25);
+ const size_t kBlockSize = 1 << 16;
+
+ CCompressionMethodMode options2;
+ if (options != 0)
+ options2 = *options;
+
+ bool mtMode = ((options != 0) && (numThreads > 1));
+
+ if (numFilesToCompress <= 1)
+ mtMode = false;
+
+ if (mtMode)
+ {
+ Byte method = options->MethodSequence.Front();
+ if (method == NFileHeader::NCompressionMethod::kStored && !options->PasswordIsDefined)
+ mtMode = false;
+ if (method == NFileHeader::NCompressionMethod::kBZip2)
+ {
+ UInt64 averageSize = numBytesToCompress / numFilesToCompress;
+ UInt32 blockSize = options->DicSize;
+ if (blockSize == 0)
+ blockSize = 1;
+ UInt64 averageNumberOfBlocks = averageSize / blockSize;
+ UInt32 numBZip2Threads = 32;
+ if (averageNumberOfBlocks < numBZip2Threads)
+ numBZip2Threads = (UInt32)averageNumberOfBlocks;
+ if (numBZip2Threads < 1)
+ numBZip2Threads = 1;
+ numThreads = numThreads / numBZip2Threads;
+ options2.NumThreads = numBZip2Threads;
+ if (numThreads <= 1)
+ mtMode = false;
+ }
+ }
+
+ if (!mtMode)
+ #endif
+ return Update2St(archive, inArchive,inStream,
+ inputItems, updateItems, options, comment, updateCallback);
+
+
+ #ifdef COMPRESS_MT
+
+ CObjectVector<CItem> items;
+
+ CLocalProgress *localProgressSpec = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
+ localProgressSpec->Init(updateCallback, true);
+
+ CMtCompressProgressMixer mtCompressProgressMixer;
+ mtCompressProgressMixer.Init(numThreads + 1, localProgress);
+
+ // we need one item for main stream
+ CMtCompressProgress *progressMainSpec = new CMtCompressProgress();
+ CMyComPtr<ICompressProgressInfo> progressMain = progressMainSpec;
+ progressMainSpec->Init(&mtCompressProgressMixer, (int)numThreads);
+
+ CMemBlockManagerMt memManager(kBlockSize);
+ CMemRefs refs(&memManager);
+
+ CThreads threads;
+ CRecordVector<HANDLE> compressingCompletedEvents;
+ CRecordVector<int> threadIndices; // list threads in order of updateItems
+
+ {
+ if (!memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize)))
+ return E_OUTOFMEMORY;
+ for(i = 0; i < updateItems.Size(); i++)
+ refs.Refs.Add(CMemBlocks2());
+
+ UInt32 i;
+ for (i = 0; i < numThreads; i++)
+ threads.Threads.Add(CThreadInfo(options2));
+
+ for (i = 0; i < numThreads; i++)
+ {
+ CThreadInfo &threadInfo = threads.Threads[i];
+ threadInfo.CreateEvents();
+ threadInfo.OutStreamSpec = new COutMemStream(&memManager);
+ threadInfo.OutStream = threadInfo.OutStreamSpec;
+ threadInfo.IsFree = true;
+ threadInfo.ProgressSpec = new CMtCompressProgress();
+ threadInfo.Progress = threadInfo.ProgressSpec;
+ threadInfo.ProgressSpec->Init(&mtCompressProgressMixer, (int)i);
+ if (!threadInfo.CreateThread())
+ return ::GetLastError();
+ }
+ }
+ int mtItemIndex = 0;
+
+ int itemIndex = 0;
+ int lastRealStreamItemIndex = -1;
+
+ while (itemIndex < updateItems.Size())
+ {
+ if ((UInt32)threadIndices.Size() < numThreads && mtItemIndex < updateItems.Size())
+ {
+ const CUpdateItem &updateItem = updateItems[mtItemIndex++];
+ if (!updateItem.NewData)
+ continue;
+ CItemEx item;
+ if (updateItem.NewProperties)
+ {
+ if (updateItem.IsDirectory)
+ continue;
+ }
+ else
+ {
+ item = inputItems[updateItem.IndexInArchive];
+ if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
+ return E_NOTIMPL;
+ if (item.IsDirectory())
+ continue;
+ }
+ CMyComPtr<ISequentialInStream> fileInStream;
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(mtCompressProgressMixer.CriticalSection);
+ HRESULT res = updateCallback->GetStream(updateItem.IndexInClient, &fileInStream);
+ if (res == S_FALSE)
+ {
+ complexity += updateItem.Size;
+ complexity++;
+ RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ refs.Refs[mtItemIndex - 1].Skip = true;
+ continue;
+ }
+ RINOK(res);
+ RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ }
+
+ for (UInt32 i = 0; i < numThreads; i++)
+ {
+ CThreadInfo &threadInfo = threads.Threads[i];
+ if (threadInfo.IsFree)
+ {
+ threadInfo.IsFree = false;
+ threadInfo.InStream = fileInStream;
+ threadInfo.OutStreamSpec->Init();
+ threadInfo.ProgressSpec->Reinit();
+ threadInfo.CompressEvent->Set();
+ threadInfo.UpdateIndex = mtItemIndex - 1;
+
+ compressingCompletedEvents.Add(*threadInfo.CompressionCompletedEvent);
+ threadIndices.Add(i);
+ break;
+ }
+ }
+ continue;
+ }
+
+ if (refs.Refs[itemIndex].Skip)
+ {
+ itemIndex++;
+ continue;
+ }
+
+ const CUpdateItem &updateItem = updateItems[itemIndex];
+
+ CItemEx item;
+ if (!updateItem.NewProperties || !updateItem.NewData)
+ {
+ item = inputItems[updateItem.IndexInArchive];
+ if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
+ return E_NOTIMPL;
+ }
+
+ if (updateItem.NewData)
+ {
+ bool isDirectory = ((updateItem.NewProperties) ? updateItem.IsDirectory : item.IsDirectory());
+ if (isDirectory)
+ {
+ RINOK(WriteDirHeader(archive, options, updateItem, item));
+ }
+ else
+ {
+ if (lastRealStreamItemIndex < itemIndex)
+ {
+ lastRealStreamItemIndex = itemIndex;
+ SetFileHeader(archive, *options, updateItem, item);
+ // file Size can be 64-bit !!!
+ archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), updateItem.Size, options->IsAesMode);
+ }
+
+ CMemBlocks2 &memRef = refs.Refs[itemIndex];
+ if (memRef.Defined)
+ {
+ CMyComPtr<IOutStream> outStream;
+ archive.CreateStreamForCompressing(&outStream);
+ memRef.WriteToStream(memManager.GetBlockSize(), outStream);
+ SetItemInfoFromCompressingResult(memRef.CompressingResult,
+ options->IsAesMode, options->AesKeyMode, item);
+ SetFileHeader(archive, *options, updateItem, item);
+ RINOK(archive.WriteLocalHeader(item));
+ complexity += item.UnPackSize;
+ // RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
+ memRef.FreeOpt(&memManager);
+ }
+ else
+ {
+ {
+ CThreadInfo &thread = threads.Threads[threadIndices.Front()];
+ if (!thread.OutStreamSpec->WasUnlockEventSent())
+ {
+ CMyComPtr<IOutStream> outStream;
+ archive.CreateStreamForCompressing(&outStream);
+ thread.OutStreamSpec->SetOutStream(outStream);
+ thread.OutStreamSpec->SetRealStreamMode();
+ }
+ }
+
+ DWORD result = ::WaitForMultipleObjects(compressingCompletedEvents.Size(),
+ &compressingCompletedEvents.Front(), FALSE, INFINITE);
+ int t = (int)(result - WAIT_OBJECT_0);
+ CThreadInfo &threadInfo = threads.Threads[threadIndices[t]];
+ threadInfo.InStream.Release();
+ threadInfo.IsFree = true;
+ RINOK(threadInfo.Result);
+ threadIndices.Delete(t);
+ compressingCompletedEvents.Delete(t);
+ if (t == 0)
+ {
+ RINOK(threadInfo.OutStreamSpec->WriteToRealStream());
+ threadInfo.OutStreamSpec->ReleaseOutStream();
+ SetItemInfoFromCompressingResult(threadInfo.CompressingResult,
+ options->IsAesMode, options->AesKeyMode, item);
+ SetFileHeader(archive, *options, updateItem, item);
+ RINOK(archive.WriteLocalHeader(item));
+ complexity += item.UnPackSize;
+ }
+ else
+ {
+ CMemBlocks2 &memRef = refs.Refs[threadInfo.UpdateIndex];
+ threadInfo.OutStreamSpec->DetachData(memRef);
+ memRef.CompressingResult = threadInfo.CompressingResult;
+ memRef.Defined = true;
+ continue;
+ }
+ }
+ }
+ }
+ else
+ {
+ progressMainSpec->Reinit();
+ RINOK(UpdateItemOldData(archive, inStream, updateItem, item, progressMain, complexity));
+ }
+ items.Add(item);
+ complexity += NFileHeader::kLocalBlockSize;
+ itemIndex++;
+ }
+ archive.WriteCentralDir(items, comment);
+ return S_OK;
+ #endif
+}
+
+HRESULT Update(
+ const CObjectVector<CItemEx> &inputItems,
+ const CObjectVector<CUpdateItem> &updateItems,
+ ISequentialOutStream *seqOutStream,
+ CInArchive *inArchive,
+ CCompressionMethodMode *compressionMethodMode,
+ IArchiveUpdateCallback *updateCallback)
+{
+ CMyComPtr<IOutStream> outStream;
+ RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream));
+ if (!outStream)
+ return E_NOTIMPL;
+
+ CInArchiveInfo archiveInfo;
+ if(inArchive != 0)
+ {
+ inArchive->GetArchiveInfo(archiveInfo);
+ if (archiveInfo.Base != 0)
+ return E_NOTIMPL;
+ }
+ else
+ archiveInfo.StartPosition = 0;
+
+ COutArchive outArchive;
+ outArchive.Create(outStream);
+ if (archiveInfo.StartPosition > 0)
+ {
+ CMyComPtr<ISequentialInStream> inStream;
+ inStream.Attach(inArchive->CreateLimitedStream(0, archiveInfo.StartPosition));
+ RINOK(CopyBlockToArchive(inStream, outArchive, NULL));
+ outArchive.MoveBasePosition(archiveInfo.StartPosition);
+ }
+ CMyComPtr<IInStream> inStream;
+ if(inArchive != 0)
+ inStream.Attach(inArchive->CreateStream());
+
+ return Update2(outArchive, inArchive, inStream,
+ inputItems, updateItems,
+ compressionMethodMode,
+ archiveInfo.Comment, updateCallback);
+}
+
+}}
diff --git a/7zip/Archive/Zip/ZipUpdate.h b/CPP/7zip/Archive/Zip/ZipUpdate.h
index d846b05f..d846b05f 100755
--- a/7zip/Archive/Zip/ZipUpdate.h
+++ b/CPP/7zip/Archive/Zip/ZipUpdate.h
diff --git a/7zip/Archive/Zip/makefile b/CPP/7zip/Archive/Zip/makefile
index eaf1031f..eaf1031f 100755
--- a/7zip/Archive/Zip/makefile
+++ b/CPP/7zip/Archive/Zip/makefile
diff --git a/7zip/Archive/Zip/resource.rc b/CPP/7zip/Archive/Zip/resource.rc
index 388f349e..388f349e 100755
--- a/7zip/Archive/Zip/resource.rc
+++ b/CPP/7zip/Archive/Zip/resource.rc
diff --git a/7zip/Archive/Zip/zip.ico b/CPP/7zip/Archive/Zip/zip.ico
index 2af46066..2af46066 100755
--- a/7zip/Archive/Zip/zip.ico
+++ b/CPP/7zip/Archive/Zip/zip.ico
Binary files differ
diff --git a/7zip/Archive/makefile b/CPP/7zip/Archive/makefile
index 7512ad56..7512ad56 100755
--- a/7zip/Archive/makefile
+++ b/CPP/7zip/Archive/makefile
diff --git a/CPP/7zip/Bundles/Alone/Alone.dsp b/CPP/7zip/Bundles/Alone/Alone.dsp
new file mode 100755
index 00000000..982cfb31
--- /dev/null
+++ b/CPP/7zip/Bundles/Alone/Alone.dsp
@@ -0,0 +1,2301 @@
+# Microsoft Developer Studio Project File - Name="Alone" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Alone - Win32 DebugU
+!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 "Alone.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 "Alone.mak" CFG="Alone - Win32 DebugU"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Alone - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Alone - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "Alone - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
+!MESSAGE "Alone - Win32 DebugU" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Alone - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /c
+# 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 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 /subsystem:console /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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7za.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "Alone - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /GZ /c
+# 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 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 /subsystem:console /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za.exe" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseU"
+# PROP BASE Intermediate_Dir "ReleaseU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseU"
+# PROP Intermediate_Dir "ReleaseU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /c
+# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7za.exe" /opt:NOWIN98
+# SUBTRACT BASE LINK32 /pdb:none
+# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7zan.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugU"
+# PROP BASE Intermediate_Dir "DebugU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugU"
+# PROP Intermediate_Dir "DebugU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /GZ /c
+# 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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za.exe" /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7zan.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "Alone - Win32 Release"
+# Name "Alone - Win32 Debug"
+# Name "Alone - Win32 ReleaseU"
+# Name "Alone - Win32 DebugU"
+# Begin Group "Console"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ArError.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\CompressionMode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ConsoleClose.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ConsoleClose.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ExtractCallbackConsole.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ExtractCallbackConsole.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\List.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\List.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\Main.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\MainAr.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\OpenCallbackConsole.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\OpenCallbackConsole.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\PercentPrinter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\PercentPrinter.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\UpdateCallbackConsole.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\UpdateCallbackConsole.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\UserInputUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\UserInputUtils.h
+# End Source File
+# End Group
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# 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 "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\AlignedBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\AlignedBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\AutoPtr.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Buffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CommandLineParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CommandLineParser.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\ComTry.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Defs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\DynamicBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Exception.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\ListFileUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\ListFileUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyCom.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyGuidDef.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyInitGuid.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyUnknown.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyWindows.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyWindows.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\Random.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Random.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdOutStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdOutStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.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
+# Begin Source File
+
+SOURCE=..\..\..\Common\Types.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\UTFConvert.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\UTFConvert.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.h
+# End Source File
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Defs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Device.h
+# End Source File
+# 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\Error.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Error.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.cpp
+# 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\MemoryLock.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\MemoryLock.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\PropVariantConversions.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\PropVariantConversions.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\Thread.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Time.h
+# End Source File
+# End Group
+# Begin Group "7zip Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CrossThreadProgress.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.h
+# End Source File
+# 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\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\LSBFDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFEncoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MemBlocks.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MSBFDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MSBFEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OffsetStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OffsetStream.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\OutMemStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OutMemStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\ProgressMt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\ProgressMt.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\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
+# End Group
+# Begin Group "Compress"
+
+# PROP Default_Filter ""
+# Begin Group "Branch"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\BranchCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\BranchCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\Coder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86_2.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86_2.h
+# End Source File
+# End Group
+# Begin Group "BZip2"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2CRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2Decoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2Decoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2Encoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2Encoder.h
+# End Source File
+# End Group
+# Begin Group "Copy"
+
+# 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 "Deflate"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateConst.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateDecoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateEncoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateExtConst.h
+# End Source File
+# End Group
+# Begin Group "Huffman"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Huffman\HuffmanDecoder.h
+# End Source File
+# End Group
+# Begin Group "Implode"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Implode\ImplodeDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Implode\ImplodeDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Implode\ImplodeHuffmanDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Implode\ImplodeHuffmanDecoder.h
+# End Source File
+# End Group
+# Begin Group "LZ"
+
+# PROP Default_Filter ""
+# Begin Group "MT"
+
+# PROP Default_Filter ""
+# End Group
+# Begin Group "HC"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC2.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC3.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC4.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC4b.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HCMain.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\IMatchFinder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\LZOutWindow.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\LZOutWindow.h
+# End Source File
+# End Group
+# Begin Group "LZMA"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMA.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMADecoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMADecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMAEncoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMAEncoder.h
+# End Source File
+# End Group
+# Begin Group "PPMd"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDContext.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDDecoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDEncode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDEncoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDSubAlloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDType.h
+# End Source File
+# End Group
+# Begin Group "RangeCoder"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderBitTree.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderOpt.h
+# End Source File
+# End Group
+# Begin Group "Shrink"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Shrink\ShrinkDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Shrink\ShrinkDecoder.h
+# End Source File
+# End Group
+# Begin Group "Z"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Z\ZDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Z\ZDecoder.h
+# End Source File
+# End Group
+# Begin Group "BWT"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\BWT\BlockSort.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BWT\BlockSort.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BWT\Mtf8.h
+# End Source File
+# End Group
+# Begin Group "LZX"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Lzx\Lzx.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Lzx\Lzx86Converter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Lzx\Lzx86Converter.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Lzx\LzxDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Lzx\LzxDecoder.h
+# End Source File
+# End Group
+# Begin Group "Quantum"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Quantum\QuantumDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Quantum\QuantumDecoder.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "Archive"
+
+# PROP Default_Filter ""
+# Begin Group "7z"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zCompressionMode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zDecode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zEncode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zEncode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zExtract.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderOutStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHeader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHeader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zItem.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zMethodID.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zMethodID.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zOut.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zProperties.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zSpecStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zSpecStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zUpdate.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zUpdate.h
+# End Source File
+# End Group
+# Begin Group "bz2"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\BZip2\BZip2Handler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\BZip2\BZip2Handler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\BZip2\BZip2HandlerOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\BZip2\BZip2Item.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\BZip2\BZip2Update.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\BZip2\BZip2Update.h
+# End Source File
+# End Group
+# Begin Group "gz"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipHandlerOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipHeader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipHeader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipItem.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipOut.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipUpdate.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\GZip\GZipUpdate.h
+# End Source File
+# End Group
+# Begin Group "tar"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarHandlerOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarHeader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarHeader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarItem.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarOut.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarUpdate.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Tar\TarUpdate.h
+# End Source File
+# End Group
+# Begin Group "zip"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipAddCommon.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipAddCommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipCompressionMode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipHandlerOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipHeader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipHeader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipItem.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipItem.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipItemEx.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipOut.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipUpdate.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Zip\ZipUpdate.h
+# End Source File
+# End Group
+# Begin Group "Archive Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2MT.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2MT.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2ST.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2ST.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\DummyOutStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\DummyOutStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\FilterCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\FilterCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\InStreamWithCRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\InStreamWithCRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ItemNameUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\MultiStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\MultiStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ParseProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ParseProperties.h
+# End Source File
+# End Group
+# Begin Group "split"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Split\SplitHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Split\SplitHandler.h
+# 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
+# End Group
+# Begin Group "cab"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Cab\CabBlockInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Cab\CabBlockInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Cab\CabHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Cab\CabHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Cab\CabHeader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Cab\CabHeader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Cab\CabIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Cab\CabIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Cab\CabItem.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "UI Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveCommandLine.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveCommandLine.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveExtractCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveExtractCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveOpenCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveOpenCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiverInfo.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiverInfo.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\DefaultName.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\DefaultName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\EnumDirItems.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\EnumDirItems.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Extract.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Extract.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ExtractingFilePath.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ExtractingFilePath.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\OpenArchive.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\OpenArchive.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\PropIDUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\PropIDUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\SetProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\SetProperties.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\SortUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\SortUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\TempFiles.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\TempFiles.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Update.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Update.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateAction.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateAction.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdatePair.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdatePair.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateProduce.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateProduce.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\WorkDir.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\WorkDir.h
+# End Source File
+# End Group
+# Begin Group "Crypto"
+
+# PROP Default_Filter ""
+# Begin Group "Zip Crypto"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Crypto\Zip\ZipCipher.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Zip\ZipCipher.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Zip\ZipCrypto.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Zip\ZipCrypto.h
+# End Source File
+# End Group
+# Begin Group "AES"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aes.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\AES_CBC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aescpp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aescrypt.c
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aeskey.c
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aesopt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aestab.c
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\MyAES.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\MyAES.h
+# End Source File
+# End Group
+# Begin Group "7z AES"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Crypto\7zAES\7zAES.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\7zAES\7zAES.h
+# End Source File
+# End Group
+# Begin Group "WzAES"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Crypto\WzAES\WzAES.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\WzAES\WzAES.h
+# End Source File
+# End Group
+# Begin Group "Hash"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\HmacSha1.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\HmacSha1.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\Pbkdf2HmacSha1.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\Pbkdf2HmacSha1.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\RandGen.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\RandGen.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\Sha1.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\Sha1.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\Sha256.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\Sha256.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "7-zip"
+
+# PROP Default_Filter ""
+# 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 "C"
+
+# PROP Default_Filter ""
+# Begin Group "C-Compress"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Huffman\HuffmanEncode.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Huffman\HuffmanEncode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\LzHash.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.h
+# End Source File
+# End Group
+# 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\IStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.c
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.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
+# End Target
+# End Project
diff --git a/7zip/Bundles/Alone/Alone.dsw b/CPP/7zip/Bundles/Alone/Alone.dsw
index 65eca43f..65eca43f 100755
--- a/7zip/Bundles/Alone/Alone.dsw
+++ b/CPP/7zip/Bundles/Alone/Alone.dsw
diff --git a/7zip/Bundles/Alone/StdAfx.cpp b/CPP/7zip/Bundles/Alone/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Bundles/Alone/StdAfx.cpp
+++ b/CPP/7zip/Bundles/Alone/StdAfx.cpp
diff --git a/7zip/Bundles/Alone/StdAfx.h b/CPP/7zip/Bundles/Alone/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Bundles/Alone/StdAfx.h
+++ b/CPP/7zip/Bundles/Alone/StdAfx.h
diff --git a/7zip/Bundles/Alone/afxres.h b/CPP/7zip/Bundles/Alone/afxres.h
index c2fadd4a..c2fadd4a 100755
--- a/7zip/Bundles/Alone/afxres.h
+++ b/CPP/7zip/Bundles/Alone/afxres.h
diff --git a/CPP/7zip/Bundles/Alone/makefile b/CPP/7zip/Bundles/Alone/makefile
new file mode 100755
index 00000000..e076ed3a
--- /dev/null
+++ b/CPP/7zip/Bundles/Alone/makefile
@@ -0,0 +1,390 @@
+PROG = 7za.exe
+LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib
+
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DEXCLUDE_COM \
+ -DNO_REGISTRY \
+ -DWIN_LONG_PATH \
+ -DFORMAT_7Z \
+ -DFORMAT_BZIP2 \
+ -DFORMAT_CAB \
+ -DFORMAT_GZIP \
+ -DFORMAT_SPLIT \
+ -DFORMAT_TAR \
+ -DFORMAT_Z \
+ -DFORMAT_ZIP \
+ -DCOMPRESS_MT \
+ -DCOMPRESS_BCJ_X86 \
+ -DCOMPRESS_BCJ2 \
+ -DCOMPRESS_BZIP2 \
+ -DCOMPRESS_BZIP2_MT \
+ -DCOMPRESS_COPY \
+ -DCOMPRESS_DEFLATE \
+ -DCOMPRESS_DEFLATE64 \
+ -DCOMPRESS_IMPLODE \
+ -DCOMPRESS_LZMA \
+ -DCOMPRESS_MF_MT \
+ -DCOMPRESS_PPMD \
+ -DCRYPTO_7ZAES \
+ -DCRYPTO_AES \
+ -DCRYPTO_ZIP \
+
+
+CONSOLE_OBJS = \
+ $O\ConsoleClose.obj \
+ $O\ExtractCallbackConsole.obj \
+ $O\List.obj \
+ $O\Main.obj \
+ $O\MainAr.obj \
+ $O\OpenCallbackConsole.obj \
+ $O\PercentPrinter.obj \
+ $O\UpdateCallbackConsole.obj \
+ $O\UserInputUtils.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CommandLineParser.obj \
+ $O\CRC.obj \
+ $O\IntToString.obj \
+ $O\ListFileUtils.obj \
+ $O\NewHandler.obj \
+ $O\StdInStream.obj \
+ $O\StdOutStream.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\UTFConvert.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\DLL.obj \
+ $O\Error.obj \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\FileName.obj \
+ $O\MemoryLock.obj \
+ $O\PropVariant.obj \
+ $O\PropVariantConversions.obj \
+ $O\Synchronization.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\FilePathAutoRename.obj \
+ $O\FileStreams.obj \
+ $O\InBuffer.obj \
+ $O\InOutTempBuffer.obj \
+ $O\LimitedStreams.obj \
+ $O\LockedStream.obj \
+ $O\LSBFDecoder.obj \
+ $O\LSBFEncoder.obj \
+ $O\MemBlocks.obj \
+ $O\OffsetStream.obj \
+ $O\OutBuffer.obj \
+ $O\OutMemStream.obj \
+ $O\ProgressMt.obj \
+ $O\ProgressUtils.obj \
+ $O\StreamBinder.obj \
+ $O\StreamObjects.obj \
+ $O\StreamUtils.obj \
+
+UI_COMMON_OBJS = \
+ $O\ArchiveCommandLine.obj \
+ $O\ArchiveExtractCallback.obj \
+ $O\ArchiveOpenCallback.obj \
+ $O\ArchiverInfo.obj \
+ $O\DefaultName.obj \
+ $O\EnumDirItems.obj \
+ $O\Extract.obj \
+ $O\ExtractingFilePath.obj \
+ $O\OpenArchive.obj \
+ $O\PropIDUtils.obj \
+ $O\SetProperties.obj \
+ $O\SortUtils.obj \
+ $O\TempFiles.obj \
+ $O\Update.obj \
+ $O\UpdateAction.obj \
+ $O\UpdateCallback.obj \
+ $O\UpdatePair.obj \
+ $O\UpdateProduce.obj \
+ $O\WorkDir.obj \
+
+AR_COMMON_OBJS = \
+ $O\CoderMixer2.obj \
+ $O\CoderMixer2MT.obj \
+ $O\CrossThreadProgress.obj \
+ $O\DummyOutStream.obj \
+ $O\FilterCoder.obj \
+ $O\InStreamWithCRC.obj \
+ $O\ItemNameUtils.obj \
+ $O\MultiStream.obj \
+ $O\OutStreamWithCRC.obj \
+ $O\ParseProperties.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\7zMethodID.obj \
+ $O\7zOut.obj \
+ $O\7zProperties.obj \
+ $O\7zSpecStream.obj \
+ $O\7zUpdate.obj \
+
+BZ2_OBJS = \
+ $O\BZip2Handler.obj \
+ $O\BZip2HandlerOut.obj \
+ $O\BZip2Update.obj \
+
+CAB_OBJS = \
+ $O\CabBlockInStream.obj \
+ $O\CabHandler.obj \
+ $O\CabHeader.obj \
+ $O\CabIn.obj \
+
+GZ_OBJS = \
+ $O\GZipHandler.obj \
+ $O\GZipHandlerOut.obj \
+ $O\GZipHeader.obj \
+ $O\GZipIn.obj \
+ $O\GZipOut.obj \
+ $O\GZipUpdate.obj \
+
+SPLIT_OBJS = \
+ $O\SplitHandler.obj \
+ $O\SplitHandlerOut.obj \
+
+TAR_OBJS = \
+ $O\TarHandler.obj \
+ $O\TarHandlerOut.obj \
+ $O\TarHeader.obj \
+ $O\TarIn.obj \
+ $O\TarOut.obj \
+ $O\TarUpdate.obj \
+
+Z_OBJS = \
+ $O\ZHandler.obj \
+
+ZIP_OBJS = \
+ $O\ZipAddCommon.obj \
+ $O\ZipHandler.obj \
+ $O\ZipHandlerOut.obj \
+ $O\ZipHeader.obj \
+ $O\ZipIn.obj \
+ $O\ZipItem.obj \
+ $O\ZipOut.obj \
+ $O\ZipUpdate.obj \
+
+
+BRANCH_OPT_OBJS = \
+ $O\BranchCoder.obj \
+ $O\x86.obj \
+ $O\x86_2.obj \
+
+BZIP2_OBJS = \
+ $O\BZip2CRC.obj \
+
+BZIP2_OPT_OBJS = \
+ $O\BZip2Decoder.obj \
+ $O\BZip2Encoder.obj \
+
+DEFLATE_OPT_OBJS = \
+ $O\DeflateDecoder.obj \
+ $O\DeflateEncoder.obj \
+
+LZ_OBJS = \
+ $O\LzOutWindow.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+ $O\LZMAEncoder.obj \
+
+LZX_OBJS = \
+ $O\LzxDecoder.obj \
+ $O\Lzx86Converter.obj \
+
+IMPLODE_OBJS = \
+ $O\ImplodeDecoder.obj \
+ $O\ImplodeHuffmanDecoder.obj \
+
+PPMD_OPT_OBJS = \
+ $O\PPMDDecoder.obj \
+ $O\PPMDEncoder.obj \
+
+SHRINK_OBJS = \
+ $O\ShrinkDecoder.obj \
+
+COMPRESS_Z_OBJS = \
+ $O\ZDecoder.obj \
+
+
+7ZAES_OPT_OBJS = \
+ $O\7zAES.obj \
+
+AES_OPT_OBJS = \
+ $O\MyAES.obj \
+
+AES_ORIG_OBJS = \
+ $O\aescrypt.obj \
+ $O\aeskey.obj \
+ $O\aestab.obj \
+
+CRYPTO_HASH_OBJS = \
+ $O\HmacSha1.obj \
+ $O\Pbkdf2HmacSha1.obj \
+ $O\RandGen.obj \
+ $O\Sha1.obj \
+ $O\Sha256.obj \
+
+CRYPTO_WZAES_OBJS = \
+ $O\WzAES.obj \
+
+CRYPTO_ZIP_OBJS = \
+ $O\ZipCipher.obj \
+ $O\ZipCrypto.obj \
+
+C_OBJS = \
+ $O\7zCrc.obj \
+ $O\Sort.obj \
+ $O\Threads.obj \
+
+C_LZ_OBJS = \
+ $O\MatchFinder.obj \
+ $O\MatchFinderMt.obj \
+
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(CONSOLE_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $(AR_COMMON_OBJS) \
+ $(7Z_OBJS) \
+ $(BZ2_OBJS) \
+ $(CAB_OBJS) \
+ $(GZ_OBJS) \
+ $(SPLIT_OBJS) \
+ $(TAR_OBJS) \
+ $(Z_OBJS) \
+ $(ZIP_OBJS) \
+ $(BZIP2_OBJS) \
+ $(BZIP2_OPT_OBJS) \
+ $(BRANCH_OPT_OBJS) \
+ $(DEFLATE_OPT_OBJS) \
+ $(IMPLODE_OBJS) \
+ $(LZ_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $(LZX_OBJS) \
+ $(PPMD_OPT_OBJS) \
+ $(SHRINK_OBJS) \
+ $(COMPRESS_Z_OBJS) \
+ $(C_OBJS) \
+ $(C_LZ_OBJS) \
+ $O\BlockSort.obj \
+ $O\CopyCoder.obj \
+ $O\HuffmanEncode.obj \
+ $O\RangeCoderBit.obj \
+ $(7ZAES_OPT_OBJS) \
+ $(AES_OPT_OBJS) \
+ $(AES_ORIG_OBJS) \
+ $(CRYPTO_HASH_OBJS) \
+ $(CRYPTO_ZIP_OBJS) \
+ $(CRYPTO_WZAES_OBJS) \
+ $O\QuantumDecoder.obj \
+ $O\resource.res
+
+
+!include "../../../Build.mak"
+
+$(CONSOLE_OBJS): ../../UI/Console/$(*B).cpp
+ $(COMPL)
+
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp
+ $(COMPL)
+$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
+ $(COMPL)
+
+$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
+ $(COMPL)
+$(BZ2_OBJS): ../../Archive/BZip2/$(*B).cpp
+ $(COMPL)
+$(CAB_OBJS): ../../Archive/Cab/$(*B).cpp
+ $(COMPL)
+$(GZ_OBJS): ../../Archive/GZip/$(*B).cpp
+ $(COMPL)
+$(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)
+
+$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
+ $(COMPL_O2)
+$(BZIP2_OBJS): ../../Compress/BZip2/$(*B).cpp
+ $(COMPL)
+$(BZIP2_OPT_OBJS): ../../Compress/BZip2/$(*B).cpp
+ $(COMPL_O2)
+$(DEFLATE_OPT_OBJS): ../../Compress/Deflate/$(*B).cpp
+ $(COMPL_O2)
+$(IMPLODE_OBJS): ../../Compress/Implode/$(*B).cpp
+ $(COMPL)
+$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
+ $(COMPL_O2)
+$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
+ $(COMPL_O2)
+$(LZX_OBJS): ../../Compress/Lzx/$(*B).cpp
+ $(COMPL_O2)
+$(PPMD_OPT_OBJS): ../../Compress/PPMD/$(*B).cpp
+ $(COMPL_O2)
+$(SHRINK_OBJS): ../../Compress/Shrink/$(*B).cpp
+ $(COMPL)
+$(COMPRESS_Z_OBJS): ../../Compress/Z/$(*B).cpp
+ $(COMPL)
+
+$O\BlockSort.obj: ../../Compress/BWT/$(*B).cpp
+ $(COMPL_O2)
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
+$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp
+ $(COMPL)
+$O\QuantumDecoder.obj: ../../Compress/Quantum/$(*B).cpp
+ $(COMPL)
+
+$(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp
+ $(COMPL_O2)
+$(AES_ORIG_OBJS): ../../Crypto/AES/$(*B).c
+ $(COMPL_O2_W3)
+$(7ZAES_OPT_OBJS): ../../Crypto/7zAES/$(*B).cpp
+ $(COMPL_O2)
+$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp
+ $(COMPL_O2)
+$(CRYPTO_ZIP_OBJS): ../../Crypto/Zip/$(*B).cpp
+ $(COMPL)
+$(CRYPTO_WZAES_OBJS): ../../Crypto/WzAES/$(*B).cpp
+ $(COMPL_O2)
+
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c
+ $(COMPL_O2)
+$O\HuffmanEncode.obj: ../../../../C/Compress/Huffman/$(*B).c
+ $(COMPL_O2)
diff --git a/7zip/Bundles/Alone/resource.rc b/CPP/7zip/Bundles/Alone/resource.rc
index fc9063c1..fc9063c1 100755
--- a/7zip/Bundles/Alone/resource.rc
+++ b/CPP/7zip/Bundles/Alone/resource.rc
diff --git a/CPP/7zip/Bundles/Alone7z/Alone.dsp b/CPP/7zip/Bundles/Alone7z/Alone.dsp
new file mode 100755
index 00000000..5ff71f2c
--- /dev/null
+++ b/CPP/7zip/Bundles/Alone7z/Alone.dsp
@@ -0,0 +1,1358 @@
+# Microsoft Developer Studio Project File - Name="Alone" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Alone - Win32 DebugU
+!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 "Alone.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 "Alone.mak" CFG="Alone - Win32 DebugU"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Alone - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Alone - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "Alone - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
+!MESSAGE "Alone - Win32 DebugU" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Alone - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMFORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
+# 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 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 /subsystem:console /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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7zr.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "Alone - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMFORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
+# 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 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 /subsystem:console /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7zr.exe" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseU"
+# PROP BASE Intermediate_Dir "ReleaseU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseU"
+# PROP Intermediate_Dir "ReleaseU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMFORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
+# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7za.exe" /opt:NOWIN98
+# SUBTRACT BASE LINK32 /pdb:none
+# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7zr.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugU"
+# PROP BASE Intermediate_Dir "DebugU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugU"
+# PROP Intermediate_Dir "DebugU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /W4 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMFORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
+# 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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za.exe" /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7zr.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "Alone - Win32 Release"
+# Name "Alone - Win32 Debug"
+# Name "Alone - Win32 ReleaseU"
+# Name "Alone - Win32 DebugU"
+# Begin Group "Console"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ArError.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\CompressionMode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ConsoleClose.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ConsoleClose.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ExtractCallbackConsole.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ExtractCallbackConsole.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\List.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\List.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\Main.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\MainAr.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\OpenCallbackConsole.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\OpenCallbackConsole.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\PercentPrinter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\PercentPrinter.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\UpdateCallbackConsole.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\UpdateCallbackConsole.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\UserInputUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\UserInputUtils.h
+# End Source File
+# End Group
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# 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 "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\AlignedBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\AlignedBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\AutoPtr.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Buffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CommandLineParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CommandLineParser.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\ComTry.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Defs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\DynamicBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Exception.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\ListFileUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\ListFileUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyCom.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyGuidDef.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyInitGuid.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyUnknown.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyWindows.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyWindows.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\Random.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Random.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdOutStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdOutStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.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
+# Begin Source File
+
+SOURCE=..\..\..\Common\Types.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\UTFConvert.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\UTFConvert.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.h
+# End Source File
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Defs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Device.h
+# End Source File
+# 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\Error.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Error.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.cpp
+# 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\MemoryLock.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\MemoryLock.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\PropVariantConversions.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\PropVariantConversions.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\Thread.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Time.h
+# End Source File
+# End Group
+# Begin Group "7zip Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CrossThreadProgress.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.h
+# End Source File
+# 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\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\LSBFDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFEncoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MSBFDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MSBFEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OffsetStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OffsetStream.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\ProgressMt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\ProgressMt.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\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
+# End Group
+# Begin Group "Compress"
+
+# PROP Default_Filter ""
+# Begin Group "Branch"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\BranchCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\BranchCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\Coder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86_2.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86_2.h
+# End Source File
+# End Group
+# Begin Group "Copy"
+
+# 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 "LZ"
+
+# PROP Default_Filter ""
+# Begin Group "MT"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\MT\MT.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\MT\MT.h
+# End Source File
+# End Group
+# Begin Group "HC"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC2.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC3.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC4.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HC4b.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\HashChain\HCMain.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\IMatchFinder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\LZInWindow.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\LZInWindow.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\LZOutWindow.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\LZOutWindow.h
+# End Source File
+# End Group
+# Begin Group "LZMA"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMA.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMADecoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMADecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMAEncoder.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMAEncoder.h
+# End Source File
+# End Group
+# Begin Group "RangeCoder"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.cpp
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# ADD CPP /O1
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderBitTree.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderOpt.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "Archive"
+
+# PROP Default_Filter ""
+# Begin Group "7z"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zCompressionMode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zDecode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zEncode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zEncode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zExtract.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderOutStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHeader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHeader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zItem.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zMethodID.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zMethodID.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zOut.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zProperties.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zSpecStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zSpecStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zUpdate.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zUpdate.h
+# End Source File
+# End Group
+# Begin Group "Archive Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2MT.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2MT.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2ST.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2ST.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\DummyOutStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\DummyOutStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\FilterCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\FilterCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\InStreamWithCRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\InStreamWithCRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ItemNameUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\MultiStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\MultiStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ParseProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ParseProperties.h
+# End Source File
+# End Group
+# Begin Group "split"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Split\SplitHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Split\SplitHandler.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "UI Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveCommandLine.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveCommandLine.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveExtractCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveExtractCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveOpenCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiveOpenCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiverInfo.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ArchiverInfo.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\DefaultName.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\DefaultName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\EnumDirItems.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\EnumDirItems.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Extract.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Extract.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ExtractingFilePath.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\ExtractingFilePath.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\OpenArchive.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\OpenArchive.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\PropIDUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\PropIDUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\SetProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\SetProperties.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\SortUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\SortUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\TempFiles.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\TempFiles.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Update.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Update.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateAction.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateAction.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdatePair.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdatePair.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateProduce.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\UpdateProduce.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\WorkDir.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\WorkDir.h
+# End Source File
+# End Group
+# Begin Group "7-zip"
+
+# PROP Default_Filter ""
+# 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
+# End Target
+# End Project
diff --git a/7zip/Bundles/Alone7z/Alone.dsw b/CPP/7zip/Bundles/Alone7z/Alone.dsw
index 65eca43f..65eca43f 100755
--- a/7zip/Bundles/Alone7z/Alone.dsw
+++ b/CPP/7zip/Bundles/Alone7z/Alone.dsw
diff --git a/7zip/Bundles/Alone7z/StdAfx.cpp b/CPP/7zip/Bundles/Alone7z/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Bundles/Alone7z/StdAfx.cpp
+++ b/CPP/7zip/Bundles/Alone7z/StdAfx.cpp
diff --git a/7zip/Bundles/Alone7z/StdAfx.h b/CPP/7zip/Bundles/Alone7z/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Bundles/Alone7z/StdAfx.h
+++ b/CPP/7zip/Bundles/Alone7z/StdAfx.h
diff --git a/CPP/7zip/Bundles/Alone7z/makefile b/CPP/7zip/Bundles/Alone7z/makefile
new file mode 100755
index 00000000..9bec8059
--- /dev/null
+++ b/CPP/7zip/Bundles/Alone7z/makefile
@@ -0,0 +1,196 @@
+PROG = 7za.exe
+LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib
+
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DEXCLUDE_COM \
+ -DNO_REGISTRY \
+ -D_NO_CRYPTO \
+ -DWIN_LONG_PATH \
+ -DFORMAT_7Z \
+ -DCOMPRESS_MT \
+ -DCOMPRESS_BCJ_X86 \
+ -DCOMPRESS_BCJ2 \
+ -DCOMPRESS_COPY \
+ -DCOMPRESS_LZMA \
+ -DCOMPRESS_MF_MT \
+ -D_NO_CRYPTO
+
+
+CONSOLE_OBJS = \
+ $O\ConsoleClose.obj \
+ $O\ExtractCallbackConsole.obj \
+ $O\List.obj \
+ $O\Main.obj \
+ $O\MainAr.obj \
+ $O\OpenCallbackConsole.obj \
+ $O\PercentPrinter.obj \
+ $O\UpdateCallbackConsole.obj \
+ $O\UserInputUtils.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CommandLineParser.obj \
+ $O\CRC.obj \
+ $O\IntToString.obj \
+ $O\ListFileUtils.obj \
+ $O\NewHandler.obj \
+ $O\StdInStream.obj \
+ $O\StdOutStream.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\UTFConvert.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\DLL.obj \
+ $O\Error.obj \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\FileName.obj \
+ $O\MemoryLock.obj \
+ $O\PropVariant.obj \
+ $O\PropVariantConversions.obj \
+ $O\Synchronization.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\FilePathAutoRename.obj \
+ $O\FileStreams.obj \
+ $O\InBuffer.obj \
+ $O\InOutTempBuffer.obj \
+ $O\LimitedStreams.obj \
+ $O\LockedStream.obj \
+ $O\OffsetStream.obj \
+ $O\OutBuffer.obj \
+ $O\ProgressUtils.obj \
+ $O\StreamBinder.obj \
+ $O\StreamObjects.obj \
+ $O\StreamUtils.obj \
+
+UI_COMMON_OBJS = \
+ $O\ArchiveCommandLine.obj \
+ $O\ArchiveExtractCallback.obj \
+ $O\ArchiveOpenCallback.obj \
+ $O\ArchiverInfo.obj \
+ $O\DefaultName.obj \
+ $O\EnumDirItems.obj \
+ $O\Extract.obj \
+ $O\ExtractingFilePath.obj \
+ $O\OpenArchive.obj \
+ $O\PropIDUtils.obj \
+ $O\SetProperties.obj \
+ $O\SortUtils.obj \
+ $O\TempFiles.obj \
+ $O\Update.obj \
+ $O\UpdateAction.obj \
+ $O\UpdateCallback.obj \
+ $O\UpdatePair.obj \
+ $O\UpdateProduce.obj \
+ $O\WorkDir.obj \
+
+AR_COMMON_OBJS = \
+ $O\CoderMixer2.obj \
+ $O\CoderMixer2MT.obj \
+ $O\CrossThreadProgress.obj \
+ $O\DummyOutStream.obj \
+ $O\FilterCoder.obj \
+ $O\InStreamWithCRC.obj \
+ $O\ItemNameUtils.obj \
+ $O\MultiStream.obj \
+ $O\OutStreamWithCRC.obj \
+ $O\ParseProperties.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\7zMethodID.obj \
+ $O\7zOut.obj \
+ $O\7zProperties.obj \
+ $O\7zSpecStream.obj \
+ $O\7zUpdate.obj \
+
+
+BRANCH_OPT_OBJS = \
+ $O\BranchCoder.obj \
+ $O\x86.obj \
+ $O\x86_2.obj \
+
+LZ_OBJS = \
+ $O\LZOutWindow.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+ $O\LZMAEncoder.obj \
+
+C_OBJS = \
+ $O\7zCrc.obj \
+ $O\Sort.obj \
+ $O\Threads.obj \
+
+C_LZ_OBJS = \
+ $O\MatchFinder.obj \
+ $O\MatchFinderMt.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(CONSOLE_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $(AR_COMMON_OBJS) \
+ $(7Z_OBJS) \
+ $(BRANCH_OPT_OBJS) \
+ $(LZ_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $(C_OBJS) \
+ $(C_LZ_OBJS) \
+ $O\CopyCoder.obj \
+ $O\RangeCoderBit.obj \
+ $O\resource.res
+
+
+!include "../../../Build.mak"
+
+$(CONSOLE_OBJS): ../../UI/Console/$(*B).cpp
+ $(COMPL)
+
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp
+ $(COMPL)
+$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
+ $(COMPL)
+
+$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
+ $(COMPL)
+$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
+ $(COMPL_O2)
+$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
+ $(COMPL)
+$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
+ $(COMPL_O2)
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
+$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp
+ $(COMPL)
+
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c
+ $(COMPL_O2)
diff --git a/7zip/Bundles/Alone7z/resource.rc b/CPP/7zip/Bundles/Alone7z/resource.rc
index fc9063c1..fc9063c1 100755
--- a/7zip/Bundles/Alone7z/resource.rc
+++ b/CPP/7zip/Bundles/Alone7z/resource.rc
diff --git a/CPP/7zip/Bundles/Format7z/Format7z.dsp b/CPP/7zip/Bundles/Format7z/Format7z.dsp
new file mode 100755
index 00000000..a59cd581
--- /dev/null
+++ b/CPP/7zip/Bundles/Format7z/Format7z.dsp
@@ -0,0 +1,1006 @@
+# 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 "Format7z.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 "Format7z.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 /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /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\Formats\7za.dll" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none /debug
+
+!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 "..\..\..\..\SDK" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /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\Formats\7za.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\7z\7z.ico
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Archive.def
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\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 "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.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\NewHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.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
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.h
+# End Source File
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# 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\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
+# End Group
+# Begin Group "Archive common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2MT.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CoderMixer2MT.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\CrossThreadProgress.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\FilterCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\FilterCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\InStreamWithCRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\InStreamWithCRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ItemNameUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ParseProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\ParseProperties.h
+# End Source File
+# End Group
+# Begin Group "Compress"
+
+# PROP Default_Filter ""
+# Begin Group "LZ"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\LZOutWindow.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZ\LZOutWindow.h
+# End Source File
+# End Group
+# Begin Group "PPMD"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDContext.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDDecoder.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDEncode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDEncoder.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDSubAlloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\PPMD\PPMDType.h
+# End Source File
+# End Group
+# Begin Group "Branch"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\BranchCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\BranchCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86_2.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Branch\x86_2.h
+# End Source File
+# End Group
+# Begin Group "LZMA"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMA.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMADecoder.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMADecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMAEncoder.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA\LZMAEncoder.h
+# End Source File
+# End Group
+# Begin Group "Copy"
+
+# 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 "RangeCoder"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderBit.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderBitTree.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\RangeCoder\RangeCoderOpt.h
+# End Source File
+# End Group
+# Begin Group "Deflate"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateConst.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateDecoder.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\DeflateExtConst.h
+# End Source File
+# End Group
+# Begin Group "BZip2"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2Const.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2CRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2Decoder.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\BZip2\BZip2Decoder.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "Crypto"
+
+# PROP Default_Filter ""
+# Begin Group "AES"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aes.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\AES_CBC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aescpp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aescrypt.c
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aeskey.c
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aesopt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\aestab.c
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\MyAES.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\AES\MyAES.h
+# End Source File
+# End Group
+# Begin Group "7zAES"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Crypto\7zAES\7zAES.cpp
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\7zAES\7zAES.h
+# End Source File
+# End Group
+# Begin Group "Hash"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\Sha256.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Crypto\Hash\Sha256.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "7z"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zCompressionMode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zCompressionMode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zDecode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zEncode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zEncode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zExtract.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zFolderOutStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHandlerOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHeader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zHeader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zItem.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zMethodID.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zMethodID.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zMethods.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zOut.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zProperties.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zSpecStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zSpecStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zUpdate.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zUpdate.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\7z\7zUpdateItem.h
+# End Source File
+# End Group
+# Begin Group "7zip 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\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\LSBFDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFDecoder.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\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
+# End Group
+# Begin Group "C"
+
+# PROP Default_Filter ""
+# Begin Group "C-Lz"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\LzHash.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.c
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.c
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=..\..\..\..\C\7zCrc.c
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "7z - 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\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/7zip/Bundles/Format7z/Format7z.dsw b/CPP/7zip/Bundles/Format7z/Format7z.dsw
index 324dab1f..324dab1f 100755
--- a/7zip/Bundles/Format7z/Format7z.dsw
+++ b/CPP/7zip/Bundles/Format7z/Format7z.dsw
diff --git a/7zip/Bundles/Format7z/StdAfx.cpp b/CPP/7zip/Bundles/Format7z/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Bundles/Format7z/StdAfx.cpp
+++ b/CPP/7zip/Bundles/Format7z/StdAfx.cpp
diff --git a/7zip/Bundles/Format7z/StdAfx.h b/CPP/7zip/Bundles/Format7z/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Bundles/Format7z/StdAfx.h
+++ b/CPP/7zip/Bundles/Format7z/StdAfx.h
diff --git a/CPP/7zip/Bundles/Format7z/makefile b/CPP/7zip/Bundles/Format7z/makefile
new file mode 100755
index 00000000..1134faee
--- /dev/null
+++ b/CPP/7zip/Bundles/Format7z/makefile
@@ -0,0 +1,201 @@
+PROG = 7za.dll
+DEF_FILE = ../../Archive/Archive.def
+LIBS = $(LIBS) user32.lib oleaut32.lib
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DEXCLUDE_COM \
+ -DNO_REGISTRY \
+ -DFORMAT_7Z \
+ -DCOMPRESS_MT \
+ -DCOMPRESS_BCJ_X86 \
+ -DCOMPRESS_BCJ2 \
+ -DCOMPRESS_BZIP2_DECODER \
+ -DCOMPRESS_BZIP2_MT \
+ -DCOMPRESS_COPY \
+ -DCOMPRESS_DEFLATE_DECODER \
+ -DCOMPRESS_LZMA \
+ -DCOMPRESS_MF_MT \
+ -DCOMPRESS_PPMD \
+ -DCRYPTO_7ZAES \
+ -DCRYPTO_AES \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CRC.obj \
+ $O\IntToString.obj \
+ $O\NewHandler.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\PropVariant.obj \
+ $O\Synchronization.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\InOutTempBuffer.obj \
+ $O\LimitedStreams.obj \
+ $O\LockedStream.obj \
+ $O\LSBFDecoder.obj \
+ $O\OutBuffer.obj \
+ $O\ProgressUtils.obj \
+ $O\StreamBinder.obj \
+ $O\StreamObjects.obj \
+ $O\StreamUtils.obj \
+
+AR_COMMON_OBJS = \
+ $O\CoderMixer2.obj \
+ $O\CoderMixer2MT.obj \
+ $O\CrossThreadProgress.obj \
+ $O\FilterCoder.obj \
+ $O\InStreamWithCRC.obj \
+ $O\ItemNameUtils.obj \
+ $O\OutStreamWithCRC.obj \
+ $O\ParseProperties.obj \
+
+
+7Z_OBJS = \
+ $O\DllExports.obj \
+ $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\7zMethodID.obj \
+ $O\7zOut.obj \
+ $O\7zProperties.obj \
+ $O\7zSpecStream.obj \
+ $O\7zUpdate.obj \
+
+
+BRANCH_OPT_OBJS = \
+ $O\BranchCoder.obj \
+ $O\x86.obj \
+ $O\x86_2.obj \
+
+BZIP2_OBJS = \
+ $O\BZip2CRC.obj \
+
+BZIP2_OPT_OBJS = \
+ $O\BZip2Decoder.obj \
+
+DEFLATE_OPT_OBJS = \
+ $O\DeflateDecoder.obj \
+
+LZ_OBJS = \
+ $O\LZOutWindow.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+ $O\LZMAEncoder.obj \
+
+PPMD_OPT_OBJS = \
+ $O\PPMDDecoder.obj \
+ $O\PPMDEncoder.obj \
+
+
+7ZAES_OPT_OBJS = \
+ $O\7zAES.obj \
+
+AES_OPT_OBJS = \
+ $O\MyAES.obj \
+
+AES_ORIG_OBJS = \
+ $O\aescrypt.obj \
+ $O\aeskey.obj \
+ $O\aestab.obj \
+
+CRYPTO_HASH_OBJS = \
+ $O\Sha256.obj \
+
+C_OBJS = \
+ $O\7zCrc.obj \
+ $O\Threads.obj \
+
+C_LZ_OBJS = \
+ $O\MatchFinder.obj \
+ $O\MatchFinderMt.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(CONSOLE_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(AR_COMMON_OBJS) \
+ $(7Z_OBJS) \
+ $(BZIP2_OBJS) \
+ $(BZIP2_OPT_OBJS) \
+ $(BRANCH_OPT_OBJS) \
+ $(DEFLATE_OPT_OBJS) \
+ $(LZ_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $(PPMD_OPT_OBJS) \
+ $(C_OBJS) \
+ $(C_LZ_OBJS) \
+ $O\CopyCoder.obj \
+ $O\RangeCoderBit.obj \
+ $(7ZAES_OPT_OBJS) \
+ $(AES_OPT_OBJS) \
+ $(AES_ORIG_OBJS) \
+ $(CRYPTO_HASH_OBJS) \
+ $O\resource.res
+
+
+!include "../../../Build.mak"
+
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
+ $(COMPL)
+
+$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
+ $(COMPL)
+
+$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
+ $(COMPL_O2)
+$(BZIP2_OBJS): ../../Compress/BZip2/$(*B).cpp
+ $(COMPL)
+$(BZIP2_OPT_OBJS): ../../Compress/BZip2/$(*B).cpp
+ $(COMPL_O2)
+$(DEFLATE_OPT_OBJS): ../../Compress/Deflate/$(*B).cpp
+ $(COMPL_O2)
+$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
+ $(COMPL)
+$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
+ $(COMPL_O2)
+$(PPMD_OPT_OBJS): ../../Compress/PPMD/$(*B).cpp
+ $(COMPL_O2)
+
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
+$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp
+ $(COMPL)
+
+$(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp
+ $(COMPL_O2)
+$(AES_ORIG_OBJS): ../../Crypto/AES/$(*B).c
+ $(COMPL_O2_W3)
+$(7ZAES_OPT_OBJS): ../../Crypto/7zAES/$(*B).cpp
+ $(COMPL_O2)
+$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp
+ $(COMPL_O2)
+
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c
+ $(COMPL_O2)
diff --git a/7zip/Bundles/Format7z/resource.rc b/CPP/7zip/Bundles/Format7z/resource.rc
index 5b3f363e..5b3f363e 100755
--- a/7zip/Bundles/Format7z/resource.rc
+++ b/CPP/7zip/Bundles/Format7z/resource.rc
diff --git a/7zip/Bundles/Format7zExtract/Format7z.dsp b/CPP/7zip/Bundles/Format7zExtract/Format7z.dsp
index d049d00c..d049d00c 100755
--- a/7zip/Bundles/Format7zExtract/Format7z.dsp
+++ b/CPP/7zip/Bundles/Format7zExtract/Format7z.dsp
diff --git a/7zip/Bundles/Format7zExtract/Format7z.dsw b/CPP/7zip/Bundles/Format7zExtract/Format7z.dsw
index 324dab1f..324dab1f 100755
--- a/7zip/Bundles/Format7zExtract/Format7z.dsw
+++ b/CPP/7zip/Bundles/Format7zExtract/Format7z.dsw
diff --git a/7zip/Bundles/Format7zExtract/StdAfx.cpp b/CPP/7zip/Bundles/Format7zExtract/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Bundles/Format7zExtract/StdAfx.cpp
+++ b/CPP/7zip/Bundles/Format7zExtract/StdAfx.cpp
diff --git a/7zip/Bundles/Format7zExtract/StdAfx.h b/CPP/7zip/Bundles/Format7zExtract/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Bundles/Format7zExtract/StdAfx.h
+++ b/CPP/7zip/Bundles/Format7zExtract/StdAfx.h
diff --git a/CPP/7zip/Bundles/Format7zExtract/makefile b/CPP/7zip/Bundles/Format7zExtract/makefile
new file mode 100755
index 00000000..e52ab019
--- /dev/null
+++ b/CPP/7zip/Bundles/Format7zExtract/makefile
@@ -0,0 +1,174 @@
+PROG = 7zxa.dll
+DEF_FILE = ../../Archive/Archive.def
+LIBS = $(LIBS) user32.lib oleaut32.lib
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DEXCLUDE_COM \
+ -DNO_REGISTRY \
+ -DEXTRACT_ONLY \
+ -DFORMAT_7Z \
+ -DCOMPRESS_MT \
+ -DCOMPRESS_BCJ_X86 \
+ -DCOMPRESS_BCJ2 \
+ -DCOMPRESS_BZIP2_DECODER \
+ -DCOMPRESS_BZIP2_MT \
+ -DCOMPRESS_COPY \
+ -DCOMPRESS_DEFLATE_DECODER \
+ -DCOMPRESS_LZMA \
+ -DCOMPRESS_PPMD \
+ -DCRYPTO_7ZAES \
+ -DCRYPTO_AES \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CRC.obj \
+ $O\IntToString.obj \
+ $O\NewHandler.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\PropVariant.obj \
+ $O\Synchronization.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\InOutTempBuffer.obj \
+ $O\LimitedStreams.obj \
+ $O\LockedStream.obj \
+ $O\LSBFDecoder.obj \
+ $O\OutBuffer.obj \
+ $O\ProgressUtils.obj \
+ $O\StreamBinder.obj \
+ $O\StreamObjects.obj \
+ $O\StreamUtils.obj \
+
+AR_COMMON_OBJS = \
+ $O\CoderMixer2.obj \
+ $O\CoderMixer2MT.obj \
+ $O\CrossThreadProgress.obj \
+ $O\FilterCoder.obj \
+ $O\ItemNameUtils.obj \
+ $O\OutStreamWithCRC.obj \
+ $O\ParseProperties.obj \
+
+
+7Z_OBJS = \
+ $O\DllExports.obj \
+ $O\7zCompressionMode.obj \
+ $O\7zDecode.obj \
+ $O\7zExtract.obj \
+ $O\7zFolderOutStream.obj \
+ $O\7zHandler.obj \
+ $O\7zHeader.obj \
+ $O\7zIn.obj \
+ $O\7zMethodID.obj \
+ $O\7zProperties.obj \
+
+
+BRANCH_OPT_OBJS = \
+ $O\BranchCoder.obj \
+ $O\x86.obj \
+ $O\x86_2.obj \
+
+BZIP2_OBJS = \
+ $O\BZip2CRC.obj \
+
+BZIP2_OPT_OBJS = \
+ $O\BZip2Decoder.obj \
+
+DEFLATE_OPT_OBJS = \
+ $O\DeflateDecoder.obj \
+
+LZ_OBJS = \
+ $O\LZOutWindow.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+
+PPMD_OPT_OBJS = \
+ $O\PPMDDecoder.obj \
+
+
+7ZAES_OPT_OBJS = \
+ $O\7zAES.obj \
+
+AES_OPT_OBJS = \
+ $O\MyAES.obj \
+
+AES_ORIG_OBJS = \
+ $O\aescrypt.obj \
+ $O\aeskey.obj \
+ $O\aestab.obj \
+
+CRYPTO_HASH_OBJS = \
+ $O\Sha256.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(CONSOLE_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(AR_COMMON_OBJS) \
+ $(7Z_OBJS) \
+ $(BZIP2_OBJS) \
+ $(BZIP2_OPT_OBJS) \
+ $(BRANCH_OPT_OBJS) \
+ $(DEFLATE_OPT_OBJS) \
+ $(LZ_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $(PPMD_OPT_OBJS) \
+ $O\CopyCoder.obj \
+ $(7ZAES_OPT_OBJS) \
+ $(AES_OPT_OBJS) \
+ $(AES_ORIG_OBJS) \
+ $(CRYPTO_HASH_OBJS) \
+ $O\resource.res
+
+
+!include "../../../Build.mak"
+
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
+ $(COMPL)
+
+$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
+ $(COMPL)
+
+$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
+ $(COMPL_O2)
+$(BZIP2_OBJS): ../../Compress/BZip2/$(*B).cpp
+ $(COMPL)
+$(BZIP2_OPT_OBJS): ../../Compress/BZip2/$(*B).cpp
+ $(COMPL_O2)
+$(DEFLATE_OPT_OBJS): ../../Compress/Deflate/$(*B).cpp
+ $(COMPL_O2)
+$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
+ $(COMPL)
+$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
+ $(COMPL_O2)
+$(PPMD_OPT_OBJS): ../../Compress/PPMD/$(*B).cpp
+ $(COMPL_O2)
+
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
+
+$(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp
+ $(COMPL_O2)
+$(AES_ORIG_OBJS): ../../Crypto/AES/$(*B).c
+ $(COMPL_O2_W3)
+$(7ZAES_OPT_OBJS): ../../Crypto/7zAES/$(*B).cpp
+ $(COMPL_O2)
+$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp
+ $(COMPL_O2)
diff --git a/7zip/Bundles/Format7zExtract/resource.rc b/CPP/7zip/Bundles/Format7zExtract/resource.rc
index 56e6b5d7..56e6b5d7 100755
--- a/7zip/Bundles/Format7zExtract/resource.rc
+++ b/CPP/7zip/Bundles/Format7zExtract/resource.rc
diff --git a/7zip/Bundles/SFXCon/StdAfx.cpp b/CPP/7zip/Bundles/Format7zExtractR/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Bundles/SFXCon/StdAfx.cpp
+++ b/CPP/7zip/Bundles/Format7zExtractR/StdAfx.cpp
diff --git a/7zip/Bundles/SFXCon/StdAfx.h b/CPP/7zip/Bundles/Format7zExtractR/StdAfx.h
index 2e4be10b..2e4be10b 100755
--- a/7zip/Bundles/SFXCon/StdAfx.h
+++ b/CPP/7zip/Bundles/Format7zExtractR/StdAfx.h
diff --git a/CPP/7zip/Bundles/Format7zExtractR/makefile b/CPP/7zip/Bundles/Format7zExtractR/makefile
new file mode 100755
index 00000000..b8bfde85
--- /dev/null
+++ b/CPP/7zip/Bundles/Format7zExtractR/makefile
@@ -0,0 +1,117 @@
+PROG = 7zxr.dll
+DEF_FILE = ../../Archive/Archive.def
+LIBS = $(LIBS) user32.lib oleaut32.lib
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DEXCLUDE_COM \
+ -DNO_REGISTRY \
+ -DEXTRACT_ONLY \
+ -DFORMAT_7Z \
+ -DCOMPRESS_MT \
+ -DCOMPRESS_BCJ_X86 \
+ -DCOMPRESS_BCJ2 \
+ -DCOMPRESS_COPY \
+ -DCOMPRESS_LZMA \
+ -D_NO_CRYPTO
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CRC.obj \
+ $O\IntToString.obj \
+ $O\NewHandler.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\PropVariant.obj \
+ $O\Synchronization.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\InOutTempBuffer.obj \
+ $O\LimitedStreams.obj \
+ $O\LockedStream.obj \
+ $O\OutBuffer.obj \
+ $O\ProgressUtils.obj \
+ $O\StreamBinder.obj \
+ $O\StreamObjects.obj \
+ $O\StreamUtils.obj \
+
+AR_COMMON_OBJS = \
+ $O\CoderMixer2.obj \
+ $O\CoderMixer2MT.obj \
+ $O\CrossThreadProgress.obj \
+ $O\FilterCoder.obj \
+ $O\ItemNameUtils.obj \
+ $O\OutStreamWithCRC.obj \
+ $O\ParseProperties.obj \
+
+
+7Z_OBJS = \
+ $O\DllExports.obj \
+ $O\7zCompressionMode.obj \
+ $O\7zDecode.obj \
+ $O\7zExtract.obj \
+ $O\7zFolderOutStream.obj \
+ $O\7zHandler.obj \
+ $O\7zHeader.obj \
+ $O\7zIn.obj \
+ $O\7zMethodID.obj \
+ $O\7zProperties.obj \
+
+
+BRANCH_OPT_OBJS = \
+ $O\BranchCoder.obj \
+ $O\x86.obj \
+ $O\x86_2.obj \
+
+LZ_OBJS = \
+ $O\LZOutWindow.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(CONSOLE_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(AR_COMMON_OBJS) \
+ $(7Z_OBJS) \
+ $(BRANCH_OPT_OBJS) \
+ $(LZ_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $O\CopyCoder.obj \
+ $O\resource.res
+
+
+!include "../../../Build.mak"
+
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
+ $(COMPL)
+
+$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
+ $(COMPL)
+
+$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
+ $(COMPL_O2)
+$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
+ $(COMPL)
+$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
+ $(COMPL_O2)
+
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
diff --git a/CPP/7zip/Bundles/Format7zExtractR/resource.rc b/CPP/7zip/Bundles/Format7zExtractR/resource.rc
new file mode 100755
index 00000000..09708cff
--- /dev/null
+++ b/CPP/7zip/Bundles/Format7zExtractR/resource.rc
@@ -0,0 +1,5 @@
+#include "../../MyVersionInfo.rc"
+
+MY_VERSION_INFO_DLL("7z Standalone Extracting Plugin", "7zxr")
+
+101 ICON "../../Archive/7z/7z.ico"
diff --git a/7zip/Bundles/SFXSetup/StdAfx.cpp b/CPP/7zip/Bundles/Format7zR/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Bundles/SFXSetup/StdAfx.cpp
+++ b/CPP/7zip/Bundles/Format7zR/StdAfx.cpp
diff --git a/CPP/7zip/Bundles/Format7zR/StdAfx.h b/CPP/7zip/Bundles/Format7zR/StdAfx.h
new file mode 100755
index 00000000..2e4be10b
--- /dev/null
+++ b/CPP/7zip/Bundles/Format7zR/StdAfx.h
@@ -0,0 +1,9 @@
+// StdAfx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#include "../../../Common/MyWindows.h"
+#include "../../../Common/NewHandler.h"
+
+#endif
diff --git a/CPP/7zip/Bundles/Format7zR/makefile b/CPP/7zip/Bundles/Format7zR/makefile
new file mode 100755
index 00000000..d3cc3d55
--- /dev/null
+++ b/CPP/7zip/Bundles/Format7zR/makefile
@@ -0,0 +1,150 @@
+PROG = 7zra.dll
+DEF_FILE = ../../Archive/Archive.def
+LIBS = $(LIBS) user32.lib oleaut32.lib
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DEXCLUDE_COM \
+ -DNO_REGISTRY \
+ -DFORMAT_7Z \
+ -DCOMPRESS_MT \
+ -DCOMPRESS_BCJ_X86 \
+ -DCOMPRESS_BCJ2 \
+ -DCOMPRESS_COPY \
+ -DCOMPRESS_LZMA \
+ -DCOMPRESS_MF_MT \
+ -D_NO_CRYPTO
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CRC.obj \
+ $O\IntToString.obj \
+ $O\NewHandler.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\PropVariant.obj \
+ $O\Synchronization.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\InOutTempBuffer.obj \
+ $O\LimitedStreams.obj \
+ $O\LockedStream.obj \
+ $O\OutBuffer.obj \
+ $O\ProgressUtils.obj \
+ $O\StreamBinder.obj \
+ $O\StreamObjects.obj \
+ $O\StreamUtils.obj \
+
+AR_COMMON_OBJS = \
+ $O\CoderMixer2.obj \
+ $O\CoderMixer2MT.obj \
+ $O\CrossThreadProgress.obj \
+ $O\FilterCoder.obj \
+ $O\InStreamWithCRC.obj \
+ $O\ItemNameUtils.obj \
+ $O\OutStreamWithCRC.obj \
+ $O\ParseProperties.obj \
+
+
+7Z_OBJS = \
+ $O\DllExports.obj \
+ $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\7zMethodID.obj \
+ $O\7zOut.obj \
+ $O\7zProperties.obj \
+ $O\7zSpecStream.obj \
+ $O\7zUpdate.obj \
+
+
+BRANCH_OPT_OBJS = \
+ $O\BranchCoder.obj \
+ $O\x86.obj \
+ $O\x86_2.obj \
+
+LZ_OBJS = \
+ $O\LZOutWindow.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+ $O\LZMAEncoder.obj \
+
+C_OBJS = \
+ $O\7zCrc.obj \
+ $O\Sort.obj \
+ $O\Threads.obj \
+
+C_LZ_OBJS = \
+ $O\MatchFinder.obj \
+ $O\MatchFinderMt.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(CONSOLE_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(AR_COMMON_OBJS) \
+ $(7Z_OBJS) \
+ $(BZIP2_OBJS) \
+ $(BZIP2_OPT_OBJS) \
+ $(BRANCH_OPT_OBJS) \
+ $(DEFLATE_OPT_OBJS) \
+ $(LZ_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $(PPMD_OPT_OBJS) \
+ $(C_OBJS) \
+ $(C_LZ_OBJS) \
+ $O\CopyCoder.obj \
+ $O\RangeCoderBit.obj \
+ $(7ZAES_OPT_OBJS) \
+ $(AES_OPT_OBJS) \
+ $(AES_ORIG_OBJS) \
+ $(CRYPTO_HASH_OBJS) \
+ $O\resource.res
+
+
+!include "../../../Build.mak"
+
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
+ $(COMPL)
+
+$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
+ $(COMPL)
+
+$(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp
+ $(COMPL_O2)
+$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp
+ $(COMPL)
+$(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp
+ $(COMPL_O2)
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
+$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp
+ $(COMPL)
+
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c
+ $(COMPL_O2)
diff --git a/CPP/7zip/Bundles/Format7zR/resource.rc b/CPP/7zip/Bundles/Format7zR/resource.rc
new file mode 100755
index 00000000..60a17fe8
--- /dev/null
+++ b/CPP/7zip/Bundles/Format7zR/resource.rc
@@ -0,0 +1,5 @@
+#include "../../MyVersionInfo.rc"
+
+MY_VERSION_INFO_DLL("7z Standalone Plugin", "7zr")
+
+101 ICON "../../Archive/7z/7z.ico"
diff --git a/7zip/Bundles/SFXCon/7z.ico b/CPP/7zip/Bundles/SFXCon/7z.ico
index 47ffb781..47ffb781 100755
--- a/7zip/Bundles/SFXCon/7z.ico
+++ b/CPP/7zip/Bundles/SFXCon/7z.ico
Binary files differ
diff --git a/7zip/Bundles/SFXCon/Main.cpp b/CPP/7zip/Bundles/SFXCon/Main.cpp
index 65ed8931..65ed8931 100755
--- a/7zip/Bundles/SFXCon/Main.cpp
+++ b/CPP/7zip/Bundles/SFXCon/Main.cpp
diff --git a/7zip/Bundles/SFXCon/SFXCon.dsp b/CPP/7zip/Bundles/SFXCon/SFXCon.dsp
index 5b61dae3..5b61dae3 100755
--- a/7zip/Bundles/SFXCon/SFXCon.dsp
+++ b/CPP/7zip/Bundles/SFXCon/SFXCon.dsp
diff --git a/7zip/Bundles/SFXCon/SFXCon.dsw b/CPP/7zip/Bundles/SFXCon/SFXCon.dsw
index 27bf7e6d..27bf7e6d 100755
--- a/7zip/Bundles/SFXCon/SFXCon.dsw
+++ b/CPP/7zip/Bundles/SFXCon/SFXCon.dsw
diff --git a/7zip/Bundles/SFXWin/StdAfx.cpp b/CPP/7zip/Bundles/SFXCon/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Bundles/SFXWin/StdAfx.cpp
+++ b/CPP/7zip/Bundles/SFXCon/StdAfx.cpp
diff --git a/CPP/7zip/Bundles/SFXCon/StdAfx.h b/CPP/7zip/Bundles/SFXCon/StdAfx.h
new file mode 100755
index 00000000..2e4be10b
--- /dev/null
+++ b/CPP/7zip/Bundles/SFXCon/StdAfx.h
@@ -0,0 +1,9 @@
+// StdAfx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#include "../../../Common/MyWindows.h"
+#include "../../../Common/NewHandler.h"
+
+#endif
diff --git a/7zip/Bundles/SFXCon/makefile b/CPP/7zip/Bundles/SFXCon/makefile
index 7501a497..7501a497 100755
--- a/7zip/Bundles/SFXCon/makefile
+++ b/CPP/7zip/Bundles/SFXCon/makefile
diff --git a/7zip/Bundles/SFXCon/resource.rc b/CPP/7zip/Bundles/SFXCon/resource.rc
index 58331b81..58331b81 100755
--- a/7zip/Bundles/SFXCon/resource.rc
+++ b/CPP/7zip/Bundles/SFXCon/resource.rc
diff --git a/7zip/Bundles/SFXSetup/ExtractCallback.cpp b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp
index 6294516c..6294516c 100755
--- a/7zip/Bundles/SFXSetup/ExtractCallback.cpp
+++ b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp
diff --git a/7zip/Bundles/SFXSetup/ExtractCallback.h b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h
index f3880890..f3880890 100755
--- a/7zip/Bundles/SFXSetup/ExtractCallback.h
+++ b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h
diff --git a/7zip/Bundles/SFXSetup/ExtractEngine.cpp b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp
index 19fcb0d2..19fcb0d2 100755
--- a/7zip/Bundles/SFXSetup/ExtractEngine.cpp
+++ b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp
diff --git a/7zip/Bundles/SFXSetup/ExtractEngine.h b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.h
index 595d2b29..595d2b29 100755
--- a/7zip/Bundles/SFXSetup/ExtractEngine.h
+++ b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.h
diff --git a/7zip/Bundles/SFXSetup/Main.cpp b/CPP/7zip/Bundles/SFXSetup/Main.cpp
index 12de5c01..12de5c01 100755
--- a/7zip/Bundles/SFXSetup/Main.cpp
+++ b/CPP/7zip/Bundles/SFXSetup/Main.cpp
diff --git a/7zip/Bundles/SFXSetup/SFXSetup.dsp b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp
index a58feab5..a58feab5 100755
--- a/7zip/Bundles/SFXSetup/SFXSetup.dsp
+++ b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp
diff --git a/7zip/Bundles/SFXSetup/SFXSetup.dsw b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsw
index f563b21f..f563b21f 100755
--- a/7zip/Bundles/SFXSetup/SFXSetup.dsw
+++ b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsw
diff --git a/7zip/Compress/BZip2/StdAfx.cpp b/CPP/7zip/Bundles/SFXSetup/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/BZip2/StdAfx.cpp
+++ b/CPP/7zip/Bundles/SFXSetup/StdAfx.cpp
diff --git a/7zip/Bundles/SFXSetup/StdAfx.h b/CPP/7zip/Bundles/SFXSetup/StdAfx.h
index 19ece34b..19ece34b 100755
--- a/7zip/Bundles/SFXSetup/StdAfx.h
+++ b/CPP/7zip/Bundles/SFXSetup/StdAfx.h
diff --git a/7zip/Bundles/SFXSetup/makefile b/CPP/7zip/Bundles/SFXSetup/makefile
index 1f86c42c..1f86c42c 100755
--- a/7zip/Bundles/SFXSetup/makefile
+++ b/CPP/7zip/Bundles/SFXSetup/makefile
diff --git a/7zip/Bundles/SFXSetup/resource.h b/CPP/7zip/Bundles/SFXSetup/resource.h
index 2c7e5a22..2c7e5a22 100755
--- a/7zip/Bundles/SFXSetup/resource.h
+++ b/CPP/7zip/Bundles/SFXSetup/resource.h
diff --git a/7zip/Bundles/SFXSetup/resource.rc b/CPP/7zip/Bundles/SFXSetup/resource.rc
index 4bf6a585..4bf6a585 100755
--- a/7zip/Bundles/SFXSetup/resource.rc
+++ b/CPP/7zip/Bundles/SFXSetup/resource.rc
diff --git a/7zip/Bundles/SFXSetup/setup.ico b/CPP/7zip/Bundles/SFXSetup/setup.ico
index bb455be1..bb455be1 100755
--- a/7zip/Bundles/SFXSetup/setup.ico
+++ b/CPP/7zip/Bundles/SFXSetup/setup.ico
Binary files differ
diff --git a/7zip/Bundles/SFXWin/7z.ico b/CPP/7zip/Bundles/SFXWin/7z.ico
index 47ffb781..47ffb781 100755
--- a/7zip/Bundles/SFXWin/7z.ico
+++ b/CPP/7zip/Bundles/SFXWin/7z.ico
Binary files differ
diff --git a/7zip/Bundles/SFXWin/Main.cpp b/CPP/7zip/Bundles/SFXWin/Main.cpp
index 166d58cb..166d58cb 100755
--- a/7zip/Bundles/SFXWin/Main.cpp
+++ b/CPP/7zip/Bundles/SFXWin/Main.cpp
diff --git a/7zip/Bundles/SFXWin/SFXWin.dsp b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp
index ead66bc6..ead66bc6 100755
--- a/7zip/Bundles/SFXWin/SFXWin.dsp
+++ b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp
diff --git a/7zip/Bundles/SFXWin/SFXWin.dsw b/CPP/7zip/Bundles/SFXWin/SFXWin.dsw
index a9926c71..a9926c71 100755
--- a/7zip/Bundles/SFXWin/SFXWin.dsw
+++ b/CPP/7zip/Bundles/SFXWin/SFXWin.dsw
diff --git a/7zip/Compress/BZip2Original/StdAfx.cpp b/CPP/7zip/Bundles/SFXWin/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/BZip2Original/StdAfx.cpp
+++ b/CPP/7zip/Bundles/SFXWin/StdAfx.cpp
diff --git a/7zip/Bundles/SFXWin/StdAfx.h b/CPP/7zip/Bundles/SFXWin/StdAfx.h
index c5f7231f..c5f7231f 100755
--- a/7zip/Bundles/SFXWin/StdAfx.h
+++ b/CPP/7zip/Bundles/SFXWin/StdAfx.h
diff --git a/7zip/Bundles/SFXWin/makefile b/CPP/7zip/Bundles/SFXWin/makefile
index 00d3ecc6..00d3ecc6 100755
--- a/7zip/Bundles/SFXWin/makefile
+++ b/CPP/7zip/Bundles/SFXWin/makefile
diff --git a/7zip/Bundles/SFXWin/resource.h b/CPP/7zip/Bundles/SFXWin/resource.h
index 0a460213..0a460213 100755
--- a/7zip/Bundles/SFXWin/resource.h
+++ b/CPP/7zip/Bundles/SFXWin/resource.h
diff --git a/7zip/Bundles/SFXWin/resource.rc b/CPP/7zip/Bundles/SFXWin/resource.rc
index 60304803..60304803 100755
--- a/7zip/Bundles/SFXWin/resource.rc
+++ b/CPP/7zip/Bundles/SFXWin/resource.rc
diff --git a/CPP/7zip/Bundles/makefile b/CPP/7zip/Bundles/makefile
new file mode 100755
index 00000000..7e7d7cdc
--- /dev/null
+++ b/CPP/7zip/Bundles/makefile
@@ -0,0 +1,15 @@
+DIRS = \
+ Alone\~ \
+ Alone7z\~ \
+ Format7z\~ \
+ Format7zR\~ \
+ Format7zExtract\~ \
+ Format7zExtractR\~ \
+ SFXCon\~ \
+ SFXSetup\~ \
+ SFXWin\~ \
+
+all: $(DIRS)
+
+$(DIRS):
+!include "../SubBuild.mak"
diff --git a/7zip/Common/FilePathAutoRename.cpp b/CPP/7zip/Common/FilePathAutoRename.cpp
index 3c5b910f..3c5b910f 100755
--- a/7zip/Common/FilePathAutoRename.cpp
+++ b/CPP/7zip/Common/FilePathAutoRename.cpp
diff --git a/7zip/Common/FilePathAutoRename.h b/CPP/7zip/Common/FilePathAutoRename.h
index 99323094..99323094 100755
--- a/7zip/Common/FilePathAutoRename.h
+++ b/CPP/7zip/Common/FilePathAutoRename.h
diff --git a/7zip/Common/FileStreams.cpp b/CPP/7zip/Common/FileStreams.cpp
index 8a000e4e..8a000e4e 100755
--- a/7zip/Common/FileStreams.cpp
+++ b/CPP/7zip/Common/FileStreams.cpp
diff --git a/7zip/Common/FileStreams.h b/CPP/7zip/Common/FileStreams.h
index 9326372a..9326372a 100755
--- a/7zip/Common/FileStreams.h
+++ b/CPP/7zip/Common/FileStreams.h
diff --git a/7zip/Common/InBuffer.cpp b/CPP/7zip/Common/InBuffer.cpp
index 02f2adfa..02f2adfa 100755
--- a/7zip/Common/InBuffer.cpp
+++ b/CPP/7zip/Common/InBuffer.cpp
diff --git a/7zip/Common/InBuffer.h b/CPP/7zip/Common/InBuffer.h
index 057caa16..057caa16 100755
--- a/7zip/Common/InBuffer.h
+++ b/CPP/7zip/Common/InBuffer.h
diff --git a/7zip/Common/InMemStream.cpp b/CPP/7zip/Common/InMemStream.cpp
index 036ef3bd..036ef3bd 100755
--- a/7zip/Common/InMemStream.cpp
+++ b/CPP/7zip/Common/InMemStream.cpp
diff --git a/7zip/Common/InMemStream.h b/CPP/7zip/Common/InMemStream.h
index fcd0092d..fcd0092d 100755
--- a/7zip/Common/InMemStream.h
+++ b/CPP/7zip/Common/InMemStream.h
diff --git a/7zip/Common/InOutTempBuffer.cpp b/CPP/7zip/Common/InOutTempBuffer.cpp
index ffaed32c..ffaed32c 100755
--- a/7zip/Common/InOutTempBuffer.cpp
+++ b/CPP/7zip/Common/InOutTempBuffer.cpp
diff --git a/7zip/Common/InOutTempBuffer.h b/CPP/7zip/Common/InOutTempBuffer.h
index 3abe76ec..3abe76ec 100755
--- a/7zip/Common/InOutTempBuffer.h
+++ b/CPP/7zip/Common/InOutTempBuffer.h
diff --git a/CPP/7zip/Common/LSBFDecoder.cpp b/CPP/7zip/Common/LSBFDecoder.cpp
new file mode 100755
index 00000000..76dd090f
--- /dev/null
+++ b/CPP/7zip/Common/LSBFDecoder.cpp
@@ -0,0 +1,27 @@
+// Stream/LSBFDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "LSBFDecoder.h"
+
+namespace NStream {
+namespace NLSBF {
+
+Byte kInvertTable[256];
+
+class CInverterTableInitializer
+{
+public:
+ CInverterTableInitializer()
+ {
+ for (int i = 0; i < 256; i++)
+ {
+ int x = ((i & 0x55) << 1) | ((i & 0xAA) >> 1);
+ x = ((x & 0x33) << 2) | ((x & 0xCC) >> 2);
+ kInvertTable[i] = (Byte)(((x & 0x0F) << 4) | ((x & 0xF0) >> 4));
+ }
+ }
+} g_InverterTableInitializer;
+
+
+}}
diff --git a/7zip/Common/LSBFDecoder.h b/CPP/7zip/Common/LSBFDecoder.h
index 75458452..75458452 100755
--- a/7zip/Common/LSBFDecoder.h
+++ b/CPP/7zip/Common/LSBFDecoder.h
diff --git a/7zip/Common/LSBFEncoder.cpp b/CPP/7zip/Common/LSBFEncoder.cpp
index 6322cae3..6322cae3 100755
--- a/7zip/Common/LSBFEncoder.cpp
+++ b/CPP/7zip/Common/LSBFEncoder.cpp
diff --git a/7zip/Common/LSBFEncoder.h b/CPP/7zip/Common/LSBFEncoder.h
index 72c84d9f..72c84d9f 100755
--- a/7zip/Common/LSBFEncoder.h
+++ b/CPP/7zip/Common/LSBFEncoder.h
diff --git a/7zip/Common/LimitedStreams.cpp b/CPP/7zip/Common/LimitedStreams.cpp
index af721146..af721146 100755
--- a/7zip/Common/LimitedStreams.cpp
+++ b/CPP/7zip/Common/LimitedStreams.cpp
diff --git a/7zip/Common/LimitedStreams.h b/CPP/7zip/Common/LimitedStreams.h
index ec4a3a70..ec4a3a70 100755
--- a/7zip/Common/LimitedStreams.h
+++ b/CPP/7zip/Common/LimitedStreams.h
diff --git a/7zip/Common/LockedStream.cpp b/CPP/7zip/Common/LockedStream.cpp
index 36be1ceb..36be1ceb 100755
--- a/7zip/Common/LockedStream.cpp
+++ b/CPP/7zip/Common/LockedStream.cpp
diff --git a/7zip/Common/LockedStream.h b/CPP/7zip/Common/LockedStream.h
index 1c1e1793..1c1e1793 100755
--- a/7zip/Common/LockedStream.h
+++ b/CPP/7zip/Common/LockedStream.h
diff --git a/7zip/Common/MSBFDecoder.h b/CPP/7zip/Common/MSBFDecoder.h
index dc80c0f7..dc80c0f7 100755
--- a/7zip/Common/MSBFDecoder.h
+++ b/CPP/7zip/Common/MSBFDecoder.h
diff --git a/7zip/Common/MSBFEncoder.h b/CPP/7zip/Common/MSBFEncoder.h
index 767a0e57..767a0e57 100755
--- a/7zip/Common/MSBFEncoder.h
+++ b/CPP/7zip/Common/MSBFEncoder.h
diff --git a/7zip/Common/MemBlocks.cpp b/CPP/7zip/Common/MemBlocks.cpp
index d2b79a70..d2b79a70 100755
--- a/7zip/Common/MemBlocks.cpp
+++ b/CPP/7zip/Common/MemBlocks.cpp
diff --git a/7zip/Common/MemBlocks.h b/CPP/7zip/Common/MemBlocks.h
index 31cd3546..31cd3546 100755
--- a/7zip/Common/MemBlocks.h
+++ b/CPP/7zip/Common/MemBlocks.h
diff --git a/7zip/Common/OffsetStream.cpp b/CPP/7zip/Common/OffsetStream.cpp
index 997ccae2..997ccae2 100755
--- a/7zip/Common/OffsetStream.cpp
+++ b/CPP/7zip/Common/OffsetStream.cpp
diff --git a/7zip/Common/OffsetStream.h b/CPP/7zip/Common/OffsetStream.h
index 57a055cc..57a055cc 100755
--- a/7zip/Common/OffsetStream.h
+++ b/CPP/7zip/Common/OffsetStream.h
diff --git a/7zip/Common/OutBuffer.cpp b/CPP/7zip/Common/OutBuffer.cpp
index a73fa7c5..a73fa7c5 100755
--- a/7zip/Common/OutBuffer.cpp
+++ b/CPP/7zip/Common/OutBuffer.cpp
diff --git a/7zip/Common/OutBuffer.h b/CPP/7zip/Common/OutBuffer.h
index 0ce54e21..0ce54e21 100755
--- a/7zip/Common/OutBuffer.h
+++ b/CPP/7zip/Common/OutBuffer.h
diff --git a/7zip/Common/OutMemStream.cpp b/CPP/7zip/Common/OutMemStream.cpp
index 2953afd8..2953afd8 100755
--- a/7zip/Common/OutMemStream.cpp
+++ b/CPP/7zip/Common/OutMemStream.cpp
diff --git a/7zip/Common/OutMemStream.h b/CPP/7zip/Common/OutMemStream.h
index ea98de17..ea98de17 100755
--- a/7zip/Common/OutMemStream.h
+++ b/CPP/7zip/Common/OutMemStream.h
diff --git a/7zip/Common/ProgressMt.cpp b/CPP/7zip/Common/ProgressMt.cpp
index 319bd241..319bd241 100755
--- a/7zip/Common/ProgressMt.cpp
+++ b/CPP/7zip/Common/ProgressMt.cpp
diff --git a/7zip/Common/ProgressMt.h b/CPP/7zip/Common/ProgressMt.h
index c0776944..c0776944 100755
--- a/7zip/Common/ProgressMt.h
+++ b/CPP/7zip/Common/ProgressMt.h
diff --git a/7zip/Common/ProgressUtils.cpp b/CPP/7zip/Common/ProgressUtils.cpp
index 40e13877..40e13877 100755
--- a/7zip/Common/ProgressUtils.cpp
+++ b/CPP/7zip/Common/ProgressUtils.cpp
diff --git a/7zip/Common/ProgressUtils.h b/CPP/7zip/Common/ProgressUtils.h
index f89839fa..f89839fa 100755
--- a/7zip/Common/ProgressUtils.h
+++ b/CPP/7zip/Common/ProgressUtils.h
diff --git a/7zip/Common/StdAfx.h b/CPP/7zip/Common/StdAfx.h
index 27a77b10..27a77b10 100755
--- a/7zip/Common/StdAfx.h
+++ b/CPP/7zip/Common/StdAfx.h
diff --git a/7zip/Common/StreamBinder.cpp b/CPP/7zip/Common/StreamBinder.cpp
index 2984c2d9..2984c2d9 100755
--- a/7zip/Common/StreamBinder.cpp
+++ b/CPP/7zip/Common/StreamBinder.cpp
diff --git a/7zip/Common/StreamBinder.h b/CPP/7zip/Common/StreamBinder.h
index a66c3acb..a66c3acb 100755
--- a/7zip/Common/StreamBinder.h
+++ b/CPP/7zip/Common/StreamBinder.h
diff --git a/7zip/Common/StreamObjects.cpp b/CPP/7zip/Common/StreamObjects.cpp
index 32f8f306..32f8f306 100755
--- a/7zip/Common/StreamObjects.cpp
+++ b/CPP/7zip/Common/StreamObjects.cpp
diff --git a/7zip/Common/StreamObjects.h b/CPP/7zip/Common/StreamObjects.h
index 6f670f59..6f670f59 100755
--- a/7zip/Common/StreamObjects.h
+++ b/CPP/7zip/Common/StreamObjects.h
diff --git a/7zip/Common/StreamUtils.cpp b/CPP/7zip/Common/StreamUtils.cpp
index a5d9ac0e..a5d9ac0e 100755
--- a/7zip/Common/StreamUtils.cpp
+++ b/CPP/7zip/Common/StreamUtils.cpp
diff --git a/7zip/Common/StreamUtils.h b/CPP/7zip/Common/StreamUtils.h
index 59f88733..59f88733 100755
--- a/7zip/Common/StreamUtils.h
+++ b/CPP/7zip/Common/StreamUtils.h
diff --git a/7zip/Compress/Arj/ArjDecoder1.cpp b/CPP/7zip/Compress/Arj/ArjDecoder1.cpp
index 7f720807..7f720807 100755
--- a/7zip/Compress/Arj/ArjDecoder1.cpp
+++ b/CPP/7zip/Compress/Arj/ArjDecoder1.cpp
diff --git a/7zip/Compress/Arj/ArjDecoder1.h b/CPP/7zip/Compress/Arj/ArjDecoder1.h
index 434a0a41..434a0a41 100755
--- a/7zip/Compress/Arj/ArjDecoder1.h
+++ b/CPP/7zip/Compress/Arj/ArjDecoder1.h
diff --git a/7zip/Compress/Arj/ArjDecoder2.cpp b/CPP/7zip/Compress/Arj/ArjDecoder2.cpp
index a734d1b4..a734d1b4 100755
--- a/7zip/Compress/Arj/ArjDecoder2.cpp
+++ b/CPP/7zip/Compress/Arj/ArjDecoder2.cpp
diff --git a/7zip/Compress/Arj/ArjDecoder2.h b/CPP/7zip/Compress/Arj/ArjDecoder2.h
index 7a33f6bd..7a33f6bd 100755
--- a/7zip/Compress/Arj/ArjDecoder2.h
+++ b/CPP/7zip/Compress/Arj/ArjDecoder2.h
diff --git a/7zip/Compress/Arj/StdAfx.h b/CPP/7zip/Compress/Arj/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/Arj/StdAfx.h
+++ b/CPP/7zip/Compress/Arj/StdAfx.h
diff --git a/CPP/7zip/Compress/BWT/BlockSort.cpp b/CPP/7zip/Compress/BWT/BlockSort.cpp
new file mode 100755
index 00000000..9e28c85f
--- /dev/null
+++ b/CPP/7zip/Compress/BWT/BlockSort.cpp
@@ -0,0 +1,487 @@
+// BlockSort.cpp
+
+#include "StdAfx.h"
+
+#include "BlockSort.h"
+
+extern "C"
+{
+ #include "../../../../C/Sort.h"
+}
+
+// use BLOCK_SORT_EXTERNAL_FLAGS if blockSize > 1M
+// #define BLOCK_SORT_USE_HEAP_SORT
+
+#if _MSC_VER >= 1300
+ #define NO_INLINE __declspec(noinline) __fastcall
+#else
+#ifdef _MSC_VER
+ #define NO_INLINE __fastcall
+#else
+ #define NO_INLINE
+#endif
+#endif
+
+// Don't change it !!
+static const int kNumHashBytes = 2;
+static const UInt32 kNumHashValues = 1 << (kNumHashBytes * 8);
+
+static const int kNumRefBitsMax = 12; // must be < (kNumHashBytes * 8) = 16
+static const UInt32 kNumRefsMax = (1 << kNumRefBitsMax);
+
+#define BS_TEMP_SIZE kNumHashValues
+
+#ifdef BLOCK_SORT_EXTERNAL_FLAGS
+
+static const int kNumFlagsBits = 5; // 32 Flags in UInt32 word
+static const UInt32 kNumFlagsInWord = (1 << kNumFlagsBits);
+static const UInt32 kFlagsMask = kNumFlagsInWord - 1;
+static const UInt32 kAllFlags = 0xFFFFFFFF;
+
+#else
+
+const int kNumBitsMax = 20;
+const UInt32 kIndexMask = (1 << kNumBitsMax) - 1;
+const int kNumExtraBits = 32 - kNumBitsMax;
+const int kNumExtra0Bits = kNumExtraBits - 2;
+const UInt32 kNumExtra0Mask = (1 << kNumExtra0Bits) - 1;
+
+#define SetFinishedGroupSize(p, size) \
+ { *(p) |= ((((size) - 1) & kNumExtra0Mask) << kNumBitsMax); \
+ if ((size) > (1 << kNumExtra0Bits)) { \
+ *(p) |= 0x40000000; *((p) + 1) |= ((((size) - 1)>> kNumExtra0Bits) << kNumBitsMax); } } \
+
+inline void SetGroupSize(UInt32 *p, UInt32 size)
+{
+ if (--size == 0)
+ return;
+ *p |= 0x80000000 | ((size & kNumExtra0Mask) << kNumBitsMax);
+ if (size >= (1 << kNumExtra0Bits))
+ {
+ *p |= 0x40000000;
+ p[1] |= ((size >> kNumExtra0Bits) << kNumBitsMax);
+ }
+}
+
+#endif
+
+// SortGroup - is recursive Range-Sort function with HeapSort optimization for small blocks
+// "range" is not real range. It's only for optimization.
+// returns: 1 - if there are groups, 0 - no more groups
+
+UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 groupOffset, UInt32 groupSize, int NumRefBits, UInt32 *Indices
+ #ifndef BLOCK_SORT_USE_HEAP_SORT
+ , UInt32 left, UInt32 range
+ #endif
+ )
+{
+ UInt32 *ind2 = Indices + groupOffset;
+ if (groupSize <= 1)
+ {
+ /*
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetFinishedGroupSize(ind2, 1);
+ #endif
+ */
+ return 0;
+ }
+ UInt32 *Groups = Indices + BlockSize + BS_TEMP_SIZE;
+ if (groupSize <= ((UInt32)1 << NumRefBits)
+ #ifndef BLOCK_SORT_USE_HEAP_SORT
+ && groupSize <= range
+ #endif
+ )
+ {
+ UInt32 *temp = Indices + BlockSize;
+ UInt32 j;
+ {
+ UInt32 gPrev;
+ UInt32 gRes = 0;
+ {
+ UInt32 sp = ind2[0] + NumSortedBytes;
+ if (sp >= BlockSize) sp -= BlockSize;
+ gPrev = Groups[sp];
+ temp[0] = (gPrev << NumRefBits);
+ }
+
+ for (j = 1; j < groupSize; j++)
+ {
+ UInt32 sp = ind2[j] + NumSortedBytes;
+ if (sp >= BlockSize) sp -= BlockSize;
+ UInt32 g = Groups[sp];
+ temp[j] = (g << NumRefBits) | j;
+ gRes |= (gPrev ^ g);
+ }
+ if (gRes == 0)
+ {
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(ind2, groupSize);
+ #endif
+ return 1;
+ }
+ }
+
+ HeapSort(temp, groupSize);
+ const UInt32 mask = ((1 << NumRefBits) - 1);
+ UInt32 thereAreGroups = 0;
+
+ UInt32 group = groupOffset;
+ UInt32 cg = (temp[0] >> NumRefBits);
+ temp[0] = ind2[temp[0] & mask];
+
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 *Flags = Groups + BlockSize;
+ #else
+ UInt32 prevGroupStart = 0;
+ #endif
+
+ for (j = 1; j < groupSize; j++)
+ {
+ UInt32 val = temp[j];
+ UInt32 cgCur = (val >> NumRefBits);
+
+ if (cgCur != cg)
+ {
+ cg = cgCur;
+ group = groupOffset + j;
+
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 t = group - 1;
+ Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
+ #else
+ SetGroupSize(temp + prevGroupStart, j - prevGroupStart);
+ prevGroupStart = j;
+ #endif
+ }
+ else
+ thereAreGroups = 1;
+ UInt32 ind = ind2[val & mask];
+ temp[j] = ind;
+ Groups[ind] = group;
+ }
+
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(temp + prevGroupStart, j - prevGroupStart);
+ #endif
+
+ for (j = 0; j < groupSize; j++)
+ ind2[j] = temp[j];
+ return thereAreGroups;
+ }
+
+ // Check that all strings are in one group (cannot sort)
+ {
+ UInt32 sp = ind2[0] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ UInt32 group = Groups[sp];
+ UInt32 j;
+ for (j = 1; j < groupSize; j++)
+ {
+ sp = ind2[j] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ if (Groups[sp] != group)
+ break;
+ }
+ if (j == groupSize)
+ {
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(ind2, groupSize);
+ #endif
+ return 1;
+ }
+ }
+
+ #ifndef BLOCK_SORT_USE_HEAP_SORT
+ //--------------------------------------
+ // Range Sort
+ UInt32 i;
+ UInt32 mid;
+ for (;;)
+ {
+ if (range <= 1)
+ {
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(ind2, groupSize);
+ #endif
+ return 1;
+ }
+ mid = left + ((range + 1) >> 1);
+ UInt32 j = groupSize;
+ i = 0;
+ do
+ {
+ UInt32 sp = ind2[i] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ if (Groups[sp] >= mid)
+ {
+ for (j--; j > i; j--)
+ {
+ sp = ind2[j] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ if (Groups[sp] < mid)
+ {
+ UInt32 temp = ind2[i]; ind2[i] = ind2[j]; ind2[j] = temp;
+ break;
+ }
+ }
+ if (i >= j)
+ break;
+ }
+ }
+ while(++i < j);
+ if (i == 0)
+ {
+ range = range - (mid - left);
+ left = mid;
+ }
+ else if (i == groupSize)
+ range = (mid - left);
+ else
+ break;
+ }
+
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ {
+ UInt32 t = (groupOffset + i - 1);
+ UInt32 *Flags = Groups + BlockSize;
+ Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
+ }
+ #endif
+
+ for (UInt32 j = i; j < groupSize; j++)
+ Groups[ind2[j]] = groupOffset + i;
+
+ UInt32 res = SortGroup(BlockSize, NumSortedBytes, groupOffset, i, NumRefBits, Indices, left, mid - left);
+ return res | SortGroup(BlockSize, NumSortedBytes, groupOffset + i, groupSize - i, NumRefBits, Indices, mid, range - (mid - left));
+
+ #else
+
+ //--------------------------------------
+ // Heap Sort
+
+ {
+ UInt32 j;
+ for (j = 0; j < groupSize; j++)
+ {
+ UInt32 sp = ind2[j] + NumSortedBytes; if (sp >= BlockSize) sp -= BlockSize;
+ ind2[j] = sp;
+ }
+
+ HeapSortRef(ind2, Groups, groupSize);
+
+ // Write Flags
+ UInt32 sp = ind2[0];
+ UInt32 group = Groups[sp];
+
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 *Flags = Groups + BlockSize;
+ #else
+ UInt32 prevGroupStart = 0;
+ #endif
+
+ for (j = 1; j < groupSize; j++)
+ {
+ sp = ind2[j];
+ if (Groups[sp] != group)
+ {
+ group = Groups[sp];
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 t = groupOffset + j - 1;
+ Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
+ #else
+ SetGroupSize(ind2 + prevGroupStart, j - prevGroupStart);
+ prevGroupStart = j;
+ #endif
+ }
+ }
+
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ SetGroupSize(ind2 + prevGroupStart, j - prevGroupStart);
+ #endif
+
+ // Write new Groups values and Check that there are groups
+ UInt32 thereAreGroups = 0;
+ for (j = 0; j < groupSize; j++)
+ {
+ UInt32 group = groupOffset + j;
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 subGroupSize = ((ind2[j] & ~0xC0000000) >> kNumBitsMax);
+ if ((ind2[j] & 0x40000000) != 0)
+ subGroupSize += ((ind2[j + 1] >> kNumBitsMax) << kNumExtra0Bits);
+ subGroupSize++;
+ for (;;)
+ {
+ UInt32 original = ind2[j];
+ UInt32 sp = original & kIndexMask;
+ if (sp < NumSortedBytes) sp += BlockSize; sp -= NumSortedBytes;
+ ind2[j] = sp | (original & ~kIndexMask);
+ Groups[sp] = group;
+ if (--subGroupSize == 0)
+ break;
+ j++;
+ thereAreGroups = 1;
+ }
+ #else
+ for (;;)
+ {
+ UInt32 sp = ind2[j]; if (sp < NumSortedBytes) sp += BlockSize; sp -= NumSortedBytes;
+ ind2[j] = sp;
+ Groups[sp] = group;
+ if ((Flags[(groupOffset + j) >> kNumFlagsBits] & (1 << ((groupOffset + j) & kFlagsMask))) == 0)
+ break;
+ j++;
+ thereAreGroups = 1;
+ }
+ #endif
+ }
+ return thereAreGroups;
+ }
+ #endif
+}
+
+// conditions: blockSize > 0
+UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
+{
+ UInt32 *counters = Indices + blockSize;
+ UInt32 i;
+
+ // Radix-Sort for 2 bytes
+ for (i = 0; i < kNumHashValues; i++)
+ counters[i] = 0;
+ for (i = 0; i < blockSize - 1; i++)
+ counters[((UInt32)data[i] << 8) | data[i + 1]]++;
+ counters[((UInt32)data[i] << 8) | data[0]]++;
+
+ UInt32 *Groups = counters + BS_TEMP_SIZE;
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 *Flags = Groups + blockSize;
+ {
+ UInt32 numWords = (blockSize + kFlagsMask) >> kNumFlagsBits;
+ for (i = 0; i < numWords; i++)
+ Flags[i] = kAllFlags;
+ }
+ #endif
+
+ {
+ UInt32 sum = 0;
+ for (i = 0; i < kNumHashValues; i++)
+ {
+ UInt32 groupSize = counters[i];
+ if (groupSize > 0)
+ {
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 t = sum + groupSize - 1;
+ Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
+ #endif
+ sum += groupSize;
+ }
+ counters[i] = sum - groupSize;
+ }
+
+ for (i = 0; i < blockSize - 1; i++)
+ Groups[i] = counters[((UInt32)data[i] << 8) | data[i + 1]];
+ Groups[i] = counters[((UInt32)data[i] << 8) | data[0]];
+
+ for (i = 0; i < blockSize - 1; i++)
+ Indices[counters[((UInt32)data[i] << 8) | data[i + 1]]++] = i;
+ Indices[counters[((UInt32)data[i] << 8) | data[0]]++] = i;
+
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 prev = 0;
+ for (i = 0; i < kNumHashValues; i++)
+ {
+ UInt32 prevGroupSize = counters[i] - prev;
+ if (prevGroupSize == 0)
+ continue;
+ SetGroupSize(Indices + prev, prevGroupSize);
+ prev = counters[i];
+ }
+ #endif
+ }
+
+ int NumRefBits;
+ for (NumRefBits = 0; ((blockSize - 1) >> NumRefBits) != 0; NumRefBits++);
+ NumRefBits = 32 - NumRefBits;
+ if (NumRefBits > kNumRefBitsMax)
+ NumRefBits = kNumRefBitsMax;
+
+ for (UInt32 NumSortedBytes = kNumHashBytes; ; NumSortedBytes <<= 1)
+ {
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ UInt32 finishedGroupSize = 0;
+ #endif
+ UInt32 newLimit = 0;
+ for (i = 0; i < blockSize;)
+ {
+ #ifdef BLOCK_SORT_EXTERNAL_FLAGS
+
+ if ((Flags[i >> kNumFlagsBits] & (1 << (i & kFlagsMask))) == 0)
+ {
+ i++;
+ continue;
+ }
+ UInt32 groupSize;
+ for(groupSize = 1;
+ (Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0;
+ groupSize++);
+
+ groupSize++;
+
+ #else
+
+ UInt32 groupSize = ((Indices[i] & ~0xC0000000) >> kNumBitsMax);
+ bool finishedGroup = ((Indices[i] & 0x80000000) == 0);
+ if ((Indices[i] & 0x40000000) != 0)
+ {
+ groupSize += ((Indices[i + 1] >> kNumBitsMax) << kNumExtra0Bits);
+ Indices[i + 1] &= kIndexMask;
+ }
+ Indices[i] &= kIndexMask;
+ groupSize++;
+ if (finishedGroup || groupSize == 1)
+ {
+ Indices[i - finishedGroupSize] &= kIndexMask;
+ if (finishedGroupSize > 1)
+ Indices[i - finishedGroupSize + 1] &= kIndexMask;
+ UInt32 newGroupSize = groupSize + finishedGroupSize;
+ SetFinishedGroupSize(Indices + i - finishedGroupSize, newGroupSize);
+ finishedGroupSize = newGroupSize;
+ i += groupSize;
+ continue;
+ }
+ finishedGroupSize = 0;
+
+ #endif
+
+ if (NumSortedBytes >= blockSize)
+ for (UInt32 j = 0; j < groupSize; j++)
+ {
+ UInt32 t = (i + j);
+ // Flags[t >> kNumFlagsBits] &= ~(1 << (t & kFlagsMask));
+ Groups[Indices[t]] = t;
+ }
+ else
+ if (SortGroup(blockSize, NumSortedBytes, i, groupSize, NumRefBits, Indices
+ #ifndef BLOCK_SORT_USE_HEAP_SORT
+ , 0, blockSize
+ #endif
+ ) != 0)
+ newLimit = i + groupSize;
+ i += groupSize;
+ }
+ if (newLimit == 0)
+ break;
+ }
+ #ifndef BLOCK_SORT_EXTERNAL_FLAGS
+ for (i = 0; i < blockSize;)
+ {
+ UInt32 groupSize = ((Indices[i] & ~0xC0000000) >> kNumBitsMax);
+ if ((Indices[i] & 0x40000000) != 0)
+ {
+ groupSize += ((Indices[i + 1] >> kNumBitsMax) << kNumExtra0Bits);
+ Indices[i + 1] &= kIndexMask;
+ }
+ Indices[i] &= kIndexMask;
+ groupSize++;
+ i += groupSize;
+ }
+ #endif
+ return Groups[0];
+}
+
diff --git a/CPP/7zip/Compress/BWT/BlockSort.h b/CPP/7zip/Compress/BWT/BlockSort.h
new file mode 100755
index 00000000..def48a96
--- /dev/null
+++ b/CPP/7zip/Compress/BWT/BlockSort.h
@@ -0,0 +1,21 @@
+// BlockSort.h
+
+#ifndef __BLOCKSORT_H
+#define __BLOCKSORT_H
+
+#include "Common/Types.h"
+
+// use BLOCK_SORT_EXTERNAL_FLAGS if blockSize can be > 1M
+// #define BLOCK_SORT_EXTERNAL_FLAGS
+
+#ifdef BLOCK_SORT_EXTERNAL_FLAGS
+#define BLOCK_SORT_EXTERNAL_SIZE(blockSize) ((((blockSize) + 31) >> 5))
+#else
+#define BLOCK_SORT_EXTERNAL_SIZE(blockSize) 0
+#endif
+
+#define BLOCK_SORT_BUF_SIZE(blockSize) ((blockSize) * 2 + BLOCK_SORT_EXTERNAL_SIZE(blockSize) + (1 << 16))
+
+UInt32 BlockSort(UInt32 *indices, const Byte *data, UInt32 blockSize);
+
+#endif
diff --git a/CPP/7zip/Compress/BWT/Mtf8.h b/CPP/7zip/Compress/BWT/Mtf8.h
new file mode 100755
index 00000000..92e4df20
--- /dev/null
+++ b/CPP/7zip/Compress/BWT/Mtf8.h
@@ -0,0 +1,195 @@
+// Mtf8.h
+
+#ifndef __MTF8_H
+#define __MTF8_H
+
+#include "Common/Types.h"
+
+namespace NCompress {
+
+class CMtf8Encoder
+{
+public:
+ Byte Buffer[256];
+ int FindAndMove(Byte v)
+ {
+ int pos;
+ for (pos = 0; Buffer[pos] != v; pos++);
+ int resPos = pos;
+ for (; pos >= 8; pos -= 8)
+ {
+ Buffer[pos] = Buffer[pos - 1];
+ Buffer[pos - 1] = Buffer[pos - 2];
+ Buffer[pos - 2] = Buffer[pos - 3];
+ Buffer[pos - 3] = Buffer[pos - 4];
+ Buffer[pos - 4] = Buffer[pos - 5];
+ Buffer[pos - 5] = Buffer[pos - 6];
+ Buffer[pos - 6] = Buffer[pos - 7];
+ Buffer[pos - 7] = Buffer[pos - 8];
+ }
+ for (; pos > 0; pos--)
+ Buffer[pos] = Buffer[pos - 1];
+ Buffer[0] = v;
+ return resPos;
+ }
+};
+
+/*
+class CMtf8Decoder
+{
+public:
+ Byte Buffer[256];
+ void Init(int) {};
+ Byte GetHead() const { return Buffer[0]; }
+ Byte GetAndMove(int pos)
+ {
+ Byte res = Buffer[pos];
+ for (; pos >= 8; pos -= 8)
+ {
+ Buffer[pos] = Buffer[pos - 1];
+ Buffer[pos - 1] = Buffer[pos - 2];
+ Buffer[pos - 2] = Buffer[pos - 3];
+ Buffer[pos - 3] = Buffer[pos - 4];
+ Buffer[pos - 4] = Buffer[pos - 5];
+ Buffer[pos - 5] = Buffer[pos - 6];
+ Buffer[pos - 6] = Buffer[pos - 7];
+ Buffer[pos - 7] = Buffer[pos - 8];
+ }
+ for (; pos > 0; pos--)
+ Buffer[pos] = Buffer[pos - 1];
+ Buffer[0] = res;
+ return res;
+ }
+};
+*/
+
+#ifdef _WIN64
+#define MODE_64BIT
+#endif
+
+#ifdef MODE_64BIT
+typedef UInt64 CMtfVar;
+#define MTF_MOVS 3
+#else
+typedef UInt32 CMtfVar;
+#define MTF_MOVS 2
+#endif
+
+#define MTF_MASK ((1 << MTF_MOVS) - 1)
+
+
+class CMtf8Decoder
+{
+public:
+ CMtfVar Buffer[256 >> MTF_MOVS];
+ void StartInit() { memset(Buffer, 0, sizeof(Buffer)); }
+ void Add(unsigned int pos, Byte val) { Buffer[pos >> MTF_MOVS] |= ((CMtfVar)val << ((pos & MTF_MASK) << 3)); }
+ Byte GetHead() const { return (Byte)Buffer[0]; }
+ Byte GetAndMove(unsigned int pos)
+ {
+ UInt32 lim = ((UInt32)pos >> MTF_MOVS);
+ pos = (pos & MTF_MASK) << 3;
+ CMtfVar prev = (Buffer[lim] >> pos) & 0xFF;
+
+ UInt32 i = 0;
+ if ((lim & 1) != 0)
+ {
+ CMtfVar next = Buffer[0];
+ Buffer[0] = (next << 8) | prev;
+ prev = (next >> (MTF_MASK << 3));
+ i = 1;
+ lim -= 1;
+ }
+ for (; i < lim; i += 2)
+ {
+ CMtfVar next = Buffer[i];
+ Buffer[i] = (next << 8) | prev;
+ prev = (next >> (MTF_MASK << 3));
+ next = Buffer[i + 1];
+ Buffer[i + 1] = (next << 8) | prev;
+ prev = (next >> (MTF_MASK << 3));
+ }
+ CMtfVar next = Buffer[i];
+ CMtfVar mask = (((CMtfVar)0x100 << pos) - 1);
+ Buffer[i] = (next & ~mask) | (((next << 8) | prev) & mask);
+ return (Byte)Buffer[0];
+ }
+};
+
+/*
+const int kSmallSize = 64;
+class CMtf8Decoder
+{
+ Byte SmallBuffer[kSmallSize];
+ int SmallSize;
+ Byte Counts[16];
+ int Size;
+public:
+ Byte Buffer[256];
+
+ Byte GetHead() const
+ {
+ if (SmallSize > 0)
+ return SmallBuffer[kSmallSize - SmallSize];
+ return Buffer[0];
+ }
+
+ void Init(int size)
+ {
+ Size = size;
+ SmallSize = 0;
+ for (int i = 0; i < 16; i++)
+ {
+ Counts[i] = ((size >= 16) ? 16 : size);
+ size -= Counts[i];
+ }
+ }
+
+ Byte GetAndMove(int pos)
+ {
+ if (pos < SmallSize)
+ {
+ Byte *p = SmallBuffer + kSmallSize - SmallSize;
+ Byte res = p[pos];
+ for (; pos > 0; pos--)
+ p[pos] = p[pos - 1];
+ SmallBuffer[kSmallSize - SmallSize] = res;
+ return res;
+ }
+ if (SmallSize == kSmallSize)
+ {
+ int i = Size - 1;
+ int g = 16;
+ do
+ {
+ g--;
+ int offset = (g << 4);
+ for (int t = Counts[g] - 1; t >= 0; t--, i--)
+ Buffer[i] = Buffer[offset + t];
+ }
+ while(g != 0);
+
+ for (i = kSmallSize - 1; i >= 0; i--)
+ Buffer[i] = SmallBuffer[i];
+ Init(Size);
+ }
+ pos -= SmallSize;
+ int g;
+ for (g = 0; pos >= Counts[g]; g++)
+ pos -= Counts[g];
+ int offset = (g << 4);
+ Byte res = Buffer[offset + pos];
+ for (pos; pos < 16 - 1; pos++)
+ Buffer[offset + pos] = Buffer[offset + pos + 1];
+
+ SmallSize++;
+ SmallBuffer[kSmallSize - SmallSize] = res;
+
+ Counts[g]--;
+ return res;
+ }
+};
+*/
+
+}
+#endif
diff --git a/7zip/Compress/BWT/StdAfx.h b/CPP/7zip/Compress/BWT/StdAfx.h
index b637fd40..b637fd40 100755
--- a/7zip/Compress/BWT/StdAfx.h
+++ b/CPP/7zip/Compress/BWT/StdAfx.h
diff --git a/CPP/7zip/Compress/BZip2/BZip2.dsp b/CPP/7zip/Compress/BZip2/BZip2.dsp
new file mode 100755
index 00000000..121602d8
--- /dev/null
+++ b/CPP/7zip/Compress/BZip2/BZip2.dsp
@@ -0,0 +1,303 @@
+# Microsoft Developer Studio Project File - Name="BZip2" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=BZip2 - 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 "BZip2.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 "BZip2.mak" CFG="BZip2 - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "BZip2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "BZip2 - 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)" == "BZip2 - 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 "BZIP2_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "BZ_NO_STDIO" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /D "COMPRESS_BZIP2_MT" /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\BZip2.dll" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "BZip2 - 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 "BZIP2_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /D "COMPRESS_BZIP2_MT" /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\BZip2.dll" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "BZip2 - Win32 Release"
+# Name "BZip2 - Win32 Debug"
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Codec.def
+# 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 "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\NewHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\NewHandler.h
+# End Source File
+# End Group
+# Begin Group "Huffman"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Huffman\HuffmanDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Huffman\HuffmanEncode.c
+
+!IF "$(CFG)" == "BZip2 - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Huffman\HuffmanEncode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.c
+
+!IF "$(CFG)" == "BZip2 - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.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\MSBFDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MSBFEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OutBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OutBuffer.h
+# End Source File
+# End Group
+# Begin Group "BWT"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\BWT\BlockSort.cpp
+
+!IF "$(CFG)" == "BZip2 - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\BWT\BlockSort.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\BWT\Mtf8.h
+# End Source File
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# 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\Thread.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\BZip2Const.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BZip2CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BZip2CRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BZip2Decoder.cpp
+
+!IF "$(CFG)" == "BZip2 - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\BZip2Decoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BZip2Encoder.cpp
+
+!IF "$(CFG)" == "BZip2 - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "BZip2 - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\BZip2Encoder.h
+# End Source File
+# End Target
+# End Project
diff --git a/7zip/Compress/BZip2/BZip2.dsw b/CPP/7zip/Compress/BZip2/BZip2.dsw
index 697e5095..697e5095 100755
--- a/7zip/Compress/BZip2/BZip2.dsw
+++ b/CPP/7zip/Compress/BZip2/BZip2.dsw
diff --git a/7zip/Compress/BZip2/BZip2CRC.cpp b/CPP/7zip/Compress/BZip2/BZip2CRC.cpp
index ba9ddb7e..ba9ddb7e 100755
--- a/7zip/Compress/BZip2/BZip2CRC.cpp
+++ b/CPP/7zip/Compress/BZip2/BZip2CRC.cpp
diff --git a/CPP/7zip/Compress/BZip2/BZip2CRC.h b/CPP/7zip/Compress/BZip2/BZip2CRC.h
new file mode 100755
index 00000000..8ac2a504
--- /dev/null
+++ b/CPP/7zip/Compress/BZip2/BZip2CRC.h
@@ -0,0 +1,31 @@
+// BZip2CRC.h
+
+#ifndef __BZIP2_CRC_H
+#define __BZIP2_CRC_H
+
+#include "Common/Types.h"
+
+class CBZip2CRC
+{
+ UInt32 _value;
+ static UInt32 Table[256];
+public:
+ static void InitTable();
+ CBZip2CRC(): _value(0xFFFFFFFF) {};
+ 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; }
+};
+
+class CBZip2CombinedCRC
+{
+ UInt32 _value;
+public:
+ CBZip2CombinedCRC(): _value(0){};
+ void Init() { _value = 0; }
+ void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; }
+ UInt32 GetDigest() const { return _value ; }
+};
+
+#endif
diff --git a/7zip/Compress/BZip2/BZip2Const.h b/CPP/7zip/Compress/BZip2/BZip2Const.h
index 62427aa6..62427aa6 100755
--- a/7zip/Compress/BZip2/BZip2Const.h
+++ b/CPP/7zip/Compress/BZip2/BZip2Const.h
diff --git a/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp b/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp
new file mode 100755
index 00000000..a0b16b18
--- /dev/null
+++ b/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp
@@ -0,0 +1,770 @@
+// BZip2Decoder.cpp
+
+#include "StdAfx.h"
+
+#include "BZip2Decoder.h"
+
+#include "../../../Common/Alloc.h"
+#include "../../../Common/Defs.h"
+#include "../BWT/Mtf8.h"
+#include "BZip2CRC.h"
+
+namespace NCompress {
+namespace NBZip2 {
+
+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,
+ 936, 638
+};
+
+bool CState::Alloc()
+{
+ if (Counters == 0)
+ Counters = (UInt32 *)BigAlloc((256 + kBlockSizeMax) * sizeof(UInt32));
+ return (Counters != 0);
+}
+
+void CState::Free()
+{
+ ::BigFree(Counters);
+ Counters = 0;
+}
+
+UInt32 CDecoder::ReadBits(int numBits) { return m_InStream.ReadBits(numBits); }
+Byte CDecoder::ReadByte() {return (Byte)ReadBits(8); }
+bool CDecoder::ReadBit() { return ReadBits(1) != 0; }
+
+UInt32 CDecoder::ReadCRC()
+{
+ UInt32 crc = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ crc <<= 8;
+ crc |= ReadByte();
+ }
+ return crc;
+}
+
+UInt32 NO_INLINE ReadBits(NStream::NMSBF::CDecoder<CInBuffer> *m_InStream, int num)
+{
+ return m_InStream->ReadBits(num);
+}
+
+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,
+ 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)
+ return S_FALSE;
+
+ CMtf8Decoder mtf;
+ mtf.StartInit();
+
+ int numInUse = 0;
+ {
+ Byte inUse16[16];
+ int i;
+ for (i = 0; i < 16; i++)
+ inUse16[i] = (Byte)ReadBit(m_InStream);
+ for (i = 0; i < 256; i++)
+ if (inUse16[i >> 4])
+ {
+ if (ReadBit(m_InStream))
+ mtf.Add(numInUse++, (Byte)i);
+ }
+ if (numInUse == 0)
+ return S_FALSE;
+ // mtf.Init(numInUse);
+ }
+ int alphaSize = numInUse + 2;
+
+ int numTables = ReadBits(m_InStream, kNumTablesBits);
+ if (numTables < kNumTablesMin || numTables > kNumTablesMax)
+ return S_FALSE;
+
+ UInt32 numSelectors = ReadBits(m_InStream, kNumSelectorsBits);
+ if (numSelectors < 1 || numSelectors > kNumSelectorsMax)
+ return S_FALSE;
+
+ {
+ Byte mtfPos[kNumTablesMax];
+ int t = 0;
+ do
+ mtfPos[t] = (Byte)t;
+ while(++t < numTables);
+ UInt32 i = 0;
+ do
+ {
+ int j = 0;
+ while (ReadBit(m_InStream))
+ if (++j >= numTables)
+ return S_FALSE;
+ Byte tmp = mtfPos[j];
+ for (;j > 0; j--)
+ mtfPos[j] = mtfPos[j - 1];
+ m_Selectors[i] = mtfPos[0] = tmp;
+ }
+ while(++i < numSelectors);
+ }
+
+ int t = 0;
+ do
+ {
+ Byte lens[kMaxAlphaSize];
+ int len = (int)ReadBits(m_InStream, kNumLevelsBits);
+ int i;
+ for (i = 0; i < alphaSize; i++)
+ {
+ for (;;)
+ {
+ if (len < 1 || len > kMaxHuffmanLen)
+ return S_FALSE;
+ if (!ReadBit(m_InStream))
+ break;
+ len += 1 - (int)(ReadBit(m_InStream) << 1);
+ }
+ lens[i] = (Byte)len;
+ }
+ for (; i < kMaxAlphaSize; i++)
+ lens[i] = 0;
+ if(!m_HuffmanDecoders[t].SetCodeLengths(lens))
+ return S_FALSE;
+ }
+ while(++t < numTables);
+
+ {
+ for (int i = 0; i < 256; i++)
+ CharCounters[i] = 0;
+ }
+
+ UInt32 blockSize = 0;
+ {
+ UInt32 groupIndex = 0;
+ UInt32 groupSize = 0;
+ CHuffmanDecoder *huffmanDecoder = 0;
+ int runPower = 0;
+ UInt32 runCounter = 0;
+
+ for (;;)
+ {
+ if (groupSize == 0)
+ {
+ if (groupIndex >= numSelectors)
+ return S_FALSE;
+ groupSize = kGroupSize;
+ huffmanDecoder = &m_HuffmanDecoders[m_Selectors[groupIndex++]];
+ }
+ groupSize--;
+
+ UInt32 nextSym = huffmanDecoder->DecodeSymbol(m_InStream);
+
+ if (nextSym < 2)
+ {
+ runCounter += ((UInt32)(nextSym + 1) << runPower++);
+ if (blockSizeMax - blockSize < runCounter)
+ return S_FALSE;
+ continue;
+ }
+ if (runCounter != 0)
+ {
+ UInt32 b = (UInt32)mtf.GetHead();
+ CharCounters[b] += runCounter;
+ do
+ CharCounters[256 + blockSize++] = b;
+ while(--runCounter != 0);
+ runPower = 0;
+ }
+ if (nextSym <= (UInt32)numInUse)
+ {
+ UInt32 b = (UInt32)mtf.GetAndMove((int)nextSym - 1);
+ if (blockSize >= blockSizeMax)
+ return S_FALSE;
+ CharCounters[b]++;
+ CharCounters[256 + blockSize++] = b;
+ }
+ else if (nextSym == (UInt32)numInUse + 1)
+ break;
+ else
+ return S_FALSE;
+ }
+ }
+ *blockSizeRes = blockSize;
+ return (*origPtrRes < blockSize) ? S_OK : S_FALSE;
+}
+
+void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize)
+{
+ {
+ UInt32 sum = 0;
+ for (UInt32 i = 0; i < 256; i++)
+ {
+ sum += charCounters[i];
+ charCounters[i] = sum - charCounters[i];
+ }
+ }
+
+ UInt32 *tt = charCounters + 256;
+ // Compute the T^(-1) vector
+ UInt32 i = 0;
+ do
+ tt[charCounters[tt[i] & 0xFF]++] |= (i << 8);
+ while(++i < blockSize);
+}
+
+static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32 OrigPtr, COutBuffer &m_OutStream)
+{
+ CBZip2CRC crc;
+
+ // it's for speed optimization: prefetch & prevByte_init;
+ UInt32 tPos = tt[tt[OrigPtr] >> 8];
+ unsigned int prevByte = (unsigned int)(tPos & 0xFF);
+
+ int numReps = 0;
+
+ do
+ {
+ unsigned int b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+
+ if (numReps == kRleModeRepSize)
+ {
+ for (; b > 0; b--)
+ {
+ crc.UpdateByte(prevByte);
+ m_OutStream.WriteByte((Byte)prevByte);
+ }
+ numReps = 0;
+ continue;
+ }
+ if (b != prevByte)
+ numReps = 0;
+ numReps++;
+ prevByte = b;
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+
+ /*
+ prevByte = b;
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ for (; --blockSize != 0;)
+ {
+ b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ if (b != prevByte)
+ {
+ prevByte = b;
+ continue;
+ }
+ if (--blockSize == 0)
+ break;
+
+ b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ if (b != prevByte)
+ {
+ prevByte = b;
+ continue;
+ }
+ if (--blockSize == 0)
+ break;
+
+ b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ if (b != prevByte)
+ {
+ prevByte = b;
+ continue;
+ }
+ --blockSize;
+ break;
+ }
+ if (blockSize == 0)
+ break;
+
+ b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+
+ for (; b > 0; b--)
+ {
+ crc.UpdateByte(prevByte);
+ m_OutStream.WriteByte((Byte)prevByte);
+ }
+ */
+ }
+ while(--blockSize != 0);
+ return crc.GetDigest();
+}
+
+static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UInt32 OrigPtr, COutBuffer &m_OutStream)
+{
+ CBZip2CRC crc;
+
+ UInt32 randIndex = 1;
+ UInt32 randToGo = kRandNums[0] - 2;
+
+ int numReps = 0;
+
+ // it's for speed optimization: prefetch & prevByte_init;
+ UInt32 tPos = tt[tt[OrigPtr] >> 8];
+ unsigned int prevByte = (unsigned int)(tPos & 0xFF);
+
+ do
+ {
+ unsigned int b = (unsigned int)(tPos & 0xFF);
+ tPos = tt[tPos >> 8];
+
+ {
+ if (randToGo == 0)
+ {
+ b ^= 1;
+ randToGo = kRandNums[randIndex++];
+ randIndex &= 0x1FF;
+ }
+ randToGo--;
+ }
+
+ if (numReps == kRleModeRepSize)
+ {
+ for (; b > 0; b--)
+ {
+ crc.UpdateByte(prevByte);
+ m_OutStream.WriteByte((Byte)prevByte);
+ }
+ numReps = 0;
+ continue;
+ }
+ if (b != prevByte)
+ numReps = 0;
+ numReps++;
+ prevByte = b;
+ crc.UpdateByte(b);
+ m_OutStream.WriteByte((Byte)b);
+ }
+ while(--blockSize != 0);
+ return crc.GetDigest();
+}
+
+#ifdef COMPRESS_BZIP2_MT
+
+static DWORD WINAPI MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; }
+
+CDecoder::CDecoder():
+ m_States(0)
+{
+ m_NumThreadsPrev = 0;
+ NumThreads = 1;
+ CS.Enter();
+}
+
+CDecoder::~CDecoder()
+{
+ Free();
+}
+
+bool CDecoder::Create()
+{
+ try
+ {
+ if (m_States != 0 && m_NumThreadsPrev == NumThreads)
+ return true;
+ Free();
+ MtMode = (NumThreads > 1);
+ m_NumThreadsPrev = NumThreads;
+ m_States = new CState[NumThreads];
+ if (m_States == 0)
+ return false;
+ #ifdef COMPRESS_BZIP2_MT
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CState &ti = m_States[t];
+ ti.Decoder = this;
+ if (MtMode)
+ if (!ti.Thread.Create(MFThread, &ti))
+ {
+ NumThreads = t;
+ Free();
+ return false;
+ }
+ }
+ #endif
+ }
+ catch(...) { return false; }
+ return true;
+}
+
+void CDecoder::Free()
+{
+ if (!m_States)
+ return;
+ CloseThreads = true;
+ CS.Leave();
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CState &s = m_States[t];
+ if (MtMode)
+ s.Thread.Wait();
+ s.Free();
+ }
+ delete []m_States;
+ m_States = 0;
+}
+#endif
+
+HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
+{
+ wasFinished = false;
+ Byte s[6];
+ for (int i = 0; i < 6; i++)
+ s[i] = ReadByte();
+ crc = ReadCRC();
+ if (s[0] == kFinSig0)
+ {
+ 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 ||
+ s[5] != kBlockSig5)
+ return S_FALSE;
+ CombinedCRC.Update(crc);
+ return S_OK;
+}
+
+HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
+{
+ #ifdef COMPRESS_BZIP2_MT
+ Progress = progress;
+ if (!Create())
+ return E_FAIL;
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CState &s = m_States[t];
+ if (!s.Alloc())
+ return E_OUTOFMEMORY;
+ s.StreamWasFinishedEvent.Reset();
+ s.WaitingWasStartedEvent.Reset();
+ s.CanWriteEvent.Reset();
+ }
+ #else
+ if (!m_States[0].Alloc())
+ return E_OUTOFMEMORY;
+ #endif
+
+ isBZ = false;
+ Byte s[6];
+ int i;
+ for (i = 0; i < 4; i++)
+ s[i] = ReadByte();
+ if (s[0] != kArSig0 ||
+ s[1] != kArSig1 ||
+ s[2] != kArSig2 ||
+ s[3] <= kArSig3 ||
+ s[3] > kArSig3 + kBlockSizeMultMax)
+ return S_OK;
+ isBZ = true;
+ UInt32 dicSize = (UInt32)(s[3] - kArSig3) * kBlockSizeStep;
+
+ CombinedCRC.Init();
+ #ifdef COMPRESS_BZIP2_MT
+ if (MtMode)
+ {
+ NextBlockIndex = 0;
+ StreamWasFinished1 = StreamWasFinished2 = false;
+ CloseThreads = false;
+ CanStartWaitingEvent.Reset();
+ m_States[0].CanWriteEvent.Set();
+ BlockSizeMax = dicSize;
+ Result1 = Result2 = S_OK;
+ CS.Leave();
+ UInt32 t;
+ for (t = 0; t < NumThreads; t++)
+ m_States[t].StreamWasFinishedEvent.Lock();
+ CS.Enter();
+ CanStartWaitingEvent.Set();
+ for (t = 0; t < NumThreads; t++)
+ m_States[t].WaitingWasStartedEvent.Lock();
+ CanStartWaitingEvent.Reset();
+ RINOK(Result2);
+ RINOK(Result1);
+ }
+ else
+ #endif
+ {
+ CState &state = m_States[0];
+ for (;;)
+ {
+ if (progress)
+ {
+ UInt64 packSize = m_InStream.GetProcessedSize();
+ UInt64 unpackSize = m_OutStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &unpackSize));
+ }
+ bool wasFinished;
+ UInt32 crc;
+ RINOK(ReadSignatures(wasFinished, crc));
+ if (wasFinished)
+ return S_OK;
+
+ UInt32 blockSize, origPtr;
+ bool randMode;
+ RINOK(ReadBlock(&m_InStream, state.Counters, dicSize,
+ m_Selectors, m_HuffmanDecoders,
+ &blockSize, &origPtr, &randMode));
+ DecodeBlock1(state.Counters, blockSize);
+ if ((randMode ?
+ DecodeBlock2Rand(state.Counters + 256, blockSize, origPtr, m_OutStream) :
+ DecodeBlock2(state.Counters + 256, blockSize, origPtr, m_OutStream)) != crc)
+ return S_FALSE;
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
+ ICompressProgressInfo *progress)
+{
+ if (!m_InStream.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ if (!m_OutStream.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+
+ m_InStream.SetStream(inStream);
+ m_InStream.Init();
+
+ m_OutStream.SetStream(outStream);
+ m_OutStream.Init();
+
+ CDecoderFlusher flusher(this);
+
+ bool isBZ;
+ RINOK(DecodeFile(isBZ, progress));
+ return isBZ ? S_OK: S_FALSE;
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return E_FAIL; }
+}
+
+STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
+{
+ if (value == NULL)
+ return E_INVALIDARG;
+ *value = m_InStream.GetProcessedSize();
+ return S_OK;
+}
+
+#ifdef COMPRESS_BZIP2_MT
+void CState::FinishStream()
+{
+ Decoder->StreamWasFinished1 = true;
+ StreamWasFinishedEvent.Set();
+ Decoder->CS.Leave();
+ Decoder->CanStartWaitingEvent.Lock();
+ WaitingWasStartedEvent.Set();
+}
+
+void CState::ThreadFunc()
+{
+ for (;;)
+ {
+ Decoder->CS.Enter();
+ if (Decoder->CloseThreads)
+ {
+ Decoder->CS.Leave();
+ return;
+ }
+ if (Decoder->StreamWasFinished1)
+ {
+ FinishStream();
+ continue;
+ }
+ HRESULT res = S_OK;
+
+ UInt32 blockIndex = Decoder->NextBlockIndex;
+ UInt32 nextBlockIndex = blockIndex + 1;
+ if (nextBlockIndex == Decoder->NumThreads)
+ nextBlockIndex = 0;
+ Decoder->NextBlockIndex = nextBlockIndex;
+ UInt32 crc;
+ UInt64 packSize;
+ UInt32 blockSize = 0, origPtr = 0;
+ bool randMode = false;
+
+ try
+ {
+ bool wasFinished;
+ res = Decoder->ReadSignatures(wasFinished, crc);
+ if (res != S_OK)
+ {
+ Decoder->Result1 = res;
+ FinishStream();
+ continue;
+ }
+ if (wasFinished)
+ {
+ Decoder->Result1 = res;
+ FinishStream();
+ continue;
+ }
+
+ res = ReadBlock(&Decoder->m_InStream, Counters, Decoder->BlockSizeMax,
+ Decoder->m_Selectors, Decoder->m_HuffmanDecoders,
+ &blockSize, &origPtr, &randMode);
+ if (res != S_OK)
+ {
+ Decoder->Result1 = res;
+ FinishStream();
+ continue;
+ }
+ packSize = Decoder->m_InStream.GetProcessedSize();
+ }
+ catch(const CInBufferException &e) { res = e.ErrorCode; if (res != S_OK) res = E_FAIL; }
+ catch(...) { res = E_FAIL; }
+ if (res != S_OK)
+ {
+ Decoder->Result1 = res;
+ FinishStream();
+ continue;
+ }
+
+ Decoder->CS.Leave();
+
+ DecodeBlock1(Counters, blockSize);
+
+ bool needFinish = true;
+ try
+ {
+ Decoder->m_States[blockIndex].CanWriteEvent.Lock();
+ needFinish = Decoder->StreamWasFinished2;
+ if (!needFinish)
+ {
+ if ((randMode ?
+ DecodeBlock2Rand(Counters + 256, blockSize, origPtr, Decoder->m_OutStream) :
+ DecodeBlock2(Counters + 256, blockSize, origPtr, Decoder->m_OutStream)) == crc)
+ {
+ if (Decoder->Progress)
+ {
+ UInt64 unpackSize = Decoder->m_OutStream.GetProcessedSize();
+ res = Decoder->Progress->SetRatioInfo(&packSize, &unpackSize);
+ }
+ }
+ else
+ res = S_FALSE;
+ }
+ }
+ catch(const COutBufferException &e) { res = e.ErrorCode; if (res != S_OK) res = E_FAIL; }
+ catch(...) { res = E_FAIL; }
+ if (res != S_OK)
+ {
+ Decoder->Result2 = res;
+ Decoder->StreamWasFinished2 = true;
+ }
+ Decoder->m_States[nextBlockIndex].CanWriteEvent.Set();
+ if (res != S_OK || needFinish)
+ {
+ StreamWasFinishedEvent.Set();
+ Decoder->CanStartWaitingEvent.Lock();
+ WaitingWasStartedEvent.Set();
+ }
+ }
+}
+
+STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
+{
+ NumThreads = numThreads;
+ if (NumThreads < 1)
+ NumThreads = 1;
+ if (NumThreads > kNumThreadsMax)
+ NumThreads = kNumThreadsMax;
+ return S_OK;
+}
+#endif
+
+}}
diff --git a/CPP/7zip/Compress/BZip2/BZip2Decoder.h b/CPP/7zip/Compress/BZip2/BZip2Decoder.h
new file mode 100755
index 00000000..2375b755
--- /dev/null
+++ b/CPP/7zip/Compress/BZip2/BZip2Decoder.h
@@ -0,0 +1,164 @@
+// Compress/BZip2/Decoder.h
+
+#ifndef __COMPRESS_BZIP2_DECODER_H
+#define __COMPRESS_BZIP2_DECODER_H
+
+#include "../../ICoder.h"
+#include "../../../Common/MyCom.h"
+#include "../../Common/MSBFDecoder.h"
+#include "../../Common/InBuffer.h"
+#include "../../Common/OutBuffer.h"
+#include "../Huffman/HuffmanDecoder.h"
+#include "BZip2Const.h"
+#include "BZip2CRC.h"
+
+#ifdef COMPRESS_BZIP2_MT
+#include "../../../Windows/Thread.h"
+#include "../../../Windows/Synchronization.h"
+#endif
+
+#if _MSC_VER >= 1300
+#define NO_INLINE __declspec(noinline) __fastcall
+#else
+#ifdef _MSC_VER
+#define NO_INLINE __fastcall
+#endif
+#endif
+
+namespace NCompress {
+namespace NBZip2 {
+
+typedef NCompress::NHuffman::CDecoder<kMaxHuffmanLen, kMaxAlphaSize> CHuffmanDecoder;
+
+class CDecoder;
+
+struct CState
+{
+ UInt32 *Counters;
+
+ #ifdef COMPRESS_BZIP2_MT
+
+ CDecoder *Decoder;
+ NWindows::CThread Thread;
+ bool m_OptimizeNumTables;
+
+ NWindows::NSynchronization::CAutoResetEvent StreamWasFinishedEvent;
+ NWindows::NSynchronization::CAutoResetEvent WaitingWasStartedEvent;
+
+ // it's not member of this thread. We just need one event per thread
+ NWindows::NSynchronization::CAutoResetEvent CanWriteEvent;
+
+ Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
+
+ void FinishStream();
+ void ThreadFunc();
+
+ #endif
+
+ CState(): Counters(0) {}
+ ~CState() { Free(); }
+ bool Alloc();
+ void Free();
+};
+
+class CDecoder :
+ public ICompressCoder,
+ #ifdef COMPRESS_BZIP2_MT
+ public ICompressSetCoderMt,
+ #endif
+ public ICompressGetInStreamProcessedSize,
+ public CMyUnknownImp
+{
+public:
+ COutBuffer m_OutStream;
+ Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
+ NStream::NMSBF::CDecoder<CInBuffer> m_InStream;
+ Byte m_Selectors[kNumSelectorsMax];
+ CHuffmanDecoder m_HuffmanDecoders[kNumTablesMax];
+private:
+
+ UInt32 m_NumThreadsPrev;
+
+ UInt32 ReadBits(int numBits);
+ Byte ReadByte();
+ bool ReadBit();
+ UInt32 ReadCRC();
+ HRESULT PrepareBlock(CState &state);
+ HRESULT DecodeFile(bool &isBZ, ICompressProgressInfo *progress);
+ HRESULT CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+ class CDecoderFlusher
+ {
+ CDecoder *_decoder;
+ public:
+ bool NeedFlush;
+ CDecoderFlusher(CDecoder *decoder): _decoder(decoder), NeedFlush(true) {}
+ ~CDecoderFlusher()
+ {
+ if (NeedFlush)
+ _decoder->Flush();
+ _decoder->ReleaseStreams();
+ }
+ };
+
+public:
+ CBZip2CombinedCRC CombinedCRC;
+
+ #ifdef COMPRESS_BZIP2_MT
+ ICompressProgressInfo *Progress;
+ CState *m_States;
+
+ NWindows::NSynchronization::CCriticalSection CS;
+ UInt32 NumThreads;
+ bool MtMode;
+ UInt32 NextBlockIndex;
+ bool CloseThreads;
+ bool StreamWasFinished1;
+ bool StreamWasFinished2;
+ NWindows::NSynchronization::CManualResetEvent CanStartWaitingEvent;
+
+ HRESULT Result1;
+ HRESULT Result2;
+
+ UInt32 BlockSizeMax;
+ CDecoder();
+ ~CDecoder();
+ bool Create();
+ void Free();
+
+ #else
+ CState m_States[1];
+ #endif
+
+ HRESULT ReadSignatures(bool &wasFinished, UInt32 &crc);
+
+
+ HRESULT Flush() { return m_OutStream.Flush(); }
+ void ReleaseStreams()
+ {
+ m_InStream.ReleaseStream();
+ m_OutStream.ReleaseStream();
+ }
+
+ #ifdef COMPRESS_BZIP2_MT
+ MY_UNKNOWN_IMP2(ICompressSetCoderMt, ICompressGetInStreamProcessedSize)
+ #else
+ MY_UNKNOWN_IMP1(ICompressGetInStreamProcessedSize)
+ #endif
+
+
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
+
+ #ifdef COMPRESS_BZIP2_MT
+ STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
+ #endif
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp b/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp
new file mode 100755
index 00000000..1542b07c
--- /dev/null
+++ b/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp
@@ -0,0 +1,883 @@
+// BZip2Encoder.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Common/Alloc.h"
+
+#include "BZip2Encoder.h"
+
+#include "../BWT/BlockSort.h"
+#include "../BWT/Mtf8.h"
+#include "BZip2CRC.h"
+
+extern "C"
+{
+ #include "../../../../C/Compress/Huffman/HuffmanEncode.h"
+}
+
+namespace NCompress {
+namespace NBZip2 {
+
+const int kMaxHuffmanLenForEncoding = 16; // it must be < kMaxHuffmanLen = 20
+
+static const UInt32 kBufferSize = (1 << 17);
+static const int kNumHuffPasses = 4;
+
+bool CThreadInfo::Create()
+{
+ if (m_BlockSorterIndex != 0)
+ return true;
+ m_BlockSorterIndex = (UInt32 *)::BigAlloc(BLOCK_SORT_BUF_SIZE(kBlockSizeMax) * sizeof(UInt32));
+ if (m_BlockSorterIndex == 0)
+ return false;
+
+
+ if (m_Block == 0)
+ {
+ m_Block = (Byte *)::MidAlloc(kBlockSizeMax * 5 + kBlockSizeMax / 10 + (20 << 10));
+ if (m_Block == 0)
+ return false;
+ m_MtfArray = m_Block + kBlockSizeMax;
+ m_TempArray = m_MtfArray + kBlockSizeMax * 2 + 2;
+ }
+ return true;
+}
+
+void CThreadInfo::Free()
+{
+ ::BigFree(m_BlockSorterIndex);
+ m_BlockSorterIndex = 0;
+ ::MidFree(m_Block);
+ m_Block = 0;
+}
+
+#ifdef COMPRESS_BZIP2_MT
+void CThreadInfo::FinishStream(bool needLeave)
+{
+ Encoder->StreamWasFinished = true;
+ StreamWasFinishedEvent.Set();
+ if (needLeave)
+ Encoder->CS.Leave();
+ Encoder->CanStartWaitingEvent.Lock();
+ WaitingWasStartedEvent.Set();
+}
+
+DWORD CThreadInfo::ThreadFunc()
+{
+ for (;;)
+ {
+ Encoder->CS.Enter();
+ if (Encoder->CloseThreads)
+ {
+ Encoder->CS.Leave();
+ return 0;
+ }
+ if (Encoder->StreamWasFinished)
+ {
+ FinishStream(true);
+ continue;
+ }
+ HRESULT res = S_OK;
+ bool needLeave = true;
+ try
+ {
+ UInt32 blockSize = Encoder->ReadRleBlock(m_Block);
+ m_PackSize = Encoder->m_InStream.GetProcessedSize();
+ m_BlockIndex = Encoder->NextBlockIndex;
+ if (++Encoder->NextBlockIndex == Encoder->NumThreads)
+ Encoder->NextBlockIndex = 0;
+ if (blockSize == 0)
+ {
+ FinishStream(true);
+ continue;
+ }
+ Encoder->CS.Leave();
+ needLeave = false;
+ res = EncodeBlock3(blockSize);
+ }
+ catch(const CInBufferException &e) { res = e.ErrorCode; }
+ catch(const COutBufferException &e) { res = e.ErrorCode; }
+ catch(...) { res = E_FAIL; }
+ if (res != S_OK)
+ {
+ Encoder->Result = res;
+ FinishStream(needLeave);
+ continue;
+ }
+ }
+}
+
+static DWORD WINAPI MFThread(void *threadCoderInfo)
+{
+ return ((CThreadInfo *)threadCoderInfo)->ThreadFunc();
+}
+#endif
+
+CEncoder::CEncoder():
+ NumPasses(1),
+ m_OptimizeNumTables(false),
+ m_BlockSizeMult(kBlockSizeMultMax)
+{
+ #ifdef COMPRESS_BZIP2_MT
+ ThreadsInfo = 0;
+ m_NumThreadsPrev = 0;
+ NumThreads = 1;
+ CS.Enter();
+ #endif
+}
+
+#ifdef COMPRESS_BZIP2_MT
+CEncoder::~CEncoder()
+{
+ Free();
+}
+
+bool CEncoder::Create()
+{
+ try
+ {
+ if (ThreadsInfo != 0 && m_NumThreadsPrev == NumThreads)
+ return true;
+ Free();
+ MtMode = (NumThreads > 1);
+ m_NumThreadsPrev = NumThreads;
+ ThreadsInfo = new CThreadInfo[NumThreads];
+ if (ThreadsInfo == 0)
+ return false;
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CThreadInfo &ti = ThreadsInfo[t];
+ ti.Encoder = this;
+ if (MtMode)
+ if (!ti.Thread.Create(MFThread, &ti))
+ {
+ NumThreads = t;
+ Free();
+ return false;
+ }
+ }
+ }
+ catch(...) { return false; }
+ return true;
+}
+
+void CEncoder::Free()
+{
+ if (!ThreadsInfo)
+ return;
+ CloseThreads = true;
+ CS.Leave();
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CThreadInfo &ti = ThreadsInfo[t];
+ if (MtMode)
+ ti.Thread.Wait();
+ ti.Free();
+ }
+ delete []ThreadsInfo;
+ ThreadsInfo = 0;
+}
+#endif
+
+UInt32 CEncoder::ReadRleBlock(Byte *buffer)
+{
+ UInt32 i = 0;
+ Byte prevByte;
+ if (m_InStream.ReadByte(prevByte))
+ {
+ UInt32 blockSize = m_BlockSizeMult * kBlockSizeStep - 1;
+ int numReps = 1;
+ buffer[i++] = prevByte;
+ while (i < blockSize) // "- 1" to support RLE
+ {
+ Byte b;
+ if (!m_InStream.ReadByte(b))
+ break;
+ if (b != prevByte)
+ {
+ if (numReps >= kRleModeRepSize)
+ buffer[i++] = (Byte)(numReps - kRleModeRepSize);
+ buffer[i++] = b;
+ numReps = 1;
+ prevByte = b;
+ continue;
+ }
+ numReps++;
+ if (numReps <= kRleModeRepSize)
+ buffer[i++] = b;
+ else if (numReps == kRleModeRepSize + 255)
+ {
+ buffer[i++] = (Byte)(numReps - kRleModeRepSize);
+ numReps = 0;
+ }
+ }
+ // it's to support original BZip2 decoder
+ if (numReps >= kRleModeRepSize)
+ buffer[i++] = (Byte)(numReps - kRleModeRepSize);
+ }
+ return i;
+}
+
+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)
+{
+ for (int i = 0; i < 4; i++)
+ WriteByte2(((Byte)(v >> (24 - i * 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)
+{
+ for (int i = 0; i < 4; i++)
+ WriteByte(((Byte)(v >> (24 - i * 8))));
+}
+
+
+// blockSize > 0
+void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
+{
+ WriteBit2(false); // Randomised = false
+
+ {
+ UInt32 origPtr = BlockSort(m_BlockSorterIndex, block, blockSize);
+ // if (m_BlockSorterIndex[origPtr] != 0) throw 1;
+ m_BlockSorterIndex[origPtr] = blockSize;
+ WriteBits2(origPtr, kNumOrigBits);
+ }
+
+ CMtf8Encoder mtf;
+ int numInUse = 0;
+ {
+ bool inUse[256];
+ bool inUse16[16];
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ inUse[i] = false;
+ 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++)
+ if (inUse[i])
+ {
+ inUse16[i >> 4] = true;
+ mtf.Buffer[numInUse++] = (Byte)i;
+ }
+ for (i = 0; i < 16; i++)
+ WriteBit2(inUse16[i]);
+ for (i = 0; i < 256; i++)
+ if (inUse16[i >> 4])
+ WriteBit2(inUse[i]);
+ }
+ int alphaSize = numInUse + 2;
+
+ Byte *mtfs = m_MtfArray;
+ UInt32 mtfArraySize = 0;
+ UInt32 symbolCounts[kMaxAlphaSize];
+ {
+ for (int i = 0; i < kMaxAlphaSize; i++)
+ symbolCounts[i] = 0;
+ }
+
+ {
+ UInt32 rleSize = 0;
+ UInt32 i = 0;
+ const UInt32 *bsIndex = m_BlockSorterIndex;
+ block--;
+ do
+ {
+ int pos = mtf.FindAndMove(block[bsIndex[i]]);
+ if (pos == 0)
+ rleSize++;
+ else
+ {
+ while (rleSize != 0)
+ {
+ rleSize--;
+ mtfs[mtfArraySize++] = (Byte)(rleSize & 1);
+ symbolCounts[rleSize & 1]++;
+ rleSize >>= 1;
+ }
+ if (pos >= 0xFE)
+ {
+ mtfs[mtfArraySize++] = 0xFF;
+ mtfs[mtfArraySize++] = (Byte)(pos - 0xFE);
+ }
+ else
+ mtfs[mtfArraySize++] = (Byte)(pos + 1);
+ symbolCounts[pos + 1]++;
+ }
+ }
+ while (++i < blockSize);
+
+ while (rleSize != 0)
+ {
+ rleSize--;
+ mtfs[mtfArraySize++] = (Byte)(rleSize & 1);
+ symbolCounts[rleSize & 1]++;
+ rleSize >>= 1;
+ }
+
+ if (alphaSize < 256)
+ mtfs[mtfArraySize++] = (Byte)(alphaSize - 1);
+ else
+ {
+ mtfs[mtfArraySize++] = 0xFF;
+ mtfs[mtfArraySize++] = (Byte)(alphaSize - 256);
+ }
+ symbolCounts[alphaSize - 1]++;
+ }
+
+ UInt32 numSymbols = 0;
+ {
+ for (int i = 0; i < kMaxAlphaSize; i++)
+ numSymbols += symbolCounts[i];
+ }
+
+ int bestNumTables = kNumTablesMin;
+ UInt32 bestPrice = 0xFFFFFFFF;
+ UInt32 startPos = m_OutStreamCurrent->GetPos();
+ Byte startCurByte = m_OutStreamCurrent->GetCurByte();
+ for (int nt = kNumTablesMin; nt <= kNumTablesMax + 1; nt++)
+ {
+ int numTables;
+
+ if(m_OptimizeNumTables)
+ {
+ m_OutStreamCurrent->SetPos(startPos);
+ m_OutStreamCurrent->SetCurState((startPos & 7), startCurByte);
+ if (nt <= kNumTablesMax)
+ numTables = nt;
+ else
+ numTables = bestNumTables;
+ }
+ else
+ {
+ 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;
+ }
+
+ WriteBits2(numTables, kNumTablesBits);
+
+ UInt32 numSelectors = (numSymbols + kGroupSize - 1) / kGroupSize;
+ WriteBits2(numSelectors, kNumSelectorsBits);
+
+ {
+ UInt32 remFreq = numSymbols;
+ int gs = 0;
+ int t = numTables;
+ do
+ {
+ UInt32 tFreq = remFreq / t;
+ int ge = gs;
+ UInt32 aFreq = 0;
+ while (aFreq < tFreq) // && ge < alphaSize)
+ aFreq += symbolCounts[ge++];
+
+ if (ge - 1 > gs && t != numTables && t != 1 && (((numTables - t) & 1) == 1))
+ aFreq -= symbolCounts[--ge];
+
+ Byte *lens = Lens[t - 1];
+ int i = 0;
+ do
+ lens[i] = (i >= gs && i < ge) ? 0 : 1;
+ while (++i < alphaSize);
+ gs = ge;
+ remFreq -= aFreq;
+ }
+ while(--t != 0);
+ }
+
+
+ for (int pass = 0; pass < kNumHuffPasses; pass++)
+ {
+ {
+ int t = 0;
+ do
+ memset(Freqs[t], 0, sizeof(Freqs[t]));
+ while(++t < numTables);
+ }
+
+ {
+ UInt32 mtfPos = 0;
+ UInt32 g = 0;
+ do
+ {
+ UInt32 symbols[kGroupSize];
+ int i = 0;
+ do
+ {
+ UInt32 symbol = mtfs[mtfPos++];
+ if (symbol >= 0xFF)
+ symbol += mtfs[mtfPos++];
+ symbols[i] = symbol;
+ }
+ while (++i < kGroupSize && mtfPos < mtfArraySize);
+
+ UInt32 bestPrice = 0xFFFFFFFF;
+ int t = 0;
+ do
+ {
+ const Byte *lens = Lens[t];
+ UInt32 price = 0;
+ int j = 0;
+ do
+ price += lens[symbols[j]];
+ while (++j < i);
+ if (price < bestPrice)
+ {
+ m_Selectors[g] = (Byte)t;
+ bestPrice = price;
+ }
+ }
+ while(++t < numTables);
+ UInt32 *freqs = Freqs[m_Selectors[g++]];
+ int j = 0;
+ do
+ freqs[symbols[j]]++;
+ while (++j < i);
+ }
+ while (mtfPos < mtfArraySize);
+ }
+
+ int t = 0;
+ do
+ {
+ UInt32 *freqs = Freqs[t];
+ int i = 0;
+ do
+ if (freqs[i] == 0)
+ freqs[i] = 1;
+ while(++i < alphaSize);
+ Huffman_Generate(freqs, Codes[t], Lens[t], kMaxAlphaSize, kMaxHuffmanLenForEncoding);
+ }
+ while(++t < numTables);
+ }
+
+ {
+ Byte mtfSel[kNumTablesMax];
+ {
+ int t = 0;
+ do
+ mtfSel[t] = (Byte)t;
+ while(++t < numTables);
+ }
+
+ UInt32 i = 0;
+ do
+ {
+ Byte sel = m_Selectors[i];
+ int pos;
+ for (pos = 0; mtfSel[pos] != sel; pos++)
+ WriteBit2(true);
+ WriteBit2(false);
+ for (; pos > 0; pos--)
+ mtfSel[pos] = mtfSel[pos - 1];
+ mtfSel[0] = sel;
+ }
+ while(++i < numSelectors);
+ }
+
+ {
+ int t = 0;
+ do
+ {
+ const Byte *lens = Lens[t];
+ UInt32 len = lens[0];
+ WriteBits2(len, kNumLevelsBits);
+ int i = 0;
+ do
+ {
+ UInt32 level = lens[i];
+ while (len != level)
+ {
+ WriteBit2(true);
+ if (len < level)
+ {
+ WriteBit2(false);
+ len++;
+ }
+ else
+ {
+ WriteBit2(true);
+ len--;
+ }
+ }
+ WriteBit2(false);
+ }
+ while (++i < alphaSize);
+ }
+ while(++t < numTables);
+ }
+
+ {
+ UInt32 groupSize = 0;
+ UInt32 groupIndex = 0;
+ const Byte *lens = 0;
+ const UInt32 *codes = 0;
+ UInt32 mtfPos = 0;
+ do
+ {
+ UInt32 symbol = mtfs[mtfPos++];
+ if (symbol >= 0xFF)
+ symbol += mtfs[mtfPos++];
+ if (groupSize == 0)
+ {
+ groupSize = kGroupSize;
+ int t = m_Selectors[groupIndex++];
+ lens = Lens[t];
+ codes = Codes[t];
+ }
+ groupSize--;
+ m_OutStreamCurrent->WriteBits(codes[symbol], lens[symbol]);
+ }
+ while (mtfPos < mtfArraySize);
+ }
+
+ if (!m_OptimizeNumTables)
+ break;
+ UInt32 price = m_OutStreamCurrent->GetPos() - startPos;
+ if (price <= bestPrice)
+ {
+ if (nt == kNumTablesMax)
+ break;
+ bestPrice = price;
+ bestNumTables = nt;
+ }
+ }
+}
+
+// blockSize > 0
+UInt32 CThreadInfo::EncodeBlockWithHeaders(const Byte *block, UInt32 blockSize)
+{
+ WriteByte2(kBlockSig0);
+ WriteByte2(kBlockSig1);
+ WriteByte2(kBlockSig2);
+ WriteByte2(kBlockSig3);
+ WriteByte2(kBlockSig4);
+ WriteByte2(kBlockSig5);
+
+ CBZip2CRC crc;
+ int numReps = 0;
+ Byte prevByte = block[0];
+ UInt32 i = 0;
+ do
+ {
+ Byte b = block[i];
+ if (numReps == kRleModeRepSize)
+ {
+ for (; b > 0; b--)
+ crc.UpdateByte(prevByte);
+ numReps = 0;
+ continue;
+ }
+ if (prevByte == b)
+ numReps++;
+ else
+ {
+ numReps = 1;
+ prevByte = b;
+ }
+ crc.UpdateByte(b);
+ }
+ while (++i < blockSize);
+ UInt32 crcRes = crc.GetDigest();
+ WriteCRC2(crcRes);
+ EncodeBlock(block, blockSize);
+ return crcRes;
+}
+
+void CThreadInfo::EncodeBlock2(const Byte *block, UInt32 blockSize, UInt32 numPasses)
+{
+ UInt32 numCrcs = m_NumCrcs;
+ bool needCompare = false;
+
+ UInt32 startBytePos = m_OutStreamCurrent->GetBytePos();
+ UInt32 startPos = m_OutStreamCurrent->GetPos();
+ Byte startCurByte = m_OutStreamCurrent->GetCurByte();
+ Byte endCurByte = 0;
+ UInt32 endPos = 0;
+ if (numPasses > 1 && blockSize >= (1 << 10))
+ {
+ UInt32 blockSize0 = blockSize / 2;
+ for (;(block[blockSize0] == block[blockSize0 - 1] ||
+ block[blockSize0 - 1] == block[blockSize0 - 2]) &&
+ blockSize0 < blockSize; blockSize0++);
+ if (blockSize0 < blockSize)
+ {
+ EncodeBlock2(block, blockSize0, numPasses - 1);
+ EncodeBlock2(block + blockSize0, blockSize - blockSize0, numPasses - 1);
+ endPos = m_OutStreamCurrent->GetPos();
+ endCurByte = m_OutStreamCurrent->GetCurByte();
+ if ((endPos & 7) > 0)
+ WriteBits2(0, 8 - (endPos & 7));
+ m_OutStreamCurrent->SetCurState((startPos & 7), startCurByte);
+ needCompare = true;
+ }
+ }
+
+ UInt32 startBytePos2 = m_OutStreamCurrent->GetBytePos();
+ UInt32 startPos2 = m_OutStreamCurrent->GetPos();
+ UInt32 crcVal = EncodeBlockWithHeaders(block, blockSize);
+ UInt32 endPos2 = m_OutStreamCurrent->GetPos();
+
+ if (needCompare)
+ {
+ 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++)
+ buffer[startBytePos + i] = buffer[startBytePos2 + i];
+ m_OutStreamCurrent->SetPos(startPos + endPos2 - startPos2);
+ m_NumCrcs = numCrcs;
+ m_CRCs[m_NumCrcs++] = crcVal;
+ }
+ else
+ {
+ m_OutStreamCurrent->SetPos(endPos);
+ m_OutStreamCurrent->SetCurState((endPos & 7), endCurByte);
+ }
+ }
+ else
+ {
+ m_NumCrcs = numCrcs;
+ m_CRCs[m_NumCrcs++] = crcVal;
+ }
+}
+
+HRESULT CThreadInfo::EncodeBlock3(UInt32 blockSize)
+{
+ CMsbfEncoderTemp outStreamTemp;
+ outStreamTemp.SetStream(m_TempArray);
+ outStreamTemp.Init();
+ m_OutStreamCurrent = &outStreamTemp;
+
+ m_NumCrcs = 0;
+
+ EncodeBlock2(m_Block, blockSize, Encoder->NumPasses);
+
+ #ifdef COMPRESS_BZIP2_MT
+ if (Encoder->MtMode)
+ Encoder->ThreadsInfo[m_BlockIndex].CanWriteEvent.Lock();
+ #endif
+ for (UInt32 i = 0; i < m_NumCrcs; i++)
+ Encoder->CombinedCRC.Update(m_CRCs[i]);
+ Encoder->WriteBytes(m_TempArray, outStreamTemp.GetPos(), outStreamTemp.GetCurByte());
+ HRESULT res = S_OK;
+ #ifdef COMPRESS_BZIP2_MT
+ if (Encoder->MtMode)
+ {
+ UInt32 blockIndex = m_BlockIndex + 1;
+ if (blockIndex == Encoder->NumThreads)
+ blockIndex = 0;
+
+ if (Encoder->Progress)
+ {
+ UInt64 unpackSize = Encoder->m_OutStream.GetProcessedSize();
+ res = Encoder->Progress->SetRatioInfo(&m_PackSize, &unpackSize);
+ }
+
+ Encoder->ThreadsInfo[blockIndex].CanWriteEvent.Set();
+ }
+ #endif
+ return res;
+}
+
+void CEncoder::WriteBytes(const Byte *data, UInt32 sizeInBits, Byte lastByte)
+{
+ UInt32 bytesSize = (sizeInBits / 8);
+ for (UInt32 i = 0; i < bytesSize; i++)
+ m_OutStream.WriteBits(data[i], 8);
+ WriteBits(lastByte, (sizeInBits & 7));
+}
+
+
+HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
+ ICompressProgressInfo *progress)
+{
+ #ifdef COMPRESS_BZIP2_MT
+ Progress = progress;
+ if (!Create())
+ return E_FAIL;
+ for (UInt32 t = 0; t < NumThreads; t++)
+ #endif
+ {
+ #ifdef COMPRESS_BZIP2_MT
+ CThreadInfo &ti = ThreadsInfo[t];
+ ti.StreamWasFinishedEvent.Reset();
+ ti.WaitingWasStartedEvent.Reset();
+ ti.CanWriteEvent.Reset();
+ #else
+ CThreadInfo &ti = ThreadsInfo;
+ ti.Encoder = this;
+ #endif
+
+ ti.m_OptimizeNumTables = m_OptimizeNumTables;
+
+ if (!ti.Create())
+ return E_OUTOFMEMORY;
+ }
+
+
+ if (!m_InStream.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ if (!m_OutStream.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+
+
+ m_InStream.SetStream(inStream);
+ m_InStream.Init();
+
+ m_OutStream.SetStream(outStream);
+ m_OutStream.Init();
+
+ CFlusher flusher(this);
+
+ CombinedCRC.Init();
+ #ifdef COMPRESS_BZIP2_MT
+ NextBlockIndex = 0;
+ StreamWasFinished = false;
+ CloseThreads = false;
+ CanStartWaitingEvent.Reset();
+ #endif
+
+ WriteByte(kArSig0);
+ WriteByte(kArSig1);
+ WriteByte(kArSig2);
+ WriteByte((Byte)(kArSig3 + m_BlockSizeMult));
+
+ #ifdef COMPRESS_BZIP2_MT
+
+ if (MtMode)
+ {
+ ThreadsInfo[0].CanWriteEvent.Set();
+ Result = S_OK;
+ CS.Leave();
+ UInt32 t;
+ for (t = 0; t < NumThreads; t++)
+ ThreadsInfo[t].StreamWasFinishedEvent.Lock();
+ CS.Enter();
+ CanStartWaitingEvent.Set();
+ for (t = 0; t < NumThreads; t++)
+ ThreadsInfo[t].WaitingWasStartedEvent.Lock();
+ CanStartWaitingEvent.Reset();
+ RINOK(Result);
+ }
+ else
+ #endif
+ {
+ for (;;)
+ {
+ CThreadInfo &ti =
+ #ifdef COMPRESS_BZIP2_MT
+ ThreadsInfo[0];
+ #else
+ ThreadsInfo;
+ #endif
+ UInt32 blockSize = ReadRleBlock(ti.m_Block);
+ if (blockSize == 0)
+ break;
+ RINOK(ti.EncodeBlock3(blockSize));
+ if (progress)
+ {
+ UInt64 packSize = m_InStream.GetProcessedSize();
+ UInt64 unpackSize = m_OutStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &unpackSize));
+ }
+ }
+ }
+ WriteByte(kFinSig0);
+ WriteByte(kFinSig1);
+ WriteByte(kFinSig2);
+ WriteByte(kFinSig3);
+ WriteByte(kFinSig4);
+ WriteByte(kFinSig5);
+
+ WriteCRC(CombinedCRC.GetDigest());
+ return S_OK;
+}
+
+STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties)
+{
+ for(UInt32 i = 0; i < numProperties; i++)
+ {
+ const PROPVARIANT &property = properties[i];
+ switch(propIDs[i])
+ {
+ case NCoderPropID::kNumPasses:
+ {
+ if (property.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 numPasses = property.ulVal;
+ if (numPasses == 0)
+ numPasses = 1;
+ if (numPasses > kNumPassesMax)
+ numPasses = kNumPassesMax;
+ NumPasses = numPasses;
+ m_OptimizeNumTables = (NumPasses > 1);
+ break;
+ }
+ case NCoderPropID::kDictionarySize:
+ {
+ if (property.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 dictionary = property.ulVal / kBlockSizeStep;
+ if (dictionary < kBlockSizeMultMin)
+ dictionary = kBlockSizeMultMin;
+ else if (dictionary > kBlockSizeMultMax)
+ dictionary = kBlockSizeMultMax;
+ m_BlockSizeMult = dictionary;
+ break;
+ }
+ case NCoderPropID::kNumThreads:
+ {
+ #ifdef COMPRESS_BZIP2_MT
+ if (property.vt != VT_UI4)
+ return E_INVALIDARG;
+ NumThreads = property.ulVal;
+ if (NumThreads < 1)
+ NumThreads = 1;
+ #endif
+ break;
+ }
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ return S_OK;
+}
+
+#ifdef COMPRESS_BZIP2_MT
+STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads)
+{
+ NumThreads = numThreads;
+ if (NumThreads < 1)
+ NumThreads = 1;
+ return S_OK;
+}
+#endif
+
+}}
diff --git a/CPP/7zip/Compress/BZip2/BZip2Encoder.h b/CPP/7zip/Compress/BZip2/BZip2Encoder.h
new file mode 100755
index 00000000..62b255d4
--- /dev/null
+++ b/CPP/7zip/Compress/BZip2/BZip2Encoder.h
@@ -0,0 +1,246 @@
+// Compress/BZip2/Encoder.h
+
+#ifndef __COMPRESS_BZIP2_ENCODER_H
+#define __COMPRESS_BZIP2_ENCODER_H
+
+#include "../../ICoder.h"
+#include "../../../Common/MyCom.h"
+#include "../../Common/MSBFEncoder.h"
+#include "../../Common/InBuffer.h"
+#include "../../Common/OutBuffer.h"
+#include "BZip2Const.h"
+#include "BZip2CRC.h"
+
+#ifdef COMPRESS_BZIP2_MT
+#include "../../../Windows/Thread.h"
+#include "../../../Windows/Synchronization.h"
+#endif
+
+namespace NCompress {
+namespace NBZip2 {
+
+class CMsbfEncoderTemp
+{
+ UInt32 m_Pos;
+ int m_BitPos;
+ Byte m_CurByte;
+ Byte *Buffer;
+public:
+ void SetStream(Byte *buffer) { Buffer = buffer; }
+ Byte *GetStream() const { return Buffer; }
+
+ void Init()
+ {
+ m_Pos = 0;
+ m_BitPos = 8;
+ m_CurByte = 0;
+ }
+
+ void Flush()
+ {
+ if(m_BitPos < 8)
+ WriteBits(0, m_BitPos);
+ }
+
+ void WriteBits(UInt32 value, int numBits)
+ {
+ while(numBits > 0)
+ {
+ int numNewBits = MyMin(numBits, m_BitPos);
+ numBits -= numNewBits;
+
+ m_CurByte <<= numNewBits;
+ UInt32 newBits = value >> numBits;
+ m_CurByte |= Byte(newBits);
+ value -= (newBits << numBits);
+
+ m_BitPos -= numNewBits;
+
+ if (m_BitPos == 0)
+ {
+ Buffer[m_Pos++] = m_CurByte;
+ m_BitPos = 8;
+ }
+ }
+ }
+
+ UInt32 GetBytePos() const { return m_Pos ; }
+ 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 - (bitPos & 7);
+ }
+ void SetCurState(UInt32 bitPos, Byte curByte)
+ {
+ m_BitPos = 8 - bitPos;
+ m_CurByte = curByte;
+ }
+};
+
+class CEncoder;
+
+const int kNumPassesMax = 10;
+
+class CThreadInfo
+{
+public:
+ Byte *m_Block;
+private:
+ Byte *m_MtfArray;
+ Byte *m_TempArray;
+ UInt32 *m_BlockSorterIndex;
+
+ CMsbfEncoderTemp *m_OutStreamCurrent;
+
+ Byte Lens[kNumTablesMax][kMaxAlphaSize];
+ UInt32 Freqs[kNumTablesMax][kMaxAlphaSize];
+ UInt32 Codes[kNumTablesMax][kMaxAlphaSize];
+
+ Byte m_Selectors[kNumSelectorsMax];
+
+ UInt32 m_CRCs[1 << kNumPassesMax];
+ UInt32 m_NumCrcs;
+
+ int m_BlockIndex;
+
+ void FinishStream(bool needLeave);
+
+ void WriteBits2(UInt32 value, UInt32 numBits);
+ void WriteByte2(Byte b);
+ void WriteBit2(bool v);
+ void WriteCRC2(UInt32 v);
+
+ void EncodeBlock(const Byte *block, UInt32 blockSize);
+ UInt32 EncodeBlockWithHeaders(const Byte *block, UInt32 blockSize);
+ void EncodeBlock2(const Byte *block, UInt32 blockSize, UInt32 numPasses);
+public:
+ bool m_OptimizeNumTables;
+ CEncoder *Encoder;
+ #ifdef COMPRESS_BZIP2_MT
+ NWindows::CThread Thread;
+
+ NWindows::NSynchronization::CAutoResetEvent StreamWasFinishedEvent;
+ NWindows::NSynchronization::CAutoResetEvent WaitingWasStartedEvent;
+
+ // it's not member of this thread. We just need one event per thread
+ NWindows::NSynchronization::CAutoResetEvent CanWriteEvent;
+
+ UInt64 m_PackSize;
+
+ Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
+ #endif
+
+ CThreadInfo(): m_BlockSorterIndex(0), m_Block(0) {}
+ ~CThreadInfo() { Free(); }
+ bool Create();
+ void Free();
+
+ HRESULT EncodeBlock3(UInt32 blockSize);
+ DWORD ThreadFunc();
+};
+
+class CEncoder :
+ public ICompressCoder,
+ public ICompressSetCoderProperties,
+ #ifdef COMPRESS_BZIP2_MT
+ public ICompressSetCoderMt,
+ #endif
+ public CMyUnknownImp
+{
+ UInt32 m_BlockSizeMult;
+ bool m_OptimizeNumTables;
+
+ UInt32 m_NumPassesPrev;
+
+ UInt32 m_NumThreadsPrev;
+public:
+ CInBuffer m_InStream;
+ Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
+ NStream::NMSBF::CEncoder<COutBuffer> m_OutStream;
+ UInt32 NumPasses;
+ CBZip2CombinedCRC CombinedCRC;
+
+ #ifdef COMPRESS_BZIP2_MT
+ CThreadInfo *ThreadsInfo;
+ NWindows::NSynchronization::CCriticalSection CS;
+ UInt32 NumThreads;
+ bool MtMode;
+ UInt32 NextBlockIndex;
+
+ bool CloseThreads;
+ bool StreamWasFinished;
+ NWindows::NSynchronization::CManualResetEvent CanStartWaitingEvent;
+
+ HRESULT Result;
+ ICompressProgressInfo *Progress;
+ #else
+ CThreadInfo ThreadsInfo;
+ #endif
+
+ UInt32 ReadRleBlock(Byte *buffer);
+ void WriteBytes(const Byte *data, UInt32 sizeInBits, Byte lastByte);
+
+ void WriteBits(UInt32 value, UInt32 numBits);
+ void WriteByte(Byte b);
+ void WriteBit(bool v);
+ void WriteCRC(UInt32 v);
+
+ #ifdef COMPRESS_BZIP2_MT
+ bool Create();
+ void Free();
+ #endif
+
+public:
+ CEncoder();
+ #ifdef COMPRESS_BZIP2_MT
+ ~CEncoder();
+ #endif
+
+ HRESULT Flush() { return m_OutStream.Flush(); }
+
+ void ReleaseStreams()
+ {
+ m_InStream.ReleaseStream();
+ m_OutStream.ReleaseStream();
+ }
+
+ class CFlusher
+ {
+ CEncoder *_coder;
+ public:
+ bool NeedFlush;
+ CFlusher(CEncoder *coder): _coder(coder), NeedFlush(true) {}
+ ~CFlusher()
+ {
+ if (NeedFlush)
+ _coder->Flush();
+ _coder->ReleaseStreams();
+ }
+ };
+
+ #ifdef COMPRESS_BZIP2_MT
+ MY_UNKNOWN_IMP2(ICompressSetCoderMt, ICompressSetCoderProperties)
+ #else
+ MY_UNKNOWN_IMP1(ICompressGetInStreamProcessedSize)
+ #endif
+
+ HRESULT CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties);
+
+ #ifdef COMPRESS_BZIP2_MT
+ STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
+ #endif
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Compress/BZip2/DllExports.cpp b/CPP/7zip/Compress/BZip2/DllExports.cpp
new file mode 100755
index 00000000..57a3ae65
--- /dev/null
+++ b/CPP/7zip/Compress/BZip2/DllExports.cpp
@@ -0,0 +1,93 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+#include "Common/ComTry.h"
+#ifdef _WIN32
+#include "Common/Alloc.h"
+#endif
+
+#include "BZip2Encoder.h"
+#include "BZip2Decoder.h"
+
+// {23170F69-40C1-278B-0402-020000000000}
+DEFINE_GUID(CLSID_CCompressBZip2Decoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+// {23170F69-40C1-278B-0402-020000000100}
+DEFINE_GUID(CLSID_CCompressBZip2Encoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00);
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ #ifdef _WIN32
+ if (dwReason == DLL_PROCESS_ATTACH)
+ SetLargePageSize();
+ #endif
+ return TRUE;
+}
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ int correctInterface = (*iid == IID_ICompressCoder);
+ CMyComPtr<ICompressCoder> coder;
+ if (*clsid == CLSID_CCompressBZip2Decoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NBZip2::CDecoder;
+ }
+ else if (*clsid == CLSID_CCompressBZip2Encoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NBZip2::CEncoder;
+ }
+ else
+ return CLASS_E_CLASSNOTAVAILABLE;
+ *outObject = coder.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[] = { 0x04, 0x02, 0x02 };
+ if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ case NMethodPropID::kName:
+ if ((value->bstrVal = ::SysAllocString(L"BZip2")) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kDecoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CCompressBZip2Decoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kEncoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CCompressBZip2Encoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ return S_OK;
+}
diff --git a/7zip/Compress/Branch/StdAfx.cpp b/CPP/7zip/Compress/BZip2/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/Branch/StdAfx.cpp
+++ b/CPP/7zip/Compress/BZip2/StdAfx.cpp
diff --git a/7zip/Compress/BZip2/StdAfx.h b/CPP/7zip/Compress/BZip2/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/BZip2/StdAfx.h
+++ b/CPP/7zip/Compress/BZip2/StdAfx.h
diff --git a/CPP/7zip/Compress/BZip2/makefile b/CPP/7zip/Compress/BZip2/makefile
new file mode 100755
index 00000000..9e8cbdcb
--- /dev/null
+++ b/CPP/7zip/Compress/BZip2/makefile
@@ -0,0 +1,56 @@
+PROG = BZip2.dll
+DEF_FILE = ../Codec.def
+CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_BZIP2_MT
+LIBS = $(LIBS) oleaut32.lib
+
+BZIP2_OBJS = \
+ $O\DllExports.obj \
+ $O\BZip2CRC.obj \
+
+BZIP2_OPT_OBJS = \
+ $O\BZip2Decoder.obj \
+ $O\BZip2Encoder.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+
+WIN_OBJS = \
+ $O\Synchronization.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\OutBuffer.obj \
+
+C_OBJS = \
+ $O\Sort.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(BZIP2_OBJS) \
+ $(BZIP2_OPT_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $O\BlockSort.obj \
+ $(C_OBJS) \
+ $O\HuffmanEncode.obj \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(BZIP2_OBJS): $(*B).cpp
+ $(COMPL)
+$(BZIP2_OPT_OBJS): $(*B).cpp
+ $(COMPL_O2)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$O\BlockSort.obj: ../BWT/$(*B).cpp
+ $(COMPL_O2)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+$O\HuffmanEncode.obj: ../../../../C/Compress/Huffman/$(*B).c
+ $(COMPL_O2)
diff --git a/7zip/Compress/BZip2/resource.rc b/CPP/7zip/Compress/BZip2/resource.rc
index c5bea782..c5bea782 100755
--- a/7zip/Compress/BZip2/resource.rc
+++ b/CPP/7zip/Compress/BZip2/resource.rc
diff --git a/7zip/Compress/BZip2Original/BZip2Decoder.cpp b/CPP/7zip/Compress/BZip2Original/BZip2Decoder.cpp
index 5fb77d01..5fb77d01 100755
--- a/7zip/Compress/BZip2Original/BZip2Decoder.cpp
+++ b/CPP/7zip/Compress/BZip2Original/BZip2Decoder.cpp
diff --git a/7zip/Compress/BZip2Original/BZip2Decoder.h b/CPP/7zip/Compress/BZip2Original/BZip2Decoder.h
index e41f730f..e41f730f 100755
--- a/7zip/Compress/BZip2Original/BZip2Decoder.h
+++ b/CPP/7zip/Compress/BZip2Original/BZip2Decoder.h
diff --git a/7zip/Compress/BZip2Original/BZip2Encoder.cpp b/CPP/7zip/Compress/BZip2Original/BZip2Encoder.cpp
index bcd7dec0..bcd7dec0 100755
--- a/7zip/Compress/BZip2Original/BZip2Encoder.cpp
+++ b/CPP/7zip/Compress/BZip2Original/BZip2Encoder.cpp
diff --git a/7zip/Compress/BZip2Original/BZip2Encoder.h b/CPP/7zip/Compress/BZip2Original/BZip2Encoder.h
index c451a08d..c451a08d 100755
--- a/7zip/Compress/BZip2Original/BZip2Encoder.h
+++ b/CPP/7zip/Compress/BZip2Original/BZip2Encoder.h
diff --git a/7zip/Compress/BZip2Original/BZip2Error.cpp b/CPP/7zip/Compress/BZip2Original/BZip2Error.cpp
index c8a912dc..c8a912dc 100755
--- a/7zip/Compress/BZip2Original/BZip2Error.cpp
+++ b/CPP/7zip/Compress/BZip2Original/BZip2Error.cpp
diff --git a/CPP/7zip/Compress/BZip2Original/DllExports.cpp b/CPP/7zip/Compress/BZip2Original/DllExports.cpp
new file mode 100755
index 00000000..572d1fda
--- /dev/null
+++ b/CPP/7zip/Compress/BZip2Original/DllExports.cpp
@@ -0,0 +1,86 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+#include "Common/ComTry.h"
+
+#include "BZip2Encoder.h"
+#include "BZip2Decoder.h"
+
+// {23170F69-40C1-278B-0402-020000000000}
+DEFINE_GUID(CLSID_CCompressBZip2Decoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+// {23170F69-40C1-278B-0402-020000000100}
+DEFINE_GUID(CLSID_CCompressBZip2Encoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00);
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ return TRUE;
+}
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ int correctInterface = (*iid == IID_ICompressCoder);
+ CMyComPtr<ICompressCoder> coder;
+ if (*clsid == CLSID_CCompressBZip2Decoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NBZip2::CDecoder;
+ }
+ else if (*clsid == CLSID_CCompressBZip2Encoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NBZip2::CEncoder;
+ }
+ else
+ return CLASS_E_CLASSNOTAVAILABLE;
+ *outObject = coder.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[] = { 0x04, 0x02, 0x02 };
+ if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ case NMethodPropID::kName:
+ if ((value->bstrVal = ::SysAllocString(L"BZip2")) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kDecoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CCompressBZip2Decoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kEncoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CCompressBZip2Encoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ return S_OK;
+}
diff --git a/7zip/Compress/ByteSwap/StdAfx.cpp b/CPP/7zip/Compress/BZip2Original/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/ByteSwap/StdAfx.cpp
+++ b/CPP/7zip/Compress/BZip2Original/StdAfx.cpp
diff --git a/7zip/Compress/BZip2Original/StdAfx.h b/CPP/7zip/Compress/BZip2Original/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/BZip2Original/StdAfx.h
+++ b/CPP/7zip/Compress/BZip2Original/StdAfx.h
diff --git a/CPP/7zip/Compress/Branch/ARM.cpp b/CPP/7zip/Compress/Branch/ARM.cpp
new file mode 100755
index 00000000..0918cfb7
--- /dev/null
+++ b/CPP/7zip/Compress/Branch/ARM.cpp
@@ -0,0 +1,16 @@
+// ARM.cpp
+
+#include "StdAfx.h"
+#include "ARM.h"
+
+#include "../../../../C/Compress/Branch/BranchARM.c"
+
+UInt32 CBC_ARM_Encoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::ARM_Convert(data, size, _bufferPos, 1);
+}
+
+UInt32 CBC_ARM_Decoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::ARM_Convert(data, size, _bufferPos, 0);
+}
diff --git a/7zip/Compress/Branch/ARM.h b/CPP/7zip/Compress/Branch/ARM.h
index 5561299b..5561299b 100755
--- a/7zip/Compress/Branch/ARM.h
+++ b/CPP/7zip/Compress/Branch/ARM.h
diff --git a/CPP/7zip/Compress/Branch/ARMThumb.cpp b/CPP/7zip/Compress/Branch/ARMThumb.cpp
new file mode 100755
index 00000000..50189adb
--- /dev/null
+++ b/CPP/7zip/Compress/Branch/ARMThumb.cpp
@@ -0,0 +1,16 @@
+// ARMThumb.cpp
+
+#include "StdAfx.h"
+#include "ARMThumb.h"
+
+#include "../../../../C/Compress/Branch/BranchARMThumb.c"
+
+UInt32 CBC_ARMThumb_Encoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::ARMThumb_Convert(data, size, _bufferPos, 1);
+}
+
+UInt32 CBC_ARMThumb_Decoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::ARMThumb_Convert(data, size, _bufferPos, 0);
+}
diff --git a/7zip/Compress/Branch/ARMThumb.h b/CPP/7zip/Compress/Branch/ARMThumb.h
index 601e40bf..601e40bf 100755
--- a/7zip/Compress/Branch/ARMThumb.h
+++ b/CPP/7zip/Compress/Branch/ARMThumb.h
diff --git a/7zip/Compress/Branch/Branch.dsp b/CPP/7zip/Compress/Branch/Branch.dsp
index 220cb8ab..220cb8ab 100755
--- a/7zip/Compress/Branch/Branch.dsp
+++ b/CPP/7zip/Compress/Branch/Branch.dsp
diff --git a/7zip/Compress/Branch/Branch.dsw b/CPP/7zip/Compress/Branch/Branch.dsw
index 841c85a3..841c85a3 100755
--- a/7zip/Compress/Branch/Branch.dsw
+++ b/CPP/7zip/Compress/Branch/Branch.dsw
diff --git a/7zip/Compress/Branch/BranchCoder.cpp b/CPP/7zip/Compress/Branch/BranchCoder.cpp
index 8d25f0d5..8d25f0d5 100755
--- a/7zip/Compress/Branch/BranchCoder.cpp
+++ b/CPP/7zip/Compress/Branch/BranchCoder.cpp
diff --git a/7zip/Compress/Branch/BranchCoder.h b/CPP/7zip/Compress/Branch/BranchCoder.h
index 4b53b6cb..4b53b6cb 100755
--- a/7zip/Compress/Branch/BranchCoder.h
+++ b/CPP/7zip/Compress/Branch/BranchCoder.h
diff --git a/7zip/Compress/Branch/DllExports.cpp b/CPP/7zip/Compress/Branch/DllExports.cpp
index e7928f75..e7928f75 100755
--- a/7zip/Compress/Branch/DllExports.cpp
+++ b/CPP/7zip/Compress/Branch/DllExports.cpp
diff --git a/CPP/7zip/Compress/Branch/IA64.cpp b/CPP/7zip/Compress/Branch/IA64.cpp
new file mode 100755
index 00000000..4d57916c
--- /dev/null
+++ b/CPP/7zip/Compress/Branch/IA64.cpp
@@ -0,0 +1,16 @@
+// IA64.cpp
+
+#include "StdAfx.h"
+#include "IA64.h"
+
+#include "../../../../C/Compress/Branch/BranchIA64.c"
+
+UInt32 CBC_IA64_Encoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::IA64_Convert(data, size, _bufferPos, 1);
+}
+
+UInt32 CBC_IA64_Decoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::IA64_Convert(data, size, _bufferPos, 0);
+}
diff --git a/7zip/Compress/Branch/IA64.h b/CPP/7zip/Compress/Branch/IA64.h
index 7fe715ed..7fe715ed 100755
--- a/7zip/Compress/Branch/IA64.h
+++ b/CPP/7zip/Compress/Branch/IA64.h
diff --git a/CPP/7zip/Compress/Branch/PPC.cpp b/CPP/7zip/Compress/Branch/PPC.cpp
new file mode 100755
index 00000000..08c436e1
--- /dev/null
+++ b/CPP/7zip/Compress/Branch/PPC.cpp
@@ -0,0 +1,17 @@
+// PPC.cpp
+
+#include "StdAfx.h"
+#include "PPC.h"
+
+#include "Windows/Defs.h"
+#include "../../../../C/Compress/Branch/BranchPPC.c"
+
+UInt32 CBC_PPC_B_Encoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::PPC_B_Convert(data, size, _bufferPos, 1);
+}
+
+UInt32 CBC_PPC_B_Decoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::PPC_B_Convert(data, size, _bufferPos, 0);
+}
diff --git a/7zip/Compress/Branch/PPC.h b/CPP/7zip/Compress/Branch/PPC.h
index a0e33444..a0e33444 100755
--- a/7zip/Compress/Branch/PPC.h
+++ b/CPP/7zip/Compress/Branch/PPC.h
diff --git a/CPP/7zip/Compress/Branch/SPARC.cpp b/CPP/7zip/Compress/Branch/SPARC.cpp
new file mode 100755
index 00000000..7a218fe4
--- /dev/null
+++ b/CPP/7zip/Compress/Branch/SPARC.cpp
@@ -0,0 +1,17 @@
+// SPARC.cpp
+
+#include "StdAfx.h"
+#include "SPARC.h"
+
+#include "Windows/Defs.h"
+#include "../../../../C/Compress/Branch/BranchSPARC.c"
+
+UInt32 CBC_SPARC_Encoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::SPARC_Convert(data, size, _bufferPos, 1);
+}
+
+UInt32 CBC_SPARC_Decoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::SPARC_Convert(data, size, _bufferPos, 0);
+}
diff --git a/7zip/Compress/Branch/SPARC.h b/CPP/7zip/Compress/Branch/SPARC.h
index e0a682ef..e0a682ef 100755
--- a/7zip/Compress/Branch/SPARC.h
+++ b/CPP/7zip/Compress/Branch/SPARC.h
diff --git a/7zip/Compress/Copy/StdAfx.cpp b/CPP/7zip/Compress/Branch/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/Copy/StdAfx.cpp
+++ b/CPP/7zip/Compress/Branch/StdAfx.cpp
diff --git a/7zip/Compress/Branch/StdAfx.h b/CPP/7zip/Compress/Branch/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/Branch/StdAfx.h
+++ b/CPP/7zip/Compress/Branch/StdAfx.h
diff --git a/7zip/Compress/Branch/makefile b/CPP/7zip/Compress/Branch/makefile
index 6857d39f..6857d39f 100755
--- a/7zip/Compress/Branch/makefile
+++ b/CPP/7zip/Compress/Branch/makefile
diff --git a/7zip/Compress/Branch/resource.rc b/CPP/7zip/Compress/Branch/resource.rc
index 5476d4fa..5476d4fa 100755
--- a/7zip/Compress/Branch/resource.rc
+++ b/CPP/7zip/Compress/Branch/resource.rc
diff --git a/CPP/7zip/Compress/Branch/x86.cpp b/CPP/7zip/Compress/Branch/x86.cpp
new file mode 100755
index 00000000..60640d29
--- /dev/null
+++ b/CPP/7zip/Compress/Branch/x86.cpp
@@ -0,0 +1,18 @@
+// x86.cpp
+
+#include "StdAfx.h"
+#include "x86.h"
+
+#include "Windows/Defs.h"
+
+#include "../../../../C/Compress/Branch/BranchX86.c"
+
+UInt32 CBCJ_x86_Encoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 1);
+}
+
+UInt32 CBCJ_x86_Decoder::SubFilter(Byte *data, UInt32 size)
+{
+ return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 0);
+}
diff --git a/CPP/7zip/Compress/Branch/x86.h b/CPP/7zip/Compress/Branch/x86.h
new file mode 100755
index 00000000..f795e778
--- /dev/null
+++ b/CPP/7zip/Compress/Branch/x86.h
@@ -0,0 +1,19 @@
+// x86.h
+
+#ifndef __X86_H
+#define __X86_H
+
+#include "BranchCoder.h"
+#include "../../../../C/Compress/Branch/BranchX86.h"
+
+struct CBranch86
+{
+ UInt32 _prevMask;
+ UInt32 _prevPos;
+ void x86Init() { x86_Convert_Init(_prevMask, _prevPos); }
+};
+
+MyClassB(BCJ_x86, 0x01, 3, CBranch86 ,
+ virtual void SubInit() { x86Init(); })
+
+#endif
diff --git a/7zip/Compress/Branch/x86_2.cpp b/CPP/7zip/Compress/Branch/x86_2.cpp
index ca37ab83..ca37ab83 100755
--- a/7zip/Compress/Branch/x86_2.cpp
+++ b/CPP/7zip/Compress/Branch/x86_2.cpp
diff --git a/7zip/Compress/Branch/x86_2.h b/CPP/7zip/Compress/Branch/x86_2.h
index 3d34eb8d..3d34eb8d 100755
--- a/7zip/Compress/Branch/x86_2.h
+++ b/CPP/7zip/Compress/Branch/x86_2.h
diff --git a/7zip/Compress/ByteSwap/ByteSwap.cpp b/CPP/7zip/Compress/ByteSwap/ByteSwap.cpp
index 3f252f2c..3f252f2c 100755
--- a/7zip/Compress/ByteSwap/ByteSwap.cpp
+++ b/CPP/7zip/Compress/ByteSwap/ByteSwap.cpp
diff --git a/7zip/Compress/ByteSwap/ByteSwap.dsp b/CPP/7zip/Compress/ByteSwap/ByteSwap.dsp
index 1a73d67f..1a73d67f 100755
--- a/7zip/Compress/ByteSwap/ByteSwap.dsp
+++ b/CPP/7zip/Compress/ByteSwap/ByteSwap.dsp
diff --git a/7zip/Compress/ByteSwap/ByteSwap.dsw b/CPP/7zip/Compress/ByteSwap/ByteSwap.dsw
index 413d7e6e..413d7e6e 100755
--- a/7zip/Compress/ByteSwap/ByteSwap.dsw
+++ b/CPP/7zip/Compress/ByteSwap/ByteSwap.dsw
diff --git a/7zip/Compress/ByteSwap/ByteSwap.h b/CPP/7zip/Compress/ByteSwap/ByteSwap.h
index 00303063..00303063 100755
--- a/7zip/Compress/ByteSwap/ByteSwap.h
+++ b/CPP/7zip/Compress/ByteSwap/ByteSwap.h
diff --git a/7zip/Compress/ByteSwap/DllExports.cpp b/CPP/7zip/Compress/ByteSwap/DllExports.cpp
index cc737590..cc737590 100755
--- a/7zip/Compress/ByteSwap/DllExports.cpp
+++ b/CPP/7zip/Compress/ByteSwap/DllExports.cpp
diff --git a/7zip/Compress/Deflate/StdAfx.cpp b/CPP/7zip/Compress/ByteSwap/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/Deflate/StdAfx.cpp
+++ b/CPP/7zip/Compress/ByteSwap/StdAfx.cpp
diff --git a/7zip/Compress/ByteSwap/StdAfx.h b/CPP/7zip/Compress/ByteSwap/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/ByteSwap/StdAfx.h
+++ b/CPP/7zip/Compress/ByteSwap/StdAfx.h
diff --git a/7zip/Compress/ByteSwap/makefile b/CPP/7zip/Compress/ByteSwap/makefile
index f73a8079..f73a8079 100755
--- a/7zip/Compress/ByteSwap/makefile
+++ b/CPP/7zip/Compress/ByteSwap/makefile
diff --git a/7zip/Compress/ByteSwap/resource.rc b/CPP/7zip/Compress/ByteSwap/resource.rc
index 21c0c505..21c0c505 100755
--- a/7zip/Compress/ByteSwap/resource.rc
+++ b/CPP/7zip/Compress/ByteSwap/resource.rc
diff --git a/7zip/Compress/Codec.def b/CPP/7zip/Compress/Codec.def
index ebf73a3b..ebf73a3b 100755
--- a/7zip/Compress/Codec.def
+++ b/CPP/7zip/Compress/Codec.def
diff --git a/7zip/Compress/Copy/Copy.dsp b/CPP/7zip/Compress/Copy/Copy.dsp
index 099a433d..099a433d 100755
--- a/7zip/Compress/Copy/Copy.dsp
+++ b/CPP/7zip/Compress/Copy/Copy.dsp
diff --git a/7zip/Compress/Copy/Copy.dsw b/CPP/7zip/Compress/Copy/Copy.dsw
index 53ddf6cf..53ddf6cf 100755
--- a/7zip/Compress/Copy/Copy.dsw
+++ b/CPP/7zip/Compress/Copy/Copy.dsw
diff --git a/7zip/Compress/Copy/CopyCoder.cpp b/CPP/7zip/Compress/Copy/CopyCoder.cpp
index ce1bde03..ce1bde03 100755
--- a/7zip/Compress/Copy/CopyCoder.cpp
+++ b/CPP/7zip/Compress/Copy/CopyCoder.cpp
diff --git a/7zip/Compress/Copy/CopyCoder.h b/CPP/7zip/Compress/Copy/CopyCoder.h
index d2a26a89..d2a26a89 100755
--- a/7zip/Compress/Copy/CopyCoder.h
+++ b/CPP/7zip/Compress/Copy/CopyCoder.h
diff --git a/7zip/Compress/Copy/DllExports.cpp b/CPP/7zip/Compress/Copy/DllExports.cpp
index 756dcc9c..756dcc9c 100755
--- a/7zip/Compress/Copy/DllExports.cpp
+++ b/CPP/7zip/Compress/Copy/DllExports.cpp
diff --git a/7zip/Compress/Implode/StdAfx.cpp b/CPP/7zip/Compress/Copy/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/Implode/StdAfx.cpp
+++ b/CPP/7zip/Compress/Copy/StdAfx.cpp
diff --git a/7zip/Compress/Copy/StdAfx.h b/CPP/7zip/Compress/Copy/StdAfx.h
index 92239aeb..92239aeb 100755
--- a/7zip/Compress/Copy/StdAfx.h
+++ b/CPP/7zip/Compress/Copy/StdAfx.h
diff --git a/7zip/Compress/Copy/makefile b/CPP/7zip/Compress/Copy/makefile
index 8c108fbc..8c108fbc 100755
--- a/7zip/Compress/Copy/makefile
+++ b/CPP/7zip/Compress/Copy/makefile
diff --git a/7zip/Compress/Copy/resource.rc b/CPP/7zip/Compress/Copy/resource.rc
index 234c85bf..234c85bf 100755
--- a/7zip/Compress/Copy/resource.rc
+++ b/CPP/7zip/Compress/Copy/resource.rc
diff --git a/CPP/7zip/Compress/Deflate/Deflate.dsp b/CPP/7zip/Compress/Deflate/Deflate.dsp
new file mode 100755
index 00000000..a1baccad
--- /dev/null
+++ b/CPP/7zip/Compress/Deflate/Deflate.dsp
@@ -0,0 +1,341 @@
+# Microsoft Developer Studio Project File - Name="Deflate" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=Deflate - 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 "Deflate.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 "Deflate.mak" CFG="Deflate - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Deflate - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "Deflate - 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)" == "Deflate - 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 "DEFLATE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /D "_ST_MODE" /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\Codecs\Deflate.dll" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "Deflate - 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 "DEFLATE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /D "_ST_MODE" /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\Codecs\Deflate.dll" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "Deflate - Win32 Release"
+# Name "Deflate - Win32 Debug"
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Codec.def
+# 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 "Huffman"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Huffman\HuffmanDecoder.h
+# End Source File
+# End Group
+# Begin Group "Interface"
+
+# PROP Default_Filter ""
+# End Group
+# Begin Group "7zip 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\LSBFDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFEncoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LSBFEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OutBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OutBuffer.h
+# End Source File
+# End Group
+# Begin Group "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\NewHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\NewHandler.h
+# End Source File
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# 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 "LZ_C"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\7zCrc.c
+
+!IF "$(CFG)" == "Deflate - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Deflate - 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\Compress\Lz\LzHash.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.c
+
+!IF "$(CFG)" == "Deflate - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Deflate - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.h
+# End Source File
+# End Group
+# Begin Group "C Huffman"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Huffman\HuffmanEncode.c
+
+!IF "$(CFG)" == "Deflate - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Deflate - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Huffman\HuffmanEncode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.c
+
+!IF "$(CFG)" == "Deflate - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Deflate - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\DeflateConst.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\DeflateDecoder.cpp
+
+!IF "$(CFG)" == "Deflate - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Deflate - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\DeflateDecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\DeflateEncoder.cpp
+
+!IF "$(CFG)" == "Deflate - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Deflate - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\DeflateEncoder.h
+# End Source File
+# End Target
+# End Project
diff --git a/7zip/Compress/Deflate/Deflate.dsw b/CPP/7zip/Compress/Deflate/Deflate.dsw
index f17203ed..f17203ed 100755
--- a/7zip/Compress/Deflate/Deflate.dsw
+++ b/CPP/7zip/Compress/Deflate/Deflate.dsw
diff --git a/7zip/Compress/Deflate/DeflateConst.h b/CPP/7zip/Compress/Deflate/DeflateConst.h
index 766b589a..766b589a 100755
--- a/7zip/Compress/Deflate/DeflateConst.h
+++ b/CPP/7zip/Compress/Deflate/DeflateConst.h
diff --git a/7zip/Compress/Deflate/DeflateDecoder.cpp b/CPP/7zip/Compress/Deflate/DeflateDecoder.cpp
index 0de5534b..0de5534b 100755
--- a/7zip/Compress/Deflate/DeflateDecoder.cpp
+++ b/CPP/7zip/Compress/Deflate/DeflateDecoder.cpp
diff --git a/7zip/Compress/Deflate/DeflateDecoder.h b/CPP/7zip/Compress/Deflate/DeflateDecoder.h
index 99928b72..99928b72 100755
--- a/7zip/Compress/Deflate/DeflateDecoder.h
+++ b/CPP/7zip/Compress/Deflate/DeflateDecoder.h
diff --git a/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
new file mode 100755
index 00000000..4e9ffe6d
--- /dev/null
+++ b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
@@ -0,0 +1,963 @@
+// DeflateEncoder.cpp
+
+#include "StdAfx.h"
+
+#include "DeflateEncoder.h"
+
+#include "Windows/Defs.h"
+#include "Common/ComTry.h"
+#include "../../../Common/Alloc.h"
+// #include "../LZ/BinTree/BinTree3Z.h"
+
+#if _MSC_VER >= 1300
+#define NO_INLINE __declspec(noinline)
+#else
+#define NO_INLINE
+#endif
+
+extern "C"
+{
+ #include "../../../../C/Compress/Huffman/HuffmanEncode.h"
+}
+
+namespace NCompress {
+namespace NDeflate {
+namespace NEncoder {
+
+const int kNumDivPassesMax = 10; // [0, 16); ratio/speed/ram tradeoff; use big value for better compression ratio.
+const UInt32 kNumTables = (1 << kNumDivPassesMax);
+
+static UInt32 kFixedHuffmanCodeBlockSizeMax = (1 << 8); // [0, (1 << 32)); ratio/speed tradeoff; use big value for better compression ratio.
+static UInt32 kDivideCodeBlockSizeMin = (1 << 6); // [1, (1 << 32)); ratio/speed tradeoff; use small value for better compression ratio.
+static UInt32 kDivideBlockSizeMin = (1 << 6); // [1, (1 << 32)); ratio/speed tradeoff; use small value for better compression ratio.
+
+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 -
+ kMatchMaxLen - kNumOpts;
+
+static const int kMaxCodeBitLength = 15;
+static const int kMaxLevelBitLength = 7;
+
+static Byte kNoLiteralStatPrice = 13;
+static Byte kNoLenStatPrice = 13;
+static Byte kNoPosStatPrice = 6;
+
+static Byte g_LenSlots[kNumLenSymbolsMax];
+static Byte g_FastPos[1 << 9];
+
+class CFastPosInit
+{
+public:
+ CFastPosInit()
+ {
+ int i;
+ for(i = 0; i < kNumLenSlots; i++)
+ {
+ int c = kLenStart32[i];
+ int j = 1 << kLenDirectBits32[i];
+ for(int k = 0; k < j; k++, c++)
+ g_LenSlots[c] = (Byte)i;
+ }
+
+ const int kFastSlots = 18;
+ int c = 0;
+ for (Byte slotFast = 0; slotFast < kFastSlots; slotFast++)
+ {
+ UInt32 k = (1 << kDistDirectBits[slotFast]);
+ for (UInt32 j = 0; j < k; j++, c++)
+ g_FastPos[c] = slotFast;
+ }
+ }
+};
+
+static CFastPosInit g_FastPosInit;
+
+
+inline UInt32 GetPosSlot(UInt32 pos)
+{
+ if (pos < 0x200)
+ return g_FastPos[pos];
+ return g_FastPos[pos >> 8] + 16;
+}
+
+void *SzAlloc(size_t size)
+{
+ if (size == 0)
+ return 0;
+ return malloc(size);
+}
+
+void SzFree(void *address)
+{
+ free(address);
+}
+
+ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+CCoder::CCoder(bool deflate64Mode):
+ m_Deflate64Mode(deflate64Mode),
+ m_NumPasses(1),
+ m_NumDivPasses(1),
+ m_NumFastBytes(32),
+ m_OnePosMatchesMemory(0),
+ m_DistanceMemory(0),
+ m_Created(false),
+ m_Values(0),
+ m_Tables(0),
+ m_MatchFinderCycles(0)
+ // m_SetMfPasses(0)
+{
+ m_MatchMaxLen = deflate64Mode ? kMatchMaxLen64 : kMatchMaxLen32;
+ m_NumLenCombinations = deflate64Mode ? kNumLenSymbols64 : kNumLenSymbols32;
+ m_LenStart = deflate64Mode ? kLenStart64 : kLenStart32;
+ m_LenDirectBits = deflate64Mode ? kLenDirectBits64 : kLenDirectBits32;
+ MatchFinder_Construct(&_lzInWindow);
+}
+
+HRESULT CCoder::Create()
+{
+ COM_TRY_BEGIN
+ if (m_Values == 0)
+ {
+ m_Values = (CCodeValue *)MyAlloc((kMaxUncompressedBlockSize) * sizeof(CCodeValue));
+ if (m_Values == 0)
+ return E_OUTOFMEMORY;
+ }
+ if (m_Tables == 0)
+ {
+ m_Tables = (CTables *)MyAlloc((kNumTables) * sizeof(CTables));
+ if (m_Tables == 0)
+ return E_OUTOFMEMORY;
+ }
+
+ if (m_IsMultiPass)
+ {
+ if (m_OnePosMatchesMemory == 0)
+ {
+ m_OnePosMatchesMemory = (UInt16 *)::MidAlloc(kMatchArraySize * sizeof(UInt16));
+ if (m_OnePosMatchesMemory == 0)
+ return E_OUTOFMEMORY;
+ }
+ }
+ else
+ {
+ if (m_DistanceMemory == 0)
+ {
+ m_DistanceMemory = (UInt16 *)MyAlloc((kMatchMaxLen + 2) * 2 * sizeof(UInt16));
+ if (m_DistanceMemory == 0)
+ return E_OUTOFMEMORY;
+ m_MatchDistances = m_DistanceMemory;
+ }
+ }
+
+ if (!m_Created)
+ {
+ _lzInWindow.btMode = 1;
+ _lzInWindow.numHashBytes = 3;
+ 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))
+ return E_OUTOFMEMORY;
+ }
+ if (m_MatchFinderCycles != 0)
+ _lzInWindow.cutValue = m_MatchFinderCycles;
+ m_Created = true;
+ return S_OK;
+ COM_TRY_END
+}
+
+// ICompressSetEncoderProperties2
+HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties)
+{
+ for(UInt32 i = 0; i < numProperties; i++)
+ {
+ const PROPVARIANT &prop = properties[i];
+ switch(propIDs[i])
+ {
+ case NCoderPropID::kNumPasses:
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ m_NumDivPasses = prop.ulVal;
+ if (m_NumDivPasses == 0)
+ m_NumDivPasses = 1;
+ if (m_NumDivPasses == 1)
+ m_NumPasses = 1;
+ else if (m_NumDivPasses <= kNumDivPassesMax)
+ m_NumPasses = 2;
+ else
+ {
+ m_NumPasses = 2 + (m_NumDivPasses - kNumDivPassesMax);
+ m_NumDivPasses = kNumDivPassesMax;
+ }
+ break;
+ case NCoderPropID::kNumFastBytes:
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ m_NumFastBytes = prop.ulVal;
+ if(m_NumFastBytes < kMatchMinLen || m_NumFastBytes > m_MatchMaxLen)
+ return E_INVALIDARG;
+ break;
+ case NCoderPropID::kMatchFinderCycles:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ m_MatchFinderCycles = prop.ulVal;
+ break;
+ }
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ return S_OK;
+}
+
+void CCoder::Free()
+{
+ ::MidFree(m_OnePosMatchesMemory);
+ m_OnePosMatchesMemory = 0;
+ ::MyFree(m_DistanceMemory);
+ m_DistanceMemory = 0;
+ ::MyFree(m_Values);
+ m_Values = 0;
+ ::MyFree(m_Tables);
+ m_Tables = 0;
+}
+
+CCoder::~CCoder()
+{
+ Free();
+ MatchFinder_Free(&_lzInWindow, &g_Alloc);
+}
+
+void CCoder::GetMatches()
+{
+ if (m_IsMultiPass)
+ {
+ m_MatchDistances = m_OnePosMatchesMemory + m_Pos;
+ if (m_SecondPass)
+ {
+ m_Pos += *m_MatchDistances + 1;
+ return;
+ }
+ }
+
+ UInt32 distanceTmp[kMatchMaxLen * 2 + 3];
+
+ UInt32 numPairs = Bt3Zip_MatchFinder_GetMatches(&_lzInWindow, distanceTmp);
+ *m_MatchDistances = (UInt16)numPairs;
+
+ if (numPairs > 0)
+ {
+ UInt32 i;
+ for(i = 0; i < numPairs; i += 2)
+ {
+ m_MatchDistances[i + 1] = (UInt16)distanceTmp[i];
+ m_MatchDistances[i + 2] = (UInt16)distanceTmp[i + 1];
+ }
+ UInt32 len = distanceTmp[numPairs - 2];
+ if (len == m_NumFastBytes && m_NumFastBytes != m_MatchMaxLen)
+ {
+ UInt32 numAvail = Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) + 1;
+ const Byte *pby = Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow) - 1;
+ UInt32 distance = distanceTmp[numPairs - 1] + 1;
+ if (numAvail > m_MatchMaxLen)
+ numAvail = m_MatchMaxLen;
+ for (; len < numAvail && pby[len] == pby[(size_t)len - distance]; len++);
+ m_MatchDistances[i - 1] = (UInt16)len;
+ }
+ }
+ if (m_IsMultiPass)
+ m_Pos += numPairs + 1;
+ if (!m_SecondPass)
+ m_AdditionalOffset++;
+}
+
+void CCoder::MovePos(UInt32 num)
+{
+ if (!m_SecondPass && num > 0)
+ {
+ Bt3Zip_MatchFinder_Skip(&_lzInWindow, num);
+ m_AdditionalOffset += num;
+ }
+}
+
+static const UInt32 kIfinityPrice = 0xFFFFFFF;
+
+NO_INLINE UInt32 CCoder::Backward(UInt32 &backRes, UInt32 cur)
+{
+ m_OptimumEndIndex = cur;
+ UInt32 posMem = m_Optimum[cur].PosPrev;
+ UInt16 backMem = m_Optimum[cur].BackPrev;
+ do
+ {
+ UInt32 posPrev = posMem;
+ UInt16 backCur = backMem;
+ backMem = m_Optimum[posPrev].BackPrev;
+ posMem = m_Optimum[posPrev].PosPrev;
+ m_Optimum[posPrev].BackPrev = backCur;
+ m_Optimum[posPrev].PosPrev = (UInt16)cur;
+ cur = posPrev;
+ }
+ while(cur > 0);
+ backRes = m_Optimum[0].BackPrev;
+ m_OptimumCurrentIndex = m_Optimum[0].PosPrev;
+ return m_OptimumCurrentIndex;
+}
+
+NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
+{
+ if(m_OptimumEndIndex != m_OptimumCurrentIndex)
+ {
+ UInt32 len = m_Optimum[m_OptimumCurrentIndex].PosPrev - m_OptimumCurrentIndex;
+ backRes = m_Optimum[m_OptimumCurrentIndex].BackPrev;
+ m_OptimumCurrentIndex = m_Optimum[m_OptimumCurrentIndex].PosPrev;
+ return len;
+ }
+ m_OptimumCurrentIndex = m_OptimumEndIndex = 0;
+
+ GetMatches();
+
+ UInt32 numDistancePairs = m_MatchDistances[0];
+ if(numDistancePairs == 0)
+ return 1;
+
+ const UInt16 *matchDistances = m_MatchDistances + 1;
+ UInt32 lenMain = matchDistances[numDistancePairs - 2];
+
+ if(lenMain > m_NumFastBytes)
+ {
+ backRes = matchDistances[numDistancePairs - 1];
+ MovePos(lenMain - 1);
+ return lenMain;
+ }
+ m_Optimum[1].Price = m_LiteralPrices[Inline_MatchFinder_GetIndexByte(&_lzInWindow, 0 - m_AdditionalOffset)];
+ m_Optimum[1].PosPrev = 0;
+
+ m_Optimum[2].Price = kIfinityPrice;
+ m_Optimum[2].PosPrev = 1;
+
+
+ UInt32 offs = 0;
+ for(UInt32 i = kMatchMinLen; i <= lenMain; i++)
+ {
+ UInt32 distance = matchDistances[offs + 1];
+ m_Optimum[i].PosPrev = 0;
+ m_Optimum[i].BackPrev = (UInt16)distance;
+ m_Optimum[i].Price = m_LenPrices[i - kMatchMinLen] + m_PosPrices[GetPosSlot(distance)];
+ if (i == matchDistances[offs])
+ offs += 2;
+ }
+
+ UInt32 cur = 0;
+ UInt32 lenEnd = lenMain;
+ for (;;)
+ {
+ ++cur;
+ if(cur == lenEnd || cur == kNumOptsBase || m_Pos >= kMatchArrayLimit)
+ return Backward(backRes, cur);
+ GetMatches();
+ matchDistances = m_MatchDistances + 1;
+
+ UInt32 numDistancePairs = m_MatchDistances[0];
+ UInt32 newLen = 0;
+ if(numDistancePairs != 0)
+ {
+ newLen = matchDistances[numDistancePairs - 2];
+ if(newLen > m_NumFastBytes)
+ {
+ UInt32 len = Backward(backRes, cur);
+ m_Optimum[cur].BackPrev = matchDistances[numDistancePairs - 1];
+ m_OptimumEndIndex = cur + newLen;
+ m_Optimum[cur].PosPrev = (UInt16)m_OptimumEndIndex;
+ MovePos(newLen - 1);
+ return len;
+ }
+ }
+ 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)
+ {
+ optimum.Price = curAnd1Price;
+ optimum.PosPrev = (UInt16)cur;
+ }
+ if(numDistancePairs == 0)
+ continue;
+ while(lenEnd < cur + newLen)
+ m_Optimum[++lenEnd].Price = kIfinityPrice;
+ offs = 0;
+ UInt32 distance = matchDistances[offs + 1];
+ curPrice += m_PosPrices[GetPosSlot(distance)];
+ for(UInt32 lenTest = kMatchMinLen; ; lenTest++)
+ {
+ UInt32 curAndLenPrice = curPrice + m_LenPrices[lenTest - kMatchMinLen];
+ COptimal &optimum = m_Optimum[cur + lenTest];
+ if (curAndLenPrice < optimum.Price)
+ {
+ optimum.Price = curAndLenPrice;
+ optimum.PosPrev = (UInt16)cur;
+ optimum.BackPrev = (UInt16)distance;
+ }
+ if (lenTest == matchDistances[offs])
+ {
+ offs += 2;
+ if (offs == numDistancePairs)
+ break;
+ curPrice -= m_PosPrices[GetPosSlot(distance)];
+ distance = matchDistances[offs + 1];
+ curPrice += m_PosPrices[GetPosSlot(distance)];
+ }
+ }
+ }
+}
+
+void CTables::InitStructures()
+{
+ UInt32 i;
+ for(i = 0; i < 256; i++)
+ litLenLevels[i] = 8;
+ litLenLevels[i++] = 13;
+ for(;i < kFixedMainTableSize; i++)
+ litLenLevels[i] = 5;
+ for(i = 0; i < kFixedDistTableSize; i++)
+ distLevels[i] = 5;
+}
+
+NO_INLINE void CCoder::LevelTableDummy(const Byte *levels, int numLevels, UInt32 *freqs)
+{
+ int prevLen = 0xFF;
+ int nextLen = levels[0];
+ int count = 0;
+ int maxCount = 7;
+ int minCount = 4;
+ if (nextLen == 0)
+ {
+ maxCount = 138;
+ minCount = 3;
+ }
+ for (int n = 0; n < numLevels; n++)
+ {
+ int curLen = nextLen;
+ nextLen = (n < numLevels - 1) ? levels[n + 1] : 0xFF;
+ count++;
+ if (count < maxCount && curLen == nextLen)
+ continue;
+
+ if (count < minCount)
+ freqs[curLen] += (UInt32)count;
+ else if (curLen != 0)
+ {
+ if (curLen != prevLen)
+ {
+ freqs[curLen]++;
+ count--;
+ }
+ freqs[kTableLevelRepNumber]++;
+ }
+ else if (count <= 10)
+ freqs[kTableLevel0Number]++;
+ else
+ freqs[kTableLevel0Number2]++;
+
+ count = 0;
+ prevLen = curLen;
+
+ if (nextLen == 0)
+ {
+ maxCount = 138;
+ minCount = 3;
+ }
+ else if (curLen == nextLen)
+ {
+ maxCount = 6;
+ minCount = 3;
+ }
+ else
+ {
+ maxCount = 7;
+ minCount = 4;
+ }
+ }
+}
+
+#define WRITE_HF2(codes, lens, i) m_OutStream.WriteBits(codes[i], lens[i])
+#define WRITE_HF(i) m_OutStream.WriteBits(codes[i], lens[i])
+
+NO_INLINE void CCoder::LevelTableCode(const Byte *levels, int numLevels, const Byte *lens, const UInt32 *codes)
+{
+ int prevLen = 0xFF;
+ int nextLen = levels[0];
+ int count = 0;
+ int maxCount = 7;
+ int minCount = 4;
+ if (nextLen == 0)
+ {
+ maxCount = 138;
+ minCount = 3;
+ }
+ for (int n = 0; n < numLevels; n++)
+ {
+ int curLen = nextLen;
+ nextLen = (n < numLevels - 1) ? levels[n + 1] : 0xFF;
+ count++;
+ if (count < maxCount && curLen == nextLen)
+ continue;
+
+ if (count < minCount)
+ for(int i = 0; i < count; i++)
+ WRITE_HF(curLen);
+ else if (curLen != 0)
+ {
+ if (curLen != prevLen)
+ {
+ WRITE_HF(curLen);
+ count--;
+ }
+ WRITE_HF(kTableLevelRepNumber);
+ m_OutStream.WriteBits(count - 3, 2);
+ }
+ else if (count <= 10)
+ {
+ WRITE_HF(kTableLevel0Number);
+ m_OutStream.WriteBits(count - 3, 3);
+ }
+ else
+ {
+ WRITE_HF(kTableLevel0Number2);
+ m_OutStream.WriteBits(count - 11, 7);
+ }
+
+ count = 0;
+ prevLen = curLen;
+
+ if (nextLen == 0)
+ {
+ maxCount = 138;
+ minCount = 3;
+ }
+ else if (curLen == nextLen)
+ {
+ maxCount = 6;
+ minCount = 3;
+ }
+ else
+ {
+ maxCount = 7;
+ minCount = 4;
+ }
+ }
+}
+
+NO_INLINE void CCoder::MakeTables()
+{
+ Huffman_Generate(mainFreqs, mainCodes, m_NewLevels.litLenLevels, kFixedMainTableSize, kMaxCodeBitLength);
+ Huffman_Generate(distFreqs, distCodes, m_NewLevels.distLevels, kDistTableSize64, kMaxCodeBitLength);
+}
+
+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];
+ return price;
+};
+
+NO_INLINE UInt32 Huffman_GetPrice_Spec(const UInt32 *freqs, const Byte *lens, UInt32 num, const Byte *extraBits, UInt32 extraBase)
+{
+ return Huffman_GetPrice(freqs, lens, num) +
+ Huffman_GetPrice(freqs + extraBase, extraBits, num - extraBase);
+}
+
+NO_INLINE UInt32 CCoder::GetLzBlockPrice() const
+{
+ return
+ Huffman_GetPrice_Spec(mainFreqs, m_NewLevels.litLenLevels, kFixedMainTableSize, m_LenDirectBits, kSymbolMatch) +
+ Huffman_GetPrice_Spec(distFreqs, m_NewLevels.distLevels, kDistTableSize64, kDistDirectBits, 0);
+}
+
+NO_INLINE void CCoder::TryBlock()
+{
+ memset(mainFreqs, 0, sizeof(mainFreqs));
+ memset(distFreqs, 0, sizeof(distFreqs));
+
+ m_ValueIndex = 0;
+ UInt32 blockSize = BlockSizeRes;
+ BlockSizeRes = 0;
+ for (;;)
+ {
+ if (m_OptimumCurrentIndex == m_OptimumEndIndex)
+ {
+ if (m_Pos >= kMatchArrayLimit || BlockSizeRes >= blockSize || !m_SecondPass &&
+ ((Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) == 0) || m_ValueIndex >= m_ValueBlockSize))
+ break;
+ }
+ UInt32 pos;
+ UInt32 len = GetOptimal(pos);
+ CCodeValue &codeValue = m_Values[m_ValueIndex++];
+ if (len >= kMatchMinLen)
+ {
+ UInt32 newLen = len - kMatchMinLen;
+ codeValue.Len = (UInt16)newLen;
+ mainFreqs[kSymbolMatch + g_LenSlots[newLen]]++;
+ codeValue.Pos = (UInt16)pos;
+ distFreqs[GetPosSlot(pos)]++;
+ }
+ else
+ {
+ Byte b = Inline_MatchFinder_GetIndexByte(&_lzInWindow, 0 - m_AdditionalOffset);
+ mainFreqs[b]++;
+ codeValue.SetAsLiteral();
+ codeValue.Pos = b;
+ }
+ m_AdditionalOffset -= len;
+ BlockSizeRes += len;
+ }
+ mainFreqs[kSymbolEndOfBlock]++;
+ m_AdditionalOffset += BlockSizeRes;
+ m_SecondPass = true;
+}
+
+NO_INLINE void CCoder::SetPrices(const CLevels &levels)
+{
+ UInt32 i;
+ for(i = 0; i < 256; i++)
+ {
+ Byte price = levels.litLenLevels[i];
+ m_LiteralPrices[i] = ((price != 0) ? price : kNoLiteralStatPrice);
+ }
+
+ for(i = 0; i < m_NumLenCombinations; i++)
+ {
+ UInt32 slot = g_LenSlots[i];
+ Byte price = levels.litLenLevels[kSymbolMatch + slot];
+ m_LenPrices[i] = (Byte)(((price != 0) ? price : kNoLenStatPrice) + m_LenDirectBits[slot]);
+ }
+
+ for(i = 0; i < kDistTableSize64; i++)
+ {
+ Byte price = levels.distLevels[i];
+ m_PosPrices[i] = (Byte)(((price != 0) ? price: kNoPosStatPrice) + kDistDirectBits[i]);
+ }
+}
+
+NO_INLINE void Huffman_ReverseBits(UInt32 *codes, const Byte *lens, UInt32 num)
+{
+ for (UInt32 i = 0; i < num; i++)
+ {
+ UInt32 x = codes[i];
+ x = ((x & 0x5555) << 1) | ((x & 0xAAAA) >> 1);
+ x = ((x & 0x3333) << 2) | ((x & 0xCCCC) >> 2);
+ x = ((x & 0x0F0F) << 4) | ((x & 0xF0F0) >> 4);
+ codes[i] = (((x & 0x00FF) << 8) | ((x & 0xFF00) >> 8)) >> (16 - lens[i]);
+ }
+}
+
+NO_INLINE void CCoder::WriteBlock()
+{
+ Huffman_ReverseBits(mainCodes, m_NewLevels.litLenLevels, kFixedMainTableSize);
+ Huffman_ReverseBits(distCodes, m_NewLevels.distLevels, kDistTableSize64);
+
+ for (UInt32 i = 0; i < m_ValueIndex; i++)
+ {
+ const CCodeValue &codeValue = m_Values[i];
+ if (codeValue.IsLiteral())
+ WRITE_HF2(mainCodes, m_NewLevels.litLenLevels, codeValue.Pos);
+ else
+ {
+ UInt32 len = codeValue.Len;
+ UInt32 lenSlot = g_LenSlots[len];
+ WRITE_HF2(mainCodes, m_NewLevels.litLenLevels, kSymbolMatch + lenSlot);
+ m_OutStream.WriteBits(len - m_LenStart[lenSlot], m_LenDirectBits[lenSlot]);
+ UInt32 dist = codeValue.Pos;
+ UInt32 posSlot = GetPosSlot(dist);
+ WRITE_HF2(distCodes, m_NewLevels.distLevels, posSlot);
+ m_OutStream.WriteBits(dist - kDistStart[posSlot], kDistDirectBits[posSlot]);
+ }
+ }
+ WRITE_HF2(mainCodes, m_NewLevels.litLenLevels, kSymbolEndOfBlock);
+}
+
+static UInt32 GetStorePrice(UInt32 blockSize, int bitPosition)
+{
+ UInt32 price = 0;
+ do
+ {
+ UInt32 nextBitPosition = (bitPosition + kFinalBlockFieldSize + kBlockTypeFieldSize) & 7;
+ int numBitsForAlign = nextBitPosition > 0 ? (8 - nextBitPosition): 0;
+ UInt32 curBlockSize = (blockSize < (1 << 16)) ? blockSize : (1 << 16) - 1;
+ price += kFinalBlockFieldSize + kBlockTypeFieldSize + numBitsForAlign + (2 + 2) * 8 + curBlockSize * 8;
+ bitPosition = 0;
+ blockSize -= curBlockSize;
+ }
+ while(blockSize != 0);
+ return price;
+}
+
+void CCoder::WriteStoreBlock(UInt32 blockSize, UInt32 additionalOffset, bool finalBlock)
+{
+ do
+ {
+ UInt32 curBlockSize = (blockSize < (1 << 16)) ? blockSize : (1 << 16) - 1;
+ blockSize -= curBlockSize;
+ m_OutStream.WriteBits((finalBlock && (blockSize == 0) ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
+ m_OutStream.WriteBits(NBlockType::kStored, kBlockTypeFieldSize);
+ m_OutStream.FlushByte();
+ m_OutStream.WriteBits((UInt16)curBlockSize, kStoredBlockLengthFieldSize);
+ m_OutStream.WriteBits((UInt16)~curBlockSize, kStoredBlockLengthFieldSize);
+ const Byte *data = Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow)- additionalOffset;
+ for(UInt32 i = 0; i < curBlockSize; i++)
+ m_OutStream.WriteByte(data[i]);
+ additionalOffset -= curBlockSize;
+ }
+ while(blockSize != 0);
+}
+
+NO_INLINE UInt32 CCoder::TryDynBlock(int tableIndex, UInt32 numPasses)
+{
+ CTables &t = m_Tables[tableIndex];
+ BlockSizeRes = t.BlockSizeRes;
+ UInt32 posTemp = t.m_Pos;
+ SetPrices(t);
+
+ for (UInt32 p = 0; p < numPasses; p++)
+ {
+ m_Pos = posTemp;
+ TryBlock();
+ MakeTables();
+ SetPrices(m_NewLevels);
+ }
+
+ (CLevels &)t = m_NewLevels;
+
+ m_NumLitLenLevels = kMainTableSize;
+ while(m_NumLitLenLevels > kNumLitLenCodesMin && m_NewLevels.litLenLevels[m_NumLitLenLevels - 1] == 0)
+ m_NumLitLenLevels--;
+
+ m_NumDistLevels = kDistTableSize64;
+ while(m_NumDistLevels > kNumDistCodesMin && m_NewLevels.distLevels[m_NumDistLevels - 1] == 0)
+ m_NumDistLevels--;
+
+ UInt32 levelFreqs[kLevelTableSize];
+ memset(levelFreqs, 0, sizeof(levelFreqs));
+
+ LevelTableDummy(m_NewLevels.litLenLevels, m_NumLitLenLevels, levelFreqs);
+ LevelTableDummy(m_NewLevels.distLevels, m_NumDistLevels, levelFreqs);
+
+ Huffman_Generate(levelFreqs, levelCodes, levelLens, kLevelTableSize, kMaxLevelBitLength);
+
+ m_NumLevelCodes = kNumLevelCodesMin;
+ for (UInt32 i = 0; i < kLevelTableSize; i++)
+ {
+ Byte level = levelLens[kCodeLengthAlphabetOrder[i]];
+ if (level > 0 && i >= m_NumLevelCodes)
+ m_NumLevelCodes = i + 1;
+ m_LevelLevels[i] = level;
+ }
+
+ return GetLzBlockPrice() +
+ Huffman_GetPrice_Spec(levelFreqs, levelLens, kLevelTableSize, kLevelDirectBits, kTableDirectLevels) +
+ kNumLenCodesFieldSize + kNumDistCodesFieldSize + kNumLevelCodesFieldSize +
+ m_NumLevelCodes * kLevelFieldSize + kFinalBlockFieldSize + kBlockTypeFieldSize;
+}
+
+NO_INLINE UInt32 CCoder::TryFixedBlock(int tableIndex)
+{
+ CTables &t = m_Tables[tableIndex];
+ BlockSizeRes = t.BlockSizeRes;
+ m_Pos = t.m_Pos;
+ m_NewLevels.SetFixedLevels();
+ SetPrices(m_NewLevels);
+ TryBlock();
+ return kFinalBlockFieldSize + kBlockTypeFieldSize + GetLzBlockPrice();
+}
+
+NO_INLINE UInt32 CCoder::GetBlockPrice(int tableIndex, int numDivPasses)
+{
+ CTables &t = m_Tables[tableIndex];
+ t.StaticMode = false;
+ UInt32 price = TryDynBlock(tableIndex, m_NumPasses);
+ t.BlockSizeRes = BlockSizeRes;
+ UInt32 numValues = m_ValueIndex;
+ UInt32 posTemp = m_Pos;
+ UInt32 additionalOffsetEnd = m_AdditionalOffset;
+
+ if (m_CheckStatic && m_ValueIndex <= kFixedHuffmanCodeBlockSizeMax)
+ {
+ const UInt32 fixedPrice = TryFixedBlock(tableIndex);
+ t.StaticMode = (fixedPrice < price);
+ if (t.StaticMode)
+ price = fixedPrice;
+ }
+
+ const UInt32 storePrice = GetStorePrice(BlockSizeRes, 0); // bitPosition
+ t.StoreMode = (storePrice <= price);
+ if (t.StoreMode)
+ price = storePrice;
+
+ t.UseSubBlocks = false;
+
+ if (numDivPasses > 1 && numValues >= kDivideCodeBlockSizeMin)
+ {
+ CTables &t0 = m_Tables[(tableIndex << 1)];
+ (CLevels &)t0 = t;
+ t0.BlockSizeRes = t.BlockSizeRes >> 1;
+ t0.m_Pos = t.m_Pos;
+ UInt32 subPrice = GetBlockPrice((tableIndex << 1), numDivPasses - 1);
+
+ UInt32 blockSize2 = t.BlockSizeRes - t0.BlockSizeRes;
+ if (t0.BlockSizeRes >= kDivideBlockSizeMin && blockSize2 >= kDivideBlockSizeMin)
+ {
+ CTables &t1 = m_Tables[(tableIndex << 1) + 1];
+ (CLevels &)t1 = t;
+ t1.BlockSizeRes = blockSize2;
+ t1.m_Pos = m_Pos;
+ m_AdditionalOffset -= t0.BlockSizeRes;
+ subPrice += GetBlockPrice((tableIndex << 1) + 1, numDivPasses - 1);
+ t.UseSubBlocks = (subPrice < price);
+ if (t.UseSubBlocks)
+ price = subPrice;
+ }
+ }
+ m_AdditionalOffset = additionalOffsetEnd;
+ m_Pos = posTemp;
+ return price;
+}
+
+void CCoder::CodeBlock(int tableIndex, bool finalBlock)
+{
+ CTables &t = m_Tables[tableIndex];
+ if (t.UseSubBlocks)
+ {
+ CodeBlock((tableIndex << 1), false);
+ CodeBlock((tableIndex << 1) + 1, finalBlock);
+ }
+ else
+ {
+ if (t.StoreMode)
+ WriteStoreBlock(t.BlockSizeRes, m_AdditionalOffset, finalBlock);
+ else
+ {
+ m_OutStream.WriteBits((finalBlock ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
+ if (t.StaticMode)
+ {
+ m_OutStream.WriteBits(NBlockType::kFixedHuffman, kBlockTypeFieldSize);
+ TryFixedBlock(tableIndex);
+ int i;
+ for (i = 0; i < kFixedMainTableSize; i++)
+ mainFreqs[i] = (UInt32)1 << (kNumHuffmanBits - m_NewLevels.litLenLevels[i]);
+ for (i = 0; i < kFixedDistTableSize; i++)
+ distFreqs[i] = (UInt32)1 << (kNumHuffmanBits - m_NewLevels.distLevels[i]);
+ MakeTables();
+ }
+ else
+ {
+ if (m_NumDivPasses > 1 || m_CheckStatic)
+ TryDynBlock(tableIndex, 1);
+ m_OutStream.WriteBits(NBlockType::kDynamicHuffman, kBlockTypeFieldSize);
+ m_OutStream.WriteBits(m_NumLitLenLevels - kNumLitLenCodesMin, kNumLenCodesFieldSize);
+ m_OutStream.WriteBits(m_NumDistLevels - kNumDistCodesMin, kNumDistCodesFieldSize);
+ m_OutStream.WriteBits(m_NumLevelCodes - kNumLevelCodesMin, kNumLevelCodesFieldSize);
+
+ for (UInt32 i = 0; i < m_NumLevelCodes; i++)
+ m_OutStream.WriteBits(m_LevelLevels[i], kLevelFieldSize);
+
+ Huffman_ReverseBits(levelCodes, levelLens, kLevelTableSize);
+ LevelTableCode(m_NewLevels.litLenLevels, m_NumLitLenLevels, levelLens, levelCodes);
+ LevelTableCode(m_NewLevels.distLevels, m_NumDistLevels, levelLens, levelCodes);
+ }
+ WriteBlock();
+ }
+ m_AdditionalOffset -= t.BlockSizeRes;
+ }
+}
+
+HRes Read(void *object, void *data, UInt32 size, UInt32 *processedSize)
+{
+ return (HRes)((CSeqInStream *)object)->RealStream->Read(data, size, processedSize);
+}
+
+HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */ , const UInt64 * /* outSize */ ,
+ ICompressProgressInfo *progress)
+{
+ m_CheckStatic = (m_NumPasses != 1 || m_NumDivPasses != 1);
+ m_IsMultiPass = (m_CheckStatic || (m_NumPasses != 1 || m_NumDivPasses != 1));
+
+ RINOK(Create());
+
+ m_ValueBlockSize = (1 << 13) + (1 << 12) * m_NumDivPasses;
+
+ UInt64 nowPos = 0;
+
+ _seqInStream.RealStream = inStream;
+ _seqInStream.SeqInStream.Read = Read;
+ _lzInWindow.stream = &_seqInStream.SeqInStream;
+
+ MatchFinder_Init(&_lzInWindow);
+ m_OutStream.SetStream(outStream);
+ m_OutStream.Init();
+
+ CCoderReleaser coderReleaser(this);
+
+ m_OptimumEndIndex = m_OptimumCurrentIndex = 0;
+
+ CTables &t = m_Tables[1];
+ t.m_Pos = 0;
+ t.InitStructures();
+
+ m_AdditionalOffset = 0;
+ do
+ {
+ t.BlockSizeRes = kBlockUncompressedSizeThreshold;
+ m_SecondPass = false;
+ GetBlockPrice(1, m_NumDivPasses);
+ CodeBlock(1, Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) == 0);
+ nowPos += m_Tables[1].BlockSizeRes;
+ if (progress != NULL)
+ {
+ UInt64 packSize = m_OutStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&nowPos, &packSize));
+ }
+ }
+ while (Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) != 0);
+ if (_lzInWindow.result != SZ_OK)
+ return _lzInWindow.result;
+ return m_OutStream.Flush();
+}
+
+HRESULT CCoder::BaseCode(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return E_FAIL; }
+}
+
+STDMETHODIMP CCOMCoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+ { return BaseCode(inStream, outStream, inSize, outSize, progress); }
+
+STDMETHODIMP CCOMCoder::SetCoderProperties(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties)
+ { return BaseSetEncoderProperties2(propIDs, properties, numProperties); }
+
+STDMETHODIMP CCOMCoder64::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+ { return BaseCode(inStream, outStream, inSize, outSize, progress); }
+
+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
new file mode 100755
index 00000000..86eede6f
--- /dev/null
+++ b/CPP/7zip/Compress/Deflate/DeflateEncoder.h
@@ -0,0 +1,221 @@
+// DeflateEncoder.h
+
+#ifndef __DEFLATE_ENCODER_H
+#define __DEFLATE_ENCODER_H
+
+#include "Common/MyCom.h"
+
+#include "../../ICoder.h"
+#include "../../Common/LSBFEncoder.h"
+
+#include "DeflateConst.h"
+
+extern "C"
+{
+ #include "../../../../C/Compress/Lz/MatchFinder.h"
+}
+
+namespace NCompress {
+namespace NDeflate {
+namespace NEncoder {
+
+struct CCodeValue
+{
+ UInt16 Len;
+ UInt16 Pos;
+ void SetAsLiteral() { Len = (1 << 15); }
+ bool IsLiteral() const { return ((Len & (1 << 15)) != 0); }
+};
+
+struct COptimal
+{
+ UInt32 Price;
+ UInt16 PosPrev;
+ UInt16 BackPrev;
+};
+
+const UInt32 kNumOptsBase = 1 << 12;
+const UInt32 kNumOpts = kNumOptsBase + kMatchMaxLen;
+
+class CCoder;
+
+struct CTables: public CLevels
+{
+ bool UseSubBlocks;
+ bool StoreMode;
+ bool StaticMode;
+ UInt32 BlockSizeRes;
+ UInt32 m_Pos;
+ void InitStructures();
+};
+
+typedef struct _CSeqInStream
+{
+ ISeqInStream SeqInStream;
+ CMyComPtr<ISequentialInStream> RealStream;
+} CSeqInStream;
+
+class CCoder
+{
+ CMatchFinder _lzInWindow;
+ NStream::NLSBF::CEncoder m_OutStream;
+
+ CSeqInStream _seqInStream;
+
+public:
+ CCodeValue *m_Values;
+
+ UInt16 *m_MatchDistances;
+ UInt32 m_NumFastBytes;
+
+ UInt16 *m_OnePosMatchesMemory;
+ UInt16 *m_DistanceMemory;
+
+ UInt32 m_Pos;
+
+ int m_NumPasses;
+ int m_NumDivPasses;
+ bool m_CheckStatic;
+ bool m_IsMultiPass;
+ UInt32 m_ValueBlockSize;
+
+ UInt32 m_NumLenCombinations;
+ UInt32 m_MatchMaxLen;
+ const Byte *m_LenStart;
+ const Byte *m_LenDirectBits;
+
+ bool m_Created;
+ bool m_Deflate64Mode;
+
+ Byte m_LevelLevels[kLevelTableSize];
+ int m_NumLitLenLevels;
+ int m_NumDistLevels;
+ UInt32 m_NumLevelCodes;
+ UInt32 m_ValueIndex;
+
+ bool m_SecondPass;
+ UInt32 m_AdditionalOffset;
+
+ UInt32 m_OptimumEndIndex;
+ UInt32 m_OptimumCurrentIndex;
+
+ Byte m_LiteralPrices[256];
+ Byte m_LenPrices[kNumLenSymbolsMax];
+ Byte m_PosPrices[kDistTableSize64];
+
+ CLevels m_NewLevels;
+ UInt32 mainFreqs[kFixedMainTableSize];
+ UInt32 distFreqs[kDistTableSize64];
+ UInt32 mainCodes[kFixedMainTableSize];
+ UInt32 distCodes[kDistTableSize64];
+ UInt32 levelCodes[kLevelTableSize];
+ Byte levelLens[kLevelTableSize];
+
+ UInt32 BlockSizeRes;
+
+ CTables *m_Tables;
+ COptimal m_Optimum[kNumOpts];
+
+ UInt32 m_MatchFinderCycles;
+ // IMatchFinderSetNumPasses *m_SetMfPasses;
+
+ void GetMatches();
+ void MovePos(UInt32 num);
+ UInt32 Backward(UInt32 &backRes, UInt32 cur);
+ UInt32 GetOptimal(UInt32 &backRes);
+
+ void LevelTableDummy(const Byte *levels, int numLevels, UInt32 *freqs);
+ void LevelTableCode(const Byte *levels, int numLevels, const Byte *lens, const UInt32 *codes);
+
+ void MakeTables();
+ UInt32 GetLzBlockPrice() const;
+ void TryBlock();
+ UInt32 TryDynBlock(int tableIndex, UInt32 numPasses);
+
+ UInt32 TryFixedBlock(int tableIndex);
+
+ void SetPrices(const CLevels &levels);
+ void WriteBlock();
+
+ HRESULT Create();
+ void Free();
+
+ void WriteStoreBlock(UInt32 blockSize, UInt32 additionalOffset, bool finalBlock);
+ void WriteTables(bool writeMode, bool finalBlock);
+
+ void WriteBlockData(bool writeMode, bool finalBlock);
+
+ void ReleaseStreams()
+ {
+ _seqInStream.RealStream.Release();
+ m_OutStream.ReleaseStream();
+ }
+ class CCoderReleaser
+ {
+ CCoder *m_Coder;
+ public:
+ CCoderReleaser(CCoder *coder): m_Coder(coder) {}
+ ~CCoderReleaser() { m_Coder->ReleaseStreams(); }
+ };
+ friend class CCoderReleaser;
+
+ UInt32 GetBlockPrice(int tableIndex, int numDivPasses);
+ void CodeBlock(int tableIndex, bool finalBlock);
+
+public:
+ CCoder(bool deflate64Mode = false);
+ ~CCoder();
+
+ HRESULT CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ HRESULT BaseCode(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ // ICompressSetCoderProperties
+ HRESULT BaseSetEncoderProperties2(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties);
+};
+
+///////////////////////////////////////////////////////////////
+
+class CCOMCoder :
+ public ICompressCoder,
+ public ICompressSetCoderProperties,
+ public CMyUnknownImp,
+ public CCoder
+{
+public:
+ MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
+ CCOMCoder(): CCoder(false) {};
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+ // ICompressSetCoderProperties
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties);
+};
+
+class CCOMCoder64 :
+ public ICompressCoder,
+ public ICompressSetCoderProperties,
+ public CMyUnknownImp,
+ public CCoder
+{
+public:
+ MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
+ CCOMCoder64(): CCoder(true) {};
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+ // ICompressSetCoderProperties
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties);
+};
+
+
+}}}
+
+#endif
diff --git a/CPP/7zip/Compress/Deflate/DllExports.cpp b/CPP/7zip/Compress/Deflate/DllExports.cpp
new file mode 100755
index 00000000..a0b23562
--- /dev/null
+++ b/CPP/7zip/Compress/Deflate/DllExports.cpp
@@ -0,0 +1,157 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+#include "Common/ComTry.h"
+
+#include "DeflateEncoder.h"
+#include "DeflateDecoder.h"
+
+#ifdef CRC_GENERATE_TABLE
+extern "C"
+{
+ #include "../../../../C/7zCrc.h"
+}
+#endif
+
+// {23170F69-40C1-278B-0401-080000000000}
+DEFINE_GUID(CLSID_CCompressDeflateDecoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+// {23170F69-40C1-278B-0401-090000000000}
+DEFINE_GUID(CLSID_CCompressDeflate64Decoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+// {23170F69-40C1-278B-0401-080000000100}
+DEFINE_GUID(CLSID_CCompressDeflateEncoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00);
+
+// {23170F69-40C1-278B-0401-090000000100}
+DEFINE_GUID(CLSID_CCompressDeflate64Encoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00);
+
+
+// {23170F69-40C1-278B-0409-010000000000}
+DEFINE_GUID(CLSID_CCompressDeflateNsisDecoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ #ifdef CRC_GENERATE_TABLE
+ CrcGenerateTable();
+ #endif
+ }
+ return TRUE;
+}
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ int correctInterface = (*iid == IID_ICompressCoder);
+ CMyComPtr<ICompressCoder> coder;
+ if (*clsid == CLSID_CCompressDeflateDecoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NDeflate::NDecoder::CCOMCoder();
+ }
+ else if (*clsid == CLSID_CCompressDeflateNsisDecoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NDeflate::NDecoder::CNsisCOMCoder();
+ }
+ else if (*clsid == CLSID_CCompressDeflateEncoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NDeflate::NEncoder::CCOMCoder();
+ }
+ else if (*clsid == CLSID_CCompressDeflate64Decoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NDeflate::NDecoder::CCOMCoder64();
+ }
+ else if (*clsid == CLSID_CCompressDeflate64Encoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NDeflate::NEncoder::CCOMCoder64();
+ }
+ else
+ return CLASS_E_CLASSNOTAVAILABLE;
+ *outObject = coder.Detach();
+ COM_TRY_END
+ return S_OK;
+}
+
+struct CDeflateMethodItem
+{
+ char ID[3];
+ const wchar_t *UserName;
+ const GUID *Decoder;
+ const GUID *Encoder;
+};
+
+#define METHOD_ITEM(Name, id, UserName) \
+ { { 0x04, 0x01, id }, UserName, \
+ &CLSID_CCompress ## Name ## Decoder, \
+ &CLSID_CCompress ## Name ## Encoder }
+
+#define METHOD_ITEM_DE(Name, id1, id2, UserName) \
+ { { 0x04, id1, id2 }, UserName, \
+ &CLSID_CCompress ## Name ## Decoder, NULL }
+
+
+static CDeflateMethodItem g_Methods[] =
+{
+ METHOD_ITEM(Deflate, 0x08, L"Deflate"),
+ METHOD_ITEM(Deflate64, 0x09, L"Deflate64"),
+ METHOD_ITEM_DE(DeflateNsis, 0x09, 0x01, L"DeflateNSIS")
+};
+
+STDAPI GetNumberOfMethods(UINT32 *numMethods)
+{
+ *numMethods = sizeof(g_Methods) / sizeof(g_Methods[0]);
+ return S_OK;
+}
+
+STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
+{
+ if (index > sizeof(g_Methods) / sizeof(g_Methods[0]))
+ return E_INVALIDARG;
+ VariantClear((tagVARIANT *)value);
+ const CDeflateMethodItem &method = g_Methods[index];
+ switch(propID)
+ {
+ case NMethodPropID::kID:
+ if ((value->bstrVal = ::SysAllocStringByteLen(method.ID,
+ sizeof(method.ID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kName:
+ if ((value->bstrVal = ::SysAllocString(method.UserName)) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kDecoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)method.Decoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kEncoder:
+ if (method.Encoder)
+ {
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)method.Encoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ }
+ return S_OK;
+ }
+ return S_OK;
+}
diff --git a/7zip/Compress/LZMA/StdAfx.cpp b/CPP/7zip/Compress/Deflate/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/LZMA/StdAfx.cpp
+++ b/CPP/7zip/Compress/Deflate/StdAfx.cpp
diff --git a/7zip/Compress/Deflate/StdAfx.h b/CPP/7zip/Compress/Deflate/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/Deflate/StdAfx.h
+++ b/CPP/7zip/Compress/Deflate/StdAfx.h
diff --git a/CPP/7zip/Compress/Deflate/makefile b/CPP/7zip/Compress/Deflate/makefile
new file mode 100755
index 00000000..c533d7cc
--- /dev/null
+++ b/CPP/7zip/Compress/Deflate/makefile
@@ -0,0 +1,63 @@
+PROG = Deflate.dll
+DEF_FILE = ../Codec.def
+CFLAGS = $(CFLAGS) -I ../../../ -D_ST_MODE
+LIBS = $(LIBS) oleaut32.lib
+
+DEFLATE_OBJS = \
+ $O\DllExports.obj \
+
+DEFLATE_OPT_OBJS = \
+ $O\DeflateDecoder.obj \
+ $O\DeflateEncoder.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CRC.obj \
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\OutBuffer.obj \
+ $O\LSBFDecoder.obj \
+ $O\LSBFEncoder.obj \
+
+LZ_OBJS = \
+ $O\LZOutWindow.obj \
+
+C_OBJS = \
+ $O\7zCrc.obj \
+ $O\Sort.obj \
+
+C_LZ_OBJS = \
+ $O\MatchFinder.obj \
+
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(DEFLATE_OBJS) \
+ $(DEFLATE_OPT_OBJS) \
+ $(COMMON_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(LZ_OBJS) \
+ $(C_OBJS) \
+ $(C_LZ_OBJS) \
+ $O\HuffmanEncode.obj \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(DEFLATE_OBJS): $(*B).cpp
+ $(COMPL)
+$(DEFLATE_OPT_OBJS): $(*B).cpp
+ $(COMPL_O2)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(LZ_OBJS): ../LZ/$(*B).cpp
+ $(COMPL)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c
+ $(COMPL_O2)
+$O\HuffmanEncode.obj: ../../../../C/Compress/Huffman/$(*B).c
+ $(COMPL_O2)
diff --git a/7zip/Compress/Deflate/resource.rc b/CPP/7zip/Compress/Deflate/resource.rc
index 910bc281..910bc281 100755
--- a/7zip/Compress/Deflate/resource.rc
+++ b/CPP/7zip/Compress/Deflate/resource.rc
diff --git a/7zip/Compress/Huffman/HuffmanDecoder.h b/CPP/7zip/Compress/Huffman/HuffmanDecoder.h
index 57115197..57115197 100755
--- a/7zip/Compress/Huffman/HuffmanDecoder.h
+++ b/CPP/7zip/Compress/Huffman/HuffmanDecoder.h
diff --git a/7zip/Compress/Huffman/StdAfx.h b/CPP/7zip/Compress/Huffman/StdAfx.h
index b637fd40..b637fd40 100755
--- a/7zip/Compress/Huffman/StdAfx.h
+++ b/CPP/7zip/Compress/Huffman/StdAfx.h
diff --git a/CPP/7zip/Compress/Implode/DllExports.cpp b/CPP/7zip/Compress/Implode/DllExports.cpp
new file mode 100755
index 00000000..ff8cbe64
--- /dev/null
+++ b/CPP/7zip/Compress/Implode/DllExports.cpp
@@ -0,0 +1,65 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+#include "Common/ComTry.h"
+#include "ImplodeDecoder.h"
+
+// {23170F69-40C1-278B-0401-060000000000}
+DEFINE_GUID(CLSID_CCompressImplodeDecoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ return TRUE;
+}
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ if (*clsid != CLSID_CCompressImplodeDecoder)
+ return CLASS_E_CLASSNOTAVAILABLE;
+ if (*iid != IID_ICompressCoder)
+ return E_NOINTERFACE;
+ CMyComPtr<ICompressCoder> coder = (ICompressCoder *)new
+ NCompress::NImplode::NDecoder::CCoder;
+ *outObject = coder.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[] = { 0x04, 0x01, 0x06 };
+ if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ case NMethodPropID::kName:
+ if ((value->bstrVal = ::SysAllocString(L"Implode")) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kDecoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CCompressImplodeDecoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ return S_OK;
+}
diff --git a/7zip/Compress/Implode/ImplodeDecoder.cpp b/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp
index 19634c5c..19634c5c 100755
--- a/7zip/Compress/Implode/ImplodeDecoder.cpp
+++ b/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp
diff --git a/7zip/Compress/Implode/ImplodeDecoder.h b/CPP/7zip/Compress/Implode/ImplodeDecoder.h
index 627edba4..627edba4 100755
--- a/7zip/Compress/Implode/ImplodeDecoder.h
+++ b/CPP/7zip/Compress/Implode/ImplodeDecoder.h
diff --git a/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp b/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp
index ad2061c3..ad2061c3 100755
--- a/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp
+++ b/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp
diff --git a/7zip/Compress/Implode/ImplodeHuffmanDecoder.h b/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.h
index 9f7aeca1..9f7aeca1 100755
--- a/7zip/Compress/Implode/ImplodeHuffmanDecoder.h
+++ b/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.h
diff --git a/7zip/Compress/LZMA_Alone/StdAfx.cpp b/CPP/7zip/Compress/Implode/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/LZMA_Alone/StdAfx.cpp
+++ b/CPP/7zip/Compress/Implode/StdAfx.cpp
diff --git a/7zip/Compress/Implode/StdAfx.h b/CPP/7zip/Compress/Implode/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/Implode/StdAfx.h
+++ b/CPP/7zip/Compress/Implode/StdAfx.h
diff --git a/7zip/Compress/LZ/LZOutWindow.cpp b/CPP/7zip/Compress/LZ/LZOutWindow.cpp
index e2d6aba1..e2d6aba1 100755
--- a/7zip/Compress/LZ/LZOutWindow.cpp
+++ b/CPP/7zip/Compress/LZ/LZOutWindow.cpp
diff --git a/7zip/Compress/LZ/LZOutWindow.h b/CPP/7zip/Compress/LZ/LZOutWindow.h
index 3c50c6e7..3c50c6e7 100755
--- a/7zip/Compress/LZ/LZOutWindow.h
+++ b/CPP/7zip/Compress/LZ/LZOutWindow.h
diff --git a/7zip/Compress/LZ/StdAfx.h b/CPP/7zip/Compress/LZ/StdAfx.h
index 3ff6d8a2..3ff6d8a2 100755
--- a/7zip/Compress/LZ/StdAfx.h
+++ b/CPP/7zip/Compress/LZ/StdAfx.h
diff --git a/CPP/7zip/Compress/LZMA/DllExports.cpp b/CPP/7zip/Compress/LZMA/DllExports.cpp
new file mode 100755
index 00000000..1fc65b84
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA/DllExports.cpp
@@ -0,0 +1,109 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Common/MyInitGuid.h"
+#include "../../../Common/ComTry.h"
+#ifdef _WIN32
+#include "../../../Common/Alloc.h"
+#endif
+
+#include "LZMAEncoder.h"
+#include "LZMADecoder.h"
+
+#ifdef CRC_GENERATE_TABLE
+extern "C"
+{
+ #include "../../../../C/7zCrc.h"
+}
+#endif
+
+// {23170F69-40C1-278B-0301-010000000000}
+DEFINE_GUID(CLSID_CLZMADecoder,
+0x23170F69, 0x40C1, 0x278B, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+// {23170F69-40C1-278B-0301-010000000100}
+DEFINE_GUID(CLSID_CLZMAEncoder,
+0x23170F69, 0x40C1, 0x278B, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00);
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ // NCompress::NRangeCoder::g_PriceTables.Init();
+ #ifdef CRC_GENERATE_TABLE
+ CrcGenerateTable();
+ #endif
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+ }
+ return TRUE;
+}
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ // NCompress::NRangeCoder::g_PriceTables.Init();
+ // CCRC::InitTable();
+ COM_TRY_BEGIN
+ *outObject = 0;
+ int correctInterface = (*iid == IID_ICompressCoder);
+ CMyComPtr<ICompressCoder> coder;
+ if (*clsid == CLSID_CLZMADecoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NLZMA::CDecoder();
+ }
+ else if (*clsid == CLSID_CLZMAEncoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NLZMA::CEncoder();
+ }
+ else
+ return CLASS_E_CLASSNOTAVAILABLE;
+ *outObject = coder.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[] = { 0x03, 0x01, 0x01 };
+ if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ case NMethodPropID::kName:
+ if ((value->bstrVal = ::SysAllocString(L"LZMA")) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kDecoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CLZMADecoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kEncoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CLZMAEncoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ return S_OK;
+}
+
diff --git a/CPP/7zip/Compress/LZMA/LZMA.dsp b/CPP/7zip/Compress/LZMA/LZMA.dsp
new file mode 100755
index 00000000..3d51f1ff
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA/LZMA.dsp
@@ -0,0 +1,478 @@
+# 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 "_ST_MODE" /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 "_ST_MODE" /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=.\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=..\MatchFinders\IMatchFinder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\IStream.h
+# End Source File
+# End Group
+# Begin Group "LZ"
+
+# PROP Default_Filter ""
+# Begin Group "BT"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTree.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTree2.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTree3.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTree4.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTreeBase.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTreeD.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTreeD4.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTreeDMain.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTreeMain.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTreeR.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTreeR4.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\BinTree\BinTreeRMain.h
+# End Source File
+# End Group
+# Begin Group "HC"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\LZ\HashChain\HC4.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\HashChain\HCMain.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=..\LZ\IMatchFinder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\LZInWindow.h
+# End Source File
+# 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\AlignedBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\AlignedBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\ComTry.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.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
+# Begin Source File
+
+SOURCE=..\..\..\Common\NewHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\NewHandler.h
+# End Source File
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Handle.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\Thread.h
+# End Source File
+# End Group
+# Begin Group "C"
+
+# PROP Default_Filter ""
+# Begin Group "C_Lz"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\LzHash.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.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\Compress\Lz\MatchFinder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.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\Compress\Lz\MatchFinderMt.h
+# End Source File
+# End Group
+# 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\IStream.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
+# End Target
+# End Project
diff --git a/7zip/Compress/LZMA/LZMA.dsw b/CPP/7zip/Compress/LZMA/LZMA.dsw
index f750e453..f750e453 100755
--- a/7zip/Compress/LZMA/LZMA.dsw
+++ b/CPP/7zip/Compress/LZMA/LZMA.dsw
diff --git a/7zip/Compress/LZMA/LZMA.h b/CPP/7zip/Compress/LZMA/LZMA.h
index 7bc4c438..7bc4c438 100755
--- a/7zip/Compress/LZMA/LZMA.h
+++ b/CPP/7zip/Compress/LZMA/LZMA.h
diff --git a/7zip/Compress/LZMA/LZMADecoder.cpp b/CPP/7zip/Compress/LZMA/LZMADecoder.cpp
index 75de2245..75de2245 100755
--- a/7zip/Compress/LZMA/LZMADecoder.cpp
+++ b/CPP/7zip/Compress/LZMA/LZMADecoder.cpp
diff --git a/7zip/Compress/LZMA/LZMADecoder.h b/CPP/7zip/Compress/LZMA/LZMADecoder.h
index 1c10409f..1c10409f 100755
--- a/7zip/Compress/LZMA/LZMADecoder.h
+++ b/CPP/7zip/Compress/LZMA/LZMADecoder.h
diff --git a/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
new file mode 100755
index 00000000..0589f8a1
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
@@ -0,0 +1,1530 @@
+// LZMA/Encoder.cpp
+
+#include "StdAfx.h"
+
+#include <stdio.h>
+
+#include "../../../Common/Defs.h"
+#include "../../Common/StreamUtils.h"
+
+#include "LZMAEncoder.h"
+
+// extern "C" { #include "../../../../C/7zCrc.h" }
+
+// #define SHOW_STAT
+
+
+namespace NCompress {
+namespace NLZMA {
+
+// struct CCrcInit { CCrcInit() { InitCrcTable(); } } g_CrcInit;
+
+const int kDefaultDictionaryLogSize = 22;
+const UInt32 kNumFastBytesDefault = 0x20;
+
+Byte g_FastPos[1 << 11];
+
+class CFastPosInit
+{
+public:
+ CFastPosInit() { Init(); }
+ void Init()
+ {
+ const Byte kFastSlots = 22;
+ int c = 2;
+ g_FastPos[0] = 0;
+ g_FastPos[1] = 1;
+
+ for (Byte slotFast = 2; slotFast < kFastSlots; slotFast++)
+ {
+ UInt32 k = (1 << ((slotFast >> 1) - 1));
+ for (UInt32 j = 0; j < k; j++, c++)
+ g_FastPos[c] = slotFast;
+ }
+ }
+} g_FastPosInit;
+
+void CLiteralEncoder2::Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol)
+{
+ UInt32 context = 1;
+ int i = 8;
+ do
+ {
+ i--;
+ UInt32 bit = (symbol >> i) & 1;
+ _encoders[context].Encode(rangeEncoder, bit);
+ context = (context << 1) | bit;
+ }
+ while(i != 0);
+}
+
+void CLiteralEncoder2::EncodeMatched(NRangeCoder::CEncoder *rangeEncoder,
+ Byte matchByte, Byte symbol)
+{
+ UInt32 context = 1;
+ int i = 8;
+ do
+ {
+ i--;
+ UInt32 bit = (symbol >> i) & 1;
+ UInt32 matchBit = (matchByte >> i) & 1;
+ _encoders[0x100 + (matchBit << 8) + context].Encode(rangeEncoder, bit);
+ context = (context << 1) | bit;
+ if (matchBit != bit)
+ {
+ while(i != 0)
+ {
+ i--;
+ UInt32 bit = (symbol >> i) & 1;
+ _encoders[context].Encode(rangeEncoder, bit);
+ context = (context << 1) | bit;
+ }
+ break;
+ }
+ }
+ while(i != 0);
+}
+
+UInt32 CLiteralEncoder2::GetPrice(bool matchMode, Byte matchByte, Byte symbol) const
+{
+ UInt32 price = 0;
+ UInt32 context = 1;
+ int i = 8;
+ if (matchMode)
+ {
+ do
+ {
+ i--;
+ UInt32 matchBit = (matchByte >> i) & 1;
+ UInt32 bit = (symbol >> i) & 1;
+ price += _encoders[0x100 + (matchBit << 8) + context].GetPrice(bit);
+ context = (context << 1) | bit;
+ if (matchBit != bit)
+ break;
+ }
+ while (i != 0);
+ }
+ while(i != 0)
+ {
+ i--;
+ UInt32 bit = (symbol >> i) & 1;
+ price += _encoders[context].GetPrice(bit);
+ context = (context << 1) | bit;
+ }
+ return price;
+};
+
+
+namespace NLength {
+
+void CEncoder::Init(UInt32 numPosStates)
+{
+ _choice.Init();
+ _choice2.Init();
+ for (UInt32 posState = 0; posState < numPosStates; posState++)
+ {
+ _lowCoder[posState].Init();
+ _midCoder[posState].Init();
+ }
+ _highCoder.Init();
+}
+
+void CEncoder::Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState)
+{
+ if(symbol < kNumLowSymbols)
+ {
+ _choice.Encode(rangeEncoder, 0);
+ _lowCoder[posState].Encode(rangeEncoder, symbol);
+ }
+ else
+ {
+ _choice.Encode(rangeEncoder, 1);
+ if(symbol < kNumLowSymbols + kNumMidSymbols)
+ {
+ _choice2.Encode(rangeEncoder, 0);
+ _midCoder[posState].Encode(rangeEncoder, symbol - kNumLowSymbols);
+ }
+ else
+ {
+ _choice2.Encode(rangeEncoder, 1);
+ _highCoder.Encode(rangeEncoder, symbol - kNumLowSymbols - kNumMidSymbols);
+ }
+ }
+}
+
+void CEncoder::SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const
+{
+ UInt32 a0 = _choice.GetPrice0();
+ UInt32 a1 = _choice.GetPrice1();
+ UInt32 b0 = a1 + _choice2.GetPrice0();
+ UInt32 b1 = a1 + _choice2.GetPrice1();
+ UInt32 i = 0;
+ for (i = 0; i < kNumLowSymbols; i++)
+ {
+ if (i >= numSymbols)
+ return;
+ prices[i] = a0 + _lowCoder[posState].GetPrice(i);
+ }
+ for (; i < kNumLowSymbols + kNumMidSymbols; i++)
+ {
+ if (i >= numSymbols)
+ return;
+ prices[i] = b0 + _midCoder[posState].GetPrice(i - kNumLowSymbols);
+ }
+ for (; i < numSymbols; i++)
+ prices[i] = b1 + _highCoder.GetPrice(i - kNumLowSymbols - kNumMidSymbols);
+}
+
+}
+
+CEncoder::CEncoder():
+ _numFastBytes(kNumFastBytesDefault),
+ _distTableSize(kDefaultDictionaryLogSize * 2),
+ _posStateBits(2),
+ _posStateMask(4 - 1),
+ _numLiteralPosStateBits(0),
+ _numLiteralContextBits(3),
+ _dictionarySize(1 << kDefaultDictionaryLogSize),
+ _matchFinderCycles(0),
+ #ifdef COMPRESS_MF_MT
+ _multiThread(false),
+ #endif
+ _writeEndMark(false)
+{
+ MatchFinder_Construct(&_matchFinderBase);
+ // _maxMode = false;
+ _fastMode = false;
+ #ifdef COMPRESS_MF_MT
+ MatchFinderMt_Construct(&_matchFinderMt);
+ _matchFinderMt.MatchFinder = &_matchFinderBase;
+ #endif
+}
+
+
+static void *SzAlloc(size_t size) { return BigAlloc(size); }
+static void SzFree(void *address) { BigFree(address); }
+ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+CEncoder::~CEncoder()
+{
+ #ifdef COMPRESS_MF_MT
+ MatchFinderMt_Destruct(&_matchFinderMt, &g_Alloc);
+ #endif
+ MatchFinder_Free(&_matchFinderBase, &g_Alloc);
+}
+
+static const UInt32 kBigHashDicLimit = (UInt32)1 << 24;
+
+HRESULT CEncoder::Create()
+{
+ if (!_rangeEncoder.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ bool btMode = (_matchFinderBase.btMode != 0);
+ #ifdef COMPRESS_MF_MT
+ _mtMode = (_multiThread && !_fastMode && btMode);
+ #endif
+
+ if (!_literalEncoder.Create(_numLiteralPosStateBits, _numLiteralContextBits))
+ return E_OUTOFMEMORY;
+
+ _matchFinderBase.bigHash = (_dictionarySize > kBigHashDicLimit);
+
+ UInt32 numCycles = 16 + (_numFastBytes >> 1);
+ if (!btMode)
+ numCycles >>= 1;
+ if (_matchFinderCycles != 0)
+ numCycles = _matchFinderCycles;
+ _matchFinderBase.cutValue = numCycles;
+ #ifdef COMPRESS_MF_MT
+ if (_mtMode)
+ {
+ RINOK(MatchFinderMt_Create(&_matchFinderMt, _dictionarySize, kNumOpts, _numFastBytes, kMatchMaxLen, &g_Alloc));
+ _matchFinderObj = &_matchFinderMt;
+ MatchFinderMt_CreateVTable(&_matchFinderMt, &_matchFinder);
+ }
+ else
+ #endif
+ {
+ if (!MatchFinder_Create(&_matchFinderBase, _dictionarySize, kNumOpts, _numFastBytes, kMatchMaxLen, &g_Alloc))
+ return E_OUTOFMEMORY;
+ _matchFinderObj = &_matchFinderBase;
+ MatchFinder_CreateVTable(&_matchFinderBase, &_matchFinder);
+ }
+ return S_OK;
+}
+
+inline wchar_t GetUpperChar(wchar_t c)
+{
+ if (c >= 'a' && c <= 'z')
+ c -= 0x20;
+ return c;
+}
+
+static int ParseMatchFinder(const wchar_t *s, int *btMode, UInt32 *numHashBytes /* , int *skipModeBits */)
+{
+ wchar_t c = GetUpperChar(*s++);
+ if (c == L'H')
+ {
+ if (GetUpperChar(*s++) != L'C')
+ return 0;
+ int numHashBytesLoc = (int)(*s++ - L'0');
+ if (numHashBytesLoc < 4 || numHashBytesLoc > 4)
+ return 0;
+ if (*s++ != 0)
+ return 0;
+ *btMode = 0;
+ *numHashBytes = numHashBytesLoc;
+ return 1;
+ }
+ if (c != L'B')
+ return 0;
+
+ if (GetUpperChar(*s++) != L'T')
+ return 0;
+ int numHashBytesLoc = (int)(*s++ - L'0');
+ if (numHashBytesLoc < 2 || numHashBytesLoc > 4)
+ return 0;
+ c = GetUpperChar(*s++);
+ /*
+ int skipModeBitsLoc = 0;
+ if (c == L'D')
+ {
+ skipModeBitsLoc = 2;
+ c = GetUpperChar(*s++);
+ }
+ */
+ if (c != L'\0')
+ return 0;
+ *btMode = 1;
+ *numHashBytes = numHashBytesLoc;
+ // *skipModeBits = skipModeBitsLoc;
+ return 1;
+}
+
+STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties)
+{
+ for (UInt32 i = 0; i < numProperties; i++)
+ {
+ const PROPVARIANT &prop = properties[i];
+ switch(propIDs[i])
+ {
+ case NCoderPropID::kNumFastBytes:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 numFastBytes = prop.ulVal;
+ if(numFastBytes < 5 || numFastBytes > kMatchMaxLen)
+ return E_INVALIDARG;
+ _numFastBytes = numFastBytes;
+ break;
+ }
+ case NCoderPropID::kMatchFinderCycles:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ _matchFinderCycles = prop.ulVal;
+ break;
+ }
+ case NCoderPropID::kAlgorithm:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 maximize = prop.ulVal;
+ _fastMode = (maximize == 0);
+ // _maxMode = (maximize >= 2);
+ break;
+ }
+ case NCoderPropID::kMatchFinder:
+ {
+ if (prop.vt != VT_BSTR)
+ return E_INVALIDARG;
+ if (!ParseMatchFinder(prop.bstrVal, &_matchFinderBase.btMode, &_matchFinderBase.numHashBytes /* , &_matchFinderBase.skipModeBits */))
+ return E_INVALIDARG;
+ break;
+ }
+ #ifdef COMPRESS_MF_MT
+ case NCoderPropID::kMultiThread:
+ {
+ if (prop.vt != VT_BOOL)
+ return E_INVALIDARG;
+ Bool newMultiThread = (prop.boolVal == VARIANT_TRUE);
+ if (newMultiThread != _multiThread)
+ {
+ ReleaseMatchFinder();
+ _multiThread = newMultiThread;
+ }
+ break;
+ }
+ case NCoderPropID::kNumThreads:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ Bool newMultiThread = (prop.ulVal > 1) ? True : False;
+ if (newMultiThread != _multiThread)
+ {
+ ReleaseMatchFinder();
+ _multiThread = newMultiThread;
+ }
+ break;
+ }
+ #endif
+ case NCoderPropID::kDictionarySize:
+ {
+ const int kDicLogSizeMaxCompress = 30;
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 dictionarySize = prop.ulVal;
+ if (dictionarySize < UInt32(1 << kDicLogSizeMin) ||
+ dictionarySize > UInt32(1 << kDicLogSizeMaxCompress))
+ return E_INVALIDARG;
+ _dictionarySize = dictionarySize;
+ UInt32 dicLogSize;
+ for(dicLogSize = 0; dicLogSize < (UInt32)kDicLogSizeMaxCompress; dicLogSize++)
+ if (dictionarySize <= (UInt32(1) << dicLogSize))
+ break;
+ _distTableSize = dicLogSize * 2;
+ break;
+ }
+ case NCoderPropID::kPosStateBits:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 value = prop.ulVal;
+ if (value > (UInt32)NLength::kNumPosStatesBitsEncodingMax)
+ return E_INVALIDARG;
+ _posStateBits = value;
+ _posStateMask = (1 << _posStateBits) - 1;
+ break;
+ }
+ case NCoderPropID::kLitPosBits:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 value = prop.ulVal;
+ if (value > (UInt32)kNumLitPosStatesBitsEncodingMax)
+ return E_INVALIDARG;
+ _numLiteralPosStateBits = value;
+ break;
+ }
+ case NCoderPropID::kLitContextBits:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 value = prop.ulVal;
+ if (value > (UInt32)kNumLitContextBitsMax)
+ return E_INVALIDARG;
+ _numLiteralContextBits = value;
+ break;
+ }
+ case NCoderPropID::kEndMarker:
+ {
+ if (prop.vt != VT_BOOL)
+ return E_INVALIDARG;
+ SetWriteEndMarkerMode(prop.boolVal == VARIANT_TRUE);
+ break;
+ }
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
+{
+ const UInt32 kPropSize = 5;
+ Byte properties[kPropSize];
+ properties[0] = (Byte)((_posStateBits * 5 + _numLiteralPosStateBits) * 9 + _numLiteralContextBits);
+ for (int i = 0; i < 4; i++)
+ properties[1 + i] = Byte(_dictionarySize >> (8 * i));
+ return WriteStream(outStream, properties, kPropSize, NULL);
+}
+
+STDMETHODIMP CEncoder::SetOutStream(ISequentialOutStream *outStream)
+{
+ _rangeEncoder.SetStream(outStream);
+ return S_OK;
+}
+
+STDMETHODIMP CEncoder::ReleaseOutStream()
+{
+ _rangeEncoder.ReleaseStream();
+ return S_OK;
+}
+
+HRESULT CEncoder::Init()
+{
+ CBaseState::Init();
+
+ _rangeEncoder.Init();
+
+ for(int i = 0; i < kNumStates; i++)
+ {
+ for (UInt32 j = 0; j <= _posStateMask; j++)
+ {
+ _isMatch[i][j].Init();
+ _isRep0Long[i][j].Init();
+ }
+ _isRep[i].Init();
+ _isRepG0[i].Init();
+ _isRepG1[i].Init();
+ _isRepG2[i].Init();
+ }
+
+ _literalEncoder.Init();
+
+ {
+ for(UInt32 i = 0; i < kNumLenToPosStates; i++)
+ _posSlotEncoder[i].Init();
+ }
+ {
+ for(UInt32 i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
+ _posEncoders[i].Init();
+ }
+
+ _lenEncoder.Init(1 << _posStateBits);
+ _repMatchLenEncoder.Init(1 << _posStateBits);
+
+ _posAlignEncoder.Init();
+
+ _longestMatchWasFound = false;
+ _optimumEndIndex = 0;
+ _optimumCurrentIndex = 0;
+ _additionalOffset = 0;
+
+ return S_OK;
+}
+
+#ifdef SHOW_STAT
+static int ttt = 0;
+#endif
+
+void CEncoder::MovePos(UInt32 num)
+{
+ #ifdef SHOW_STAT
+ ttt += num;
+ printf("\n MovePos %d", num);
+ #endif
+ if (num != 0)
+ {
+ _additionalOffset += num;
+ _matchFinder.Skip(_matchFinderObj, num);
+ }
+}
+
+UInt32 CEncoder::Backward(UInt32 &backRes, UInt32 cur)
+{
+ _optimumEndIndex = cur;
+ UInt32 posMem = _optimum[cur].PosPrev;
+ UInt32 backMem = _optimum[cur].BackPrev;
+ do
+ {
+ if (_optimum[cur].Prev1IsChar)
+ {
+ _optimum[posMem].MakeAsChar();
+ _optimum[posMem].PosPrev = posMem - 1;
+ if (_optimum[cur].Prev2)
+ {
+ _optimum[posMem - 1].Prev1IsChar = false;
+ _optimum[posMem - 1].PosPrev = _optimum[cur].PosPrev2;
+ _optimum[posMem - 1].BackPrev = _optimum[cur].BackPrev2;
+ }
+ }
+ UInt32 posPrev = posMem;
+ UInt32 backCur = backMem;
+
+ backMem = _optimum[posPrev].BackPrev;
+ posMem = _optimum[posPrev].PosPrev;
+
+ _optimum[posPrev].BackPrev = backCur;
+ _optimum[posPrev].PosPrev = cur;
+ cur = posPrev;
+ }
+ while(cur != 0);
+ backRes = _optimum[0].BackPrev;
+ _optimumCurrentIndex = _optimum[0].PosPrev;
+ return _optimumCurrentIndex;
+}
+
+/*
+Out:
+ (lenRes == 1) && (backRes == 0xFFFFFFFF) means Literal
+*/
+
+UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
+{
+ if(_optimumEndIndex != _optimumCurrentIndex)
+ {
+ const COptimal &optimum = _optimum[_optimumCurrentIndex];
+ UInt32 lenRes = optimum.PosPrev - _optimumCurrentIndex;
+ backRes = optimum.BackPrev;
+ _optimumCurrentIndex = optimum.PosPrev;
+ return lenRes;
+ }
+ _optimumCurrentIndex = _optimumEndIndex = 0;
+
+ UInt32 numAvailableBytes = _matchFinder.GetNumAvailableBytes(_matchFinderObj);
+
+ UInt32 lenMain, numDistancePairs;
+ if (!_longestMatchWasFound)
+ {
+ lenMain = ReadMatchDistances(numDistancePairs);
+ }
+ else
+ {
+ lenMain = _longestMatchLength;
+ numDistancePairs = _numDistancePairs;
+ _longestMatchWasFound = false;
+ }
+
+ const Byte *data = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
+ if (numAvailableBytes < 2)
+ {
+ backRes = (UInt32)(-1);
+ return 1;
+ }
+ if (numAvailableBytes > kMatchMaxLen)
+ numAvailableBytes = kMatchMaxLen;
+
+ UInt32 reps[kNumRepDistances];
+ UInt32 repLens[kNumRepDistances];
+ UInt32 repMaxIndex = 0;
+ UInt32 i;
+ for(i = 0; i < kNumRepDistances; i++)
+ {
+ reps[i] = _repDistances[i];
+ UInt32 backOffset = reps[i] + 1;
+ if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
+ {
+ repLens[i] = 0;
+ continue;
+ }
+ UInt32 lenTest;
+ for (lenTest = 2; lenTest < numAvailableBytes &&
+ data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
+ repLens[i] = lenTest;
+ if (lenTest > repLens[repMaxIndex])
+ repMaxIndex = i;
+ }
+ if(repLens[repMaxIndex] >= _numFastBytes)
+ {
+ backRes = repMaxIndex;
+ UInt32 lenRes = repLens[repMaxIndex];
+ MovePos(lenRes - 1);
+ return lenRes;
+ }
+
+ UInt32 *matchDistances = _matchDistances;
+ if(lenMain >= _numFastBytes)
+ {
+ backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances;
+ MovePos(lenMain - 1);
+ return lenMain;
+ }
+ Byte currentByte = *data;
+ Byte matchByte = data[(size_t)0 - reps[0] - 1];
+
+ if(lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2)
+ {
+ backRes = (UInt32)-1;
+ return 1;
+ }
+
+ _optimum[0].State = _state;
+
+ UInt32 posState = (position & _posStateMask);
+
+ _optimum[1].Price = _isMatch[_state.Index][posState].GetPrice0() +
+ _literalEncoder.GetSubCoder(position, _previousByte)->GetPrice(!_state.IsCharState(), matchByte, currentByte);
+ _optimum[1].MakeAsChar();
+
+ UInt32 matchPrice = _isMatch[_state.Index][posState].GetPrice1();
+ UInt32 repMatchPrice = matchPrice + _isRep[_state.Index].GetPrice1();
+
+ if(matchByte == currentByte)
+ {
+ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(_state, posState);
+ if(shortRepPrice < _optimum[1].Price)
+ {
+ _optimum[1].Price = shortRepPrice;
+ _optimum[1].MakeAsShortRep();
+ }
+ }
+ UInt32 lenEnd = ((lenMain >= repLens[repMaxIndex]) ? lenMain : repLens[repMaxIndex]);
+
+ if(lenEnd < 2)
+ {
+ backRes = _optimum[1].BackPrev;
+ return 1;
+ }
+
+ _optimum[1].PosPrev = 0;
+ for (i = 0; i < kNumRepDistances; i++)
+ _optimum[0].Backs[i] = reps[i];
+
+ UInt32 len = lenEnd;
+ do
+ _optimum[len--].Price = kIfinityPrice;
+ while (len >= 2);
+
+ for(i = 0; i < kNumRepDistances; i++)
+ {
+ UInt32 repLen = repLens[i];
+ if (repLen < 2)
+ continue;
+ UInt32 price = repMatchPrice + GetPureRepPrice(i, _state, posState);
+ do
+ {
+ UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(repLen - 2, posState);
+ COptimal &optimum = _optimum[repLen];
+ if (curAndLenPrice < optimum.Price)
+ {
+ optimum.Price = curAndLenPrice;
+ optimum.PosPrev = 0;
+ optimum.BackPrev = i;
+ optimum.Prev1IsChar = false;
+ }
+ }
+ while(--repLen >= 2);
+ }
+
+ UInt32 normalMatchPrice = matchPrice + _isRep[_state.Index].GetPrice0();
+
+ len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);
+ if (len <= lenMain)
+ {
+ UInt32 offs = 0;
+ while (len > matchDistances[offs])
+ offs += 2;
+ for(; ; len++)
+ {
+ UInt32 distance = matchDistances[offs + 1];
+ UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState);
+ COptimal &optimum = _optimum[len];
+ if (curAndLenPrice < optimum.Price)
+ {
+ optimum.Price = curAndLenPrice;
+ optimum.PosPrev = 0;
+ optimum.BackPrev = distance + kNumRepDistances;
+ optimum.Prev1IsChar = false;
+ }
+ if (len == matchDistances[offs])
+ {
+ offs += 2;
+ if (offs == numDistancePairs)
+ break;
+ }
+ }
+ }
+
+ UInt32 cur = 0;
+
+ for (;;)
+ {
+ cur++;
+ if(cur == lenEnd)
+ {
+ return Backward(backRes, cur);
+ }
+ UInt32 numAvailableBytesFull = _matchFinder.GetNumAvailableBytes(_matchFinderObj);
+ UInt32 newLen, numDistancePairs;
+ newLen = ReadMatchDistances(numDistancePairs);
+ if(newLen >= _numFastBytes)
+ {
+ _numDistancePairs = numDistancePairs;
+ _longestMatchLength = newLen;
+ _longestMatchWasFound = true;
+ return Backward(backRes, cur);
+ }
+ position++;
+ COptimal &curOptimum = _optimum[cur];
+ UInt32 posPrev = curOptimum.PosPrev;
+ CState state;
+ if (curOptimum.Prev1IsChar)
+ {
+ posPrev--;
+ if (curOptimum.Prev2)
+ {
+ state = _optimum[curOptimum.PosPrev2].State;
+ if (curOptimum.BackPrev2 < kNumRepDistances)
+ state.UpdateRep();
+ else
+ state.UpdateMatch();
+ }
+ else
+ state = _optimum[posPrev].State;
+ state.UpdateChar();
+ }
+ else
+ state = _optimum[posPrev].State;
+ if (posPrev == cur - 1)
+ {
+ if (curOptimum.IsShortRep())
+ state.UpdateShortRep();
+ else
+ state.UpdateChar();
+ }
+ else
+ {
+ UInt32 pos;
+ if (curOptimum.Prev1IsChar && curOptimum.Prev2)
+ {
+ posPrev = curOptimum.PosPrev2;
+ pos = curOptimum.BackPrev2;
+ state.UpdateRep();
+ }
+ else
+ {
+ pos = curOptimum.BackPrev;
+ if (pos < kNumRepDistances)
+ state.UpdateRep();
+ else
+ state.UpdateMatch();
+ }
+ const COptimal &prevOptimum = _optimum[posPrev];
+ if (pos < kNumRepDistances)
+ {
+ reps[0] = prevOptimum.Backs[pos];
+ UInt32 i;
+ for(i = 1; i <= pos; i++)
+ reps[i] = prevOptimum.Backs[i - 1];
+ for(; i < kNumRepDistances; i++)
+ reps[i] = prevOptimum.Backs[i];
+ }
+ else
+ {
+ reps[0] = (pos - kNumRepDistances);
+ for(UInt32 i = 1; i < kNumRepDistances; i++)
+ reps[i] = prevOptimum.Backs[i - 1];
+ }
+ }
+ curOptimum.State = state;
+ for(UInt32 i = 0; i < kNumRepDistances; i++)
+ curOptimum.Backs[i] = reps[i];
+ UInt32 curPrice = curOptimum.Price;
+ const Byte *data = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
+ const Byte currentByte = *data;
+ const Byte matchByte = data[(size_t)0 - reps[0] - 1];
+
+ UInt32 posState = (position & _posStateMask);
+
+ UInt32 curAnd1Price = curPrice +
+ _isMatch[state.Index][posState].GetPrice0() +
+ _literalEncoder.GetSubCoder(position, data[(size_t)0 - 1])->GetPrice(!state.IsCharState(), matchByte, currentByte);
+
+ COptimal &nextOptimum = _optimum[cur + 1];
+
+ bool nextIsChar = false;
+ if (curAnd1Price < nextOptimum.Price)
+ {
+ nextOptimum.Price = curAnd1Price;
+ nextOptimum.PosPrev = cur;
+ nextOptimum.MakeAsChar();
+ nextIsChar = true;
+ }
+
+ UInt32 matchPrice = curPrice + _isMatch[state.Index][posState].GetPrice1();
+ UInt32 repMatchPrice = matchPrice + _isRep[state.Index].GetPrice1();
+
+ if(matchByte == currentByte &&
+ !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0))
+ {
+ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(state, posState);
+ if(shortRepPrice <= nextOptimum.Price)
+ {
+ nextOptimum.Price = shortRepPrice;
+ nextOptimum.PosPrev = cur;
+ nextOptimum.MakeAsShortRep();
+ nextIsChar = true;
+ }
+ }
+ /*
+ if(newLen == 2 && matchDistances[2] >= kDistLimit2) // test it maybe set 2000 ?
+ continue;
+ */
+
+ numAvailableBytesFull = MyMin(kNumOpts - 1 - cur, numAvailableBytesFull);
+ UInt32 numAvailableBytes = numAvailableBytesFull;
+
+ if (numAvailableBytes < 2)
+ continue;
+ if (numAvailableBytes > _numFastBytes)
+ numAvailableBytes = _numFastBytes;
+ if (!nextIsChar && matchByte != currentByte) // speed optimization
+ {
+ // try Literal + rep0
+ UInt32 backOffset = reps[0] + 1;
+ UInt32 limit = MyMin(numAvailableBytesFull, _numFastBytes + 1);
+ UInt32 temp;
+ for (temp = 1; temp < limit &&
+ data[temp] == data[(size_t)temp - backOffset]; temp++);
+ UInt32 lenTest2 = temp - 1;
+ if (lenTest2 >= 2)
+ {
+ CState state2 = state;
+ state2.UpdateChar();
+ UInt32 posStateNext = (position + 1) & _posStateMask;
+ UInt32 nextRepMatchPrice = curAnd1Price +
+ _isMatch[state2.Index][posStateNext].GetPrice1() +
+ _isRep[state2.Index].GetPrice1();
+ // for (; lenTest2 >= 2; lenTest2--)
+ {
+ UInt32 offset = cur + 1 + lenTest2;
+ while(lenEnd < offset)
+ _optimum[++lenEnd].Price = kIfinityPrice;
+ UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(
+ 0, lenTest2, state2, posStateNext);
+ COptimal &optimum = _optimum[offset];
+ if (curAndLenPrice < optimum.Price)
+ {
+ optimum.Price = curAndLenPrice;
+ optimum.PosPrev = cur + 1;
+ optimum.BackPrev = 0;
+ optimum.Prev1IsChar = true;
+ optimum.Prev2 = false;
+ }
+ }
+ }
+ }
+
+ UInt32 startLen = 2; // speed optimization
+ for(UInt32 repIndex = 0; repIndex < kNumRepDistances; repIndex++)
+ {
+ // UInt32 repLen = _matchFinder.GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;
+ UInt32 backOffset = reps[repIndex] + 1;
+ if (data[0] != data[(size_t)0 - backOffset] ||
+ data[1] != data[(size_t)1 - backOffset])
+ continue;
+ UInt32 lenTest;
+ for (lenTest = 2; lenTest < numAvailableBytes &&
+ data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
+ while(lenEnd < cur + lenTest)
+ _optimum[++lenEnd].Price = kIfinityPrice;
+ UInt32 lenTestTemp = lenTest;
+ UInt32 price = repMatchPrice + GetPureRepPrice(repIndex, state, posState);
+ do
+ {
+ UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState);
+ COptimal &optimum = _optimum[cur + lenTest];
+ if (curAndLenPrice < optimum.Price)
+ {
+ optimum.Price = curAndLenPrice;
+ optimum.PosPrev = cur;
+ optimum.BackPrev = repIndex;
+ optimum.Prev1IsChar = false;
+ }
+ }
+ while(--lenTest >= 2);
+ lenTest = lenTestTemp;
+
+ if (repIndex == 0)
+ startLen = lenTest + 1;
+
+ // if (_maxMode)
+ {
+ UInt32 lenTest2 = lenTest + 1;
+ UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
+ for (; lenTest2 < limit &&
+ data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
+ lenTest2 -= lenTest + 1;
+ if (lenTest2 >= 2)
+ {
+ CState state2 = state;
+ state2.UpdateRep();
+ UInt32 posStateNext = (position + lenTest) & _posStateMask;
+ UInt32 curAndLenCharPrice =
+ price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState) +
+ _isMatch[state2.Index][posStateNext].GetPrice0() +
+ _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(
+ true, data[(size_t)lenTest - backOffset], data[lenTest]);
+ state2.UpdateChar();
+ posStateNext = (position + lenTest + 1) & _posStateMask;
+ UInt32 nextRepMatchPrice = curAndLenCharPrice +
+ _isMatch[state2.Index][posStateNext].GetPrice1() +
+ _isRep[state2.Index].GetPrice1();
+
+ // for(; lenTest2 >= 2; lenTest2--)
+ {
+ UInt32 offset = cur + lenTest + 1 + lenTest2;
+ while(lenEnd < offset)
+ _optimum[++lenEnd].Price = kIfinityPrice;
+ UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(
+ 0, lenTest2, state2, posStateNext);
+ COptimal &optimum = _optimum[offset];
+ if (curAndLenPrice < optimum.Price)
+ {
+ optimum.Price = curAndLenPrice;
+ optimum.PosPrev = cur + lenTest + 1;
+ optimum.BackPrev = 0;
+ optimum.Prev1IsChar = true;
+ optimum.Prev2 = true;
+ optimum.PosPrev2 = cur;
+ optimum.BackPrev2 = repIndex;
+ }
+ }
+ }
+ }
+ }
+
+ // for(UInt32 lenTest = 2; lenTest <= newLen; lenTest++)
+ if (newLen > numAvailableBytes)
+ {
+ newLen = numAvailableBytes;
+ for (numDistancePairs = 0; newLen > matchDistances[numDistancePairs]; numDistancePairs += 2);
+ matchDistances[numDistancePairs] = newLen;
+ numDistancePairs += 2;
+ }
+ if (newLen >= startLen)
+ {
+ UInt32 normalMatchPrice = matchPrice + _isRep[state.Index].GetPrice0();
+ while(lenEnd < cur + newLen)
+ _optimum[++lenEnd].Price = kIfinityPrice;
+
+ UInt32 offs = 0;
+ while(startLen > matchDistances[offs])
+ offs += 2;
+ UInt32 curBack = matchDistances[offs + 1];
+ UInt32 posSlot = GetPosSlot2(curBack);
+ for(UInt32 lenTest = /*2*/ startLen; ; lenTest++)
+ {
+ UInt32 curAndLenPrice = normalMatchPrice;
+ UInt32 lenToPosState = GetLenToPosState(lenTest);
+ if (curBack < kNumFullDistances)
+ curAndLenPrice += _distancesPrices[lenToPosState][curBack];
+ else
+ curAndLenPrice += _posSlotPrices[lenToPosState][posSlot] + _alignPrices[curBack & kAlignMask];
+
+ curAndLenPrice += _lenEncoder.GetPrice(lenTest - kMatchMinLen, posState);
+
+ COptimal &optimum = _optimum[cur + lenTest];
+ if (curAndLenPrice < optimum.Price)
+ {
+ optimum.Price = curAndLenPrice;
+ optimum.PosPrev = cur;
+ optimum.BackPrev = curBack + kNumRepDistances;
+ optimum.Prev1IsChar = false;
+ }
+
+ if (/*_maxMode && */lenTest == matchDistances[offs])
+ {
+ // Try Match + Literal + Rep0
+ UInt32 backOffset = curBack + 1;
+ UInt32 lenTest2 = lenTest + 1;
+ UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
+ for (; lenTest2 < limit &&
+ data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
+ lenTest2 -= lenTest + 1;
+ if (lenTest2 >= 2)
+ {
+ CState state2 = state;
+ state2.UpdateMatch();
+ UInt32 posStateNext = (position + lenTest) & _posStateMask;
+ UInt32 curAndLenCharPrice = curAndLenPrice +
+ _isMatch[state2.Index][posStateNext].GetPrice0() +
+ _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(
+ true, data[(size_t)lenTest - backOffset], data[lenTest]);
+ state2.UpdateChar();
+ posStateNext = (posStateNext + 1) & _posStateMask;
+ UInt32 nextRepMatchPrice = curAndLenCharPrice +
+ _isMatch[state2.Index][posStateNext].GetPrice1() +
+ _isRep[state2.Index].GetPrice1();
+
+ // for(; lenTest2 >= 2; lenTest2--)
+ {
+ UInt32 offset = cur + lenTest + 1 + lenTest2;
+ while(lenEnd < offset)
+ _optimum[++lenEnd].Price = kIfinityPrice;
+ UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext);
+ COptimal &optimum = _optimum[offset];
+ if (curAndLenPrice < optimum.Price)
+ {
+ optimum.Price = curAndLenPrice;
+ optimum.PosPrev = cur + lenTest + 1;
+ optimum.BackPrev = 0;
+ optimum.Prev1IsChar = true;
+ optimum.Prev2 = true;
+ optimum.PosPrev2 = cur;
+ optimum.BackPrev2 = curBack + kNumRepDistances;
+ }
+ }
+ }
+ offs += 2;
+ if (offs == numDistancePairs)
+ break;
+ curBack = matchDistances[offs + 1];
+ if (curBack >= kNumFullDistances)
+ posSlot = GetPosSlot2(curBack);
+ }
+ }
+ }
+ }
+}
+
+static inline bool ChangePair(UInt32 smallDist, UInt32 bigDist)
+{
+ return ((bigDist >> 7) > smallDist);
+}
+
+UInt32 CEncoder::ReadMatchDistances(UInt32 &numDistancePairs)
+{
+ UInt32 lenRes = 0;
+ numDistancePairs = _matchFinder.GetMatches(_matchFinderObj, _matchDistances);
+ #ifdef SHOW_STAT
+ printf("\n i = %d numPairs = %d ", ttt, numDistancePairs / 2);
+ if (ttt >= 61994)
+ ttt = ttt;
+
+ ttt++;
+ for (UInt32 i = 0; i < numDistancePairs; i += 2)
+ printf("%2d %6d | ", _matchDistances[i], _matchDistances[i + 1]);
+ #endif
+ if (numDistancePairs > 0)
+ {
+ lenRes = _matchDistances[numDistancePairs - 2];
+ if (lenRes == _numFastBytes)
+ {
+ UInt32 numAvail = _matchFinder.GetNumAvailableBytes(_matchFinderObj) + 1;
+ const Byte *pby = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
+ UInt32 distance = _matchDistances[numDistancePairs - 1] + 1;
+ if (numAvail > kMatchMaxLen)
+ numAvail = kMatchMaxLen;
+ for (; lenRes < numAvail && pby[lenRes] == pby[(size_t)lenRes - distance]; lenRes++);
+ }
+ }
+ _additionalOffset++;
+ return lenRes;
+}
+
+UInt32 CEncoder::GetOptimumFast(UInt32 &backRes)
+{
+ UInt32 numAvailableBytes = _matchFinder.GetNumAvailableBytes(_matchFinderObj);
+ UInt32 lenMain, numDistancePairs;
+ if (!_longestMatchWasFound)
+ {
+ lenMain = ReadMatchDistances(numDistancePairs);
+ }
+ else
+ {
+ lenMain = _longestMatchLength;
+ numDistancePairs = _numDistancePairs;
+ _longestMatchWasFound = false;
+ }
+
+ const Byte *data = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
+ if (numAvailableBytes > kMatchMaxLen)
+ numAvailableBytes = kMatchMaxLen;
+ if (numAvailableBytes < 2)
+ {
+ backRes = (UInt32)(-1);
+ return 1;
+ }
+
+ UInt32 repLens[kNumRepDistances];
+ UInt32 repMaxIndex = 0;
+
+ for(UInt32 i = 0; i < kNumRepDistances; i++)
+ {
+ UInt32 backOffset = _repDistances[i] + 1;
+ if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
+ {
+ repLens[i] = 0;
+ continue;
+ }
+ UInt32 len;
+ for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
+ if(len >= _numFastBytes)
+ {
+ backRes = i;
+ MovePos(len - 1);
+ return len;
+ }
+ repLens[i] = len;
+ if (len > repLens[repMaxIndex])
+ repMaxIndex = i;
+ }
+ UInt32 *matchDistances = _matchDistances;
+ if(lenMain >= _numFastBytes)
+ {
+ backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances;
+ MovePos(lenMain - 1);
+ return lenMain;
+ }
+
+ UInt32 backMain = 0; // for GCC
+ if (lenMain >= 2)
+ {
+ backMain = matchDistances[numDistancePairs - 1];
+ while (numDistancePairs > 2 && lenMain == matchDistances[numDistancePairs - 4] + 1)
+ {
+ if (!ChangePair(matchDistances[numDistancePairs - 3], backMain))
+ break;
+ numDistancePairs -= 2;
+ lenMain = matchDistances[numDistancePairs - 2];
+ backMain = matchDistances[numDistancePairs - 1];
+ }
+ if (lenMain == 2 && backMain >= 0x80)
+ lenMain = 1;
+ }
+
+ if (repLens[repMaxIndex] >= 2)
+ {
+ if (repLens[repMaxIndex] + 1 >= lenMain ||
+ repLens[repMaxIndex] + 2 >= lenMain && (backMain > (1 << 9)) ||
+ repLens[repMaxIndex] + 3 >= lenMain && (backMain > (1 << 15)))
+ {
+ backRes = repMaxIndex;
+ UInt32 lenRes = repLens[repMaxIndex];
+ MovePos(lenRes - 1);
+ return lenRes;
+ }
+ }
+
+ if (lenMain >= 2 && numAvailableBytes > 2)
+ {
+ numAvailableBytes = _matchFinder.GetNumAvailableBytes(_matchFinderObj);
+ _longestMatchLength = ReadMatchDistances(_numDistancePairs);
+ if (_longestMatchLength >= 2)
+ {
+ UInt32 newDistance = matchDistances[_numDistancePairs - 1];
+ if (_longestMatchLength >= lenMain && newDistance < backMain ||
+ _longestMatchLength == lenMain + 1 && !ChangePair(backMain, newDistance) ||
+ _longestMatchLength > lenMain + 1 ||
+ _longestMatchLength + 1 >= lenMain && lenMain >= 3 && ChangePair(newDistance, backMain))
+ {
+ _longestMatchWasFound = true;
+ backRes = UInt32(-1);
+ return 1;
+ }
+ }
+ data = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
+ for(UInt32 i = 0; i < kNumRepDistances; i++)
+ {
+ UInt32 backOffset = _repDistances[i] + 1;
+ if (data[1] != data[(size_t)1 - backOffset] || data[2] != data[(size_t)2 - backOffset])
+ {
+ repLens[i] = 0;
+ continue;
+ }
+ UInt32 len;
+ for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
+ if (len + 1 >= lenMain)
+ {
+ _longestMatchWasFound = true;
+ backRes = UInt32(-1);
+ return 1;
+ }
+ }
+ backRes = backMain + kNumRepDistances;
+ MovePos(lenMain - 2);
+ return lenMain;
+ }
+ backRes = UInt32(-1);
+ return 1;
+}
+
+HRESULT CEncoder::Flush(UInt32 nowPos)
+{
+ // ReleaseMFStream();
+ if (_matchFinderBase.result != SZ_OK)
+ return _matchFinderBase.result;
+ WriteEndMarker(nowPos & _posStateMask);
+ _rangeEncoder.FlushData();
+ return _rangeEncoder.FlushStream();
+}
+
+void CEncoder::WriteEndMarker(UInt32 posState)
+{
+ // This function for writing End Mark for stream version of LZMA.
+ // In current version this feature is not used.
+ if (!_writeEndMark)
+ return;
+
+ _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);
+ _isRep[_state.Index].Encode(&_rangeEncoder, 0);
+ _state.UpdateMatch();
+ UInt32 len = kMatchMinLen; // kMatchMaxLen;
+ _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
+ UInt32 posSlot = (1 << kNumPosSlotBits) - 1;
+ UInt32 lenToPosState = GetLenToPosState(len);
+ _posSlotEncoder[lenToPosState].Encode(&_rangeEncoder, posSlot);
+ UInt32 footerBits = 30;
+ UInt32 posReduced = (UInt32(1) << footerBits) - 1;
+ _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
+ _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);
+}
+
+HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ // _needReleaseMFStream = false;
+ CCoderReleaser coderReleaser(this);
+ RINOK(SetStreams(inStream, outStream, inSize, outSize));
+ for (;;)
+ {
+ UInt64 processedInSize;
+ UInt64 processedOutSize;
+ Int32 finished;
+ RINOK(CodeOneBlock(&processedInSize, &processedOutSize, &finished));
+ if (finished != 0)
+ break;
+ if (progress != 0)
+ {
+ RINOK(progress->SetRatioInfo(&processedInSize, &processedOutSize));
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CEncoder::SetStreams(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 * /* outSize */)
+{
+ _inStream = inStream;
+ _finished = false;
+ RINOK(Create());
+ RINOK(SetOutStream(outStream));
+ RINOK(Init());
+
+ if (!_fastMode)
+ {
+ FillDistancesPrices();
+ FillAlignPrices();
+ }
+
+ _lenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
+ _lenEncoder.UpdateTables(1 << _posStateBits);
+ _repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
+ _repMatchLenEncoder.UpdateTables(1 << _posStateBits);
+
+ nowPos64 = 0;
+ return S_OK;
+}
+
+static HRes MyRead(void *object, void *data, UInt32 size, UInt32 *processedSize)
+{
+ return (HRes)((CSeqInStream *)object)->RealStream->Read(data, size, processedSize);
+}
+
+HRESULT CEncoder::CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished)
+{
+ if (_inStream != 0)
+ {
+ _seqInStream.RealStream = _inStream;
+ _seqInStream.SeqInStream.Read = MyRead;
+ _matchFinderBase.stream = &_seqInStream.SeqInStream;
+ _matchFinder.Init(_matchFinderObj);
+ _needReleaseMFStream = true;
+ _inStream = 0;
+ }
+
+
+ *finished = 1;
+ if (_finished)
+ return _matchFinderBase.result;
+ _finished = true;
+
+ if (nowPos64 == 0)
+ {
+ if (_matchFinder.GetNumAvailableBytes(_matchFinderObj) == 0)
+ return Flush((UInt32)nowPos64);
+ UInt32 len, numDistancePairs;
+ len = ReadMatchDistances(numDistancePairs);
+ UInt32 posState = UInt32(nowPos64) & _posStateMask;
+ _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);
+ _state.UpdateChar();
+ Byte curByte = _matchFinder.GetIndexByte(_matchFinderObj, 0 - _additionalOffset);
+ _literalEncoder.GetSubCoder(UInt32(nowPos64), _previousByte)->Encode(&_rangeEncoder, curByte);
+ _previousByte = curByte;
+ _additionalOffset--;
+ nowPos64++;
+ }
+
+ UInt32 nowPos32 = (UInt32)nowPos64;
+ UInt32 progressPosValuePrev = nowPos32;
+
+ if (_matchFinder.GetNumAvailableBytes(_matchFinderObj) == 0)
+ return Flush(nowPos32);
+
+ for (;;)
+ {
+ #ifdef _NO_EXCEPTIONS
+ if (_rangeEncoder.Stream.ErrorCode != S_OK)
+ return _rangeEncoder.Stream.ErrorCode;
+ #endif
+ UInt32 pos, len;
+
+ if (_fastMode)
+ len = GetOptimumFast(pos);
+ else
+ len = GetOptimum(nowPos32, pos);
+
+ UInt32 posState = nowPos32 & _posStateMask;
+ if(len == 1 && pos == 0xFFFFFFFF)
+ {
+ _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);
+ Byte curByte = _matchFinder.GetIndexByte(_matchFinderObj, 0 - _additionalOffset);
+ CLiteralEncoder2 *subCoder = _literalEncoder.GetSubCoder(nowPos32, _previousByte);
+ if(_state.IsCharState())
+ subCoder->Encode(&_rangeEncoder, curByte);
+ else
+ {
+ Byte matchByte = _matchFinder.GetIndexByte(_matchFinderObj, 0 - _repDistances[0] - 1 - _additionalOffset);
+ subCoder->EncodeMatched(&_rangeEncoder, matchByte, curByte);
+ }
+ _state.UpdateChar();
+ _previousByte = curByte;
+ }
+ else
+ {
+ _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);
+ if(pos < kNumRepDistances)
+ {
+ _isRep[_state.Index].Encode(&_rangeEncoder, 1);
+ if(pos == 0)
+ {
+ _isRepG0[_state.Index].Encode(&_rangeEncoder, 0);
+ _isRep0Long[_state.Index][posState].Encode(&_rangeEncoder, ((len == 1) ? 0 : 1));
+ }
+ else
+ {
+ UInt32 distance = _repDistances[pos];
+ _isRepG0[_state.Index].Encode(&_rangeEncoder, 1);
+ if (pos == 1)
+ _isRepG1[_state.Index].Encode(&_rangeEncoder, 0);
+ else
+ {
+ _isRepG1[_state.Index].Encode(&_rangeEncoder, 1);
+ _isRepG2[_state.Index].Encode(&_rangeEncoder, pos - 2);
+ if (pos == 3)
+ _repDistances[3] = _repDistances[2];
+ _repDistances[2] = _repDistances[1];
+ }
+ _repDistances[1] = _repDistances[0];
+ _repDistances[0] = distance;
+ }
+ if (len == 1)
+ _state.UpdateShortRep();
+ else
+ {
+ _repMatchLenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
+ _state.UpdateRep();
+ }
+ }
+ else
+ {
+ _isRep[_state.Index].Encode(&_rangeEncoder, 0);
+ _state.UpdateMatch();
+ _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
+ pos -= kNumRepDistances;
+ UInt32 posSlot = GetPosSlot(pos);
+ _posSlotEncoder[GetLenToPosState(len)].Encode(&_rangeEncoder, posSlot);
+
+ if (posSlot >= kStartPosModelIndex)
+ {
+ UInt32 footerBits = ((posSlot >> 1) - 1);
+ UInt32 base = ((2 | (posSlot & 1)) << footerBits);
+ UInt32 posReduced = pos - base;
+
+ if (posSlot < kEndPosModelIndex)
+ NRangeCoder::ReverseBitTreeEncode(_posEncoders + base - posSlot - 1,
+ &_rangeEncoder, footerBits, posReduced);
+ else
+ {
+ _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
+ _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);
+ _alignPriceCount++;
+ }
+ }
+ _repDistances[3] = _repDistances[2];
+ _repDistances[2] = _repDistances[1];
+ _repDistances[1] = _repDistances[0];
+ _repDistances[0] = pos;
+ _matchPriceCount++;
+ }
+ _previousByte = _matchFinder.GetIndexByte(_matchFinderObj, len - 1 - _additionalOffset);
+ }
+ _additionalOffset -= len;
+ nowPos32 += len;
+ if (_additionalOffset == 0)
+ {
+ if (!_fastMode)
+ {
+ if (_matchPriceCount >= (1 << 7))
+ FillDistancesPrices();
+ if (_alignPriceCount >= kAlignTableSize)
+ FillAlignPrices();
+ }
+ if (_matchFinder.GetNumAvailableBytes(_matchFinderObj) == 0)
+ return Flush(nowPos32);
+ if (nowPos32 - progressPosValuePrev >= (1 << 14))
+ {
+ nowPos64 += nowPos32 - progressPosValuePrev;
+ *inSize = nowPos64;
+ *outSize = _rangeEncoder.GetProcessedSize();
+ _finished = false;
+ *finished = 0;
+ return _matchFinderBase.result;
+ }
+ }
+ }
+}
+
+STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ #ifndef _NO_EXCEPTIONS
+ try
+ {
+ #endif
+ return CodeReal(inStream, outStream, inSize, outSize, progress);
+ #ifndef _NO_EXCEPTIONS
+ }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return E_FAIL; }
+ #endif
+}
+
+void CEncoder::FillDistancesPrices()
+{
+ UInt32 tempPrices[kNumFullDistances];
+ for (UInt32 i = kStartPosModelIndex; i < kNumFullDistances; i++)
+ {
+ UInt32 posSlot = GetPosSlot(i);
+ UInt32 footerBits = ((posSlot >> 1) - 1);
+ UInt32 base = ((2 | (posSlot & 1)) << footerBits);
+ tempPrices[i] = NRangeCoder::ReverseBitTreeGetPrice(_posEncoders +
+ base - posSlot - 1, footerBits, i - base);
+ }
+
+ for (UInt32 lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
+ {
+ UInt32 posSlot;
+ NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> &encoder = _posSlotEncoder[lenToPosState];
+ UInt32 *posSlotPrices = _posSlotPrices[lenToPosState];
+ for (posSlot = 0; posSlot < _distTableSize; posSlot++)
+ posSlotPrices[posSlot] = encoder.GetPrice(posSlot);
+ for (posSlot = kEndPosModelIndex; posSlot < _distTableSize; posSlot++)
+ posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << NRangeCoder::kNumBitPriceShiftBits);
+
+ UInt32 *distancesPrices = _distancesPrices[lenToPosState];
+ UInt32 i;
+ for (i = 0; i < kStartPosModelIndex; i++)
+ distancesPrices[i] = posSlotPrices[i];
+ for (; i < kNumFullDistances; i++)
+ distancesPrices[i] = posSlotPrices[GetPosSlot(i)] + tempPrices[i];
+ }
+ _matchPriceCount = 0;
+}
+
+void CEncoder::FillAlignPrices()
+{
+ for (UInt32 i = 0; i < kAlignTableSize; i++)
+ _alignPrices[i] = _posAlignEncoder.ReverseGetPrice(i);
+ _alignPriceCount = 0;
+}
+
+}}
diff --git a/CPP/7zip/Compress/LZMA/LZMAEncoder.h b/CPP/7zip/Compress/LZMA/LZMAEncoder.h
new file mode 100755
index 00000000..c1dc7a69
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA/LZMAEncoder.h
@@ -0,0 +1,435 @@
+// LZMA/Encoder.h
+
+#ifndef __LZMA_ENCODER_H
+#define __LZMA_ENCODER_H
+
+#include "../../../Common/MyCom.h"
+#include "../../../Common/Alloc.h"
+#include "../../ICoder.h"
+
+extern "C"
+{
+ #include "../../../../C/Compress/Lz/MatchFinder.h"
+ #ifdef COMPRESS_MF_MT
+ #include "../../../../C/Compress/Lz/MatchFinderMt.h"
+ #endif
+}
+
+#include "../RangeCoder/RangeCoderBitTree.h"
+
+#include "LZMA.h"
+
+namespace NCompress {
+namespace NLZMA {
+
+typedef NRangeCoder::CBitEncoder<kNumMoveBits> CMyBitEncoder;
+
+class CBaseState
+{
+protected:
+ CState _state;
+ Byte _previousByte;
+ UInt32 _repDistances[kNumRepDistances];
+ void Init()
+ {
+ _state.Init();
+ _previousByte = 0;
+ for(UInt32 i = 0 ; i < kNumRepDistances; i++)
+ _repDistances[i] = 0;
+ }
+};
+
+struct COptimal
+{
+ CState State;
+
+ bool Prev1IsChar;
+ bool Prev2;
+
+ UInt32 PosPrev2;
+ UInt32 BackPrev2;
+
+ UInt32 Price;
+ UInt32 PosPrev; // posNext;
+ UInt32 BackPrev;
+ UInt32 Backs[kNumRepDistances];
+ void MakeAsChar() { BackPrev = UInt32(-1); Prev1IsChar = false; }
+ void MakeAsShortRep() { BackPrev = 0; ; Prev1IsChar = false; }
+ bool IsShortRep() { return (BackPrev == 0); }
+};
+
+
+extern Byte g_FastPos[1 << 11];
+inline UInt32 GetPosSlot(UInt32 pos)
+{
+ if (pos < (1 << 11))
+ return g_FastPos[pos];
+ if (pos < (1 << 21))
+ return g_FastPos[pos >> 10] + 20;
+ return g_FastPos[pos >> 20] + 40;
+}
+
+inline UInt32 GetPosSlot2(UInt32 pos)
+{
+ if (pos < (1 << 17))
+ return g_FastPos[pos >> 6] + 12;
+ if (pos < (1 << 27))
+ return g_FastPos[pos >> 16] + 32;
+ return g_FastPos[pos >> 26] + 52;
+}
+
+const UInt32 kIfinityPrice = 0xFFFFFFF;
+
+const UInt32 kNumOpts = 1 << 12;
+
+
+class CLiteralEncoder2
+{
+ CMyBitEncoder _encoders[0x300];
+public:
+ void Init()
+ {
+ for (int i = 0; i < 0x300; i++)
+ _encoders[i].Init();
+ }
+ void Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol);
+ void EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, Byte matchByte, Byte symbol);
+ UInt32 GetPrice(bool matchMode, Byte matchByte, Byte symbol) const;
+};
+
+class CLiteralEncoder
+{
+ CLiteralEncoder2 *_coders;
+ int _numPrevBits;
+ int _numPosBits;
+ UInt32 _posMask;
+public:
+ CLiteralEncoder(): _coders(0) {}
+ ~CLiteralEncoder() { Free(); }
+ void Free()
+ {
+ MyFree(_coders);
+ _coders = 0;
+ }
+ bool Create(int numPosBits, int numPrevBits)
+ {
+ if (_coders == 0 || (numPosBits + numPrevBits) != (_numPrevBits + _numPosBits))
+ {
+ Free();
+ UInt32 numStates = 1 << (numPosBits + numPrevBits);
+ _coders = (CLiteralEncoder2 *)MyAlloc(numStates * sizeof(CLiteralEncoder2));
+ }
+ _numPosBits = numPosBits;
+ _posMask = (1 << numPosBits) - 1;
+ _numPrevBits = numPrevBits;
+ return (_coders != 0);
+ }
+ void Init()
+ {
+ UInt32 numStates = 1 << (_numPrevBits + _numPosBits);
+ for (UInt32 i = 0; i < numStates; i++)
+ _coders[i].Init();
+ }
+ CLiteralEncoder2 *GetSubCoder(UInt32 pos, Byte prevByte)
+ { return &_coders[((pos & _posMask) << _numPrevBits) + (prevByte >> (8 - _numPrevBits))]; }
+};
+
+namespace NLength {
+
+class CEncoder
+{
+ CMyBitEncoder _choice;
+ CMyBitEncoder _choice2;
+ NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumLowBits> _lowCoder[kNumPosStatesEncodingMax];
+ NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumMidBits> _midCoder[kNumPosStatesEncodingMax];
+ NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumHighBits> _highCoder;
+public:
+ void Init(UInt32 numPosStates);
+ void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState);
+ void SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const;
+};
+
+const UInt32 kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols;
+
+class CPriceTableEncoder: public CEncoder
+{
+ UInt32 _prices[kNumPosStatesEncodingMax][kNumSymbolsTotal];
+ UInt32 _tableSize;
+ UInt32 _counters[kNumPosStatesEncodingMax];
+public:
+ void SetTableSize(UInt32 tableSize) { _tableSize = tableSize; }
+ UInt32 GetPrice(UInt32 symbol, UInt32 posState) const { return _prices[posState][symbol]; }
+ void UpdateTable(UInt32 posState)
+ {
+ SetPrices(posState, _tableSize, _prices[posState]);
+ _counters[posState] = _tableSize;
+ }
+ void UpdateTables(UInt32 numPosStates)
+ {
+ for (UInt32 posState = 0; posState < numPosStates; posState++)
+ UpdateTable(posState);
+ }
+ void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState, bool updatePrice)
+ {
+ CEncoder::Encode(rangeEncoder, symbol, posState);
+ if (updatePrice)
+ if (--_counters[posState] == 0)
+ UpdateTable(posState);
+ }
+};
+
+}
+
+typedef struct _CSeqInStream
+{
+ ISeqInStream SeqInStream;
+ CMyComPtr<ISequentialInStream> RealStream;
+} CSeqInStream;
+
+
+class CEncoder :
+ public ICompressCoder,
+ public ICompressSetOutStream,
+ public ICompressSetCoderProperties,
+ public ICompressWriteCoderProperties,
+ public CBaseState,
+ public CMyUnknownImp
+{
+ NRangeCoder::CEncoder _rangeEncoder;
+
+ IMatchFinder _matchFinder;
+ void *_matchFinderObj;
+
+ #ifdef COMPRESS_MF_MT
+ Bool _multiThread;
+ Bool _mtMode;
+ CMatchFinderMt _matchFinderMt;
+ #endif
+
+ CMatchFinder _matchFinderBase;
+ #ifdef COMPRESS_MF_MT
+ Byte _pad1[kMtCacheLineDummy];
+ #endif
+
+ COptimal _optimum[kNumOpts];
+
+ CMyBitEncoder _isMatch[kNumStates][NLength::kNumPosStatesEncodingMax];
+ CMyBitEncoder _isRep[kNumStates];
+ CMyBitEncoder _isRepG0[kNumStates];
+ CMyBitEncoder _isRepG1[kNumStates];
+ CMyBitEncoder _isRepG2[kNumStates];
+ CMyBitEncoder _isRep0Long[kNumStates][NLength::kNumPosStatesEncodingMax];
+
+ NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> _posSlotEncoder[kNumLenToPosStates];
+
+ CMyBitEncoder _posEncoders[kNumFullDistances - kEndPosModelIndex];
+ NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumAlignBits> _posAlignEncoder;
+
+ NLength::CPriceTableEncoder _lenEncoder;
+ NLength::CPriceTableEncoder _repMatchLenEncoder;
+
+ CLiteralEncoder _literalEncoder;
+
+ UInt32 _matchDistances[kMatchMaxLen * 2 + 2 + 1];
+
+ bool _fastMode;
+ // bool _maxMode;
+ UInt32 _numFastBytes;
+ UInt32 _longestMatchLength;
+ UInt32 _numDistancePairs;
+
+ UInt32 _additionalOffset;
+
+ UInt32 _optimumEndIndex;
+ UInt32 _optimumCurrentIndex;
+
+ bool _longestMatchWasFound;
+
+ UInt32 _posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
+
+ UInt32 _distancesPrices[kNumLenToPosStates][kNumFullDistances];
+
+ UInt32 _alignPrices[kAlignTableSize];
+ UInt32 _alignPriceCount;
+
+ UInt32 _distTableSize;
+
+ UInt32 _posStateBits;
+ UInt32 _posStateMask;
+ UInt32 _numLiteralPosStateBits;
+ UInt32 _numLiteralContextBits;
+
+ UInt32 _dictionarySize;
+
+ UInt32 _matchPriceCount;
+ UInt64 nowPos64;
+ bool _finished;
+ ISequentialInStream *_inStream;
+
+ CSeqInStream _seqInStream;
+
+ UInt32 _matchFinderCycles;
+ // int _numSkip
+
+ bool _writeEndMark;
+
+ bool _needReleaseMFStream;
+
+ void ReleaseMatchFinder()
+ {
+ _matchFinder.Init = 0;
+ _seqInStream.RealStream.Release();
+ }
+
+ void ReleaseMFStream()
+ {
+ if (_matchFinderObj && _needReleaseMFStream)
+ {
+ #ifdef COMPRESS_MF_MT
+ if (_mtMode)
+ MatchFinderMt_ReleaseStream(&_matchFinderMt);
+ #endif
+ _needReleaseMFStream = false;
+ }
+ _seqInStream.RealStream.Release();
+ }
+
+ UInt32 ReadMatchDistances(UInt32 &numDistancePairs);
+
+ void MovePos(UInt32 num);
+ UInt32 GetRepLen1Price(CState state, UInt32 posState) const
+ {
+ return _isRepG0[state.Index].GetPrice0() +
+ _isRep0Long[state.Index][posState].GetPrice0();
+ }
+
+ UInt32 GetPureRepPrice(UInt32 repIndex, CState state, UInt32 posState) const
+ {
+ UInt32 price;
+ if(repIndex == 0)
+ {
+ price = _isRepG0[state.Index].GetPrice0();
+ price += _isRep0Long[state.Index][posState].GetPrice1();
+ }
+ else
+ {
+ price = _isRepG0[state.Index].GetPrice1();
+ if (repIndex == 1)
+ price += _isRepG1[state.Index].GetPrice0();
+ else
+ {
+ price += _isRepG1[state.Index].GetPrice1();
+ price += _isRepG2[state.Index].GetPrice(repIndex - 2);
+ }
+ }
+ return price;
+ }
+ UInt32 GetRepPrice(UInt32 repIndex, UInt32 len, CState state, UInt32 posState) const
+ {
+ return _repMatchLenEncoder.GetPrice(len - kMatchMinLen, posState) +
+ GetPureRepPrice(repIndex, state, posState);
+ }
+ /*
+ UInt32 GetPosLen2Price(UInt32 pos, UInt32 posState) const
+ {
+ if (pos >= kNumFullDistances)
+ return kIfinityPrice;
+ return _distancesPrices[0][pos] + _lenEncoder.GetPrice(0, posState);
+ }
+ UInt32 GetPosLen3Price(UInt32 pos, UInt32 len, UInt32 posState) const
+ {
+ UInt32 price;
+ UInt32 lenToPosState = GetLenToPosState(len);
+ if (pos < kNumFullDistances)
+ price = _distancesPrices[lenToPosState][pos];
+ else
+ price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] +
+ _alignPrices[pos & kAlignMask];
+ return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
+ }
+ */
+ UInt32 GetPosLenPrice(UInt32 pos, UInt32 len, UInt32 posState) const
+ {
+ UInt32 price;
+ UInt32 lenToPosState = GetLenToPosState(len);
+ if (pos < kNumFullDistances)
+ price = _distancesPrices[lenToPosState][pos];
+ else
+ price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] +
+ _alignPrices[pos & kAlignMask];
+ return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
+ }
+
+ UInt32 Backward(UInt32 &backRes, UInt32 cur);
+ UInt32 GetOptimum(UInt32 position, UInt32 &backRes);
+ UInt32 GetOptimumFast(UInt32 &backRes);
+
+ void FillDistancesPrices();
+ void FillAlignPrices();
+
+ void ReleaseStreams()
+ {
+ ReleaseMFStream();
+ ReleaseOutStream();
+ }
+
+ HRESULT Flush(UInt32 nowPos);
+ class CCoderReleaser
+ {
+ CEncoder *_coder;
+ public:
+ CCoderReleaser(CEncoder *coder): _coder(coder) {}
+ ~CCoderReleaser() { _coder->ReleaseStreams(); }
+ };
+ friend class CCoderReleaser;
+
+ void WriteEndMarker(UInt32 posState);
+
+public:
+ CEncoder();
+ void SetWriteEndMarkerMode(bool writeEndMarker)
+ { _writeEndMark= writeEndMarker; }
+
+ HRESULT Create();
+
+ MY_UNKNOWN_IMP3(
+ ICompressSetOutStream,
+ ICompressSetCoderProperties,
+ ICompressWriteCoderProperties
+ )
+
+ HRESULT Init();
+
+ // ICompressCoder interface
+ HRESULT SetStreams(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize);
+ HRESULT CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished);
+
+ HRESULT CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ // ICompressCoder interface
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ // ICompressSetCoderProperties2
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ const PROPVARIANT *properties, UInt32 numProperties);
+
+ // ICompressWriteCoderProperties
+ STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+
+ STDMETHOD(SetOutStream)(ISequentialOutStream *outStream);
+ STDMETHOD(ReleaseOutStream)();
+
+ virtual ~CEncoder();
+};
+
+}}
+
+#endif
diff --git a/7zip/Compress/PPMD/StdAfx.cpp b/CPP/7zip/Compress/LZMA/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/PPMD/StdAfx.cpp
+++ b/CPP/7zip/Compress/LZMA/StdAfx.cpp
diff --git a/7zip/Compress/LZMA/StdAfx.h b/CPP/7zip/Compress/LZMA/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/LZMA/StdAfx.h
+++ b/CPP/7zip/Compress/LZMA/StdAfx.h
diff --git a/CPP/7zip/Compress/LZMA/makefile b/CPP/7zip/Compress/LZMA/makefile
new file mode 100755
index 00000000..0b692541
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA/makefile
@@ -0,0 +1,69 @@
+PROG = LZMA.dll
+DEF_FILE = ../Codec.def
+CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MF_MT -D_ST_MODE
+LIBS = $(LIBS) oleaut32.lib
+
+LZMA_OBJS = \
+ $O\DllExports.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+ $O\LZMAEncoder.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CRC.obj \
+
+WIN_OBJS = \
+ $O\Synchronization.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\OutBuffer.obj \
+ $O\StreamUtils.obj \
+
+LZ_OBJS = \
+ $O\LZOutWindow.obj \
+
+C_OBJS = \
+ $O\7zCrc.obj \
+ $O\Sort.obj \
+ $O\Threads.obj \
+
+C_LZ_OBJS = \
+ $O\MatchFinder.obj \
+ $O\MatchFinderMt.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(LZMA_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(LZ_OBJS) \
+ $(C_OBJS) \
+ $(C_LZ_OBJS) \
+ $O\RangeCoderBit.obj \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(LZMA_OBJS): $(*B).cpp
+ $(COMPL)
+$(LZMA_OPT_OBJS): $(*B).cpp
+ $(COMPL_O2)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(LZ_OBJS): ../LZ/$(*B).cpp
+ $(COMPL)
+$O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp
+ $(COMPL)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c
+ $(COMPL_O2)
diff --git a/7zip/Compress/LZMA/resource.rc b/CPP/7zip/Compress/LZMA/resource.rc
index 1b2b6abb..1b2b6abb 100755
--- a/7zip/Compress/LZMA/resource.rc
+++ b/CPP/7zip/Compress/LZMA/resource.rc
diff --git a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp
new file mode 100755
index 00000000..6401206c
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp
@@ -0,0 +1,449 @@
+# Microsoft Developer Studio Project File - Name="AloneLZMA" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=AloneLZMA - Win32 DebugU
+!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 "AloneLZMA.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 "AloneLZMA.mak" CFG="AloneLZMA - Win32 DebugU"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "AloneLZMA - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "AloneLZMA - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "AloneLZMA - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
+!MESSAGE "AloneLZMA - Win32 DebugU" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "AloneLZMA - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /c
+# 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 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 /subsystem:console /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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "AloneLZMA - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /GZ /c
+# 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 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 /subsystem:console /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "AloneLZMA - Win32 ReleaseU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseU"
+# PROP BASE Intermediate_Dir "ReleaseU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseU"
+# PROP Intermediate_Dir "ReleaseU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /c
+# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\7za2.exe" /opt:NOWIN98
+# SUBTRACT BASE LINK32 /pdb:none
+# 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 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 /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "AloneLZMA - Win32 DebugU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugU"
+# PROP BASE Intermediate_Dir "DebugU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugU"
+# PROP Intermediate_Dir "DebugU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /GZ /c
+# 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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za2.exe" /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 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 /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "AloneLZMA - Win32 Release"
+# Name "AloneLZMA - Win32 Debug"
+# Name "AloneLZMA - Win32 ReleaseU"
+# Name "AloneLZMA - Win32 DebugU"
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# 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 "Compress"
+
+# PROP Default_Filter ""
+# Begin Group "LZMA"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\LZMA\LZMA.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZMA\LZMADecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZMA\LZMADecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZMA\LZMAEncoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZMA\LZMAEncoder.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 "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
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileIO.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileIO.h
+# End Source File
+# End Group
+# Begin Group "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CommandLineParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CommandLineParser.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Defs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Defs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyCom.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyWindows.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\String.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.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
+# Begin Source File
+
+SOURCE=..\..\..\Common\Types.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.h
+# End Source File
+# End Group
+# Begin Group "7zip Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.h
+# End Source File
+# 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 "C"
+
+# PROP Default_Filter ""
+# Begin Group "C-Lz"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.h
+# End Source File
+# End Group
+# Begin Group "LZMA_C"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lzma\LzmaDecode.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lzma\LzmaDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Lzma\LzmaTypes.h
+# End Source File
+# End Group
+# Begin Group "Branch"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Branch\BranchTypes.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.h
+# End Source File
+# End Group
+# 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
+# End Group
+# Begin Source File
+
+SOURCE=..\..\ICoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\LzmaAlone.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\LzmaBench.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\LzmaBench.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\LzmaRam.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\LzmaRam.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\LzmaRamDecode.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=.\LzmaRamDecode.h
+# End Source File
+# End Target
+# End Project
diff --git a/7zip/Compress/LZMA_Alone/AloneLZMA.dsw b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsw
index d7482d8a..d7482d8a 100755
--- a/7zip/Compress/LZMA_Alone/AloneLZMA.dsw
+++ b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsw
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
new file mode 100755
index 00000000..f5ad65da
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
@@ -0,0 +1,526 @@
+// LzmaAlone.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Common/MyWindows.h"
+#include "../../../Common/MyInitGuid.h"
+
+#include <stdio.h>
+
+#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
+#include <fcntl.h>
+#include <io.h>
+#define MY_SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY)
+#else
+#define MY_SET_BINARY_MODE(file)
+#endif
+
+#include "../../../Common/CommandLineParser.h"
+#include "../../../Common/StringConvert.h"
+#include "../../../Common/StringToInt.h"
+
+#include "../../Common/FileStreams.h"
+#include "../../Common/StreamUtils.h"
+
+#include "../LZMA/LZMADecoder.h"
+#include "../LZMA/LZMAEncoder.h"
+
+#include "LzmaBench.h"
+#include "LzmaRam.h"
+
+extern "C"
+{
+#include "LzmaRamDecode.h"
+}
+
+using namespace NCommandLineParser;
+
+#ifdef _WIN32
+bool g_IsNT = false;
+static inline bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+
+static const char *kCantAllocate = "Can not allocate memory";
+static const char *kReadError = "Read error";
+static const char *kWriteError = "Write error";
+
+namespace NKey {
+enum Enum
+{
+ kHelp1 = 0,
+ kHelp2,
+ kMode,
+ kDictionary,
+ kFastBytes,
+ kMatchFinderCycles,
+ kLitContext,
+ kLitPos,
+ kPosBits,
+ kMatchFinder,
+ kEOS,
+ kStdIn,
+ kStdOut,
+ kFilter86
+};
+}
+
+static const CSwitchForm kSwitchForms[] =
+{
+ { L"?", NSwitchType::kSimple, false },
+ { L"H", NSwitchType::kSimple, false },
+ { L"A", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"D", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"FB", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"MC", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"LC", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"LP", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"PB", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"MF", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"EOS", NSwitchType::kSimple, false },
+ { L"SI", NSwitchType::kSimple, false },
+ { L"SO", NSwitchType::kSimple, false },
+ { L"F86", NSwitchType::kSimple, false }
+};
+
+static const int kNumSwitches = sizeof(kSwitchForms) / sizeof(kSwitchForms[0]);
+
+static void PrintHelp()
+{
+ fprintf(stderr, "\nUsage: LZMA <e|d> inputFile outputFile [<switches>...]\n"
+ " e: encode file\n"
+ " d: decode file\n"
+ " b: Benchmark\n"
+ "<Switches>\n"
+ " -a{N}: set compression mode - [0, 1], default: 1 (max)\n"
+ " -d{N}: set dictionary - [0,30], default: 23 (8MB)\n"
+ " -fb{N}: set number of fast bytes - [5, 273], default: 128\n"
+ " -mc{N}: set number of cycles for match finder\n"
+ " -lc{N}: set number of literal context bits - [0, 8], default: 3\n"
+ " -lp{N}: set number of literal pos bits - [0, 4], default: 0\n"
+ " -pb{N}: set number of pos bits - [0, 4], default: 2\n"
+ " -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, hc4], default: bt4\n"
+ " -eos: write End Of Stream marker\n"
+ " -si: read data from stdin\n"
+ " -so: write data to stdout\n"
+ );
+}
+
+static void PrintHelpAndExit(const char *s)
+{
+ fprintf(stderr, "\nError: %s\n\n", s);
+ PrintHelp();
+ throw -1;
+}
+
+static void IncorrectCommand()
+{
+ PrintHelpAndExit("Incorrect command");
+}
+
+static void WriteArgumentsToStringList(int numArguments, const char *arguments[],
+ UStringVector &strings)
+{
+ for(int i = 1; i < numArguments; i++)
+ strings.Add(MultiByteToUnicodeString(arguments[i]));
+}
+
+static bool GetNumber(const wchar_t *s, UInt32 &value)
+{
+ value = 0;
+ if (MyStringLen(s) == 0)
+ return false;
+ const wchar_t *end;
+ UInt64 res = ConvertStringToUInt64(s, &end);
+ if (*end != L'\0')
+ return false;
+ if (res > 0xFFFFFFFF)
+ return false;
+ value = UInt32(res);
+ return true;
+}
+
+int main2(int n, const char *args[])
+{
+ #ifdef _WIN32
+ g_IsNT = IsItWindowsNT();
+ #endif
+
+ fprintf(stderr, "\nLZMA 4.44 Copyright (c) 1999-2006 Igor Pavlov 2006-12-26\n");
+
+ if (n == 1)
+ {
+ PrintHelp();
+ return 0;
+ }
+
+ bool unsupportedTypes = (sizeof(Byte) != 1 || sizeof(UInt32) < 4 || sizeof(UInt64) < 4);
+ if (unsupportedTypes)
+ {
+ fprintf(stderr, "Unsupported base types. Edit Common/Types.h and recompile");
+ return 1;
+ }
+
+ UStringVector commandStrings;
+ WriteArgumentsToStringList(n, args, commandStrings);
+ CParser parser(kNumSwitches);
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
+ }
+ catch(...)
+ {
+ IncorrectCommand();
+ }
+
+ if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
+ {
+ PrintHelp();
+ return 0;
+ }
+ const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
+
+ int paramIndex = 0;
+ if (paramIndex >= nonSwitchStrings.Size())
+ IncorrectCommand();
+ const UString &command = nonSwitchStrings[paramIndex++];
+
+ bool dictionaryIsDefined = false;
+ UInt32 dictionary = 1 << 21;
+ if(parser[NKey::kDictionary].ThereIs)
+ {
+ UInt32 dicLog;
+ if (!GetNumber(parser[NKey::kDictionary].PostStrings[0], dicLog))
+ IncorrectCommand();
+ dictionary = 1 << dicLog;
+ dictionaryIsDefined = true;
+ }
+ UString mf = L"BT4";
+ if (parser[NKey::kMatchFinder].ThereIs)
+ mf = parser[NKey::kMatchFinder].PostStrings[0];
+
+ if (command.CompareNoCase(L"b") == 0)
+ {
+ const UInt32 kNumDefaultItereations = 10;
+ UInt32 numIterations = kNumDefaultItereations;
+ {
+ if (paramIndex < nonSwitchStrings.Size())
+ if (!GetNumber(nonSwitchStrings[paramIndex++], numIterations))
+ numIterations = kNumDefaultItereations;
+ }
+ return LzmaBenchmark(stderr, numIterations, dictionary);
+ }
+
+ bool encodeMode = false;
+ if (command.CompareNoCase(L"e") == 0)
+ encodeMode = true;
+ else if (command.CompareNoCase(L"d") == 0)
+ encodeMode = false;
+ else
+ IncorrectCommand();
+
+ bool stdInMode = parser[NKey::kStdIn].ThereIs;
+ bool stdOutMode = parser[NKey::kStdOut].ThereIs;
+
+ CMyComPtr<ISequentialInStream> inStream;
+ CInFileStream *inStreamSpec = 0;
+ if (stdInMode)
+ {
+ inStream = new CStdInFileStream;
+ MY_SET_BINARY_MODE(stdin);
+ }
+ else
+ {
+ if (paramIndex >= nonSwitchStrings.Size())
+ IncorrectCommand();
+ 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",
+ (const char *)GetOemString(inputName));
+ return 1;
+ }
+ }
+
+ CMyComPtr<ISequentialOutStream> outStream;
+ if (stdOutMode)
+ {
+ outStream = new CStdOutFileStream;
+ MY_SET_BINARY_MODE(stdout);
+ }
+ else
+ {
+ if (paramIndex >= nonSwitchStrings.Size())
+ IncorrectCommand();
+ const UString &outputName = nonSwitchStrings[paramIndex++];
+ COutFileStream *outStreamSpec = new COutFileStream;
+ outStream = outStreamSpec;
+ if (!outStreamSpec->Create(GetSystemString(outputName), true))
+ {
+ fprintf(stderr, "\nError: can not open output file %s\n",
+ (const char *)GetOemString(outputName));
+ return 1;
+ }
+ }
+
+ if (parser[NKey::kFilter86].ThereIs)
+ {
+ // -f86 switch is for x86 filtered mode: BCJ + LZMA.
+ if (parser[NKey::kEOS].ThereIs || stdInMode)
+ throw "Can not use stdin in this mode";
+ UInt64 fileSize;
+ inStreamSpec->File.GetLength(fileSize);
+ if (fileSize > 0xF0000000)
+ throw "File is too big";
+ UInt32 inSize = (UInt32)fileSize;
+ Byte *inBuffer = 0;
+ if (inSize != 0)
+ {
+ inBuffer = (Byte *)MyAlloc((size_t)inSize);
+ if (inBuffer == 0)
+ throw kCantAllocate;
+ }
+
+ UInt32 processedSize;
+ if (ReadStream(inStream, inBuffer, (UInt32)inSize, &processedSize) != S_OK)
+ throw "Can not read";
+ if ((UInt32)inSize != processedSize)
+ throw "Read size error";
+
+ Byte *outBuffer = 0;
+ size_t outSizeProcessed;
+ if (encodeMode)
+ {
+ // we allocate 105% of original size for output buffer
+ size_t outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
+ if (outSize != 0)
+ {
+ outBuffer = (Byte *)MyAlloc((size_t)outSize);
+ if (outBuffer == 0)
+ throw kCantAllocate;
+ }
+ if (!dictionaryIsDefined)
+ dictionary = 1 << 23;
+ int res = LzmaRamEncode(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed,
+ dictionary, SZ_FILTER_AUTO);
+ if (res != 0)
+ {
+ fprintf(stderr, "\nEncoder error = %d\n", (int)res);
+ return 1;
+ }
+ }
+ else
+ {
+ size_t outSize;
+ if (LzmaRamGetUncompressedSize(inBuffer, inSize, &outSize) != 0)
+ throw "data error";
+ if (outSize != 0)
+ {
+ outBuffer = (Byte *)MyAlloc(outSize);
+ if (outBuffer == 0)
+ throw kCantAllocate;
+ }
+ int res = LzmaRamDecompress(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed, malloc, free);
+ if (res != 0)
+ throw "LzmaDecoder error";
+ }
+ if (WriteStream(outStream, outBuffer, (UInt32)outSizeProcessed, &processedSize) != S_OK)
+ throw kWriteError;
+ MyFree(outBuffer);
+ MyFree(inBuffer);
+ return 0;
+ }
+
+
+ UInt64 fileSize;
+ if (encodeMode)
+ {
+ NCompress::NLZMA::CEncoder *encoderSpec =
+ new NCompress::NLZMA::CEncoder;
+ CMyComPtr<ICompressCoder> encoder = encoderSpec;
+
+ if (!dictionaryIsDefined)
+ dictionary = 1 << 23;
+
+ UInt32 posStateBits = 2;
+ UInt32 litContextBits = 3; // for normal files
+ // UInt32 litContextBits = 0; // for 32-bit data
+ UInt32 litPosBits = 0;
+ // UInt32 litPosBits = 2; // for 32-bit data
+ UInt32 algorithm = 1;
+ UInt32 numFastBytes = 128;
+ UInt32 matchFinderCycles = 16 + numFastBytes / 2;
+ bool matchFinderCyclesDefined = false;
+
+ bool eos = parser[NKey::kEOS].ThereIs || stdInMode;
+
+ if(parser[NKey::kMode].ThereIs)
+ if (!GetNumber(parser[NKey::kMode].PostStrings[0], algorithm))
+ IncorrectCommand();
+
+ if(parser[NKey::kFastBytes].ThereIs)
+ if (!GetNumber(parser[NKey::kFastBytes].PostStrings[0], numFastBytes))
+ IncorrectCommand();
+ matchFinderCyclesDefined = parser[NKey::kMatchFinderCycles].ThereIs;
+ if (matchFinderCyclesDefined)
+ if (!GetNumber(parser[NKey::kMatchFinderCycles].PostStrings[0], matchFinderCycles))
+ IncorrectCommand();
+ if(parser[NKey::kLitContext].ThereIs)
+ if (!GetNumber(parser[NKey::kLitContext].PostStrings[0], litContextBits))
+ IncorrectCommand();
+ if(parser[NKey::kLitPos].ThereIs)
+ if (!GetNumber(parser[NKey::kLitPos].PostStrings[0], litPosBits))
+ IncorrectCommand();
+ if(parser[NKey::kPosBits].ThereIs)
+ if (!GetNumber(parser[NKey::kPosBits].PostStrings[0], posStateBits))
+ IncorrectCommand();
+
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kDictionarySize,
+ NCoderPropID::kPosStateBits,
+ NCoderPropID::kLitContextBits,
+ NCoderPropID::kLitPosBits,
+ NCoderPropID::kAlgorithm,
+ NCoderPropID::kNumFastBytes,
+ NCoderPropID::kMatchFinder,
+ NCoderPropID::kEndMarker,
+ NCoderPropID::kMatchFinderCycles
+ };
+ const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]);
+ /*
+ NWindows::NCOM::CPropVariant properties[kNumProps];
+ properties[0] = UInt32(dictionary);
+ properties[1] = UInt32(posStateBits);
+ properties[2] = UInt32(litContextBits);
+
+ properties[3] = UInt32(litPosBits);
+ properties[4] = UInt32(algorithm);
+ properties[5] = UInt32(numFastBytes);
+ properties[6] = mf;
+ properties[7] = eos;
+ */
+ PROPVARIANT properties[kNumPropsMax];
+ for (int p = 0; p < 6; p++)
+ properties[p].vt = VT_UI4;
+
+ properties[0].ulVal = UInt32(dictionary);
+ properties[1].ulVal = UInt32(posStateBits);
+ properties[2].ulVal = UInt32(litContextBits);
+ properties[3].ulVal = UInt32(litPosBits);
+ properties[4].ulVal = UInt32(algorithm);
+ properties[5].ulVal = UInt32(numFastBytes);
+
+ properties[8].vt = VT_UI4;
+ properties[8].ulVal = UInt32(matchFinderCycles);
+
+ properties[6].vt = VT_BSTR;
+ properties[6].bstrVal = (BSTR)(const wchar_t *)mf;
+
+ properties[7].vt = VT_BOOL;
+ properties[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;
+
+ int numProps = kNumPropsMax;
+ if (!matchFinderCyclesDefined)
+ numProps--;
+
+ if (encoderSpec->SetCoderProperties(propIDs, properties, numProps) != S_OK)
+ IncorrectCommand();
+ encoderSpec->WriteCoderProperties(outStream);
+
+ if (eos || stdInMode)
+ fileSize = (UInt64)(Int64)-1;
+ else
+ inStreamSpec->File.GetLength(fileSize);
+
+ for (int i = 0; i < 8; i++)
+ {
+ Byte b = Byte(fileSize >> (8 * i));
+ if (outStream->Write(&b, 1, 0) != S_OK)
+ {
+ fprintf(stderr, kWriteError);
+ return 1;
+ }
+ }
+ HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
+ if (result == E_OUTOFMEMORY)
+ {
+ 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
+ {
+ NCompress::NLZMA::CDecoder *decoderSpec =
+ new NCompress::NLZMA::CDecoder;
+ CMyComPtr<ICompressCoder> decoder = decoderSpec;
+ const UInt32 kPropertiesSize = 5;
+ Byte properties[kPropertiesSize];
+ UInt32 processedSize;
+ if (ReadStream(inStream, properties, kPropertiesSize, &processedSize) != S_OK)
+ {
+ fprintf(stderr, kReadError);
+ return 1;
+ }
+ if (processedSize != kPropertiesSize)
+ {
+ fprintf(stderr, kReadError);
+ return 1;
+ }
+ if (decoderSpec->SetDecoderProperties2(properties, kPropertiesSize) != S_OK)
+ {
+ fprintf(stderr, "SetDecoderProperties error");
+ return 1;
+ }
+ fileSize = 0;
+ for (int i = 0; i < 8; i++)
+ {
+ Byte b;
+ if (inStream->Read(&b, 1, &processedSize) != S_OK)
+ {
+ fprintf(stderr, kReadError);
+ return 1;
+ }
+ if (processedSize != 1)
+ {
+ fprintf(stderr, kReadError);
+ return 1;
+ }
+ fileSize |= ((UInt64)b) << (8 * i);
+ }
+ if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
+ {
+ fprintf(stderr, "Decoder error");
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int main(int n, const char *args[])
+{
+ try { return main2(n, args); }
+ catch(const char *s)
+ {
+ fprintf(stderr, "\nError: %s\n", s);
+ return 1;
+ }
+ catch(...)
+ {
+ fprintf(stderr, "\nError\n");
+ return 1;
+ }
+}
diff --git a/7zip/Compress/LZMA_Alone/LzmaBench.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
index f9924165..f9924165 100755
--- a/7zip/Compress/LZMA_Alone/LzmaBench.cpp
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
diff --git a/7zip/Compress/LZMA_Alone/LzmaBench.h b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h
index a6a0e82e..a6a0e82e 100755
--- a/7zip/Compress/LZMA_Alone/LzmaBench.h
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaRam.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaRam.cpp
new file mode 100755
index 00000000..31ca1c74
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaRam.cpp
@@ -0,0 +1,227 @@
+// LzmaRam.cpp
+
+#include "StdAfx.h"
+#include "../../../Common/Types.h"
+#include "../LZMA/LZMADecoder.h"
+#include "../LZMA/LZMAEncoder.h"
+#include "LzmaRam.h"
+
+extern "C"
+{
+ #include "../../../../C/Compress/Branch/BranchX86.h"
+}
+
+class CInStreamRam:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+ const Byte *Data;
+ size_t Size;
+ size_t Pos;
+public:
+ MY_UNKNOWN_IMP
+ void Init(const Byte *data, size_t size)
+ {
+ Data = data;
+ Size = size;
+ Pos = 0;
+ }
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+};
+
+STDMETHODIMP CInStreamRam::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (size > (Size - Pos))
+ size = (UInt32)(Size - Pos);
+ for (UInt32 i = 0; i < size; i++)
+ ((Byte *)data)[i] = Data[Pos + i];
+ Pos += size;
+ if(processedSize != NULL)
+ *processedSize = size;
+ return S_OK;
+}
+
+class COutStreamRam:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ size_t Size;
+public:
+ Byte *Data;
+ size_t Pos;
+ bool Overflow;
+ void Init(Byte *data, size_t size)
+ {
+ Data = data;
+ Size = size;
+ Pos = 0;
+ Overflow = false;
+ }
+ void SetPos(size_t pos)
+ {
+ Overflow = false;
+ Pos = pos;
+ }
+ MY_UNKNOWN_IMP
+ HRESULT WriteByte(Byte b)
+ {
+ if (Pos >= Size)
+ {
+ Overflow = true;
+ return E_FAIL;
+ }
+ Data[Pos++] = b;
+ return S_OK;
+ }
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+STDMETHODIMP COutStreamRam::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 i;
+ for (i = 0; i < size && Pos < Size; i++)
+ Data[Pos++] = ((const Byte *)data)[i];
+ if(processedSize != NULL)
+ *processedSize = i;
+ if (i != size)
+ {
+ Overflow = true;
+ return E_FAIL;
+ }
+ return S_OK;
+}
+
+#define SZ_RAM_E_FAIL (1)
+#define SZ_RAM_E_OUTOFMEMORY (2)
+#define SZE_OUT_OVERFLOW (3)
+
+int LzmaRamEncode(
+ const Byte *inBuffer, size_t inSize,
+ Byte *outBuffer, size_t outSize, size_t *outSizeProcessed,
+ UInt32 dictionarySize, ESzFilterMode filterMode)
+{
+ #ifndef _NO_EXCEPTIONS
+ try {
+ #endif
+
+ *outSizeProcessed = 0;
+ const size_t kIdSize = 1;
+ const size_t kLzmaPropsSize = 5;
+ const size_t kMinDestSize = kIdSize + kLzmaPropsSize + 8;
+ if (outSize < kMinDestSize)
+ return SZE_OUT_OVERFLOW;
+ NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
+ CMyComPtr<ICompressCoder> encoder = encoderSpec;
+
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kAlgorithm,
+ NCoderPropID::kDictionarySize,
+ NCoderPropID::kNumFastBytes,
+ };
+ const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
+ PROPVARIANT properties[kNumProps];
+ properties[0].vt = VT_UI4;
+ properties[1].vt = VT_UI4;
+ properties[2].vt = VT_UI4;
+ properties[0].ulVal = (UInt32)2;
+ properties[1].ulVal = (UInt32)dictionarySize;
+ properties[2].ulVal = (UInt32)64;
+
+ if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
+ return 1;
+
+ COutStreamRam *outStreamSpec = new COutStreamRam;
+ if (outStreamSpec == 0)
+ return SZ_RAM_E_OUTOFMEMORY;
+ CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
+ CInStreamRam *inStreamSpec = new CInStreamRam;
+ if (inStreamSpec == 0)
+ return SZ_RAM_E_OUTOFMEMORY;
+ CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
+
+ outStreamSpec->Init(outBuffer, outSize);
+ if (outStreamSpec->WriteByte(0) != S_OK)
+ return SZE_OUT_OVERFLOW;
+
+ if (encoderSpec->WriteCoderProperties(outStream) != S_OK)
+ return SZE_OUT_OVERFLOW;
+ if (outStreamSpec->Pos != kIdSize + kLzmaPropsSize)
+ return 1;
+
+ int i;
+ for (i = 0; i < 8; i++)
+ {
+ UInt64 t = (UInt64)(inSize);
+ if (outStreamSpec->WriteByte((Byte)((t) >> (8 * i))) != S_OK)
+ return SZE_OUT_OVERFLOW;
+ }
+
+ Byte *filteredStream = 0;
+
+ bool useFilter = (filterMode != SZ_FILTER_NO);
+ if (useFilter)
+ {
+ if (inSize != 0)
+ {
+ filteredStream = (Byte *)MyAlloc(inSize);
+ if (filteredStream == 0)
+ return SZ_RAM_E_OUTOFMEMORY;
+ memmove(filteredStream, inBuffer, inSize);
+ }
+ UInt32 _prevMask;
+ UInt32 _prevPos;
+ x86_Convert_Init(_prevMask, _prevPos);
+ x86_Convert(filteredStream, (UInt32)inSize, 0, &_prevMask, &_prevPos, 1);
+ }
+
+ size_t minSize = 0;
+ int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1;
+ bool bestIsFiltered = false;
+ int mainResult = 0;
+ size_t startPos = outStreamSpec->Pos;
+ for (i = 0; i < numPasses; i++)
+ {
+ if (numPasses > 1 && i == numPasses - 1 && !bestIsFiltered)
+ break;
+ outStreamSpec->SetPos(startPos);
+ bool curModeIsFiltered = false;
+ if (useFilter && i == 0)
+ curModeIsFiltered = true;
+ if (numPasses > 1 && i == numPasses - 1)
+ curModeIsFiltered = true;
+
+ inStreamSpec->Init(curModeIsFiltered ? filteredStream : inBuffer, inSize);
+
+ HRESULT lzmaResult = encoder->Code(inStream, outStream, 0, 0, 0);
+
+ mainResult = 0;
+ if (lzmaResult == E_OUTOFMEMORY)
+ {
+ mainResult = SZ_RAM_E_OUTOFMEMORY;
+ break;
+ }
+ if (i == 0 || outStreamSpec->Pos <= minSize)
+ {
+ minSize = outStreamSpec->Pos;
+ bestIsFiltered = curModeIsFiltered;
+ }
+ if (outStreamSpec->Overflow)
+ mainResult = SZE_OUT_OVERFLOW;
+ else if (lzmaResult != S_OK)
+ {
+ mainResult = SZ_RAM_E_FAIL;
+ break;
+ }
+ }
+ *outSizeProcessed = outStreamSpec->Pos;
+ if (bestIsFiltered)
+ outBuffer[0] = 1;
+ if (useFilter)
+ MyFree(filteredStream);
+ return mainResult;
+
+ #ifndef _NO_EXCEPTIONS
+ } catch(...) { return SZ_RAM_E_OUTOFMEMORY; }
+ #endif
+}
diff --git a/7zip/Compress/LZMA_Alone/LzmaRam.h b/CPP/7zip/Compress/LZMA_Alone/LzmaRam.h
index 1244dc86..1244dc86 100755
--- a/7zip/Compress/LZMA_Alone/LzmaRam.h
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaRam.h
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.c b/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.c
new file mode 100755
index 00000000..0767ba21
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.c
@@ -0,0 +1,79 @@
+/* LzmaRamDecode.c */
+
+#include "LzmaRamDecode.h"
+#ifdef _SZ_ONE_DIRECTORY
+#include "LzmaDecode.h"
+#include "BranchX86.h"
+#else
+#include "../../../../C/Compress/Lzma/LzmaDecode.h"
+#include "../../../../C/Compress/Branch/BranchX86.h"
+#endif
+
+#define LZMA_PROPS_SIZE 14
+#define LZMA_SIZE_OFFSET 6
+
+int LzmaRamGetUncompressedSize(
+ const unsigned char *inBuffer,
+ size_t inSize,
+ size_t *outSize)
+{
+ unsigned int i;
+ if (inSize < LZMA_PROPS_SIZE)
+ return 1;
+ *outSize = 0;
+ for(i = 0; i < sizeof(size_t); i++)
+ *outSize += ((size_t)inBuffer[LZMA_SIZE_OFFSET + i]) << (8 * i);
+ for(; i < 8; i++)
+ if (inBuffer[LZMA_SIZE_OFFSET + i] != 0)
+ return 1;
+ return 0;
+}
+
+#define SZE_DATA_ERROR (1)
+#define SZE_OUTOFMEMORY (2)
+
+int LzmaRamDecompress(
+ const unsigned char *inBuffer,
+ size_t inSize,
+ unsigned char *outBuffer,
+ size_t outSize,
+ size_t *outSizeProcessed,
+ void * (*allocFunc)(size_t size),
+ void (*freeFunc)(void *))
+{
+ CLzmaDecoderState state; /* it's about 24 bytes structure, if int is 32-bit */
+ int result;
+ SizeT outSizeProcessedLoc;
+ SizeT inProcessed;
+ int useFilter;
+
+ if (inSize < LZMA_PROPS_SIZE)
+ return 1;
+ useFilter = inBuffer[0];
+
+ *outSizeProcessed = 0;
+ if (useFilter > 1)
+ return 1;
+
+ if (LzmaDecodeProperties(&state.Properties, inBuffer + 1, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
+ return 1;
+ state.Probs = (CProb *)allocFunc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
+ if (state.Probs == 0)
+ return SZE_OUTOFMEMORY;
+
+ result = LzmaDecode(&state,
+ inBuffer + LZMA_PROPS_SIZE, (SizeT)inSize - LZMA_PROPS_SIZE, &inProcessed,
+ outBuffer, (SizeT)outSize, &outSizeProcessedLoc);
+ freeFunc(state.Probs);
+ if (result != LZMA_RESULT_OK)
+ return 1;
+ *outSizeProcessed = (size_t)outSizeProcessedLoc;
+ if (useFilter == 1)
+ {
+ UInt32 _prevMask;
+ UInt32 _prevPos;
+ x86_Convert_Init(_prevMask, _prevPos);
+ x86_Convert(outBuffer, (UInt32)outSizeProcessedLoc, 0, &_prevMask, &_prevPos, 0);
+ }
+ return 0;
+}
diff --git a/7zip/Compress/LZMA_Alone/LzmaRamDecode.h b/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.h
index 7e641c55..7e641c55 100755
--- a/7zip/Compress/LZMA_Alone/LzmaRamDecode.h
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.h
diff --git a/7zip/Compress/Rar20/StdAfx.cpp b/CPP/7zip/Compress/LZMA_Alone/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/Rar20/StdAfx.cpp
+++ b/CPP/7zip/Compress/LZMA_Alone/StdAfx.cpp
diff --git a/7zip/Compress/LZMA_Alone/StdAfx.h b/CPP/7zip/Compress/LZMA_Alone/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/LZMA_Alone/StdAfx.h
+++ b/CPP/7zip/Compress/LZMA_Alone/StdAfx.h
diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile b/CPP/7zip/Compress/LZMA_Alone/makefile
new file mode 100755
index 00000000..d3d80d88
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA_Alone/makefile
@@ -0,0 +1,124 @@
+PROG = lzma.exe
+CFLAGS = $(CFLAGS) -I ../../../
+LIBS = $(LIBS) oleaut32.lib user32.lib
+
+!IFDEF CPU
+LIBS = $(LIBS) bufferoverflowU.lib
+CFLAGS = $(CFLAGS) -GS- -Zc:forScope -W4 -Wp64 -DUNICODE -D_UNICODE
+!ENDIF
+
+!IFNDEF O
+!IFDEF CPU
+O=$(CPU)
+!ELSE
+O=O
+!ENDIF
+!ENDIF
+
+!IFDEF MY_STATIC_LINK
+!IFNDEF MY_SINGLE_THREAD
+CFLAGS = $(CFLAGS) -MT
+!ENDIF
+!ELSE
+CFLAGS = $(CFLAGS) -MD
+!ENDIF
+
+
+CFLAGS = $(CFLAGS) -nologo -EHsc -c -Fo$O/ -WX
+CFLAGS_O1 = $(CFLAGS) -O1
+CFLAGS_O2 = $(CFLAGS) -O2
+
+LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98
+
+PROGPATH = $O\$(PROG)
+
+COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
+COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
+COMPL = $(CPP) $(CFLAGS_O1) $**
+
+
+LZMA_OBJS = \
+ $O\LzmaAlone.obj \
+ $O\LzmaBench.obj \
+ $O\LzmaRam.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+ $O\LZMAEncoder.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CRC.obj \
+ $O\CommandLineParser.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\Vector.obj
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\OutBuffer.obj \
+ $O\StreamUtils.obj \
+
+LZ_OBJS = \
+ $O\LZOutWindow.obj \
+
+C_OBJS = \
+ $O\7zCrc.obj \
+
+C_LZ_OBJS = \
+ $O\MatchFinder.obj \
+
+OBJS = \
+ $(LZMA_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $(COMMON_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(LZ_OBJS) \
+ $(C_OBJS) \
+ $(C_LZ_OBJS) \
+ $O\LzmaRamDecode.obj \
+ $O\LzmaDecode.obj \
+ $O\FileStreams.obj \
+ $O\FileIO.obj \
+ $O\RangeCoderBit.obj \
+ $O\BranchX86.obj \
+
+all: $(PROGPATH)
+
+clean:
+ -del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch
+
+$O:
+ if not exist "$O" mkdir "$O"
+
+$(PROGPATH): $O $(OBJS)
+ link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)
+
+
+$(LZMA_OBJS): $(*B).cpp
+ $(COMPL)
+$(LZMA_OPT_OBJS): ../LZMA/$(*B).cpp
+ $(COMPL_O2)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(LZ_OBJS): ../LZ/$(*B).cpp
+ $(COMPL)
+$O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp
+ $(COMPL)
+$O\LzmaRamDecode.obj: LzmaRamDecode.c
+ $(COMPL_O1)
+$O\LzmaDecode.obj: ../../../../C/Compress/Lzma/LzmaDecode.c
+ $(COMPL_O2)
+$O\BranchX86.obj: ../../../../C/Compress/Branch/BranchX86.c
+ $(COMPL_O2)
+$O\FileStreams.obj: ../../Common/FileStreams.cpp
+ $(COMPL)
+$O\FileIO.obj: ../../../Windows/FileIO.cpp
+ $(COMPL)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c
+ $(COMPL_O2)
diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
new file mode 100755
index 00000000..b83717a5
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
@@ -0,0 +1,117 @@
+PROG = lzma
+CXX = g++ -O2 -Wall
+CXX_C = gcc -O2 -Wall
+LIB = -lm
+RM = rm -f
+CFLAGS = -c -I ../../../
+
+OBJS = \
+ LzmaAlone.o \
+ LzmaBench.o \
+ LzmaRam.o \
+ LzmaRamDecode.o \
+ LzmaDecode.o \
+ BranchX86.o \
+ LZMADecoder.o \
+ LZMAEncoder.o \
+ 7zCrc.o \
+ MatchFinder.o \
+ LZOutWindow.o \
+ RangeCoderBit.o \
+ InBuffer.o \
+ OutBuffer.o \
+ FileStreams.o \
+ StreamUtils.o \
+ Alloc.o \
+ C_FileIO.o \
+ CommandLineParser.o \
+ CRC.o \
+ String.o \
+ StringConvert.o \
+ StringToInt.o \
+ Vector.o \
+
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+ $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)
+
+LzmaAlone.o: LzmaAlone.cpp
+ $(CXX) $(CFLAGS) LzmaAlone.cpp
+
+LzmaBench.o: LzmaBench.cpp
+ $(CXX) $(CFLAGS) LzmaBench.cpp
+
+LzmaRam.o: LzmaRam.cpp
+ $(CXX) $(CFLAGS) LzmaRam.cpp
+
+LzmaRamDecode.o: LzmaRamDecode.c
+ $(CXX_C) $(CFLAGS) LzmaRamDecode.c
+
+LzmaDecode.o: ../../../../C/Compress/Lzma/LzmaDecode.c
+ $(CXX_C) $(CFLAGS) ../../../../C/Compress/Lzma/LzmaDecode.c
+
+BranchX86.o: ../../../../C/Compress/Branch/BranchX86.c
+ $(CXX_C) $(CFLAGS) ../../../../C/Compress/Branch/BranchX86.c
+
+LZMADecoder.o: ../LZMA/LZMADecoder.cpp
+ $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
+
+LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
+ $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
+
+MatchFinder.o: ../../../../C/Compress/Lz/MatchFinder.c
+ $(CXX_C) $(CFLAGS) ../../../../C/Compress/Lz/MatchFinder.c
+
+7zCrc.o: ../../../../C/7zCrc.c
+ $(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
+
+LZOutWindow.o: ../LZ/LZOutWindow.cpp
+ $(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
+
+RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp
+ $(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp
+
+InBuffer.o: ../../Common/InBuffer.cpp
+ $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
+
+OutBuffer.o: ../../Common/OutBuffer.cpp
+ $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp
+
+FileStreams.o: ../../Common/FileStreams.cpp
+ $(CXX) $(CFLAGS) ../../Common/FileStreams.cpp
+
+StreamUtils.o: ../../Common/StreamUtils.cpp
+ $(CXX) $(CFLAGS) ../../Common/StreamUtils.cpp
+
+Alloc.o: ../../../Common/Alloc.cpp
+ $(CXX) $(CFLAGS) ../../../Common/Alloc.cpp
+
+C_FileIO.o: ../../../Common/C_FileIO.cpp
+ $(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp
+
+CommandLineParser.o: ../../../Common/CommandLineParser.cpp
+ $(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp
+
+CRC.o: ../../../Common/CRC.cpp
+ $(CXX) $(CFLAGS) ../../../Common/CRC.cpp
+
+MyWindows.o: ../../../Common/MyWindows.cpp
+ $(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp
+
+String.o: ../../../Common/String.cpp
+ $(CXX) $(CFLAGS) ../../../Common/String.cpp
+
+StringConvert.o: ../../../Common/StringConvert.cpp
+ $(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp
+
+StringToInt.o: ../../../Common/StringToInt.cpp
+ $(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp
+
+Vector.o: ../../../Common/Vector.cpp
+ $(CXX) $(CFLAGS) ../../../Common/Vector.cpp
+
+clean:
+ -$(RM) $(PROG) $(OBJS)
+
diff --git a/CPP/7zip/Compress/Lzh/LzhDecoder.cpp b/CPP/7zip/Compress/Lzh/LzhDecoder.cpp
new file mode 100755
index 00000000..5a661047
--- /dev/null
+++ b/CPP/7zip/Compress/Lzh/LzhDecoder.cpp
@@ -0,0 +1,216 @@
+// LzhDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "LzhDecoder.h"
+
+#include "Windows/Defs.h"
+
+namespace NCompress{
+namespace NLzh {
+namespace NDecoder {
+
+static const UInt32 kHistorySize = (1 << 16);
+
+static const int kBlockSizeBits = 16;
+static const int kNumCBits = 9;
+static const int kNumLevelBits = 5; // smallest integer such that (1 << kNumLevelBits) > kNumLevelSymbols/
+
+UInt32 CCoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+
+HRESULT CCoder::ReadLevelTable()
+{
+ int n = ReadBits(kNumLevelBits);
+ if (n == 0)
+ {
+ m_LevelHuffman.Symbol = ReadBits(kNumLevelBits);
+ if (m_LevelHuffman.Symbol >= kNumLevelSymbols)
+ return S_FALSE;
+ }
+ else
+ {
+ if (n > kNumLevelSymbols)
+ return S_FALSE;
+ m_LevelHuffman.Symbol = -1;
+ Byte lens[kNumLevelSymbols];
+ int i = 0;
+ while (i < n)
+ {
+ int c = m_InBitStream.ReadBits(3);
+ if (c == 7)
+ while (ReadBits(1))
+ if (c++ > kMaxHuffmanLen)
+ return S_FALSE;
+ lens[i++] = (Byte)c;
+ if (i == kNumSpecLevelSymbols)
+ {
+ c = ReadBits(2);
+ while (--c >= 0)
+ lens[i++] = 0;
+ }
+ }
+ while (i < kNumLevelSymbols)
+ lens[i++] = 0;
+ m_LevelHuffman.SetCodeLengths(lens);
+ }
+ return S_OK;
+}
+
+HRESULT CCoder::ReadPTable(int numBits)
+{
+ int n = ReadBits(numBits);
+ if (n == 0)
+ {
+ m_PHuffmanDecoder.Symbol = ReadBits(numBits);
+ if (m_PHuffmanDecoder.Symbol >= kNumDistanceSymbols)
+ return S_FALSE;
+ }
+ else
+ {
+ if (n > kNumDistanceSymbols)
+ return S_FALSE;
+ m_PHuffmanDecoder.Symbol = -1;
+ Byte lens[kNumDistanceSymbols];
+ int i = 0;
+ while (i < n)
+ {
+ int c = m_InBitStream.ReadBits(3);
+ if (c == 7)
+ while (ReadBits(1))
+ {
+ if (c > kMaxHuffmanLen)
+ return S_FALSE;
+ c++;
+ }
+ lens[i++] = (Byte)c;
+ }
+ while (i < kNumDistanceSymbols)
+ lens[i++] = 0;
+ m_PHuffmanDecoder.SetCodeLengths(lens);
+ }
+ return S_OK;
+}
+
+HRESULT CCoder::ReadCTable()
+{
+ int n = ReadBits(kNumCBits);
+ if (n == 0)
+ {
+ m_CHuffmanDecoder.Symbol = ReadBits(kNumCBits);
+ if (m_CHuffmanDecoder.Symbol >= kNumCSymbols)
+ return S_FALSE;
+ }
+ else
+ {
+ if (n > kNumCSymbols)
+ return S_FALSE;
+ m_CHuffmanDecoder.Symbol = -1;
+ Byte lens[kNumCSymbols];
+ int i = 0;
+ while (i < n)
+ {
+ int c = m_LevelHuffman.Decode(&m_InBitStream);
+ if (c < kNumSpecLevelSymbols)
+ {
+ if (c == 0)
+ c = 1;
+ else if (c == 1)
+ c = ReadBits(4) + 3;
+ else
+ c = ReadBits(kNumCBits) + 20;
+ while (--c >= 0)
+ {
+ if (i > kNumCSymbols)
+ return S_FALSE;
+ lens[i++] = 0;
+ }
+ }
+ else
+ lens[i++] = (Byte)(c - 2);
+ }
+ while (i < kNumCSymbols)
+ lens[i++] = 0;
+ m_CHuffmanDecoder.SetCodeLengths(lens);
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ if (outSize == NULL)
+ return E_INVALIDARG;
+
+ if (!m_OutWindowStream.Create(kHistorySize))
+ return E_OUTOFMEMORY;
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ UInt64 pos = 0;
+ m_OutWindowStream.SetStream(outStream);
+ m_OutWindowStream.Init(false);
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+
+ CCoderReleaser coderReleaser(this);
+
+ int pbit;
+ if (m_NumDictBits <= 13)
+ pbit = 4;
+ else
+ pbit = 5;
+
+ UInt32 blockSize = 0;
+
+ while(pos < *outSize)
+ {
+ // for (i = 0; i < dictSize; i++) dtext[i] = 0x20;
+
+ if (blockSize == 0)
+ {
+ if (progress != NULL)
+ {
+ UInt64 packSize = m_InBitStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &pos));
+ }
+ blockSize = ReadBits(kBlockSizeBits);
+ ReadLevelTable();
+ ReadCTable();
+ RINOK(ReadPTable(pbit));
+ }
+ blockSize--;
+ UInt32 c = m_CHuffmanDecoder.Decode(&m_InBitStream);
+ if (c < 256)
+ {
+ m_OutWindowStream.PutByte((Byte)c);
+ pos++;
+ }
+ else
+ {
+ // offset = (interface->method == LARC_METHOD_NUM) ? 0x100 - 2 : 0x100 - 3;
+ UInt32 len = c - 256 + kMinMatch;
+ UInt32 distance = m_PHuffmanDecoder.Decode(&m_InBitStream);
+ if (distance != 0)
+ distance = (1 << (distance - 1)) + ReadBits(distance - 1);
+ pos += len;
+ if (distance >= pos)
+ throw 1;
+ m_OutWindowStream.CopyBlock(distance, len);
+ }
+ }
+ coderReleaser.NeedFlush = false;
+ return m_OutWindowStream.Flush();
+}
+
+STDMETHODIMP CCoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress);}
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const CLZOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+}}}
diff --git a/7zip/Compress/Lzh/LzhDecoder.h b/CPP/7zip/Compress/Lzh/LzhDecoder.h
index 79f71b88..79f71b88 100755
--- a/7zip/Compress/Lzh/LzhDecoder.h
+++ b/CPP/7zip/Compress/Lzh/LzhDecoder.h
diff --git a/7zip/Compress/Lzx/Lzx.h b/CPP/7zip/Compress/Lzx/Lzx.h
index 386a17c3..386a17c3 100755
--- a/7zip/Compress/Lzx/Lzx.h
+++ b/CPP/7zip/Compress/Lzx/Lzx.h
diff --git a/7zip/Compress/Lzx/Lzx86Converter.cpp b/CPP/7zip/Compress/Lzx/Lzx86Converter.cpp
index 1265dba0..1265dba0 100755
--- a/7zip/Compress/Lzx/Lzx86Converter.cpp
+++ b/CPP/7zip/Compress/Lzx/Lzx86Converter.cpp
diff --git a/7zip/Compress/Lzx/Lzx86Converter.h b/CPP/7zip/Compress/Lzx/Lzx86Converter.h
index b507a612..b507a612 100755
--- a/7zip/Compress/Lzx/Lzx86Converter.h
+++ b/CPP/7zip/Compress/Lzx/Lzx86Converter.h
diff --git a/7zip/Compress/Lzx/LzxDecoder.cpp b/CPP/7zip/Compress/Lzx/LzxDecoder.cpp
index e854af32..e854af32 100755
--- a/7zip/Compress/Lzx/LzxDecoder.cpp
+++ b/CPP/7zip/Compress/Lzx/LzxDecoder.cpp
diff --git a/7zip/Compress/Lzx/LzxDecoder.h b/CPP/7zip/Compress/Lzx/LzxDecoder.h
index a62662ec..a62662ec 100755
--- a/7zip/Compress/Lzx/LzxDecoder.h
+++ b/CPP/7zip/Compress/Lzx/LzxDecoder.h
diff --git a/7zip/Compress/Lzx/StdAfx.h b/CPP/7zip/Compress/Lzx/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/Lzx/StdAfx.h
+++ b/CPP/7zip/Compress/Lzx/StdAfx.h
diff --git a/CPP/7zip/Compress/PPMD/DllExports.cpp b/CPP/7zip/Compress/PPMD/DllExports.cpp
new file mode 100755
index 00000000..8159a2f8
--- /dev/null
+++ b/CPP/7zip/Compress/PPMD/DllExports.cpp
@@ -0,0 +1,93 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+#include "Common/ComTry.h"
+#ifdef _WIN32
+#include "Common/Alloc.h"
+#endif
+
+#include "PPMDEncoder.h"
+#include "PPMDDecoder.h"
+
+// {23170F69-40C1-278B-0304-010000000000}
+DEFINE_GUID(CLSID_CCompressPPMDDecoder,
+0x23170F69, 0x40C1, 0x278B, 0x03, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+// {23170F69-40C1-278B-0304-010000000100}
+DEFINE_GUID(CLSID_CCompressPPMDEncoder,
+0x23170F69, 0x40C1, 0x278B, 0x03, 0x04, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00);
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ #ifdef _WIN32
+ if (dwReason == DLL_PROCESS_ATTACH)
+ SetLargePageSize();
+ #endif
+ return TRUE;
+}
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ int correctInterface = (*iid == IID_ICompressCoder);
+ CMyComPtr<ICompressCoder> coder;
+ if (*clsid == CLSID_CCompressPPMDDecoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NPPMD::CDecoder();
+ }
+ else if (*clsid == CLSID_CCompressPPMDEncoder)
+ {
+ if (!correctInterface)
+ return E_NOINTERFACE;
+ coder = (ICompressCoder *)new NCompress::NPPMD::CEncoder();
+ }
+ else
+ return CLASS_E_CLASSNOTAVAILABLE;
+ *outObject = coder.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[] = { 0x03, 0x04, 0x01 };
+ if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ case NMethodPropID::kName:
+ if ((value->bstrVal = ::SysAllocString(L"PPMD")) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kDecoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CCompressPPMDDecoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kEncoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CCompressPPMDEncoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ return S_OK;
+}
diff --git a/7zip/Compress/PPMD/PPMD.dsp b/CPP/7zip/Compress/PPMD/PPMD.dsp
index 9e512f6c..9e512f6c 100755
--- a/7zip/Compress/PPMD/PPMD.dsp
+++ b/CPP/7zip/Compress/PPMD/PPMD.dsp
diff --git a/7zip/Compress/PPMD/PPMD.dsw b/CPP/7zip/Compress/PPMD/PPMD.dsw
index 8032f3db..8032f3db 100755
--- a/7zip/Compress/PPMD/PPMD.dsw
+++ b/CPP/7zip/Compress/PPMD/PPMD.dsw
diff --git a/7zip/Compress/PPMD/PPMDContext.h b/CPP/7zip/Compress/PPMD/PPMDContext.h
index a6a8dd60..a6a8dd60 100755
--- a/7zip/Compress/PPMD/PPMDContext.h
+++ b/CPP/7zip/Compress/PPMD/PPMDContext.h
diff --git a/CPP/7zip/Compress/PPMD/PPMDDecode.h b/CPP/7zip/Compress/PPMD/PPMDDecode.h
new file mode 100755
index 00000000..b05d8ee0
--- /dev/null
+++ b/CPP/7zip/Compress/PPMD/PPMDDecode.h
@@ -0,0 +1,154 @@
+// PPMDDecode.h
+// This code is based on Dmitry Shkarin's PPMdH code
+
+#ifndef __COMPRESS_PPMD_DECODE_H
+#define __COMPRESS_PPMD_DECODE_H
+
+#include "PPMDContext.h"
+
+namespace NCompress {
+namespace NPPMD {
+
+class CRangeDecoderVirt
+{
+public:
+ virtual UInt32 GetThreshold(UInt32 total) = 0;
+ virtual void Decode(UInt32 start, UInt32 size) = 0;
+ virtual UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits) = 0;
+};
+
+typedef NRangeCoder::CDecoder CRangeDecoderMy;
+
+class CRangeDecoder:public CRangeDecoderVirt, public CRangeDecoderMy
+{
+ UInt32 GetThreshold(UInt32 total) { return CRangeDecoderMy::GetThreshold(total); }
+ void Decode(UInt32 start, UInt32 size) { CRangeDecoderMy::Decode(start, size); }
+ UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits) { return CRangeDecoderMy::DecodeBit(size0, numTotalBits); }
+};
+
+struct CDecodeInfo: public CInfo
+{
+ void DecodeBinSymbol(CRangeDecoderVirt *rangeDecoder)
+ {
+ PPM_CONTEXT::STATE& rs = MinContext->oneState();
+ UInt16& bs = GetBinSumm(rs, GetContextNoCheck(MinContext->Suffix)->NumStats);
+ 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
+ {
+ bs = (UInt16)(bs - GET_MEAN(bs, PERIOD_BITS, 2));
+ InitEsc = ExpEscape[bs >> 10];
+ NumMasked = 1;
+ CharMask[rs.Symbol] = EscCount;
+ PrevSuccess = 0;
+ FoundState = NULL;
+ }
+ }
+
+ void DecodeSymbol1(CRangeDecoderVirt *rangeDecoder)
+ {
+ PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats);
+ int i, count, hiCnt;
+ 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);
+ MinContext->SummFreq += 4;
+ if (hiCnt > MAX_FREQ)
+ rescale();
+ return;
+ }
+ PrevSuccess = 0;
+ i = MinContext->NumStats - 1;
+ while ((hiCnt += (++p)->Freq) <= count)
+ if (--i == 0)
+ {
+ HiBitsFlag = HB2Flag[FoundState->Symbol];
+ rangeDecoder->Decode(hiCnt, MinContext->SummFreq - hiCnt); // , MinContext->SummFreq);
+ CharMask[p->Symbol] = EscCount;
+ i = (NumMasked = MinContext->NumStats)-1;
+ FoundState = NULL;
+ do { CharMask[(--p)->Symbol] = EscCount; } while ( --i );
+ return;
+ }
+ rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , MinContext->SummFreq);
+ update1(p);
+ }
+
+
+ void DecodeSymbol2(CRangeDecoderVirt *rangeDecoder)
+ {
+ int count, hiCnt, i = MinContext->NumStats - NumMasked;
+ UInt32 freqSum;
+ SEE2_CONTEXT* psee2c = makeEscFreq2(i, freqSum);
+ PPM_CONTEXT::STATE* ps[256], ** pps = ps, * p = GetStateNoCheck(MinContext->Stats)-1;
+ hiCnt = 0;
+ do
+ {
+ do { p++; } while (CharMask[p->Symbol] == EscCount);
+ hiCnt += p->Freq;
+ *pps++ = p;
+ }
+ while ( --i );
+
+ freqSum += hiCnt;
+ count = rangeDecoder->GetThreshold(freqSum);
+
+ p = *(pps = ps);
+ if (count < hiCnt)
+ {
+ hiCnt = 0;
+ while ((hiCnt += p->Freq) <= count)
+ p=*++pps;
+ rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , freqSum);
+
+ psee2c->update();
+ update2(p);
+ }
+ else
+ {
+ rangeDecoder->Decode(hiCnt, freqSum - hiCnt); // , freqSum);
+
+ i = MinContext->NumStats - NumMasked;
+ pps--;
+ do { CharMask[(*++pps)->Symbol] = EscCount; } while ( --i );
+ psee2c->Summ = (UInt16)(psee2c->Summ + freqSum);
+ NumMasked = MinContext->NumStats;
+ }
+ }
+
+ int DecodeSymbol(CRangeDecoderVirt *rangeDecoder)
+ {
+ if (MinContext->NumStats != 1)
+ DecodeSymbol1(rangeDecoder);
+ else
+ DecodeBinSymbol(rangeDecoder);
+ while ( !FoundState )
+ {
+ do
+ {
+ OrderFall++;
+ MinContext = GetContext(MinContext->Suffix);
+ if (MinContext == 0)
+ return -1;
+ }
+ while (MinContext->NumStats == NumMasked);
+ DecodeSymbol2(rangeDecoder);
+ }
+ Byte symbol = FoundState->Symbol;
+ NextContext();
+ return symbol;
+ }
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Compress/PPMD/PPMDDecoder.cpp b/CPP/7zip/Compress/PPMD/PPMDDecoder.cpp
new file mode 100755
index 00000000..2d0a2f52
--- /dev/null
+++ b/CPP/7zip/Compress/PPMD/PPMDDecoder.cpp
@@ -0,0 +1,184 @@
+// PPMDDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Defs.h"
+#include "Windows/Defs.h"
+
+#include "PPMDDecoder.h"
+
+namespace NCompress {
+namespace NPPMD {
+
+const int kLenIdFinished = -1;
+const int kLenIdNeedInit = -2;
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *properties, UInt32 size)
+{
+ if (size < 5)
+ return E_INVALIDARG;
+ _order = properties[0];
+ _usedMemorySize = 0;
+ for (int i = 0; i < 4; i++)
+ _usedMemorySize += ((UInt32)(properties[1 + i])) << (i * 8);
+
+ if (_usedMemorySize > kMaxMemBlockSize)
+ return E_NOTIMPL;
+
+ if (!_rangeDecoder.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
+ return E_OUTOFMEMORY;
+
+ return S_OK;
+}
+
+class CDecoderFlusher
+{
+ CDecoder *_coder;
+public:
+ bool NeedFlush;
+ CDecoderFlusher(CDecoder *coder): _coder(coder), NeedFlush(true) {}
+ ~CDecoderFlusher()
+ {
+ if (NeedFlush)
+ _coder->Flush();
+ _coder->ReleaseStreams();
+ }
+};
+
+HRESULT CDecoder::CodeSpec(UInt32 size, Byte *memStream)
+{
+ if (_outSizeDefined)
+ {
+ const UInt64 rem = _outSize - _processedSize;
+ if (size > rem)
+ size = (UInt32)rem;
+ }
+ const UInt32 startSize = size;
+
+ if (_remainLen == kLenIdFinished)
+ return S_OK;
+ if (_remainLen == kLenIdNeedInit)
+ {
+ _rangeDecoder.Init();
+ _remainLen = 0;
+ _info.MaxOrder = 0;
+ _info.StartModelRare(_order);
+ }
+ while (size != 0)
+ {
+ int symbol = _info.DecodeSymbol(&_rangeDecoder);
+ if (symbol < 0)
+ {
+ _remainLen = kLenIdFinished;
+ break;
+ }
+ if (memStream != 0)
+ *memStream++ = (Byte)symbol;
+ else
+ _outStream.WriteByte((Byte)symbol);
+ size--;
+ }
+ _processedSize += startSize - size;
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ if (!_outStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ SetInStream(inStream);
+ _outStream.SetStream(outStream);
+ SetOutStreamSize(outSize);
+ CDecoderFlusher flusher(this);
+
+ for (;;)
+ {
+ _processedSize = _outStream.GetProcessedSize();
+ UInt32 curSize = (1 << 18);
+ RINOK(CodeSpec(curSize, NULL));
+ if (_remainLen == kLenIdFinished)
+ break;
+ if (progress != NULL)
+ {
+ UInt64 inSize = _rangeDecoder.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&inSize, &_processedSize));
+ }
+ if (_outSizeDefined)
+ if (_outStream.GetProcessedSize() >= _outSize)
+ break;
+ }
+ flusher.NeedFlush = false;
+ return Flush();
+}
+
+#ifdef _NO_EXCEPTIONS
+
+#define PPMD_TRY_BEGIN
+#define PPMD_TRY_END
+
+#else
+
+#define PPMD_TRY_BEGIN try {
+#define PPMD_TRY_END } \
+ catch(const CInBufferException &e) { return e.ErrorCode; } \
+ catch(const COutBufferException &e) { return e.ErrorCode; } \
+ catch(...) { return S_FALSE; }
+
+#endif
+
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ PPMD_TRY_BEGIN
+ return CodeReal(inStream, outStream, inSize, outSize, progress);
+ PPMD_TRY_END
+}
+
+STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
+{
+ _rangeDecoder.SetStream(inStream);
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::ReleaseInStream()
+{
+ _rangeDecoder.ReleaseStream();
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
+{
+ _outSizeDefined = (outSize != NULL);
+ if (_outSizeDefined)
+ _outSize = *outSize;
+ _processedSize = 0;
+ _remainLen = kLenIdNeedInit;
+ _outStream.Init();
+ return S_OK;
+}
+
+#ifdef _ST_MODE
+
+STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ PPMD_TRY_BEGIN
+ if (processedSize)
+ *processedSize = 0;
+ const UInt64 startPos = _processedSize;
+ RINOK(CodeSpec(size, (Byte *)data));
+ if (processedSize)
+ *processedSize = (UInt32)(_processedSize - startPos);
+ return Flush();
+ PPMD_TRY_END
+}
+
+#endif
+
+}}
diff --git a/CPP/7zip/Compress/PPMD/PPMDDecoder.h b/CPP/7zip/Compress/PPMD/PPMDDecoder.h
new file mode 100755
index 00000000..8e30c35c
--- /dev/null
+++ b/CPP/7zip/Compress/PPMD/PPMDDecoder.h
@@ -0,0 +1,89 @@
+// Compress/PPM/PPMDDecoder.h
+
+#ifndef __COMPRESS_PPMD_DECODER_H
+#define __COMPRESS_PPMD_DECODER_H
+
+#include "../../../Common/MyCom.h"
+
+#include "../../ICoder.h"
+#include "../../Common/OutBuffer.h"
+#include "../RangeCoder/RangeCoder.h"
+
+#include "PPMDDecode.h"
+
+namespace NCompress {
+namespace NPPMD {
+
+class CDecoder :
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ #ifdef _ST_MODE
+ public ICompressSetInStream,
+ public ICompressSetOutStreamSize,
+ public ISequentialInStream,
+ #endif
+ public CMyUnknownImp
+{
+ CRangeDecoder _rangeDecoder;
+
+ COutBuffer _outStream;
+
+ CDecodeInfo _info;
+
+ Byte _order;
+ UInt32 _usedMemorySize;
+
+ int _remainLen;
+ UInt64 _outSize;
+ bool _outSizeDefined;
+ UInt64 _processedSize;
+
+ HRESULT CodeSpec(UInt32 num, Byte *memStream);
+public:
+
+ #ifdef _ST_MODE
+ MY_UNKNOWN_IMP4(
+ ICompressSetDecoderProperties2,
+ ICompressSetInStream,
+ ICompressSetOutStreamSize,
+ ISequentialInStream)
+ #else
+ MY_UNKNOWN_IMP1(
+ ICompressSetDecoderProperties2)
+ #endif
+
+ void ReleaseStreams()
+ {
+ ReleaseInStream();
+ _outStream.ReleaseStream();
+ }
+
+ HRESULT Flush() { return _outStream.Flush(); }
+
+ STDMETHOD(CodeReal)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+ STDMETHOD(SetInStream)(ISequentialInStream *inStream);
+ STDMETHOD(ReleaseInStream)();
+ STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
+
+ #ifdef _ST_MODE
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ #endif
+
+ CDecoder(): _outSizeDefined(false) {}
+
+};
+
+}}
+
+#endif
diff --git a/7zip/Compress/PPMD/PPMDEncode.h b/CPP/7zip/Compress/PPMD/PPMDEncode.h
index 6a720cac..6a720cac 100755
--- a/7zip/Compress/PPMD/PPMDEncode.h
+++ b/CPP/7zip/Compress/PPMD/PPMDEncode.h
diff --git a/7zip/Compress/PPMD/PPMDEncoder.cpp b/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp
index fe99ea5a..fe99ea5a 100755
--- a/7zip/Compress/PPMD/PPMDEncoder.cpp
+++ b/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp
diff --git a/7zip/Compress/PPMD/PPMDEncoder.h b/CPP/7zip/Compress/PPMD/PPMDEncoder.h
index 915180b9..915180b9 100755
--- a/7zip/Compress/PPMD/PPMDEncoder.h
+++ b/CPP/7zip/Compress/PPMD/PPMDEncoder.h
diff --git a/CPP/7zip/Compress/PPMD/PPMDSubAlloc.h b/CPP/7zip/Compress/PPMD/PPMDSubAlloc.h
new file mode 100755
index 00000000..dce765d6
--- /dev/null
+++ b/CPP/7zip/Compress/PPMD/PPMDSubAlloc.h
@@ -0,0 +1,292 @@
+// PPMDSubAlloc.h
+// This code is based on Dmitry Shkarin's PPMdH code
+
+#ifndef __PPMD_SUBALLOC_H
+#define __PPMD_SUBALLOC_H
+
+#include "PPMDType.h"
+
+#include "../../../Common/Alloc.h"
+
+const UINT N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
+const UINT UNIT_SIZE=12, N_INDEXES=N1+N2+N3+N4;
+
+// Extra 1 * UNIT_SIZE for NULL support
+// Extra 2 * UNIT_SIZE for s0 in GlueFreeBlocks()
+const UInt32 kExtraSize = (UNIT_SIZE * 3);
+const UInt32 kMaxMemBlockSize = 0xFFFFFFFF - kExtraSize;
+
+struct MEM_BLK
+{
+ UInt16 Stamp, NU;
+ UInt32 Next, Prev;
+ 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)
+ {
+ ((MEM_BLK *)(Base + Prev))->Next = Next;
+ ((MEM_BLK *)(Base + Next))->Prev = Prev;
+ }
+};
+
+
+class CSubAllocator
+{
+ UInt32 SubAllocatorSize;
+ Byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;
+ UInt32 FreeList[N_INDEXES];
+
+ Byte *Base;
+ Byte *HeapStart, *LoUnit, *HiUnit;
+public:
+ Byte *pText, *UnitsStart;
+ CSubAllocator():
+ SubAllocatorSize(0),
+ GlueCount(0),
+ LoUnit(0),
+ HiUnit(0),
+ pText(0),
+ UnitsStart(0)
+ {
+ memset(Indx2Units, 0, sizeof(Indx2Units));
+ memset(FreeList, 0, sizeof(FreeList));
+ }
+ ~CSubAllocator()
+ {
+ StopSubAllocator();
+ };
+
+ void *GetPtr(UInt32 offset) const { return (offset == 0) ? 0 : (void *)(Base + offset); }
+ void *GetPtrNoCheck(UInt32 offset) const { return (void *)(Base + offset); }
+ UInt32 GetOffset(void *ptr) const { return (ptr == 0) ? 0 : (UInt32)((Byte *)ptr - Base); }
+ UInt32 GetOffsetNoCheck(void *ptr) const { return (UInt32)((Byte *)ptr - Base); }
+ 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)
+ {
+ *(UInt32 *)p = FreeList[indx];
+ FreeList[indx] = GetOffsetNoCheck(p);
+ }
+
+ void* RemoveNode(int indx)
+ {
+ UInt32 offset = FreeList[indx];
+ UInt32 *p = GetNode(offset);
+ FreeList[indx] = *p;
+ return (void *)p;
+ }
+
+ UINT U2B(int NU) const { return (UINT)(NU) * UNIT_SIZE; }
+
+ void SplitBlock(void* pv, int oldIndx, int newIndx)
+ {
+ int i, UDiff = Indx2Units[oldIndx] - Indx2Units[newIndx];
+ Byte* p = ((Byte*)pv) + U2B(Indx2Units[newIndx]);
+ if (Indx2Units[i = Units2Indx[UDiff-1]] != UDiff)
+ {
+ InsertNode(p, --i);
+ p += U2B(i = Indx2Units[i]);
+ UDiff -= i;
+ }
+ InsertNode(p, Units2Indx[UDiff - 1]);
+ }
+
+ UInt32 GetUsedMemory() const
+ {
+ UInt32 RetVal = SubAllocatorSize - (UInt32)(HiUnit - LoUnit) - (UInt32)(UnitsStart - pText);
+ 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);
+ }
+
+ UInt32 GetSubAllocatorSize() const { return SubAllocatorSize; }
+
+ void StopSubAllocator()
+ {
+ if (SubAllocatorSize != 0)
+ {
+ BigFree(Base);
+ SubAllocatorSize = 0;
+ Base = 0;
+ }
+ }
+
+ bool StartSubAllocator(UInt32 size)
+ {
+ if (SubAllocatorSize == size)
+ return true;
+ StopSubAllocator();
+ if (size == 0)
+ Base = 0;
+ else
+ {
+ if ((Base = (Byte *)::BigAlloc(size + kExtraSize)) == 0)
+ return false;
+ HeapStart = Base + UNIT_SIZE; // we need such code to support NULL;
+ }
+ SubAllocatorSize = size;
+ return true;
+ }
+
+ void InitSubAllocator()
+ {
+ int i, k;
+ memset(FreeList, 0, sizeof(FreeList));
+ HiUnit = (pText = HeapStart) + SubAllocatorSize;
+ UINT Diff = UNIT_SIZE * (SubAllocatorSize / 8 / UNIT_SIZE * 7);
+ LoUnit = UnitsStart = HiUnit - Diff;
+ for (i = 0, k=1; i < N1 ; i++, k += 1) Indx2Units[i] = (Byte)k;
+ for (k++; i < N1 + N2 ;i++, k += 2) Indx2Units[i] = (Byte)k;
+ 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++)
+ {
+ i += (Indx2Units[i] < k+1);
+ Units2Indx[k] = (Byte)i;
+ }
+ }
+
+ void GlueFreeBlocks()
+ {
+ UInt32 s0 = (UInt32)(HeapStart + SubAllocatorSize - Base);
+
+ // We need add exta MEM_BLK with Stamp=0
+ GetBlk(s0)->Stamp = 0;
+ s0 += UNIT_SIZE;
+ MEM_BLK *ps0 = GetBlk(s0);
+
+ UInt32 p;
+ int i;
+ if (LoUnit != HiUnit)
+ *LoUnit=0;
+ ps0->Next = ps0->Prev = s0;
+
+ for (i = 0; i < N_INDEXES; i++)
+ while (FreeList[i] != 0)
+ {
+ MEM_BLK *pp = (MEM_BLK *)RemoveNode(i);
+ pp->InsertAt(Base, s0);
+ pp->Stamp = 0xFFFF;
+ pp->NU = Indx2Units[i];
+ }
+ for (p = ps0->Next; p != s0; p = GetBlk(p)->Next)
+ {
+ for (;;)
+ {
+ MEM_BLK *pp = GetBlk(p);
+ MEM_BLK *pp1 = GetBlk(p + pp->NU * UNIT_SIZE);
+ if (pp1->Stamp != 0xFFFF || int(pp->NU) + pp1->NU >= 0x10000)
+ break;
+ pp1->Remove(Base);
+ pp->NU = (UInt16)(pp->NU + pp1->NU);
+ }
+ }
+ 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)
+ {
+ int k = sz - Indx2Units[--i];
+ InsertNode(Base + p + (sz - k) * UNIT_SIZE, k - 1);
+ }
+ InsertNode(Base + p, i);
+ }
+ }
+ void* AllocUnitsRare(int indx)
+ {
+ if ( !GlueCount )
+ {
+ GlueCount = 255;
+ GlueFreeBlocks();
+ if (FreeList[indx] != 0)
+ return RemoveNode(indx);
+ }
+ int i = indx;
+ do
+ {
+ if (++i == N_INDEXES)
+ {
+ GlueCount--;
+ i = U2B(Indx2Units[indx]);
+ return (UnitsStart - pText > i) ? (UnitsStart -= i) : (NULL);
+ }
+ } while (FreeList[i] == 0);
+ void* RetVal = RemoveNode(i);
+ SplitBlock(RetVal, i, indx);
+ return RetVal;
+ }
+
+ void* AllocUnits(int NU)
+ {
+ int indx = Units2Indx[NU - 1];
+ if (FreeList[indx] != 0)
+ return RemoveNode(indx);
+ void* RetVal = LoUnit;
+ LoUnit += U2B(Indx2Units[indx]);
+ if (LoUnit <= HiUnit)
+ return RetVal;
+ LoUnit -= U2B(Indx2Units[indx]);
+ return AllocUnitsRare(indx);
+ }
+
+ void* AllocContext()
+ {
+ if (HiUnit != LoUnit)
+ return (HiUnit -= UNIT_SIZE);
+ if (FreeList[0] != 0)
+ return RemoveNode(0);
+ return AllocUnitsRare(0);
+ }
+
+ void* ExpandUnits(void* oldPtr, int oldNU)
+ {
+ int i0=Units2Indx[oldNU - 1], i1=Units2Indx[oldNU - 1 + 1];
+ if (i0 == i1)
+ return oldPtr;
+ void* ptr = AllocUnits(oldNU + 1);
+ if (ptr)
+ {
+ memcpy(ptr, oldPtr, U2B(oldNU));
+ InsertNode(oldPtr, i0);
+ }
+ return ptr;
+ }
+
+ void* ShrinkUnits(void* oldPtr, int oldNU, int newNU)
+ {
+ int i0 = Units2Indx[oldNU - 1], i1 = Units2Indx[newNU - 1];
+ if (i0 == i1)
+ return oldPtr;
+ if (FreeList[i1] != 0)
+ {
+ void* ptr = RemoveNode(i1);
+ memcpy(ptr, oldPtr, U2B(newNU));
+ InsertNode(oldPtr,i0);
+ return ptr;
+ }
+ else
+ {
+ SplitBlock(oldPtr, i0, i1);
+ return oldPtr;
+ }
+ }
+
+ void FreeUnits(void* ptr, int oldNU)
+ {
+ InsertNode(ptr, Units2Indx[oldNU - 1]);
+ }
+};
+
+#endif
diff --git a/7zip/Compress/PPMD/PPMDType.h b/CPP/7zip/Compress/PPMD/PPMDType.h
index 5200fa54..5200fa54 100755
--- a/7zip/Compress/PPMD/PPMDType.h
+++ b/CPP/7zip/Compress/PPMD/PPMDType.h
diff --git a/7zip/Compress/Rar29/StdAfx.cpp b/CPP/7zip/Compress/PPMD/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/Rar29/StdAfx.cpp
+++ b/CPP/7zip/Compress/PPMD/StdAfx.cpp
diff --git a/7zip/Compress/PPMD/StdAfx.h b/CPP/7zip/Compress/PPMD/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/PPMD/StdAfx.h
+++ b/CPP/7zip/Compress/PPMD/StdAfx.h
diff --git a/7zip/Compress/PPMD/makefile b/CPP/7zip/Compress/PPMD/makefile
index 2e687a70..2e687a70 100755
--- a/7zip/Compress/PPMD/makefile
+++ b/CPP/7zip/Compress/PPMD/makefile
diff --git a/7zip/Compress/PPMD/resource.rc b/CPP/7zip/Compress/PPMD/resource.rc
index fed98e19..fed98e19 100755
--- a/7zip/Compress/PPMD/resource.rc
+++ b/CPP/7zip/Compress/PPMD/resource.rc
diff --git a/7zip/Compress/Quantum/QuantumDecoder.cpp b/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp
index 5cf863bb..5cf863bb 100755
--- a/7zip/Compress/Quantum/QuantumDecoder.cpp
+++ b/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp
diff --git a/7zip/Compress/Quantum/QuantumDecoder.h b/CPP/7zip/Compress/Quantum/QuantumDecoder.h
index 8b5aaaba..8b5aaaba 100755
--- a/7zip/Compress/Quantum/QuantumDecoder.h
+++ b/CPP/7zip/Compress/Quantum/QuantumDecoder.h
diff --git a/7zip/Compress/RangeCoder/RangeCoder.h b/CPP/7zip/Compress/RangeCoder/RangeCoder.h
index bbb2ba82..bbb2ba82 100755
--- a/7zip/Compress/RangeCoder/RangeCoder.h
+++ b/CPP/7zip/Compress/RangeCoder/RangeCoder.h
diff --git a/7zip/Compress/RangeCoder/RangeCoderBit.cpp b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp
index 8e4c4d3a..8e4c4d3a 100755
--- a/7zip/Compress/RangeCoder/RangeCoderBit.cpp
+++ b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp
diff --git a/7zip/Compress/RangeCoder/RangeCoderBit.h b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.h
index 624f887c..624f887c 100755
--- a/7zip/Compress/RangeCoder/RangeCoderBit.h
+++ b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.h
diff --git a/7zip/Compress/RangeCoder/RangeCoderBitTree.h b/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h
index 4f0c78b4..4f0c78b4 100755
--- a/7zip/Compress/RangeCoder/RangeCoderBitTree.h
+++ b/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h
diff --git a/7zip/Compress/RangeCoder/RangeCoderOpt.h b/CPP/7zip/Compress/RangeCoder/RangeCoderOpt.h
index 668b9a5b..668b9a5b 100755
--- a/7zip/Compress/RangeCoder/RangeCoderOpt.h
+++ b/CPP/7zip/Compress/RangeCoder/RangeCoderOpt.h
diff --git a/7zip/Compress/RangeCoder/StdAfx.h b/CPP/7zip/Compress/RangeCoder/StdAfx.h
index b637fd40..b637fd40 100755
--- a/7zip/Compress/RangeCoder/StdAfx.h
+++ b/CPP/7zip/Compress/RangeCoder/StdAfx.h
diff --git a/CPP/7zip/Compress/Rar/DllExports.cpp b/CPP/7zip/Compress/Rar/DllExports.cpp
new file mode 100755
index 00000000..acc3068e
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/DllExports.cpp
@@ -0,0 +1,91 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+#include "Common/ComTry.h"
+
+#include "Rar1Decoder.h"
+#include "Rar2Decoder.h"
+#include "Rar3Decoder.h"
+// #include "Rar29Decoder.h"
+
+#define RarClassId(ver) CLSID_CCompressRar ## ver ## Decoder
+
+#define MyClassRar(ver) DEFINE_GUID(RarClassId(ver), \
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, ver, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+MyClassRar(1);
+MyClassRar(2);
+MyClassRar(3);
+
+#define CreateCoder(ver) if (*clsid == RarClassId(ver)) \
+{ if (!correctInterface) return E_NOINTERFACE; \
+coder = (ICompressCoder *)new NCompress::NRar ## ver::CDecoder; }
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
+{
+ return TRUE;
+}
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ int correctInterface = (*iid == IID_ICompressCoder);
+ CMyComPtr<ICompressCoder> coder;
+ CreateCoder(1) else
+ CreateCoder(2) else
+ CreateCoder(3) else
+ return CLASS_E_CLASSNOTAVAILABLE;
+ *outObject = coder.Detach();
+ COM_TRY_END
+ return S_OK;
+}
+
+struct CRarMethodItem
+{
+ char ID[3];
+ const wchar_t *UserName;
+ const GUID *Decoder;
+};
+
+static CRarMethodItem g_Methods[] =
+{
+ { { 0x04, 0x03, 0x01 }, L"Rar15", &RarClassId(1) },
+ { { 0x04, 0x03, 0x02 }, L"Rar20", &RarClassId(2) },
+ { { 0x04, 0x03, 0x03 }, L"Rar29", &RarClassId(3) }
+};
+
+STDAPI GetNumberOfMethods(UINT32 *numMethods)
+{
+ *numMethods = sizeof(g_Methods) / sizeof(g_Methods[1]);
+ return S_OK;
+}
+
+STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
+{
+ if (index > sizeof(g_Methods) / sizeof(g_Methods[1]))
+ return E_INVALIDARG;
+ VariantClear((tagVARIANT *)value);
+ const CRarMethodItem &method = g_Methods[index];
+ switch(propID)
+ {
+ case NMethodPropID::kID:
+ if ((value->bstrVal = ::SysAllocStringByteLen(method.ID,
+ sizeof(method.ID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kName:
+ if ((value->bstrVal = ::SysAllocString(method.UserName)) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kDecoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)method.Decoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ return S_OK;
+}
diff --git a/CPP/7zip/Compress/Rar/Rar1Decoder.cpp b/CPP/7zip/Compress/Rar/Rar1Decoder.cpp
new file mode 100755
index 00000000..c30443de
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar1Decoder.cpp
@@ -0,0 +1,485 @@
+// Rar1Decoder.cpp
+// According to unRAR license,
+// this code may not be used to develop a
+// RAR (WinRAR) compatible archiver
+
+#include "StdAfx.h"
+
+#include "Rar1Decoder.h"
+
+namespace NCompress {
+namespace NRar1 {
+
+static UInt32 PosL1[]={0,0,0,2,3,5,7,11,16,20,24,32,32, 256};
+static UInt32 PosL2[]={0,0,0,0,5,7,9,13,18,22,26,34,36, 256};
+static UInt32 PosHf0[]={0,0,0,0,0,8,16,24,33,33,33,33,33, 257};
+static UInt32 PosHf1[]={0,0,0,0,0,0,4,44,60,76,80,80,127, 257};
+static UInt32 PosHf2[]={0,0,0,0,0,0,2,7,53,117,233, 257,0};
+static UInt32 PosHf3[]={0,0,0,0,0,0,0,2,16,218,251, 257,0};
+static UInt32 PosHf4[]={0,0,0,0,0,0,0,0,0,255, 257,0,0};
+
+static const UInt32 kHistorySize = (1 << 16);
+
+class CCoderReleaser
+{
+ CDecoder *m_Coder;
+public:
+ CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
+ ~CCoderReleaser() { m_Coder->ReleaseStreams(); }
+};
+
+CDecoder::CDecoder(): m_IsSolid(false) { }
+
+void CDecoder::InitStructures()
+{
+ for(int i = 0; i < kNumRepDists; i++)
+ m_RepDists[i] = 0;
+ m_RepDistPtr = 0;
+ LastLength = 0;
+ LastDist = 0;
+}
+
+UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+
+HRESULT CDecoder::CopyBlock(UInt32 distance, UInt32 len)
+{
+ m_UnpackSize -= len;
+ return m_OutWindowStream.CopyBlock(distance, len) ? S_OK : S_FALSE;
+}
+
+
+UInt32 CDecoder::DecodeNum(const UInt32 *posTab)
+{
+ UInt32 startPos = 2;
+ UInt32 num = m_InBitStream.GetValue(12);
+ for (;;)
+ {
+ UInt32 cur = (posTab[startPos + 1] - posTab[startPos]) << (12 - startPos);
+ if (num < cur)
+ break;
+ startPos++;
+ num -= cur;
+ }
+ m_InBitStream.MovePos(startPos);
+ return((num >> (12 - startPos)) + posTab[startPos]);
+}
+
+static Byte kShortLen1[] = {1,3,4,4,5,6,7,8,8,4,4,5,6,6 };
+static Byte kShortLen1a[] = {1,4,4,4,5,6,7,8,8,4,4,5,6,6,4 };
+static Byte kShortLen2[] = {2,3,3,3,4,4,5,6,6,4,4,5,6,6 };
+static Byte kShortLen2a[] = {2,3,3,4,4,4,5,6,6,4,4,5,6,6,4 };
+static UInt32 kShortXor1[] = {0,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xc0,0x80,0x90,0x98,0x9c,0xb0};
+static UInt32 kShortXor2[] = {0,0x40,0x60,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xc0,0x80,0x90,0x98,0x9c,0xb0};
+
+HRESULT CDecoder::ShortLZ()
+{
+ UInt32 len, saveLen, dist;
+ int distancePlace;
+ Byte *kShortLen;
+ const UInt32 *kShortXor;
+ NumHuf = 0;
+
+ if (LCount == 2)
+ {
+ if (ReadBits(1))
+ return CopyBlock(LastDist, LastLength);
+ LCount = 0;
+ }
+
+ UInt32 bitField = m_InBitStream.GetValue(8);
+
+ if (AvrLn1 < 37)
+ {
+ kShortLen = Buf60 ? kShortLen1a : kShortLen1;
+ kShortXor = kShortXor1;
+ }
+ else
+ {
+ kShortLen = Buf60 ? kShortLen2a : kShortLen2;
+ kShortXor = kShortXor2;
+ }
+
+ for (len = 0; ((bitField ^ kShortXor[len]) & (~(0xff >> kShortLen[len]))) != 0; len++);
+ m_InBitStream.MovePos(kShortLen[len]);
+
+ if (len >= 9)
+ {
+ if (len == 9)
+ {
+ LCount++;
+ return CopyBlock(LastDist, LastLength);
+ }
+ if (len == 14)
+ {
+ LCount = 0;
+ len = DecodeNum(PosL2) + 5;
+ dist = 0x8000 + ReadBits(15) - 1;
+ LastLength = len;
+ LastDist = dist;
+ return CopyBlock(dist, len);
+ }
+
+ LCount = 0;
+ saveLen = len;
+ dist = m_RepDists[(m_RepDistPtr - (len - 9)) & 3];
+ len = DecodeNum(PosL1) + 2;
+ if (len == 0x101 && saveLen == 10)
+ {
+ Buf60 ^= 1;
+ return S_OK;
+ }
+ if (dist >= 256)
+ len++;
+ if (dist >= MaxDist3 - 1)
+ len++;
+ }
+ else
+ {
+ LCount = 0;
+ AvrLn1 += len;
+ AvrLn1 -= AvrLn1 >> 4;
+
+ distancePlace = DecodeNum(PosHf2) & 0xff;
+ dist = ChSetA[distancePlace];
+ if (--distancePlace != -1)
+ {
+ PlaceA[dist]--;
+ UInt32 lastDistance = ChSetA[distancePlace];
+ PlaceA[lastDistance]++;
+ ChSetA[distancePlace + 1] = lastDistance;
+ ChSetA[distancePlace] = dist;
+ }
+ len += 2;
+ }
+ m_RepDists[m_RepDistPtr++] = dist;
+ m_RepDistPtr &= 3;
+ LastLength = len;
+ LastDist = dist;
+ return CopyBlock(dist, len);
+}
+
+
+HRESULT CDecoder::LongLZ()
+{
+ UInt32 len;
+ UInt32 dist;
+ UInt32 distancePlace, newDistancePlace;
+ UInt32 oldAvr2, oldAvr3;
+
+ NumHuf = 0;
+ Nlzb += 16;
+ if (Nlzb > 0xff)
+ {
+ Nlzb = 0x90;
+ Nhfb >>= 1;
+ }
+ oldAvr2=AvrLn2;
+
+ if (AvrLn2 >= 122)
+ len = DecodeNum(PosL2);
+ else if (AvrLn2 >= 64)
+ len = DecodeNum(PosL1);
+ else
+ {
+ UInt32 bitField = m_InBitStream.GetValue(16);
+ if (bitField < 0x100)
+ {
+ len = bitField;
+ m_InBitStream.MovePos(16);
+ }
+ else
+ {
+ for (len = 0; ((bitField << len) & 0x8000) == 0; len++)
+ ;
+ m_InBitStream.MovePos(len + 1);
+ }
+ }
+
+ AvrLn2 += len;
+ AvrLn2 -= AvrLn2 >> 5;
+
+ if (AvrPlcB > 0x28ff)
+ distancePlace = DecodeNum(PosHf2);
+ else if (AvrPlcB > 0x6ff)
+ distancePlace = DecodeNum(PosHf1);
+ else
+ distancePlace = DecodeNum(PosHf0);
+
+ AvrPlcB += distancePlace;
+ AvrPlcB -= AvrPlcB >> 8;
+ for (;;)
+ {
+ dist = ChSetB[distancePlace & 0xff];
+ newDistancePlace = NToPlB[dist++ & 0xff]++;
+ if (!(dist & 0xff))
+ CorrHuff(ChSetB,NToPlB);
+ else
+ break;
+ }
+
+ ChSetB[distancePlace] = ChSetB[newDistancePlace];
+ ChSetB[newDistancePlace] = dist;
+
+ dist = ((dist & 0xff00) >> 1) | ReadBits(7);
+
+ oldAvr3 = AvrLn3;
+ if (len != 1 && len != 4)
+ if (len == 0 && dist <= MaxDist3)
+ {
+ AvrLn3++;
+ AvrLn3 -= AvrLn3 >> 8;
+ }
+ else
+ if (AvrLn3 > 0)
+ AvrLn3--;
+ len += 3;
+ if (dist >= MaxDist3)
+ len++;
+ if (dist <= 256)
+ len += 8;
+ if (oldAvr3 > 0xb0 || AvrPlc >= 0x2a00 && oldAvr2 < 0x40)
+ MaxDist3 = 0x7f00;
+ else
+ MaxDist3 = 0x2001;
+ m_RepDists[m_RepDistPtr++] = --dist;
+ m_RepDistPtr &= 3;
+ LastLength = len;
+ LastDist = dist;
+ return CopyBlock(dist, len);
+}
+
+
+HRESULT CDecoder::HuffDecode()
+{
+ UInt32 curByte, newBytePlace;
+ UInt32 len;
+ UInt32 dist;
+ int bytePlace;
+
+ if (AvrPlc > 0x75ff) bytePlace = DecodeNum(PosHf4);
+ else if (AvrPlc > 0x5dff) bytePlace = DecodeNum(PosHf3);
+ else if (AvrPlc > 0x35ff) bytePlace = DecodeNum(PosHf2);
+ else if (AvrPlc > 0x0dff) bytePlace = DecodeNum(PosHf1);
+ else bytePlace = DecodeNum(PosHf0);
+ if (StMode)
+ {
+ if (--bytePlace == -1)
+ {
+ if (ReadBits(1))
+ {
+ NumHuf = StMode = 0;
+ return S_OK;
+ }
+ else
+ {
+ len = (ReadBits(1)) ? 4 : 3;
+ dist = DecodeNum(PosHf2);
+ dist = (dist << 5) | ReadBits(5);
+ return CopyBlock(dist - 1, len);
+ }
+ }
+ }
+ else if (NumHuf++ >= 16 && FlagsCnt == 0)
+ StMode = 1;
+ bytePlace &= 0xff;
+ AvrPlc += bytePlace;
+ AvrPlc -= AvrPlc >> 8;
+ Nhfb+=16;
+ if (Nhfb > 0xff)
+ {
+ Nhfb=0x90;
+ Nlzb >>= 1;
+ }
+
+ m_UnpackSize --;
+ m_OutWindowStream.PutByte((Byte)(ChSet[bytePlace] >> 8));
+
+ for (;;)
+ {
+ curByte = ChSet[bytePlace];
+ newBytePlace = NToPl[curByte++ & 0xff]++;
+ if ((curByte & 0xff) > 0xa1)
+ CorrHuff(ChSet, NToPl);
+ else
+ break;
+ }
+
+ ChSet[bytePlace] = ChSet[newBytePlace];
+ ChSet[newBytePlace] = curByte;
+ return S_OK;
+}
+
+
+void CDecoder::GetFlagsBuf()
+{
+ UInt32 flags, newFlagsPlace;
+ UInt32 flagsPlace = DecodeNum(PosHf2);
+
+ for (;;)
+ {
+ flags = ChSetC[flagsPlace];
+ FlagBuf = flags >> 8;
+ newFlagsPlace = NToPlC[flags++ & 0xff]++;
+ if ((flags & 0xff) != 0)
+ break;
+ CorrHuff(ChSetC, NToPlC);
+ }
+
+ ChSetC[flagsPlace] = ChSetC[newFlagsPlace];
+ ChSetC[newFlagsPlace] = flags;
+}
+
+void CDecoder::InitData()
+{
+ if (!m_IsSolid)
+ {
+ AvrPlcB = AvrLn1 = AvrLn2 = AvrLn3 = NumHuf = Buf60 = 0;
+ AvrPlc = 0x3500;
+ MaxDist3 = 0x2001;
+ Nhfb = Nlzb = 0x80;
+ }
+ FlagsCnt = 0;
+ FlagBuf = 0;
+ StMode = 0;
+ LCount = 0;
+}
+
+void CDecoder::CorrHuff(UInt32 *CharSet,UInt32 *NumToPlace)
+{
+ int i;
+ for (i = 7; i >= 0; i--)
+ for (int j = 0; j < 32; j++, CharSet++)
+ *CharSet = (*CharSet & ~0xff) | i;
+ memset(NumToPlace, 0, sizeof(NToPl));
+ for (i = 6; i >= 0; i--)
+ NumToPlace[i] = (7 - i) * 32;
+}
+
+void CDecoder::InitHuff()
+{
+ for (UInt32 i = 0; i < 256; i++)
+ {
+ Place[i] = PlaceA[i] = PlaceB[i] = i;
+ PlaceC[i] = (~i + 1) & 0xff;
+ ChSet[i] = ChSetB[i] = i << 8;
+ ChSetA[i] = i;
+ ChSetC[i] = ((~i + 1) & 0xff) << 8;
+ }
+ memset(NToPl, 0, sizeof(NToPl));
+ memset(NToPlB, 0, sizeof(NToPlB));
+ memset(NToPlC, 0, sizeof(NToPlC));
+ CorrHuff(ChSetB, NToPlB);
+}
+
+STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo * /* progress */)
+{
+ if (inSize == NULL || outSize == NULL)
+ return E_INVALIDARG;
+
+ if (!m_OutWindowStream.Create(kHistorySize))
+ return E_OUTOFMEMORY;
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ m_UnpackSize = (Int64)*outSize;
+ m_OutWindowStream.SetStream(outStream);
+ m_OutWindowStream.Init(m_IsSolid);
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+
+ CCoderReleaser coderReleaser(this);
+ InitData();
+ if (!m_IsSolid)
+ {
+ InitStructures();
+ InitHuff();
+ }
+ if (m_UnpackSize > 0)
+ {
+ GetFlagsBuf();
+ FlagsCnt = 8;
+ }
+
+ while (m_UnpackSize > 0)
+ {
+ if (StMode)
+ {
+ RINOK(HuffDecode());
+ continue;
+ }
+
+ if (--FlagsCnt < 0)
+ {
+ GetFlagsBuf();
+ FlagsCnt=7;
+ }
+
+ if (FlagBuf & 0x80)
+ {
+ FlagBuf <<= 1;
+ if (Nlzb > Nhfb)
+ {
+ RINOK(LongLZ());
+ }
+ else
+ {
+ RINOK(HuffDecode());
+ }
+ }
+ else
+ {
+ FlagBuf <<= 1;
+ if (--FlagsCnt < 0)
+ {
+ GetFlagsBuf();
+ FlagsCnt = 7;
+ }
+ if (FlagBuf & 0x80)
+ {
+ FlagBuf <<= 1;
+ if (Nlzb > Nhfb)
+ {
+ RINOK(HuffDecode());
+ }
+ else
+ {
+ RINOK(LongLZ());
+ }
+ }
+ else
+ {
+ FlagBuf <<= 1;
+ RINOK(ShortLZ());
+ }
+ }
+ }
+ if (m_UnpackSize < 0)
+ return S_FALSE;
+ return m_OutWindowStream.Flush();
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ try
+ {
+ HRESULT res = CodeReal(inStream, outStream, inSize, outSize, progress);
+ m_OutWindowStream.Flush();
+ return res;
+ }
+ catch(const CLZOutWindowException &e) { m_OutWindowStream.Flush(); return e.ErrorCode; }
+ catch(...) { m_OutWindowStream.Flush(); return S_FALSE; }
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size < 1)
+ return E_INVALIDARG;
+ m_IsSolid = (data[0] != 0);
+ return S_OK;
+}
+
+}}
diff --git a/CPP/7zip/Compress/Rar/Rar1Decoder.h b/CPP/7zip/Compress/Rar/Rar1Decoder.h
new file mode 100755
index 00000000..bdaf4d85
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar1Decoder.h
@@ -0,0 +1,90 @@
+// Rar15Decoder.h
+// According to unRAR license,
+// this code may not be used to develop a
+// RAR (WinRAR) compatible archiver
+
+#ifndef __RAR10_DECODER_H
+#define __RAR10_DECODER_H
+
+#include "../../../Common/MyCom.h"
+
+#include "../../ICoder.h"
+#include "../../Common/MSBFDecoder.h"
+#include "../../Common/InBuffer.h"
+
+#include "../LZ/LZOutWindow.h"
+#include "../Huffman/HuffmanDecoder.h"
+
+namespace NCompress {
+namespace NRar1 {
+
+const UInt32 kNumRepDists = 4;
+
+typedef NStream::NMSBF::CDecoder<CInBuffer> CBitDecoder;
+
+class CDecoder :
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+public:
+ CLZOutWindow m_OutWindowStream;
+ CBitDecoder m_InBitStream;
+
+ UInt32 m_RepDists[kNumRepDists];
+ UInt32 m_RepDistPtr;
+
+ UInt32 LastDist;
+ UInt32 LastLength;
+
+ Int64 m_UnpackSize;
+ bool m_IsSolid;
+
+ UInt32 ReadBits(int numBits);
+ HRESULT CopyBlock(UInt32 distance, UInt32 len);
+
+ UInt32 DecodeNum(const UInt32 *posTab);
+ HRESULT ShortLZ();
+ HRESULT LongLZ();
+ HRESULT HuffDecode();
+ void GetFlagsBuf();
+ void InitData();
+ void InitHuff();
+ void CorrHuff(UInt32 *CharSet, UInt32 *NumToPlace);
+ void OldUnpWriteBuf();
+
+ UInt32 ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
+ UInt32 Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
+ UInt32 NToPl[256],NToPlB[256],NToPlC[256];
+ UInt32 FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
+ int Buf60,NumHuf,StMode,LCount,FlagsCnt;
+ UInt32 Nhfb,Nlzb,MaxDist3;
+
+ void InitStructures();
+
+public:
+ CDecoder();
+
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+
+ void ReleaseStreams()
+ {
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ }
+
+ STDMETHOD(CodeReal)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Compress/Rar/Rar29.dsp b/CPP/7zip/Compress/Rar/Rar29.dsp
new file mode 100755
index 00000000..9a0b86bb
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar29.dsp
@@ -0,0 +1,297 @@
+# Microsoft Developer Studio Project File - Name="Rar29" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=Rar29 - 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 "Rar29.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 "Rar29.mak" CFG="Rar29 - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Rar29 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "Rar29 - 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)" == "Rar29 - 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 "RAR29_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAR29_EXPORTS" /D "SILENT" /D "NOCRYPT" /D "NOVOLUME" /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\Rar29.dll" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "Rar29 - 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 "RAR29_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 "RAR29_EXPORTS" /D "SILENT" /D "NOCRYPT" /D "NOVOLUME" /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\Rar29.dll" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "Rar29 - Win32 Release"
+# Name "Rar29 - Win32 Debug"
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Codec.def
+# 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 "7zip 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\MSBFDecoder.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 "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 "Huffman"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Huffman\HuffmanDecoder.h
+# End Source File
+# End Group
+# Begin Group "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.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\Vector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.h
+# End Source File
+# End Group
+# Begin Group "Rar3"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\PPMD\PPMDContext.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\PPMD\PPMDDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\PPMD\PPMDSubAlloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\PPMD\PPMDType.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rar1Decoder.cpp
+
+!IF "$(CFG)" == "Rar29 - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rar1Decoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rar2Decoder.cpp
+
+!IF "$(CFG)" == "Rar29 - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rar2Decoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rar3Decoder.cpp
+
+!IF "$(CFG)" == "Rar29 - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rar3Decoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rar3Vm.cpp
+
+!IF "$(CFG)" == "Rar29 - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rar3Vm.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/CPP/7zip/Compress/Rar/Rar29.dsw b/CPP/7zip/Compress/Rar/Rar29.dsw
new file mode 100755
index 00000000..70172e1a
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar29.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "Rar29"=.\Rar29.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/CPP/7zip/Compress/Rar/Rar2Decoder.cpp b/CPP/7zip/Compress/Rar/Rar2Decoder.cpp
new file mode 100755
index 00000000..43473695
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar2Decoder.cpp
@@ -0,0 +1,401 @@
+// Rar2Decoder.cpp
+// According to unRAR license,
+// this code may not be used to develop a
+// RAR (WinRAR) compatible archiver
+
+#include "StdAfx.h"
+
+#include "Rar2Decoder.h"
+
+namespace NCompress {
+namespace NRar2 {
+
+namespace NMultimedia {
+
+Byte CFilter::Decode(int &channelDelta, Byte deltaByte)
+{
+ D4 = D3;
+ D3 = D2;
+ D2 = LastDelta - D1;
+ D1 = LastDelta;
+ int predictedValue = ((8 * LastChar + K1 * D1 + K2 * D2 + K3 * D3 + K4 * D4 + K5 * channelDelta) >> 3);
+
+ Byte realValue = (Byte)(predictedValue - deltaByte);
+ int i = ((int)(signed char)deltaByte) << 3;
+
+ Dif[0] += abs(i);
+ Dif[1] += abs(i - D1);
+ Dif[2] += abs(i + D1);
+ Dif[3] += abs(i - D2);
+ Dif[4] += abs(i + D2);
+ Dif[5] += abs(i - D3);
+ Dif[6] += abs(i + D3);
+ Dif[7] += abs(i - D4);
+ Dif[8] += abs(i + D4);
+ Dif[9] += abs(i - channelDelta);
+ Dif[10] += abs(i + channelDelta);
+
+ channelDelta = LastDelta = (signed char)(realValue - LastChar);
+ LastChar = realValue;
+
+ if (((++ByteCount) & 0x1F) == 0)
+ {
+ UInt32 minDif = Dif[0];
+ UInt32 numMinDif = 0;
+ Dif[0] = 0;
+ for (i = 1; i < sizeof(Dif) / sizeof(Dif[0]); i++)
+ {
+ if (Dif[i] < minDif)
+ {
+ minDif = Dif[i];
+ numMinDif = i;
+ }
+ Dif[i] = 0;
+ }
+ switch(numMinDif)
+ {
+ 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 5: if (K3 >= -16) K3--; break;
+ case 6: if (K3 < 16) K3++; break;
+ case 7: if (K4 >= -16) K4--; break;
+ case 8: if (K4 < 16) K4++; break;
+ case 9: if (K5 >= -16) K5--; break;
+ case 10:if (K5 < 16) K5++; break;
+ }
+ }
+ return realValue;
+}
+}
+
+class CException
+{
+public:
+ enum ECauseType
+ {
+ kData
+ } Cause;
+ CException(ECauseType cause): Cause(cause) {}
+};
+
+static const char *kNumberErrorMessage = "Number error";
+
+static const UInt32 kHistorySize = 1 << 20;
+
+static const int kNumStats = 11;
+
+static const UInt32 kWindowReservSize = (1 << 22) + 256;
+
+CDecoder::CDecoder():
+ m_IsSolid(false)
+{
+}
+
+void CDecoder::InitStructures()
+{
+ m_MmFilter.Init();
+ for(int i = 0; i < kNumRepDists; i++)
+ m_RepDists[i] = 0;
+ m_RepDistPtr = 0;
+ m_LastLength = 0;
+ memset(m_LastLevels, 0, kMaxTableSize);
+}
+
+UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+
+#define RIF(x) { if (!(x)) return false; }
+
+bool CDecoder::ReadTables(void)
+{
+ Byte levelLevels[kLevelTableSize];
+ Byte newLevels[kMaxTableSize];
+ m_AudioMode = (ReadBits(1) == 1);
+
+ if (ReadBits(1) == 0)
+ memset(m_LastLevels, 0, kMaxTableSize);
+ int numLevels;
+ if (m_AudioMode)
+ {
+ m_NumChannels = ReadBits(2) + 1;
+ if (m_MmFilter.CurrentChannel >= m_NumChannels)
+ m_MmFilter.CurrentChannel = 0;
+ numLevels = m_NumChannels * kMMTableSize;
+ }
+ else
+ numLevels = kHeapTablesSizesSum;
+
+ int i;
+ for (i = 0; i < kLevelTableSize; i++)
+ levelLevels[i] = (Byte)ReadBits(4);
+ RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
+ i = 0;
+ while (i < numLevels)
+ {
+ UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < kTableDirectLevels)
+ {
+ newLevels[i] = (Byte)((number + m_LastLevels[i]) & kLevelMask);
+ i++;
+ }
+ else
+ {
+ if (number == kTableLevelRepNumber)
+ {
+ int t = ReadBits(2) + 3;
+ for (int reps = t; reps > 0 && i < numLevels ; reps--, i++)
+ newLevels[i] = newLevels[i - 1];
+ }
+ else
+ {
+ int num;
+ if (number == kTableLevel0Number)
+ num = ReadBits(3) + 3;
+ else if (number == kTableLevel0Number2)
+ num = ReadBits(7) + 11;
+ else
+ return false;
+ for (;num > 0 && i < numLevels; num--)
+ newLevels[i++] = 0;
+ }
+ }
+ }
+ if (m_AudioMode)
+ for (i = 0; i < m_NumChannels; i++)
+ {
+ RIF(m_MMDecoders[i].SetCodeLengths(&newLevels[i * kMMTableSize]));
+ }
+ else
+ {
+ RIF(m_MainDecoder.SetCodeLengths(&newLevels[0]));
+ RIF(m_DistDecoder.SetCodeLengths(&newLevels[kMainTableSize]));
+ RIF(m_LenDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize]));
+ }
+ memcpy(m_LastLevels, newLevels, kMaxTableSize);
+ return true;
+}
+
+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_AudioMode)
+ {
+ UInt32 symbol = m_MMDecoders[m_MmFilter.CurrentChannel].DecodeSymbol(&m_InBitStream);
+ if (symbol == 256)
+ return ReadTables();
+ if (symbol >= kMMTableSize)
+ return false;
+ }
+ else
+ {
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ if (number == kReadTableNumber)
+ return ReadTables();
+ if (number >= kMainTableSize)
+ return false;
+ }
+ return true;
+}
+
+class CCoderReleaser
+{
+ CDecoder *m_Coder;
+public:
+ CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
+ ~CCoderReleaser()
+ {
+ m_Coder->ReleaseStreams();
+ }
+};
+
+bool CDecoder::DecodeMm(UInt32 pos)
+{
+ while (pos-- > 0)
+ {
+ UInt32 symbol = m_MMDecoders[m_MmFilter.CurrentChannel].DecodeSymbol(&m_InBitStream);
+ if (symbol == 256)
+ return true;
+ if (symbol >= kMMTableSize)
+ return false;
+ /*
+ Byte byPredict = m_Predictor.Predict();
+ Byte byReal = (Byte)(byPredict - (Byte)symbol);
+ m_Predictor.Update(byReal, byPredict);
+ */
+ Byte byReal = m_MmFilter.Decode((Byte)symbol);
+ m_OutWindowStream.PutByte(byReal);
+ if (++m_MmFilter.CurrentChannel == m_NumChannels)
+ m_MmFilter.CurrentChannel = 0;
+ }
+ return true;
+}
+
+bool CDecoder::DecodeLz(Int32 pos)
+{
+ while (pos > 0)
+ {
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ UInt32 length, distance;
+ if (number < 256)
+ {
+ m_OutWindowStream.PutByte(Byte(number));
+ pos--;
+ continue;
+ }
+ else if (number >= kMatchNumber)
+ {
+ number -= kMatchNumber;
+ length = kNormalMatchMinLen + UInt32(kLenStart[number]) +
+ m_InBitStream.ReadBits(kLenDirectBits[number]);
+ number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
+ if (number >= kDistTableSize)
+ return false;
+ distance = kDistStart[number] + m_InBitStream.ReadBits(kDistDirectBits[number]);
+ if (distance >= kDistLimit3)
+ {
+ length += 2 - ((distance - kDistLimit4) >> 31);
+ // length++;
+ // if (distance >= kDistLimit4)
+ // length++;
+ }
+ }
+ else if (number == kRepBothNumber)
+ {
+ length = m_LastLength;
+ distance = m_RepDists[(m_RepDistPtr + 4 - 1) & 3];
+ }
+ else if (number < kLen2Number)
+ {
+ distance = m_RepDists[(m_RepDistPtr - (number - kRepNumber + 1)) & 3];
+ number = m_LenDecoder.DecodeSymbol(&m_InBitStream);
+ if (number >= kLenTableSize)
+ return false;
+ length = 2 + kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
+ if (distance >= kDistLimit2)
+ {
+ length++;
+ if (distance >= kDistLimit3)
+ {
+ length += 2 - ((distance - kDistLimit4) >> 31);
+ // length++;
+ // if (distance >= kDistLimit4)
+ // length++;
+ }
+ }
+ }
+ else if (number < kReadTableNumber)
+ {
+ number -= kLen2Number;
+ distance = kLen2DistStarts[number] +
+ m_InBitStream.ReadBits(kLen2DistDirectBits[number]);
+ length = 2;
+ }
+ else if (number == kReadTableNumber)
+ return true;
+ else
+ return false;
+ m_RepDists[m_RepDistPtr++ & 3] = distance;
+ m_LastLength = length;
+ if (!m_OutWindowStream.CopyBlock(distance, length))
+ return false;
+ pos -= length;
+ }
+ return true;
+}
+
+STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ if (inSize == NULL || outSize == NULL)
+ return E_INVALIDARG;
+
+ if (!m_OutWindowStream.Create(kHistorySize))
+ return E_OUTOFMEMORY;
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+
+ m_PackSize = *inSize;
+
+ UInt64 pos = 0, unPackSize = *outSize;
+
+ m_OutWindowStream.SetStream(outStream);
+ m_OutWindowStream.Init(m_IsSolid);
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+
+ CCoderReleaser coderReleaser(this);
+ if (!m_IsSolid)
+ {
+ InitStructures();
+ if (unPackSize == 0)
+ {
+ if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
+ if (!ReadTables())
+ return S_FALSE;
+ return S_OK;
+ }
+ if (!ReadTables())
+ return S_FALSE;
+ }
+
+ UInt64 startPos = m_OutWindowStream.GetProcessedSize();
+ while(pos < unPackSize)
+ {
+ UInt32 blockSize = 1 << 20;
+ if (blockSize > unPackSize - pos)
+ blockSize = (UInt32)(unPackSize - pos);
+ UInt64 blockStartPos = m_OutWindowStream.GetProcessedSize();
+ if (m_AudioMode)
+ {
+ if (!DecodeMm(blockSize))
+ return S_FALSE;
+ }
+ else
+ {
+ if (!DecodeLz((Int32)blockSize))
+ return S_FALSE;
+ }
+ UInt64 globalPos = m_OutWindowStream.GetProcessedSize();
+ pos = globalPos - blockStartPos;
+ if (pos < blockSize)
+ if (!ReadTables())
+ return S_FALSE;
+ pos = globalPos - startPos;
+ if (progress != 0)
+ {
+ UInt64 packSize = m_InBitStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &pos));
+ }
+ }
+ if (pos > unPackSize)
+ throw CException(CException::kData);
+
+ if (!ReadLastTables())
+ return S_FALSE;
+ return m_OutWindowStream.Flush();
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CLZOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size < 1)
+ return E_INVALIDARG;
+ m_IsSolid = (data[0] != 0);
+ return S_OK;
+}
+
+}}
diff --git a/CPP/7zip/Compress/Rar/Rar2Decoder.h b/CPP/7zip/Compress/Rar/Rar2Decoder.h
new file mode 100755
index 00000000..dfd0f816
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar2Decoder.h
@@ -0,0 +1,176 @@
+// Rar2Decoder.h
+// According to unRAR license,
+// this code may not be used to develop a
+// RAR (WinRAR) compatible archiver
+
+#ifndef __RAR2DECODER_H
+#define __RAR2DECODER_H
+
+#include "../../../Common/MyCom.h"
+
+#include "../../ICoder.h"
+#include "../../Common/MSBFDecoder.h"
+#include "../../Common/InBuffer.h"
+
+#include "../LZ/LZOutWindow.h"
+#include "../Huffman/HuffmanDecoder.h"
+
+namespace NCompress {
+namespace NRar2 {
+
+const UInt32 kNumRepDists = 4;
+const UInt32 kDistTableSize = 48;
+
+const int kMMTableSize = 256 + 1;
+
+const UInt32 kMainTableSize = 298;
+const UInt32 kLenTableSize = 28;
+
+const UInt32 kDistTableStart = kMainTableSize;
+const UInt32 kLenTableStart = kDistTableStart + kDistTableSize;
+
+const UInt32 kHeapTablesSizesSum = kMainTableSize + kDistTableSize + kLenTableSize;
+
+const UInt32 kLevelTableSize = 19;
+
+const UInt32 kMMTablesSizesSum = kMMTableSize * 4;
+
+const UInt32 kMaxTableSize = kMMTablesSizesSum;
+
+const UInt32 kTableDirectLevels = 16;
+const UInt32 kTableLevelRepNumber = kTableDirectLevels;
+const UInt32 kTableLevel0Number = kTableLevelRepNumber + 1;
+const UInt32 kTableLevel0Number2 = kTableLevel0Number + 1;
+
+const UInt32 kLevelMask = 0xF;
+
+
+const UInt32 kRepBothNumber = 256;
+const UInt32 kRepNumber = kRepBothNumber + 1;
+const UInt32 kLen2Number = kRepNumber + 4;
+
+const UInt32 kLen2NumNumbers = 8;
+const UInt32 kReadTableNumber = kLen2Number + kLen2NumNumbers;
+const UInt32 kMatchNumber = kReadTableNumber + 1;
+
+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};
+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};
+
+const UInt32 kDistStart[kDistTableSize] = {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,32768U,49152U,65536,98304,131072,196608,262144,327680,393216,458752,524288,589824,655360,720896,786432,851968,917504,983040};
+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};
+
+const Byte kLevelDirectBits[kLevelTableSize] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7};
+
+const Byte kLen2DistStarts[kLen2NumNumbers]={0,4,8,16,32,64,128,192};
+const Byte kLen2DistDirectBits[kLen2NumNumbers]={2,2,3, 4, 5, 6, 6, 6};
+
+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;
+
+namespace NMultimedia {
+
+struct CFilter
+{
+ int K1,K2,K3,K4,K5;
+ int D1,D2,D3,D4;
+ int LastDelta;
+ UInt32 Dif[11];
+ UInt32 ByteCount;
+ int LastChar;
+
+ Byte Decode(int &channelDelta, Byte delta);
+
+ void Init() { memset(this, 0, sizeof(*this)); }
+
+};
+
+const int kNumChanelsMax = 4;
+
+class CFilter2
+{
+public:
+ CFilter m_Filters[kNumChanelsMax];
+ int m_ChannelDelta;
+ int CurrentChannel;
+
+ void Init() { memset(this, 0, sizeof(*this)); }
+ Byte Decode(Byte delta)
+ {
+ return m_Filters[CurrentChannel].Decode(m_ChannelDelta, delta);
+ }
+
+};
+
+}
+
+typedef NStream::NMSBF::CDecoder<CInBuffer> CBitDecoder;
+
+const int kNumHuffmanBits = 15;
+
+class CDecoder :
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+ CLZOutWindow m_OutWindowStream;
+ CBitDecoder m_InBitStream;
+ NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kDistTableSize> m_DistDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kLenTableSize> m_LenDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kMMTableSize> m_MMDecoders[NMultimedia::kNumChanelsMax];
+ NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
+
+ bool m_AudioMode;
+
+ NMultimedia::CFilter2 m_MmFilter;
+ int m_NumChannels;
+
+ UInt32 m_RepDists[kNumRepDists];
+ UInt32 m_RepDistPtr;
+
+ UInt32 m_LastLength;
+
+ Byte m_LastLevels[kMaxTableSize];
+
+ UInt64 m_PackSize;
+ bool m_IsSolid;
+
+ void InitStructures();
+ UInt32 ReadBits(int numBits);
+ bool ReadTables();
+ bool ReadLastTables();
+
+ bool DecodeMm(UInt32 pos);
+ bool DecodeLz(Int32 pos);
+
+public:
+ CDecoder();
+
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+
+ void ReleaseStreams()
+ {
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ }
+
+ STDMETHOD(CodeReal)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Compress/Rar/Rar3Decoder.cpp b/CPP/7zip/Compress/Rar/Rar3Decoder.cpp
new file mode 100755
index 00000000..478b6587
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar3Decoder.cpp
@@ -0,0 +1,832 @@
+// Rar3Decoder.cpp
+// According to unRAR license,
+// this code may not be used to develop a
+// RAR (WinRAR) compatible archiver
+
+#include "StdAfx.h"
+
+#include "Rar3Decoder.h"
+#include "../../Common/StreamUtils.h"
+
+namespace NCompress {
+namespace NRar3 {
+
+static const UInt32 kNumAlignReps = 15;
+
+static const UInt32 kSymbolReadTable = 256;
+static const UInt32 kSymbolRep = 259;
+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] =
+ {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};
+
+static const Byte kLevelDirectBits[kLevelTableSize] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
+
+static const Byte kLen2DistStarts[kNumLen2Symbols]={0,4,8,16,32,64,128,192};
+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 kVmDataSizeMax = 1 << 16;
+static const UInt32 kVmCodeSizeMax = 1 << 16;
+
+CDecoder::CDecoder():
+ _window(0),
+ _winPos(0),
+ _wrPtr(0),
+ _lzSize(0),
+ _writtenFileSize(0),
+ _vmData(0),
+ _vmCode(0),
+ m_IsSolid(false)
+{
+}
+
+CDecoder::~CDecoder()
+{
+ InitFilters();
+ if (_vmData)
+ ::MidFree(_vmData);
+}
+
+HRESULT CDecoder::WriteDataToStream(const Byte *data, UInt32 size)
+{
+ UInt32 processedSize;
+ HRESULT res = WriteStream(_outStream, data, size, &processedSize);
+ if (res == S_OK && processedSize != size)
+ res = E_FAIL;
+ return res;
+}
+
+HRESULT CDecoder::WriteData(const Byte *data, UInt32 size)
+{
+ HRESULT res = S_OK;
+ if (_writtenFileSize < _unpackSize)
+ {
+ UInt32 curSize = size;
+ UInt64 remain = _unpackSize - _writtenFileSize;
+ if (remain < curSize)
+ curSize = (UInt32)remain;
+ res = WriteDataToStream(data, curSize);
+ }
+ _writtenFileSize += size;
+ return res;
+}
+
+HRESULT CDecoder::WriteArea(UInt32 startPtr, UInt32 endPtr)
+{
+ if (startPtr <= endPtr)
+ return WriteData(_window + startPtr, endPtr - startPtr);
+ RINOK(WriteData(_window + startPtr, kWindowSize - startPtr));
+ return WriteData(_window, endPtr);
+}
+
+void CDecoder::ExecuteFilter(int tempFilterIndex, NVm::CBlockRef &outBlockRef)
+{
+ CTempFilter *tempFilter = _tempFilters[tempFilterIndex];
+ tempFilter->InitR[6] = (UInt32)_writtenFileSize;
+ NVm::SetValue32(&tempFilter->GlobalData[0x24], (UInt32)_writtenFileSize);
+ NVm::SetValue32(&tempFilter->GlobalData[0x28], (UInt32)(_writtenFileSize >> 32));
+ CFilter *filter = _filters[tempFilter->FilterIndex];
+ _vm.Execute(filter, tempFilter, outBlockRef, filter->GlobalData);
+ delete tempFilter;
+ _tempFilters[tempFilterIndex] = 0;
+}
+
+HRESULT CDecoder::WriteBuf()
+{
+ UInt32 writtenBorder = _wrPtr;
+ UInt32 writeSize = (_winPos - writtenBorder) & kWindowMask;
+ for (int i = 0; i < _tempFilters.Size(); i++)
+ {
+ CTempFilter *filter = _tempFilters[i];
+ if (filter == NULL)
+ continue;
+ if (filter->NextWindow)
+ {
+ filter->NextWindow = false;
+ continue;
+ }
+ UInt32 blockStart = filter->BlockStart;
+ UInt32 blockSize = filter->BlockSize;
+ if (((blockStart - writtenBorder) & kWindowMask) < writeSize)
+ {
+ if (writtenBorder != blockStart)
+ {
+ RINOK(WriteArea(writtenBorder, blockStart));
+ writtenBorder = blockStart;
+ writeSize = (_winPos - writtenBorder) & kWindowMask;
+ }
+ if (blockSize <= writeSize)
+ {
+ UInt32 blockEnd = (blockStart + blockSize) & kWindowMask;
+ if (blockStart < blockEnd || blockEnd == 0)
+ _vm.SetMemory(0, _window + blockStart, blockSize);
+ else
+ {
+ UInt32 tailSize = kWindowSize - blockStart;
+ _vm.SetMemory(0, _window + blockStart, tailSize);
+ _vm.SetMemory(tailSize, _window, blockEnd);
+ }
+ NVm::CBlockRef outBlockRef;
+ ExecuteFilter(i, outBlockRef);
+ while (i + 1 < _tempFilters.Size())
+ {
+ CTempFilter *nextFilter = _tempFilters[i + 1];
+ if (nextFilter == NULL || nextFilter->BlockStart != blockStart ||
+ nextFilter->BlockSize != outBlockRef.Size || nextFilter->NextWindow)
+ break;
+ _vm.SetMemory(0, _vm.GetDataPointer(outBlockRef.Offset), outBlockRef.Size);
+ ExecuteFilter(++i, outBlockRef);
+ }
+ WriteDataToStream(_vm.GetDataPointer(outBlockRef.Offset), outBlockRef.Size);
+ _writtenFileSize += outBlockRef.Size;
+ writtenBorder = blockEnd;
+ writeSize = (_winPos - writtenBorder) & kWindowMask;
+ }
+ else
+ {
+ for (int j = i; j < _tempFilters.Size(); j++)
+ {
+ CTempFilter *filter = _tempFilters[j];
+ if (filter != NULL && filter->NextWindow)
+ filter->NextWindow = false;
+ }
+ _wrPtr = writtenBorder;
+ return S_OK; // check it
+ }
+ }
+ }
+
+ _wrPtr = _winPos;
+ return WriteArea(writtenBorder, _winPos);
+}
+
+void CDecoder::InitFilters()
+{
+ _lastFilter = 0;
+ int i;
+ for (i = 0; i < _tempFilters.Size(); i++)
+ delete _tempFilters[i];
+ _tempFilters.Clear();
+ for (i = 0; i < _filters.Size(); i++)
+ delete _filters[i];
+ _filters.Clear();
+}
+
+bool CDecoder::AddVmCode(UInt32 firstByte, UInt32 codeSize)
+{
+ CMemBitDecoder inp;
+ inp.Init(_vmData, codeSize);
+
+ UInt32 filterIndex;
+ if (firstByte & 0x80)
+ {
+ filterIndex = NVm::ReadEncodedUInt32(inp);
+ if (filterIndex == 0)
+ InitFilters();
+ else
+ filterIndex--;
+ }
+ else
+ filterIndex = _lastFilter;
+ if (filterIndex > (UInt32)_filters.Size())
+ return false;
+ _lastFilter = filterIndex;
+ bool newFilter = (filterIndex == (UInt32)_filters.Size());
+
+ CFilter *filter;
+ if (newFilter)
+ {
+ // check if too many filters
+ if (filterIndex > 1024)
+ return false;
+ filter = new CFilter;
+ _filters.Add(filter);
+ }
+ else
+ {
+ filter = _filters[filterIndex];
+ filter->ExecCount++;
+ }
+
+ int numEmptyItems = 0;
+ int i;
+ for (i = 0; i < _tempFilters.Size(); i++)
+ {
+ _tempFilters[i - numEmptyItems] = _tempFilters[i];
+ if (_tempFilters[i] == NULL)
+ numEmptyItems++;
+ if (numEmptyItems > 0)
+ _tempFilters[i] = NULL;
+ }
+ if (numEmptyItems == 0)
+ {
+ _tempFilters.Add(NULL);
+ numEmptyItems = 1;
+ }
+ CTempFilter *tempFilter = new CTempFilter;
+ _tempFilters[_tempFilters.Size() - numEmptyItems] = tempFilter;
+ tempFilter->FilterIndex = filterIndex;
+ tempFilter->ExecCount = filter->ExecCount;
+
+ UInt32 blockStart = NVm::ReadEncodedUInt32(inp);
+ if (firstByte & 0x40)
+ blockStart += 258;
+ tempFilter->BlockStart = (blockStart + _winPos) & kWindowMask;
+ if (firstByte & 0x20)
+ filter->BlockSize = NVm::ReadEncodedUInt32(inp);
+ tempFilter->BlockSize = filter->BlockSize;
+ tempFilter->NextWindow = _wrPtr != _winPos && ((_wrPtr - _winPos) & kWindowMask) <= blockStart;
+
+ memset(tempFilter->InitR, 0, sizeof(tempFilter->InitR));
+ tempFilter->InitR[3] = NVm::kGlobalOffset;
+ tempFilter->InitR[4] = tempFilter->BlockSize;
+ tempFilter->InitR[5] = tempFilter->ExecCount;
+ if (firstByte & 0x10)
+ {
+ UInt32 initMask = inp.ReadBits(NVm::kNumGpRegs);
+ for (int i = 0; i < NVm::kNumGpRegs; i++)
+ if (initMask & (1 << i))
+ tempFilter->InitR[i] = NVm::ReadEncodedUInt32(inp);
+ }
+ if (newFilter)
+ {
+ UInt32 vmCodeSize = NVm::ReadEncodedUInt32(inp);
+ if (vmCodeSize >= kVmCodeSizeMax || vmCodeSize == 0)
+ return false;
+ for (UInt32 i = 0; i < vmCodeSize; i++)
+ _vmCode[i] = (Byte)inp.ReadBits(8);
+ _vm.PrepareProgram(_vmCode, vmCodeSize, filter);
+ }
+
+ tempFilter->AllocateEmptyFixedGlobal();
+
+ Byte *globalData = &tempFilter->GlobalData[0];
+ for (i = 0; i < NVm::kNumGpRegs; i++)
+ NVm::SetValue32(&globalData[i * 4], tempFilter->InitR[i]);
+ NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockSize], tempFilter->BlockSize);
+ NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockPos], 0); // It was commented. why?
+ NVm::SetValue32(&globalData[NVm::NGlobalOffset::kExecCount], tempFilter->ExecCount);
+
+ if (firstByte & 8)
+ {
+ UInt32 dataSize = NVm::ReadEncodedUInt32(inp);
+ if (dataSize > NVm::kGlobalSize - NVm::kFixedGlobalSize)
+ return false;
+ CRecordVector<Byte> &globalData = tempFilter->GlobalData;
+ int requredSize = (int)(dataSize + NVm::kFixedGlobalSize);
+ if (globalData.Size() < requredSize)
+ {
+ globalData.Reserve(requredSize);
+ for (; globalData.Size() < requredSize; i++)
+ globalData.Add(0);
+ }
+ for (UInt32 i = 0; i < dataSize; i++)
+ globalData[NVm::kFixedGlobalSize + i] = (Byte)inp.ReadBits(8);
+ }
+ return true;
+}
+
+bool CDecoder::ReadVmCodeLZ()
+{
+ UInt32 firstByte = m_InBitStream.ReadBits(8);
+ UInt32 length = (firstByte & 7) + 1;
+ if (length == 7)
+ length = m_InBitStream.ReadBits(8) + 7;
+ else if (length == 8)
+ length = m_InBitStream.ReadBits(16);
+ if (length > kVmDataSizeMax)
+ return false;
+ for (UInt32 i = 0; i < length; i++)
+ _vmData[i] = (Byte)m_InBitStream.ReadBits(8);
+ return AddVmCode(firstByte, length);
+}
+
+bool CDecoder::ReadVmCodePPM()
+{
+ int firstByte = DecodePpmSymbol();
+ if (firstByte == -1)
+ return false;
+ UInt32 length = (firstByte & 7) + 1;
+ if (length == 7)
+ {
+ int b1 = DecodePpmSymbol();
+ if (b1 == -1)
+ return false;
+ length = b1 + 7;
+ }
+ else if (length == 8)
+ {
+ int b1 = DecodePpmSymbol();
+ if (b1 == -1)
+ return false;
+ int b2 = DecodePpmSymbol();
+ if (b2 == -1)
+ return false;
+ length = b1 * 256 + b2;
+ }
+ if (length > kVmDataSizeMax)
+ return false;
+ for (UInt32 i = 0; i < length; i++)
+ {
+ int b = DecodePpmSymbol();
+ if (b == -1)
+ return false;
+ _vmData[i] = (Byte)b;
+ }
+ return AddVmCode(firstByte, length);
+}
+
+#define RIF(x) { if (!(x)) return S_FALSE; }
+
+UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+
+/////////////////////////////////////////////////
+// PPM
+
+HRESULT CDecoder::InitPPM()
+{
+ Byte maxOrder = (Byte)ReadBits(7);
+
+ bool reset = ((maxOrder & 0x20) != 0);
+ int maxMB = 0;
+ if (reset)
+ maxMB = (Byte)ReadBits(8);
+ else
+ {
+ if (_ppm.SubAllocator.GetSubAllocatorSize()== 0)
+ return S_FALSE;
+ }
+ if (maxOrder & 0x40)
+ PpmEscChar = (Byte)ReadBits(8);
+ m_InBitStream.InitRangeCoder();
+ /*
+ if (m_InBitStream.m_BitPos != 0)
+ return S_FALSE;
+ */
+ if (reset)
+ {
+ maxOrder = (maxOrder & 0x1F) + 1;
+ if (maxOrder > 16)
+ maxOrder = 16 + (maxOrder - 16) * 3;
+ if (maxOrder == 1)
+ {
+ // SubAlloc.StopSubAllocator();
+ _ppm.SubAllocator.StopSubAllocator();
+ return S_FALSE;
+ }
+ // SubAlloc.StartSubAllocator(MaxMB+1);
+ // StartModelRare(maxOrder);
+
+ if (!_ppm.SubAllocator.StartSubAllocator((maxMB + 1) << 20))
+ return E_OUTOFMEMORY;
+ _ppm.MaxOrder = 0;
+ _ppm.StartModelRare(maxOrder);
+
+ }
+ // return (minContext != NULL);
+
+ return S_OK;
+}
+
+int CDecoder::DecodePpmSymbol() { return _ppm.DecodeSymbol(&m_InBitStream); }
+
+HRESULT CDecoder::DecodePPM(Int32 num, bool &keepDecompressing)
+{
+ keepDecompressing = false;
+ do
+ {
+ if (((_wrPtr - _winPos) & kWindowMask) < 260 && _wrPtr != _winPos)
+ {
+ RINOK(WriteBuf());
+ if (_writtenFileSize > _unpackSize)
+ return S_OK;
+ }
+ int c = DecodePpmSymbol();
+ if (c == -1)
+ {
+ // Original code sets PPMError=true here and then it returns S_OK. Why ???
+ // return S_OK;
+ return S_FALSE;
+ }
+ if (c == PpmEscChar)
+ {
+ int nextCh = DecodePpmSymbol();
+ if (nextCh == 0)
+ return ReadTables(keepDecompressing);
+ if (nextCh == 2 || nextCh == -1)
+ return S_OK;
+ if (nextCh == 3)
+ {
+ if (!ReadVmCodePPM())
+ return S_FALSE;
+ continue;
+ }
+ if (nextCh == 4 || nextCh == 5)
+ {
+ UInt32 distance = 0;
+ UInt32 length = 4;
+ if (nextCh == 4)
+ {
+ for (int i = 0; i < 3; i++)
+ {
+ int c = DecodePpmSymbol();
+ if (c == -1)
+ return S_OK;
+ distance = (distance << 8) + (Byte)c;
+ }
+ distance++;
+ length += 28;
+ }
+ int c = DecodePpmSymbol();
+ if (c == -1)
+ return S_OK;
+ length += c;
+ if (distance >= _lzSize)
+ return S_FALSE;
+ CopyBlock(distance, length);
+ num -= (Int32)length;
+ continue;
+ }
+ }
+ PutByte((Byte)c);
+ num--;
+ }
+ while (num >= 0);
+ keepDecompressing = true;
+ return S_OK;
+}
+
+/////////////////////////////////////////////////
+// LZ
+
+HRESULT CDecoder::ReadTables(bool &keepDecompressing)
+{
+ keepDecompressing = true;
+ ReadBits((8 - m_InBitStream.GetBitPosition()) & 7);
+ if (ReadBits(1) != 0)
+ {
+ _lzMode = false;
+ return InitPPM();
+ }
+
+ _lzMode = true;
+ PrevAlignBits = 0;
+ PrevAlignCount = 0;
+
+ Byte levelLevels[kLevelTableSize];
+ Byte newLevels[kTablesSizesSum];
+
+ if (ReadBits(1) == 0)
+ memset(m_LastLevels, 0, kTablesSizesSum);
+
+ int i;
+ for (i = 0; i < kLevelTableSize; i++)
+ {
+ UInt32 length = ReadBits(4);
+ if (length == 15)
+ {
+ UInt32 zeroCount = ReadBits(4);
+ if (zeroCount != 0)
+ {
+ zeroCount += 2;
+ while (zeroCount-- > 0 && i < kLevelTableSize)
+ levelLevels[i++]=0;
+ i--;
+ continue;
+ }
+ }
+ levelLevels[i] = (Byte)length;
+ }
+ RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
+ i = 0;
+ while (i < kTablesSizesSum)
+ {
+ UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < 16)
+ {
+ newLevels[i] = Byte((number + m_LastLevels[i]) & 15);
+ i++;
+ }
+ else if (number > kLevelTableSize)
+ return S_FALSE;
+ else
+ {
+ int num;
+ if (((number - 16) & 1) == 0)
+ num = ReadBits(3) + 3;
+ else
+ num = ReadBits(7) + 11;
+ if (number < 18)
+ {
+ if (i == 0)
+ return S_FALSE;
+ for (; num > 0 && i < kTablesSizesSum; num--, i++)
+ newLevels[i] = newLevels[i - 1];
+ }
+ else
+ {
+ for (; num > 0 && i < kTablesSizesSum; num--)
+ newLevels[i++] = 0;
+ }
+ }
+ }
+ TablesRead = true;
+
+ // original code has check here:
+ /*
+ if (InAddr > ReadTop)
+ {
+ keepDecompressing = false;
+ return true;
+ }
+ */
+
+ RIF(m_MainDecoder.SetCodeLengths(&newLevels[0]));
+ RIF(m_DistDecoder.SetCodeLengths(&newLevels[kMainTableSize]));
+ RIF(m_AlignDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize]));
+ RIF(m_LenDecoder.SetCodeLengths(&newLevels[kMainTableSize + kDistTableSize + kAlignTableSize]));
+
+ memcpy(m_LastLevels, newLevels, kTablesSizesSum);
+ return S_OK;
+}
+
+class CCoderReleaser
+{
+ CDecoder *m_Coder;
+public:
+ CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
+ ~CCoderReleaser()
+ {
+ // m_Coder->m_OutWindowStream.Flush();
+ m_Coder->ReleaseStreams();
+ }
+};
+
+HRESULT CDecoder::ReadEndOfBlock(bool &keepDecompressing)
+{
+ if (ReadBits(1) != 0)
+ {
+ // old file
+ TablesRead = false;
+ return ReadTables(keepDecompressing);
+ }
+ // new file
+ keepDecompressing = false;
+ TablesRead = (ReadBits(1) == 0);
+ return S_OK;
+}
+
+UInt32 kDistStart[kDistTableSize];
+
+class CDistInit
+{
+public:
+ CDistInit() { Init(); }
+ void Init()
+ {
+ UInt32 start = 0;
+ for (UInt32 i = 0; i < kDistTableSize; i++)
+ {
+ kDistStart[i] = start;
+ start += (1 << kDistDirectBits[i]);
+ }
+ }
+} g_DistInit;
+
+HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
+{
+ UInt32 rep0 = _reps[0];
+ UInt32 rep1 = _reps[1];
+ UInt32 rep2 = _reps[2];
+ UInt32 rep3 = _reps[3];
+ UInt32 length = _lastLength;
+ for (;;)
+ {
+ if (((_wrPtr - _winPos) & kWindowMask) < 260 && _wrPtr != _winPos)
+ {
+ RINOK(WriteBuf());
+ if (_writtenFileSize > _unpackSize)
+ return S_OK;
+ }
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < 256)
+ {
+ PutByte(Byte(number));
+
+ continue;
+ }
+ else if (number == kSymbolReadTable)
+ {
+ RINOK(ReadEndOfBlock(keepDecompressing));
+ break;
+ }
+ else if (number == 257)
+ {
+ if (!ReadVmCodeLZ())
+ return S_FALSE;
+ continue;
+ }
+ else if (number == 258)
+ {
+ }
+ else if (number < kSymbolRep + 4)
+ {
+ if (number != kSymbolRep)
+ {
+ UInt32 distance;
+ if (number == kSymbolRep + 1)
+ distance = rep1;
+ else
+ {
+ if (number == kSymbolRep + 2)
+ distance = rep2;
+ else
+ {
+ distance = rep3;
+ rep3 = rep2;
+ }
+ rep2 = rep1;
+ }
+ rep1 = rep0;
+ rep0 = distance;
+ }
+
+ UInt32 number = m_LenDecoder.DecodeSymbol(&m_InBitStream);
+ if (number >= kLenTableSize)
+ return S_FALSE;
+ length = 2 + kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
+ }
+ else
+ {
+ rep3 = rep2;
+ rep2 = rep1;
+ rep1 = rep0;
+ if (number < 271)
+ {
+ number -= 263;
+ rep0 = kLen2DistStarts[number] + m_InBitStream.ReadBits(kLen2DistDirectBits[number]);
+ length = 2;
+ }
+ else if (number < 299)
+ {
+ number -= 271;
+ length = kNormalMatchMinLen + (UInt32)kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
+ UInt32 number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
+ if (number >= kDistTableSize)
+ return S_FALSE;
+ rep0 = kDistStart[number];
+ int numBits = kDistDirectBits[number];
+ if (number >= (kNumAlignBits * 2) + 2)
+ {
+ if (numBits > kNumAlignBits)
+ rep0 += (m_InBitStream.ReadBits(numBits - kNumAlignBits) << kNumAlignBits);
+ if (PrevAlignCount > 0)
+ {
+ PrevAlignCount--;
+ rep0 += PrevAlignBits;
+ }
+ else
+ {
+ UInt32 number = m_AlignDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < (1 << kNumAlignBits))
+ {
+ rep0 += number;
+ PrevAlignBits = number;
+ }
+ else if (number == (1 << kNumAlignBits))
+ {
+ PrevAlignCount = kNumAlignReps;
+ rep0 += PrevAlignBits;
+ }
+ else
+ return S_FALSE;
+ }
+ }
+ else
+ rep0 += m_InBitStream.ReadBits(numBits);
+ length += ((kDistLimit4 - rep0) >> 31) + ((kDistLimit3 - rep0) >> 31);
+ }
+ else
+ return S_FALSE;
+ }
+ if (rep0 >= _lzSize)
+ return S_FALSE;
+ CopyBlock(rep0, length);
+ }
+ _reps[0] = rep0;
+ _reps[1] = rep1;
+ _reps[2] = rep2;
+ _reps[3] = rep3;
+ _lastLength = length;
+
+ return S_OK;
+}
+
+HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress)
+{
+ _writtenFileSize = 0;
+ if (!m_IsSolid)
+ {
+ _lzSize = 0;
+ _winPos = 0;
+ _wrPtr = 0;
+ for (int i = 0; i < kNumReps; i++)
+ _reps[i] = 0;
+ _lastLength = 0;
+ memset(m_LastLevels, 0, kTablesSizesSum);
+ TablesRead = false;
+ PpmEscChar = 2;
+ InitFilters();
+ }
+ if (!m_IsSolid || !TablesRead)
+ {
+ bool keepDecompressing;
+ RINOK(ReadTables(keepDecompressing));
+ if (!keepDecompressing)
+ return S_OK;
+ }
+
+ for(;;)
+ {
+ bool keepDecompressing;
+ if (_lzMode)
+ {
+ RINOK(DecodeLZ(keepDecompressing))
+ }
+ else
+ {
+ RINOK(DecodePPM(1 << 18, keepDecompressing))
+ }
+ UInt64 packSize = m_InBitStream.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &_writtenFileSize));
+ if (!keepDecompressing)
+ break;
+ }
+ RINOK(WriteBuf());
+ if (_writtenFileSize < _unpackSize)
+ return S_FALSE;
+ // return m_OutWindowStream.Flush();
+ return S_OK;
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ try
+ {
+ if (inSize == NULL || outSize == NULL)
+ return E_INVALIDARG;
+
+ if (_vmData == 0)
+ {
+ _vmData = (Byte *)::MidAlloc(kVmDataSizeMax + kVmCodeSizeMax);
+ if (_vmData == 0)
+ return E_OUTOFMEMORY;
+ _vmCode = _vmData + kVmDataSizeMax;
+ }
+
+ if (_window == 0)
+ {
+ _window = (Byte *)::MidAlloc(kWindowSize);
+ if (_window == 0)
+ return E_OUTOFMEMORY;
+ }
+ if (!m_InBitStream.Create(1 << 20))
+ return E_OUTOFMEMORY;
+ if (!_vm.Create())
+ return E_OUTOFMEMORY;
+
+
+ m_InBitStream.SetStream(inStream);
+ m_InBitStream.Init();
+ _outStream = outStream;
+
+ CCoderReleaser coderReleaser(this);
+ _unpackSize = *outSize;
+ return CodeReal(progress);
+ }
+ catch(...) { return S_FALSE; }
+ // CNewException is possible here. But probably CNewException is caused
+ // by error in data stream.
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size < 1)
+ return E_INVALIDARG;
+ m_IsSolid = (data[0] != 0);
+ return S_OK;
+}
+
+}}
diff --git a/CPP/7zip/Compress/Rar/Rar3Decoder.h b/CPP/7zip/Compress/Rar/Rar3Decoder.h
new file mode 100755
index 00000000..ec07a4d3
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar3Decoder.h
@@ -0,0 +1,294 @@
+// Rar3Decoder.h
+// According to unRAR license,
+// this code may not be used to develop a
+// RAR (WinRAR) compatible archiver
+
+#ifndef __RAR3DECODER_H
+#define __RAR3DECODER_H
+
+#include "../../../Common/MyCom.h"
+
+#include "../../ICoder.h"
+#include "../../Common/MSBFDecoder.h"
+#include "../../Common/InBuffer.h"
+
+// #include "../LZ/LZOutWindow.h"
+#include "../Huffman/HuffmanDecoder.h"
+#include "../PPMD/PPMDDecode.h"
+#include "Rar3Vm.h"
+
+namespace NCompress {
+namespace NRar3 {
+
+const UInt32 kWindowSize = 1 << 22;
+const UInt32 kWindowMask = (kWindowSize - 1);
+
+const UInt32 kNumReps = 4;
+const UInt32 kNumLen2Symbols = 8;
+const UInt32 kLenTableSize = 28;
+const UInt32 kMainTableSize = 256 + 1 + 1 + 1 + kNumReps + kNumLen2Symbols + kLenTableSize;
+const UInt32 kDistTableSize = 60;
+
+const int kNumAlignBits = 4;
+const UInt32 kAlignTableSize = (1 << kNumAlignBits) + 1;
+
+const UInt32 kLevelTableSize = 20;
+
+const UInt32 kTablesSizesSum = kMainTableSize + kDistTableSize + kAlignTableSize + kLenTableSize;
+
+template<class TInByte>
+class CBitDecoder2
+{
+ UInt32 m_Value;
+public:
+ UInt32 m_BitPos;
+ TInByte m_Stream;
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+ void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
+ void ReleaseStream() { m_Stream.ReleaseStream();}
+
+ void Init()
+ {
+ m_Stream.Init();
+ m_BitPos = 0;
+ m_Value = 0;
+ // m_BitPos = kNumBigValueBits;
+ // Normalize();
+ }
+
+ UInt64 GetProcessedSize() const
+ { return m_Stream.GetProcessedSize() - (m_BitPos) / 8; }
+ UInt32 GetBitPosition() const { return ((8 - m_BitPos) & 7); }
+
+ /*
+ void Normalize()
+ {
+ for (;m_BitPos >= 8; m_BitPos -= 8)
+ m_Value = (m_Value << 8) | m_Stream.ReadByte();
+ }
+ */
+
+ UInt32 GetValue(UInt32 numBits)
+ {
+ // return (m_Value << m_BitPos) >> (kNumBigValueBits - numBits);
+ // return ((m_Value >> (8 - m_BitPos)) & kMask) >> (kNumValueBits - numBits);
+ if (m_BitPos < numBits)
+ {
+ m_BitPos += 8;
+ m_Value = (m_Value << 8) | m_Stream.ReadByte();
+ if (m_BitPos < numBits)
+ {
+ m_BitPos += 8;
+ m_Value = (m_Value << 8) | m_Stream.ReadByte();
+ }
+ }
+ return m_Value >> (m_BitPos - numBits);
+ }
+
+ void MovePos(UInt32 numBits)
+ {
+ m_BitPos -= numBits;
+ m_Value = m_Value & ((1 << m_BitPos) - 1);
+ }
+
+ UInt32 ReadBits(UInt32 numBits)
+ {
+ UInt32 res = GetValue(numBits);
+ MovePos(numBits);
+ return res;
+ }
+};
+
+typedef CBitDecoder2<CInBuffer> CBitDecoder;
+
+const int kNumTopBits = 24;
+const UInt32 kTopValue = (1 << kNumTopBits);
+const UInt32 kBot = (1 << 15);
+
+class CRangeDecoder:public NPPMD::CRangeDecoderVirt, public CBitDecoder
+{
+public:
+ UInt32 Range;
+ UInt32 Low;
+ UInt32 Code;
+
+ void Normalize()
+ {
+ while ((Low ^ (Low + Range)) < kTopValue ||
+ Range < kBot && ((Range = (0 - Low) & (kBot - 1)), 1))
+ {
+ Code = (Code << 8) | m_Stream.ReadByte();
+ Range <<= 8;
+ Low <<= 8;
+ }
+ }
+
+ void InitRangeCoder()
+ {
+ Code = 0;
+ Low = 0;
+ Range = 0xFFFFFFFF;
+ for(int i = 0; i < 4; i++)
+ Code = (Code << 8) | ReadBits(8);
+ }
+
+ virtual UInt32 GetThreshold(UInt32 total)
+ {
+ return (Code - Low) / ( Range /= total);
+ }
+
+ virtual void Decode(UInt32 start, UInt32 size)
+ {
+ Low += start * Range;
+ Range *= size;
+ Normalize();
+ }
+
+ virtual UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits)
+ {
+ if (((Code - Low) / (Range >>= numTotalBits)) < size0)
+ {
+ Decode(0, size0);
+ return 0;
+ }
+ else
+ {
+ Decode(size0, (1 << numTotalBits) - size0);
+ return 1;
+ }
+ }
+
+ // UInt64 GetProcessedSizeRangeCoder() {return Stream.GetProcessedSize(); }
+};
+
+
+struct CFilter: public NVm::CProgram
+{
+ CRecordVector<Byte> GlobalData;
+ UInt32 BlockStart;
+ UInt32 BlockSize;
+ UInt32 ExecCount;
+ CFilter(): BlockStart(0), BlockSize(0), ExecCount(0) {}
+};
+
+struct CTempFilter: public NVm::CProgramInitState
+{
+ UInt32 BlockStart;
+ UInt32 BlockSize;
+ UInt32 ExecCount;
+ bool NextWindow;
+
+ UInt32 FilterIndex;
+};
+
+const int kNumHuffmanBits = 15;
+
+class CDecoder:
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+ CRangeDecoder m_InBitStream;
+ Byte *_window;
+ UInt32 _winPos;
+ UInt32 _wrPtr;
+ UInt64 _lzSize;
+ UInt64 _unpackSize;
+ 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;
+ NHuffman::CDecoder<kNumHuffmanBits, kAlignTableSize> m_AlignDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kLenTableSize> m_LenDecoder;
+ NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
+
+ UInt32 _reps[kNumReps];
+ UInt32 _lastLength;
+
+ Byte m_LastLevels[kTablesSizesSum];
+
+ Byte *_vmData;
+ Byte *_vmCode;
+ NVm::CVm _vm;
+ CRecordVector<CFilter *> _filters;
+ CRecordVector<CTempFilter *> _tempFilters;
+ UInt32 _lastFilter;
+
+ bool m_IsSolid;
+
+ bool _lzMode;
+
+ UInt32 PrevAlignBits;
+ UInt32 PrevAlignCount;
+
+ bool TablesRead;
+
+ NPPMD::CDecodeInfo _ppm;
+ int PpmEscChar;
+
+ HRESULT WriteDataToStream(const Byte *data, UInt32 size);
+ HRESULT WriteData(const Byte *data, UInt32 size);
+ HRESULT WriteArea(UInt32 startPtr, UInt32 endPtr);
+ void ExecuteFilter(int tempFilterIndex, NVm::CBlockRef &outBlockRef);
+ HRESULT WriteBuf();
+
+ void InitFilters();
+ bool AddVmCode(UInt32 firstByte, UInt32 codeSize);
+ bool ReadVmCodeLZ();
+ bool ReadVmCodePPM();
+
+ UInt32 ReadBits(int numBits);
+
+ HRESULT InitPPM();
+ int DecodePpmSymbol();
+ HRESULT DecodePPM(Int32 num, bool &keepDecompressing);
+
+ HRESULT ReadTables(bool &keepDecompressing);
+ HRESULT ReadEndOfBlock(bool &keepDecompressing);
+ HRESULT DecodeLZ(bool &keepDecompressing);
+ HRESULT CodeReal(ICompressProgressInfo *progress);
+public:
+ CDecoder();
+ ~CDecoder();
+
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+
+ void ReleaseStreams()
+ {
+ _outStream.Release();
+ m_InBitStream.ReleaseStream();
+ }
+
+
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+
+ void CopyBlock(UInt32 distance, UInt32 len)
+ {
+ _lzSize += len;
+ UInt32 pos = (_winPos - distance - 1) & kWindowMask;
+ do
+ {
+ _window[_winPos] = _window[pos];
+ _winPos = (_winPos + 1) & kWindowMask;
+ pos = (pos + 1) & kWindowMask;
+ }
+ while(--len != 0);
+ }
+
+ void PutByte(Byte b)
+ {
+ _window[_winPos] = b;
+ _winPos = (_winPos + 1) & kWindowMask;
+ _lzSize++;
+ }
+
+
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Compress/Rar/Rar3Vm.cpp b/CPP/7zip/Compress/Rar/Rar3Vm.cpp
new file mode 100755
index 00000000..69918d94
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar3Vm.cpp
@@ -0,0 +1,1089 @@
+// Rar3Vm.cpp
+// According to unRAR license,
+// this code may not be used to develop a
+// RAR (WinRAR) compatible archiver
+
+/*
+Note:
+ 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.
+*/
+
+#include "StdAfx.h"
+
+#include "Rar3Vm.h"
+#include "Common/CRC.h"
+#include "Common/Alloc.h"
+
+namespace NCompress {
+namespace NRar3 {
+
+UInt32 CMemBitDecoder::ReadBits(int numBits)
+{
+ UInt32 res = 0;
+ for (;;)
+ {
+ Byte b = _bitPos < _bitSize ? _data[_bitPos >> 3] : 0;
+ int avail = (int)(8 - (_bitPos & 7));
+ if (numBits <= avail)
+ {
+ _bitPos += numBits;
+ return res | (b >> (avail - numBits)) & ((1 << numBits) - 1);
+ }
+ numBits -= avail;
+ res |= (UInt32)(b & ((1 << avail) - 1)) << numBits;
+ _bitPos += avail;
+ }
+}
+
+UInt32 CMemBitDecoder::ReadBit() { return ReadBits(1); }
+
+namespace NVm {
+
+const UInt32 kStackRegIndex = kNumRegs - 1;
+
+enum EFlags {FLAG_C = 1, FLAG_Z = 2, FLAG_S = 0x80000000};
+
+const Byte CF_OP0 = 0;
+const Byte CF_OP1 = 1;
+const Byte CF_OP2 = 2;
+const Byte CF_OPMASK = 3;
+const Byte CF_BYTEMODE = 4;
+const Byte CF_JUMP = 8;
+const Byte CF_PROC = 16;
+const Byte CF_USEFLAGS = 32;
+const Byte CF_CHFLAGS = 64;
+
+static Byte kCmdFlags[]=
+{
+ /* CMD_MOV */ CF_OP2 | CF_BYTEMODE,
+ /* CMD_CMP */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_ADD */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_SUB */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_JZ */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JNZ */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_INC */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_DEC */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_JMP */ CF_OP1 | CF_JUMP,
+ /* CMD_XOR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_AND */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_OR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_TEST */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_JS */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JNS */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JB */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JBE */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JA */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_JAE */ CF_OP1 | CF_JUMP | CF_USEFLAGS,
+ /* CMD_PUSH */ CF_OP1,
+ /* CMD_POP */ CF_OP1,
+ /* CMD_CALL */ CF_OP1 | CF_PROC,
+ /* CMD_RET */ CF_OP0 | CF_PROC,
+ /* CMD_NOT */ CF_OP1 | CF_BYTEMODE,
+ /* CMD_SHL */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_SHR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_SAR */ CF_OP2 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_NEG */ CF_OP1 | CF_BYTEMODE | CF_CHFLAGS,
+ /* CMD_PUSHA */ CF_OP0,
+ /* CMD_POPA */ CF_OP0,
+ /* CMD_PUSHF */ CF_OP0 | CF_USEFLAGS,
+ /* CMD_POPF */ CF_OP0 | CF_CHFLAGS,
+ /* CMD_MOVZX */ CF_OP2,
+ /* CMD_MOVSX */ CF_OP2,
+ /* CMD_XCHG */ CF_OP2 | CF_BYTEMODE,
+ /* CMD_MUL */ CF_OP2 | CF_BYTEMODE,
+ /* CMD_DIV */ CF_OP2 | CF_BYTEMODE,
+ /* CMD_ADC */ CF_OP2 | CF_BYTEMODE | CF_USEFLAGS | CF_CHFLAGS ,
+ /* CMD_SBB */ CF_OP2 | CF_BYTEMODE | CF_USEFLAGS | CF_CHFLAGS ,
+ /* CMD_PRINT */ CF_OP0
+};
+
+CVm::CVm(): Mem(NULL) {}
+
+bool CVm::Create()
+{
+ if (Mem == NULL)
+ Mem = (Byte *)::MyAlloc(kSpaceSize + 4);
+ return (Mem != NULL);
+}
+
+CVm::~CVm()
+{
+ ::MyFree(Mem);
+}
+
+// CVm::Execute can change CProgram object: it clears progarm if VM returns error.
+
+bool CVm::Execute(CProgram *prg, const CProgramInitState *initState,
+ CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData)
+{
+ memcpy(R, initState->InitR, sizeof(initState->InitR));
+ R[kStackRegIndex] = kSpaceSize;
+ R[kNumRegs] = 0;
+ Flags = 0;
+
+ UInt32 globalSize = MyMin((UInt32)initState->GlobalData.Size(), kGlobalSize);
+ if (globalSize != 0)
+ memcpy(Mem + kGlobalOffset, &initState->GlobalData[0], globalSize);
+ UInt32 staticSize = MyMin((UInt32)prg->StaticData.Size(), kGlobalSize - globalSize);
+ if (staticSize != 0)
+ memcpy(Mem + kGlobalOffset + globalSize, &prg->StaticData[0], staticSize);
+
+ bool res = true;
+ #ifdef RARVM_STANDARD_FILTERS
+ if (prg->StandardFilterIndex >= 0)
+ ExecuteStandardFilter(prg->StandardFilterIndex);
+ else
+ #endif
+ {
+ res = ExecuteCode(prg);
+ if (!res)
+ prg->Commands[0].OpCode = CMD_RET;
+ }
+ UInt32 newBlockPos = GetFixedGlobalValue32(NGlobalOffset::kBlockPos) & kSpaceMask;
+ UInt32 newBlockSize = GetFixedGlobalValue32(NGlobalOffset::kBlockSize) & kSpaceMask;
+ if (newBlockPos + newBlockSize >= kSpaceSize)
+ newBlockPos = newBlockSize = 0;
+ outBlockRef.Offset = newBlockPos;
+ outBlockRef.Size = newBlockSize;
+
+ outGlobalData.Clear();
+ UInt32 dataSize = GetFixedGlobalValue32(NGlobalOffset::kGlobalMemOutSize);
+ dataSize = MyMin(dataSize, kGlobalSize - kFixedGlobalSize);
+ if (dataSize != 0)
+ {
+ dataSize += kFixedGlobalSize;
+ outGlobalData.Reserve(dataSize);
+ for (UInt32 i = 0; i < dataSize; i++)
+ outGlobalData.Add(Mem[kGlobalOffset + i]);
+ }
+ return res;
+}
+
+
+#define SET_IP(IP) \
+ if ((IP) >= numCommands) return true; \
+ if (--maxOpCount <= 0) return false; \
+ cmd = commands + (IP);
+
+#define GET_FLAG_S_B(res) (((res) & 0x80) ? FLAG_S : 0)
+#define SET_IP_OP1 { UInt32 val = GetOperand32(&cmd->Op1); SET_IP(val); }
+#define FLAGS_UPDATE_SZ Flags = res == 0 ? FLAG_Z : res & FLAG_S
+#define FLAGS_UPDATE_SZ_B Flags = (res & 0xFF) == 0 ? FLAG_Z : GET_FLAG_S_B(res)
+
+UInt32 CVm::GetOperand32(const COperand *op) const
+{
+ switch(op->Type)
+ {
+ case OP_TYPE_REG: return R[op->Data];
+ case OP_TYPE_REGMEM: return GetValue32(&Mem[(op->Base + R[op->Data]) & kSpaceMask]);
+ default: return op->Data;
+ }
+}
+
+void CVm::SetOperand32(const COperand *op, UInt32 val)
+{
+ switch(op->Type)
+ {
+ case OP_TYPE_REG: R[op->Data] = val; return;
+ case OP_TYPE_REGMEM: SetValue32(&Mem[(op->Base + R[op->Data]) & kSpaceMask], val); return;
+ }
+}
+
+Byte CVm::GetOperand8(const COperand *op) const
+{
+ switch(op->Type)
+ {
+ case OP_TYPE_REG: return (Byte)R[op->Data];
+ case OP_TYPE_REGMEM: return Mem[(op->Base + R[op->Data]) & kSpaceMask];;
+ default: return (Byte)op->Data;
+ }
+}
+
+void CVm::SetOperand8(const COperand *op, Byte val)
+{
+ switch(op->Type)
+ {
+ case OP_TYPE_REG: R[op->Data] = (R[op->Data] & 0xFFFFFF00) | val; return;
+ case OP_TYPE_REGMEM: Mem[(op->Base + R[op->Data]) & kSpaceMask] = val; return;
+ }
+}
+
+UInt32 CVm::GetOperand(bool byteMode, const COperand *op) const
+{
+ if (byteMode)
+ return GetOperand8(op);
+ return GetOperand32(op);
+}
+
+void CVm::SetOperand(bool byteMode, const COperand *op, UInt32 val)
+{
+ if (byteMode)
+ SetOperand8(op, (Byte)(val & 0xFF));
+ else
+ SetOperand32(op, val);
+}
+
+bool CVm::ExecuteCode(const CProgram *prg)
+{
+ Int32 maxOpCount = 25000000;
+ const CCommand *commands = &prg->Commands[0];
+ const CCommand *cmd = commands;
+ UInt32 numCommands = prg->Commands.Size();
+ for (;;)
+ {
+ switch(cmd->OpCode)
+ {
+ #ifndef RARVM_NO_VM
+
+ case CMD_MOV:
+ SetOperand32(&cmd->Op1, GetOperand32(&cmd->Op2));
+ break;
+ case CMD_MOVB:
+ SetOperand8(&cmd->Op1, GetOperand8(&cmd->Op2));
+ break;
+ case CMD_CMP:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ UInt32 res = v1 - GetOperand32(&cmd->Op2);
+ Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
+ }
+ break;
+ case CMD_CMPB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ Byte res = v1 - GetOperand8(&cmd->Op2);
+ res &= 0xFF;
+ Flags = res == 0 ? FLAG_Z : (res > v1) | GET_FLAG_S_B(res);
+ }
+ break;
+ case CMD_ADD:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ UInt32 res = v1 + GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ Flags = (res < v1) | (res == 0 ? FLAG_Z : (res & FLAG_S));
+ }
+ break;
+ case CMD_ADDB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ Byte res = v1 + GetOperand8(&cmd->Op2);
+ res &= 0xFF;
+ SetOperand8(&cmd->Op1, (Byte)res);
+ Flags = (res < v1) | (res == 0 ? FLAG_Z : GET_FLAG_S_B(res));
+ }
+ break;
+ case CMD_ADC:
+ {
+ UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
+ UInt32 FC = (Flags & FLAG_C);
+ UInt32 res = v1 + GetOperand(cmd->ByteMode, &cmd->Op2) + FC;
+ if (cmd->ByteMode)
+ res &= 0xFF;
+ SetOperand(cmd->ByteMode, &cmd->Op1, res);
+ Flags = (res < v1 || res == v1 && FC) | (res == 0 ? FLAG_Z : (res & FLAG_S));
+ }
+ break;
+ case CMD_SUB:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ UInt32 res = v1 - GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
+ }
+ break;
+ case CMD_SUBB:
+ {
+ UInt32 v1 = GetOperand8(&cmd->Op1);
+ UInt32 res = v1 - GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, (Byte)res);
+ Flags = res == 0 ? FLAG_Z : (res > v1) | (res & FLAG_S);
+ }
+ break;
+ case CMD_SBB:
+ {
+ UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
+ UInt32 FC = (Flags & FLAG_C);
+ UInt32 res = v1 - GetOperand(cmd->ByteMode, &cmd->Op2) - FC;
+ // Flags = res == 0 ? FLAG_Z : (res > v1 || res == v1 && FC) | (res & FLAG_S);
+ if (cmd->ByteMode)
+ res &= 0xFF;
+ SetOperand(cmd->ByteMode, &cmd->Op1, res);
+ Flags = (res > v1 || res == v1 && FC) | (res == 0 ? FLAG_Z : (res & FLAG_S));
+ }
+ break;
+ case CMD_INC:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) + 1;
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_INCB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) + 1;
+ SetOperand8(&cmd->Op1, res);;
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_DEC:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) - 1;
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_DECB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) - 1;
+ SetOperand8(&cmd->Op1, res);;
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_XOR:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) ^ GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_XORB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) ^ GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_AND:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) & GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_ANDB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) & GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_OR:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) | GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_ORB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) | GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, res);
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_TEST:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) & GetOperand32(&cmd->Op2);
+ FLAGS_UPDATE_SZ;
+ }
+ break;
+ case CMD_TESTB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) & GetOperand8(&cmd->Op2);
+ FLAGS_UPDATE_SZ_B;
+ }
+ break;
+ case CMD_NOT:
+ SetOperand(cmd->ByteMode, &cmd->Op1, ~GetOperand(cmd->ByteMode, &cmd->Op1));
+ break;
+ case CMD_NEG:
+ {
+ UInt32 res = 0 - GetOperand32(&cmd->Op1);
+ SetOperand32(&cmd->Op1, res);
+ Flags = res == 0 ? FLAG_Z : FLAG_C | (res & FLAG_S);
+ }
+ break;
+ case CMD_NEGB:
+ {
+ Byte res = (Byte)(0 - GetOperand8(&cmd->Op1));
+ SetOperand8(&cmd->Op1, res);
+ Flags = res == 0 ? FLAG_Z : FLAG_C | GET_FLAG_S_B(res);
+ }
+ break;
+
+ case CMD_SHL:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ int v2 = (int)GetOperand32(&cmd->Op2);
+ UInt32 res = v1 << v2;
+ SetOperand32(&cmd->Op1, res);
+ Flags = (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 << (v2 - 1)) & 0x80000000 ? FLAG_C : 0);
+ }
+ break;
+ case CMD_SHLB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ int v2 = (int)GetOperand8(&cmd->Op2);
+ Byte res = (Byte)(v1 << v2);
+ SetOperand8(&cmd->Op1, res);
+ Flags = (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 << (v2 - 1)) & 0x80 ? FLAG_C : 0);
+ }
+ break;
+ case CMD_SHR:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ int v2 = (int)GetOperand32(&cmd->Op2);
+ UInt32 res = v1 >> v2;
+ SetOperand32(&cmd->Op1, res);
+ Flags = (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 >> (v2 - 1)) & FLAG_C);
+ }
+ break;
+ case CMD_SHRB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ int v2 = (int)GetOperand8(&cmd->Op2);
+ Byte res = (Byte)(v1 >> v2);
+ SetOperand8(&cmd->Op1, res);
+ Flags = (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 >> (v2 - 1)) & FLAG_C);
+ }
+ break;
+ case CMD_SAR:
+ {
+ UInt32 v1 = GetOperand32(&cmd->Op1);
+ int v2 = (int)GetOperand32(&cmd->Op2);
+ UInt32 res = UInt32(((Int32)v1) >> v2);
+ SetOperand32(&cmd->Op1, res);
+ Flags= (res == 0 ? FLAG_Z : (res & FLAG_S)) | ((v1 >> (v2 - 1)) & FLAG_C);
+ }
+ break;
+ case CMD_SARB:
+ {
+ Byte v1 = GetOperand8(&cmd->Op1);
+ int v2 = (int)GetOperand8(&cmd->Op2);
+ Byte res = (Byte)(((signed char)v1) >> v2);
+ SetOperand8(&cmd->Op1, res);
+ Flags= (res == 0 ? FLAG_Z : GET_FLAG_S_B(res)) | ((v1 >> (v2 - 1)) & FLAG_C);
+ }
+ break;
+
+ case CMD_JMP:
+ SET_IP_OP1;
+ continue;
+ case CMD_JZ:
+ if ((Flags & FLAG_Z) != 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JNZ:
+ if ((Flags & FLAG_Z) == 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JS:
+ if ((Flags & FLAG_S) != 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JNS:
+ if ((Flags & FLAG_S) == 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JB:
+ if ((Flags & FLAG_C) != 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JBE:
+ if ((Flags & (FLAG_C | FLAG_Z)) != 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JA:
+ if ((Flags & (FLAG_C | FLAG_Z)) == 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+ case CMD_JAE:
+ if ((Flags & FLAG_C) == 0)
+ {
+ SET_IP_OP1;
+ continue;
+ }
+ break;
+
+ case CMD_PUSH:
+ R[kStackRegIndex] -= 4;
+ SetValue32(&Mem[R[kStackRegIndex] & kSpaceMask], GetOperand32(&cmd->Op1));
+ break;
+ case CMD_POP:
+ SetOperand32(&cmd->Op1, GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]));
+ R[kStackRegIndex] += 4;
+ break;
+ case CMD_CALL:
+ R[kStackRegIndex] -= 4;
+ SetValue32(&Mem[R[kStackRegIndex] & kSpaceMask], (UInt32)(cmd - commands + 1));
+ SET_IP_OP1;
+ continue;
+
+ case CMD_PUSHA:
+ {
+ for (UInt32 i = 0, SP = R[kStackRegIndex] - 4; i < kNumRegs; i++, SP -= 4)
+ SetValue32(&Mem[SP & kSpaceMask], R[i]);
+ R[kStackRegIndex] -= kNumRegs * 4;
+ }
+ break;
+ case CMD_POPA:
+ {
+ for (UInt32 i = 0, SP = R[kStackRegIndex]; i < kNumRegs; i++, SP += 4)
+ R[kStackRegIndex - i] = GetValue32(&Mem[SP & kSpaceMask]);
+ }
+ break;
+ case CMD_PUSHF:
+ R[kStackRegIndex] -= 4;
+ SetValue32(&Mem[R[kStackRegIndex]&kSpaceMask], Flags);
+ break;
+ case CMD_POPF:
+ Flags = GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]);
+ R[kStackRegIndex] += 4;
+ break;
+
+ case CMD_MOVZX:
+ SetOperand32(&cmd->Op1, GetOperand8(&cmd->Op2));
+ break;
+ case CMD_MOVSX:
+ SetOperand32(&cmd->Op1, (UInt32)(Int32)(signed char)GetOperand8(&cmd->Op2));
+ break;
+ case CMD_XCHG:
+ {
+ UInt32 v1 = GetOperand(cmd->ByteMode, &cmd->Op1);
+ SetOperand(cmd->ByteMode, &cmd->Op1, GetOperand(cmd->ByteMode, &cmd->Op2));
+ SetOperand(cmd->ByteMode, &cmd->Op2, v1);
+ }
+ break;
+ case CMD_MUL:
+ {
+ UInt32 res = GetOperand32(&cmd->Op1) * GetOperand32(&cmd->Op2);
+ SetOperand32(&cmd->Op1, res);
+ }
+ break;
+ case CMD_MULB:
+ {
+ Byte res = GetOperand8(&cmd->Op1) * GetOperand8(&cmd->Op2);
+ SetOperand8(&cmd->Op1, res);
+ }
+ break;
+ case CMD_DIV:
+ {
+ UInt32 divider = GetOperand(cmd->ByteMode, &cmd->Op2);
+ if (divider != 0)
+ {
+ UInt32 res = GetOperand(cmd->ByteMode, &cmd->Op1) / divider;
+ SetOperand(cmd->ByteMode, &cmd->Op1, res);
+ }
+ }
+ break;
+
+ #endif
+
+ case CMD_RET:
+ {
+ if (R[kStackRegIndex] >= kSpaceSize)
+ return true;
+ UInt32 ip = GetValue32(&Mem[R[kStackRegIndex] & kSpaceMask]);
+ SET_IP(ip);
+ R[kStackRegIndex] += 4;
+ continue;
+ }
+ case CMD_PRINT:
+ break;
+ }
+ cmd++;
+ --maxOpCount;
+ }
+}
+
+
+//////////////////////////////////////////////////////
+// Read program
+
+UInt32 ReadEncodedUInt32(CMemBitDecoder &inp)
+{
+ switch(inp.ReadBits(2))
+ {
+ case 0:
+ return inp.ReadBits(4);
+ case 1:
+ {
+ UInt32 v = inp.ReadBits(4);
+ if (v == 0)
+ return 0xFFFFFF00 | inp.ReadBits(8);
+ else
+ return (v << 4) | inp.ReadBits(4);
+ }
+ case 2:
+ return inp.ReadBits(16);
+ default:
+ return inp.ReadBits(32);
+ }
+}
+
+void CVm::DecodeArg(CMemBitDecoder &inp, COperand &op, bool byteMode)
+{
+ if (inp.ReadBit())
+ {
+ op.Type = OP_TYPE_REG;
+ op.Data = inp.ReadBits(kNumRegBits);
+ }
+ else if (inp.ReadBit() == 0)
+ {
+ op.Type = OP_TYPE_INT;
+ if (byteMode)
+ op.Data = inp.ReadBits(8);
+ else
+ op.Data = ReadEncodedUInt32(inp);
+ }
+ else
+ {
+ op.Type = OP_TYPE_REGMEM;
+ if (inp.ReadBit() == 0)
+ {
+ op.Data = inp.ReadBits(kNumRegBits);
+ op.Base = 0;
+ }
+ else
+ {
+ if (inp.ReadBit() == 0)
+ op.Data = inp.ReadBits(kNumRegBits);
+ else
+ op.Data = kNumRegs;
+ op.Base = ReadEncodedUInt32(inp);
+ }
+ }
+}
+
+void CVm::ReadVmProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
+{
+ CMemBitDecoder inp;
+ inp.Init(code, codeSize);
+
+ prg->StaticData.Clear();
+ if (inp.ReadBit())
+ {
+ UInt32 dataSize = ReadEncodedUInt32(inp) + 1;
+ for (UInt32 i = 0; inp.Avail() && i < dataSize; i++)
+ prg->StaticData.Add((Byte)inp.ReadBits(8));
+ }
+ while (inp.Avail())
+ {
+ prg->Commands.Add(CCommand());
+ CCommand *cmd = &prg->Commands.Back();
+ if (inp.ReadBit() == 0)
+ cmd->OpCode = (ECommand)inp.ReadBits(3);
+ else
+ cmd->OpCode = (ECommand)(8 + inp.ReadBits(5));
+ if (kCmdFlags[cmd->OpCode] & CF_BYTEMODE)
+ cmd->ByteMode = (inp.ReadBit()) ? true : false;
+ else
+ cmd->ByteMode = 0;
+ int opNum = (kCmdFlags[cmd->OpCode] & CF_OPMASK);
+ if (opNum > 0)
+ {
+ DecodeArg(inp, cmd->Op1, cmd->ByteMode);
+ if (opNum == 2)
+ DecodeArg(inp, cmd->Op2, cmd->ByteMode);
+ else
+ {
+ if (cmd->Op1.Type == OP_TYPE_INT && (kCmdFlags[cmd->OpCode] & (CF_JUMP | CF_PROC)))
+ {
+ int Distance = cmd->Op1.Data;
+ if (Distance >= 256)
+ Distance -= 256;
+ else
+ {
+ if (Distance >= 136)
+ Distance -= 264;
+ else if (Distance >= 16)
+ Distance -= 8;
+ else if (Distance >= 8)
+ Distance -= 16;
+ Distance += prg->Commands.Size() - 1;
+ }
+ cmd->Op1.Data = Distance;
+ }
+ }
+ }
+ if (cmd->ByteMode)
+ {
+ switch (cmd->OpCode)
+ {
+ case CMD_MOV: cmd->OpCode = CMD_MOVB; break;
+ case CMD_CMP: cmd->OpCode = CMD_CMPB; break;
+ case CMD_ADD: cmd->OpCode = CMD_ADDB; break;
+ case CMD_SUB: cmd->OpCode = CMD_SUBB; break;
+ case CMD_INC: cmd->OpCode = CMD_INCB; break;
+ case CMD_DEC: cmd->OpCode = CMD_DECB; break;
+ case CMD_XOR: cmd->OpCode = CMD_XORB; break;
+ case CMD_AND: cmd->OpCode = CMD_ANDB; break;
+ case CMD_OR: cmd->OpCode = CMD_ORB; break;
+ case CMD_TEST: cmd->OpCode = CMD_TESTB; break;
+ case CMD_NEG: cmd->OpCode = CMD_NEGB; break;
+ case CMD_SHL: cmd->OpCode = CMD_SHLB; break;
+ case CMD_SHR: cmd->OpCode = CMD_SHRB; break;
+ case CMD_SAR: cmd->OpCode = CMD_SARB; break;
+ case CMD_MUL: cmd->OpCode = CMD_MULB; break;
+ }
+ }
+ }
+}
+
+#ifdef RARVM_STANDARD_FILTERS
+
+enum EStandardFilter
+{
+ SF_E8,
+ SF_E8E9,
+ SF_ITANIUM,
+ SF_RGB,
+ SF_AUDIO,
+ SF_DELTA,
+ SF_UPCASE
+};
+
+struct StandardFilterSignature
+{
+ UInt32 Length;
+ UInt32 CRC;
+ EStandardFilter Type;
+}
+kStdFilters[]=
+{
+ 53, 0xad576887, SF_E8,
+ 57, 0x3cd7e57e, SF_E8E9,
+ 120, 0x3769893f, SF_ITANIUM,
+ 29, 0x0e06077d, SF_DELTA,
+ 149, 0x1c2c5dc8, SF_RGB,
+ 216, 0xbc85e701, SF_AUDIO,
+ 40, 0x46b9c560, SF_UPCASE
+};
+
+static int FindStandardFilter(const Byte *code, UInt32 codeSize)
+{
+ UInt32 crc = CCRC::CalculateDigest(code, codeSize);
+ for (int i = 0; i < sizeof(kStdFilters) / sizeof(kStdFilters[0]); i++)
+ {
+ StandardFilterSignature &sfs = kStdFilters[i];
+ if (sfs.CRC == crc && sfs.Length == codeSize)
+ return i;
+ }
+ return -1;
+}
+
+#endif
+
+void CVm::PrepareProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
+{
+ Byte xorSum = 0;
+ for (UInt32 i = 1; i < codeSize; i++)
+ xorSum ^= code[i];
+
+ prg->Commands.Clear();
+ #ifdef RARVM_STANDARD_FILTERS
+ prg->StandardFilterIndex = -1;
+ #endif
+
+ if (xorSum == code[0] && codeSize > 0)
+ {
+ #ifdef RARVM_STANDARD_FILTERS
+ prg->StandardFilterIndex = FindStandardFilter(code, codeSize);
+ if (prg->StandardFilterIndex >= 0)
+ return;
+ #endif
+ // 1 byte for checksum
+ ReadVmProgram(code + 1, codeSize - 1, prg);
+ }
+ prg->Commands.Add(CCommand());
+ CCommand *cmd = &prg->Commands.Back();
+ cmd->OpCode = CMD_RET;
+}
+
+void CVm::SetMemory(UInt32 pos, const Byte *data, UInt32 dataSize)
+{
+ if (pos < kSpaceSize && data != Mem + pos)
+ memmove(Mem + pos, data, MyMin(dataSize, kSpaceSize - pos));
+}
+
+#ifdef RARVM_STANDARD_FILTERS
+
+static void E8E9Decode(Byte *data, UInt32 dataSize, UInt32 fileOffset, bool e9)
+{
+ if (dataSize <= 4)
+ return;
+ dataSize -= 4;
+ const UInt32 kFileSize = 0x1000000;
+ Byte cmpByte2 = (e9 ? 0xE9 : 0xE8);
+ for (UInt32 curPos = 0; curPos < dataSize;)
+ {
+ Byte curByte = *(data++);
+ curPos++;
+ if (curByte == 0xE8 || curByte == cmpByte2)
+ {
+ UInt32 offset = curPos + fileOffset;
+ UInt32 addr = (Int32)GetValue32(data);
+ if (addr < kFileSize)
+ SetValue32(data, addr - offset);
+ else if ((Int32)addr < 0 && (Int32)(addr + offset) >= 0)
+ SetValue32(data, addr + kFileSize);
+ data += 4;
+ curPos += 4;
+ }
+ }
+}
+
+static inline UInt32 ItaniumGetOpType(const Byte *data, int bitPos)
+{
+ return (data[(unsigned int)bitPos >> 3] >> (bitPos & 7)) & 0xF;
+}
+
+
+static void ItaniumDecode(Byte *data, UInt32 dataSize, UInt32 fileOffset)
+{
+ UInt32 curPos = 0;
+ fileOffset >>= 4;
+ while (curPos < dataSize - 21)
+ {
+ int b = (data[0] & 0x1F) - 0x10;
+ if (b >= 0)
+ {
+ static Byte kCmdMasks[16] = {4,4,6,6,0,0,7,7,4,4,0,0,4,4,0,0};
+ Byte cmdMask = kCmdMasks[b];
+ if (cmdMask != 0)
+ for (int i = 0; i < 3; i++)
+ if (cmdMask & (1 << i))
+ {
+ int startPos = i * 41 + 18;
+ if (ItaniumGetOpType(data, startPos + 24) == 5)
+ {
+ const UInt32 kMask = 0xFFFFF;
+ Byte *p = data + ((unsigned int)startPos >> 3);
+ UInt32 bitField = ((UInt32)p[0]) | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16);
+ int inBit = (startPos & 7);
+ UInt32 offset = (bitField >> inBit) & kMask;
+ UInt32 andMask = ~(kMask << inBit);
+ bitField = ((offset - fileOffset) & kMask) << inBit;
+ for (int j = 0; j < 3; j++)
+ {
+ p[j] &= andMask;
+ p[j] |= bitField;
+ andMask >>= 8;
+ bitField >>= 8;
+ }
+ }
+ }
+ }
+ data += 16;
+ curPos += 16;
+ fileOffset++;
+ }
+}
+
+static void DeltaDecode(Byte *data, UInt32 dataSize, UInt32 numChannels)
+{
+ UInt32 srcPos = 0;
+ UInt32 border = dataSize * 2;
+ for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
+ {
+ Byte prevByte = 0;
+ for (UInt32 destPos = dataSize + curChannel; destPos < border; destPos += numChannels)
+ data[destPos] = (prevByte = prevByte - data[srcPos++]);
+ }
+}
+
+static void RgbDecode(Byte *srcData, UInt32 dataSize, UInt32 width, UInt32 posR)
+{
+ Byte *destData = srcData + dataSize;
+ const UInt32 numChannels = 3;
+ for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
+ {
+ Byte prevByte = 0;
+
+ for (UInt32 i = curChannel; i < dataSize; i+= numChannels)
+ {
+ unsigned int predicted;
+ if (i < width)
+ predicted = prevByte;
+ else
+ {
+ unsigned int upperLeftByte = destData[i - width];
+ unsigned int upperByte = destData[i - width + 3];
+ predicted = prevByte + upperByte - upperLeftByte;
+ int pa = abs((int)(predicted - prevByte));
+ int pb = abs((int)(predicted - upperByte));
+ int pc = abs((int)(predicted - upperLeftByte));
+ if (pa <= pb && pa <= pc)
+ predicted = prevByte;
+ else
+ if (pb <= pc)
+ predicted = upperByte;
+ else
+ predicted = upperLeftByte;
+ }
+ destData[i] = prevByte = (Byte)(predicted - *(srcData++));
+ }
+ }
+ if (dataSize < 3)
+ return;
+ for (UInt32 i = posR, border = dataSize - 2; i < border; i += 3)
+ {
+ Byte g = destData[i + 1];
+ destData[i] = destData[i] + g;
+ destData[i + 2] = destData[i + 2] + g;
+ }
+}
+
+static void AudioDecode(Byte *srcData, UInt32 dataSize, UInt32 numChannels)
+{
+ Byte *destData = srcData + dataSize;
+ for (UInt32 curChannel = 0; curChannel < numChannels; curChannel++)
+ {
+ UInt32 prevByte = 0, prevDelta = 0, dif[7];
+ Int32 D1 = 0, D2 = 0, D3;
+ Int32 K1 = 0, K2 = 0, K3 = 0;
+ memset(dif, 0, sizeof(dif));
+
+ for (UInt32 i = curChannel, byteCount = 0; i < dataSize; i += numChannels, byteCount++)
+ {
+ D3 = D2;
+ D2 = prevDelta - D1;
+ D1 = prevDelta;
+
+ UInt32 predicted = 8 * prevByte + K1 * D1 + K2 * D2 + K3 * D3;
+ predicted = (predicted >> 3) & 0xFF;
+
+ UInt32 curByte = *(srcData++);
+
+ predicted -= curByte;
+ destData[i] = (Byte)predicted;
+ prevDelta = (UInt32)(Int32)(signed char)(predicted - prevByte);
+ prevByte = predicted;
+
+ Int32 D = ((Int32)(signed char)curByte) << 3;
+
+ dif[0] += abs(D);
+ dif[1] += abs(D - D1);
+ dif[2] += abs(D + D1);
+ dif[3] += abs(D - D2);
+ dif[4] += abs(D + D2);
+ dif[5] += abs(D - D3);
+ dif[6] += abs(D + D3);
+
+ if ((byteCount & 0x1F) == 0)
+ {
+ UInt32 minDif = dif[0], numMinDif = 0;
+ dif[0] = 0;
+ for (int j = 1; j < sizeof(dif) / sizeof(dif[0]); j++)
+ {
+ if (dif[j] < minDif)
+ {
+ minDif = dif[j];
+ numMinDif = j;
+ }
+ dif[j] = 0;
+ }
+ switch (numMinDif)
+ {
+ 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 5: if (K3 >= -16) K3--; break;
+ case 6: if (K3 < 16) K3++; break;
+ }
+ }
+ }
+ }
+}
+
+static UInt32 UpCaseDecode(Byte *data, UInt32 dataSize)
+{
+ UInt32 srcPos = 0, destPos = dataSize;
+ while (srcPos < dataSize)
+ {
+ Byte curByte = data[srcPos++];
+ if (curByte == 2 && (curByte = data[srcPos++]) != 2)
+ curByte -= 32;
+ data[destPos++] = curByte;
+ }
+ return destPos - dataSize;
+}
+
+void CVm::ExecuteStandardFilter(int filterIndex)
+{
+ UInt32 dataSize = R[4];
+ if (dataSize >= kGlobalOffset)
+ return;
+ EStandardFilter filterType = kStdFilters[filterIndex].Type;
+
+ switch (filterType)
+ {
+ case SF_E8:
+ case SF_E8E9:
+ E8E9Decode(Mem, dataSize, R[6], (filterType == SF_E8E9));
+ break;
+ case SF_ITANIUM:
+ ItaniumDecode(Mem, dataSize, R[6]);
+ break;
+ case SF_DELTA:
+ if (dataSize >= kGlobalOffset / 2)
+ break;
+ SetBlockPos(dataSize);
+ DeltaDecode(Mem, dataSize, R[0]);
+ break;
+ case SF_RGB:
+ if (dataSize >= kGlobalOffset / 2)
+ break;
+ {
+ UInt32 width = R[0];
+ if (width <= 3)
+ break;
+ SetBlockPos(dataSize);
+ RgbDecode(Mem, dataSize, width, R[1]);
+ }
+ break;
+ case SF_AUDIO:
+ if (dataSize >= kGlobalOffset / 2)
+ break;
+ SetBlockPos(dataSize);
+ AudioDecode(Mem, dataSize, R[0]);
+ break;
+ case SF_UPCASE:
+ if (dataSize >= kGlobalOffset / 2)
+ break;
+ UInt32 destSize = UpCaseDecode(Mem, dataSize);
+ SetBlockSize(destSize);
+ SetBlockPos(dataSize);
+ break;
+ }
+}
+
+#endif
+
+}}}
diff --git a/CPP/7zip/Compress/Rar/Rar3Vm.h b/CPP/7zip/Compress/Rar/Rar3Vm.h
new file mode 100755
index 00000000..d0a4f82c
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/Rar3Vm.h
@@ -0,0 +1,219 @@
+// Rar3Vm.h
+// According to unRAR license,
+// this code may not be used to develop a
+// RAR (WinRAR) compatible archiver
+
+#ifndef __RAR3VM_H
+#define __RAR3VM_H
+
+#include "Common/Types.h"
+#include "Common/Vector.h"
+
+#define RARVM_STANDARD_FILTERS
+#if defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(__i386__) || defined(__x86_64__) // || defined(_M_IA64) || defined(__ia64__)
+// Define RARVM_LITTLE_ENDIAN_UNALIGN, if CPU is LITTLE_ENDIAN and if it supports
+// unaligned 32-bit memory accesses.
+// It's for speed optimization, if you are not sure, just don't define it.
+#define RARVM_LITTLE_ENDIAN_UNALIGN
+#endif
+
+namespace NCompress {
+namespace NRar3 {
+
+class CMemBitDecoder
+{
+ const Byte *_data;
+ UInt32 _bitSize;
+ UInt32 _bitPos;
+public:
+ void Init(const Byte *data, UInt32 byteSize)
+ {
+ _data = data;
+ _bitSize = (byteSize << 3);
+ _bitPos = 0;
+ }
+ UInt32 ReadBits(int numBits);
+ UInt32 ReadBit();
+ bool Avail() const { return (_bitPos < _bitSize); }
+};
+
+namespace NVm {
+
+inline UInt32 GetValue32(const void *addr)
+{
+ #ifdef RARVM_LITTLE_ENDIAN_UNALIGN
+ return *(const UInt32 *)addr;
+ #else
+ const Byte *b = (const Byte *)addr;
+ return UInt32((UInt32)b[0]|((UInt32)b[1]<<8)|((UInt32)b[2]<<16)|((UInt32)b[3]<<24));
+ #endif
+}
+
+inline void SetValue32(void *addr, UInt32 value)
+{
+ #ifdef RARVM_LITTLE_ENDIAN_UNALIGN
+ *(UInt32 *)addr = value;
+ #else
+ ((Byte *)addr)[0] = (Byte)value;
+ ((Byte *)addr)[1] = (Byte)(value >> 8);
+ ((Byte *)addr)[2] = (Byte)(value >> 16);
+ ((Byte *)addr)[3] = (Byte)(value >> 24);
+ #endif
+}
+
+UInt32 ReadEncodedUInt32(CMemBitDecoder &inp);
+
+const int kNumRegBits = 3;
+const UInt32 kNumRegs = 1 << kNumRegBits;
+const UInt32 kNumGpRegs = kNumRegs - 1;
+
+const UInt32 kSpaceSize = 0x40000;
+const UInt32 kSpaceMask = kSpaceSize -1;
+const UInt32 kGlobalOffset = 0x3C000;
+const UInt32 kGlobalSize = 0x2000;
+const UInt32 kFixedGlobalSize = 64;
+
+namespace NGlobalOffset
+{
+ const UInt32 kBlockSize = 0x1C;
+ const UInt32 kBlockPos = 0x20;
+ const UInt32 kExecCount = 0x2C;
+ const UInt32 kGlobalMemOutSize = 0x30;
+};
+
+enum ECommand
+{
+ CMD_MOV, CMD_CMP, CMD_ADD, CMD_SUB, CMD_JZ, CMD_JNZ, CMD_INC, CMD_DEC,
+ CMD_JMP, CMD_XOR, CMD_AND, CMD_OR, CMD_TEST, CMD_JS, CMD_JNS, CMD_JB,
+ CMD_JBE, CMD_JA, CMD_JAE, CMD_PUSH, CMD_POP, CMD_CALL, CMD_RET, CMD_NOT,
+ 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_XORB, CMD_ANDB, CMD_ORB, CMD_TESTB,CMD_NEGB,
+ CMD_SHLB, CMD_SHRB, CMD_SARB, CMD_MULB
+};
+
+enum EOpType {OP_TYPE_REG, OP_TYPE_INT, OP_TYPE_REGMEM, OP_TYPE_NONE};
+
+// Addr in COperand object can link (point) to CVm object!!!
+
+struct COperand
+{
+ EOpType Type;
+ UInt32 Data;
+ UInt32 Base;
+ COperand(): Type(OP_TYPE_NONE), Data(0), Base(0) {}
+};
+
+struct CCommand
+{
+ ECommand OpCode;
+ bool ByteMode;
+ COperand Op1, Op2;
+};
+
+struct CBlockRef
+{
+ UInt32 Offset;
+ UInt32 Size;
+};
+
+struct CProgram
+{
+ CRecordVector<CCommand> Commands;
+ #ifdef RARVM_STANDARD_FILTERS
+ int StandardFilterIndex;
+ #endif
+ CRecordVector<Byte> StaticData;
+};
+
+struct CProgramInitState
+{
+ UInt32 InitR[kNumGpRegs];
+ CRecordVector<Byte> GlobalData;
+
+ void AllocateEmptyFixedGlobal()
+ {
+ GlobalData.Clear();
+ GlobalData.Reserve(NVm::kFixedGlobalSize);
+ for (UInt32 i = 0; i < NVm::kFixedGlobalSize; i++)
+ GlobalData.Add(0);
+ }
+};
+
+class CVm
+{
+ static UInt32 GetValue(bool byteMode, const void *addr)
+ {
+ if (byteMode)
+ return(*(const Byte *)addr);
+ else
+ {
+ #ifdef RARVM_LITTLE_ENDIAN_UNALIGN
+ return *(const UInt32 *)addr;
+ #else
+ const Byte *b = (const Byte *)addr;
+ return UInt32((UInt32)b[0]|((UInt32)b[1]<<8)|((UInt32)b[2]<<16)|((UInt32)b[3]<<24));
+ #endif
+ }
+ }
+
+ static void SetValue(bool byteMode, void *addr, UInt32 value)
+ {
+ if (byteMode)
+ *(Byte *)addr = (Byte)value;
+ else
+ {
+ #ifdef RARVM_LITTLE_ENDIAN_UNALIGN
+ *(UInt32 *)addr = value;
+ #else
+ ((Byte *)addr)[0] = (Byte)value;
+ ((Byte *)addr)[1] = (Byte)(value >> 8);
+ ((Byte *)addr)[2] = (Byte)(value >> 16);
+ ((Byte *)addr)[3] = (Byte)(value >> 24);
+ #endif
+ }
+ }
+
+ UInt32 GetFixedGlobalValue32(UInt32 globalOffset) { return GetValue(false, &Mem[kGlobalOffset + globalOffset]); }
+
+ void SetBlockSize(UInt32 v) { SetValue(&Mem[kGlobalOffset + NGlobalOffset::kBlockSize], v); }
+ void SetBlockPos(UInt32 v) { SetValue(&Mem[kGlobalOffset + NGlobalOffset::kBlockPos], v); }
+public:
+ static void SetValue(void *addr, UInt32 value) { SetValue(false, addr, value); }
+private:
+ UInt32 GetOperand32(const COperand *op) const;
+ void SetOperand32(const COperand *op, UInt32 val);
+ Byte GetOperand8(const COperand *op) const;
+ void SetOperand8(const COperand *op, Byte val);
+ UInt32 GetOperand(bool byteMode, const COperand *op) const;
+ void SetOperand(bool byteMode, const COperand *op, UInt32 val);
+
+ void DecodeArg(CMemBitDecoder &inp, COperand &op, bool byteMode);
+
+ bool ExecuteCode(const CProgram *prg);
+
+ #ifdef RARVM_STANDARD_FILTERS
+ void ExecuteStandardFilter(int filterIndex);
+ #endif
+
+ Byte *Mem;
+ UInt32 R[kNumRegs + 1]; // R[kNumRegs] = 0 always (speed optimization)
+ UInt32 Flags;
+ void ReadVmProgram(const Byte *code, UInt32 codeSize, CProgram *prg);
+public:
+ CVm();
+ ~CVm();
+ 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,
+ CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData);
+ const Byte *GetDataPointer(UInt32 offset) const { return Mem + offset; }
+
+};
+
+#endif
+
+}}}
diff --git a/7zip/Compress/Shrink/StdAfx.cpp b/CPP/7zip/Compress/Rar/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/Shrink/StdAfx.cpp
+++ b/CPP/7zip/Compress/Rar/StdAfx.cpp
diff --git a/7zip/Compress/Rar20/StdAfx.h b/CPP/7zip/Compress/Rar/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/Rar20/StdAfx.h
+++ b/CPP/7zip/Compress/Rar/StdAfx.h
diff --git a/CPP/7zip/Compress/Rar/makefile b/CPP/7zip/Compress/Rar/makefile
new file mode 100755
index 00000000..4d8d5304
--- /dev/null
+++ b/CPP/7zip/Compress/Rar/makefile
@@ -0,0 +1,49 @@
+PROG = Rar29.dll
+DEF_FILE = ../Codec.def
+CFLAGS = $(CFLAGS) -I ../../../
+LIBS = $(LIBS) oleaut32.lib
+
+RAR29_OBJS = \
+ $O\DllExports.obj \
+
+RAR29_OPT_OBJS = \
+ $O\Rar1Decoder.obj \
+ $O\Rar2Decoder.obj \
+ $O\Rar3Decoder.obj \
+ $O\Rar3Vm.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CRC.obj \
+ $O\Vector.obj \
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\OutBuffer.obj \
+ $O\StreamUtils.obj \
+
+LZ_OBJS = \
+ $O\LZOutWindow.obj \
+
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(RAR29_OBJS) \
+ $(RAR29_OPT_OBJS) \
+ $(COMMON_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(LZ_OBJS) \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(RAR29_OBJS): $(*B).cpp
+ $(COMPL)
+$(RAR29_OPT_OBJS): $(*B).cpp
+ $(COMPL_O2)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(LZ_OBJS): ../LZ/$(*B).cpp
+ $(COMPL)
diff --git a/7zip/Compress/Rar29/resource.rc b/CPP/7zip/Compress/Rar/resource.rc
index bb5e2ec9..bb5e2ec9 100755
--- a/7zip/Compress/Rar29/resource.rc
+++ b/CPP/7zip/Compress/Rar/resource.rc
diff --git a/CPP/7zip/Compress/Shrink/DllExports.cpp b/CPP/7zip/Compress/Shrink/DllExports.cpp
new file mode 100755
index 00000000..61bd5e69
--- /dev/null
+++ b/CPP/7zip/Compress/Shrink/DllExports.cpp
@@ -0,0 +1,64 @@
+// DLLExports.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+#include "Common/ComTry.h"
+#include "ShrinkDecoder.h"
+
+// {23170F69-40C1-278B-0401-010000000000}
+DEFINE_GUID(CLSID_CCompressShrinkDecoder,
+0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ return TRUE;
+}
+
+STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
+{
+ COM_TRY_BEGIN
+ *outObject = 0;
+ if (*clsid != CLSID_CCompressShrinkDecoder)
+ return CLASS_E_CLASSNOTAVAILABLE;
+ if (*iid != IID_ICompressCoder)
+ return E_NOINTERFACE;
+ CMyComPtr<ICompressCoder> coder = (ICompressCoder *)new NCompress::NShrink::CDecoder;
+ *outObject = coder.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[] = { 0x04, 0x01, 0x01 };
+ if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ case NMethodPropID::kName:
+ if ((value->bstrVal = ::SysAllocString(L"Shrink")) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ case NMethodPropID::kDecoder:
+ if ((value->bstrVal = ::SysAllocStringByteLen(
+ (const char *)&CLSID_CCompressShrinkDecoder, sizeof(GUID))) != 0)
+ value->vt = VT_BSTR;
+ return S_OK;
+ }
+ return S_OK;
+}
diff --git a/7zip/Compress/Shrink/ShrinkDecoder.cpp b/CPP/7zip/Compress/Shrink/ShrinkDecoder.cpp
index 12d1b8d0..12d1b8d0 100755
--- a/7zip/Compress/Shrink/ShrinkDecoder.cpp
+++ b/CPP/7zip/Compress/Shrink/ShrinkDecoder.cpp
diff --git a/7zip/Compress/Shrink/ShrinkDecoder.h b/CPP/7zip/Compress/Shrink/ShrinkDecoder.h
index 1c15ea8a..1c15ea8a 100755
--- a/7zip/Compress/Shrink/ShrinkDecoder.h
+++ b/CPP/7zip/Compress/Shrink/ShrinkDecoder.h
diff --git a/7zip/Compress/Z/StdAfx.cpp b/CPP/7zip/Compress/Shrink/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Compress/Z/StdAfx.cpp
+++ b/CPP/7zip/Compress/Shrink/StdAfx.cpp
diff --git a/7zip/Compress/Rar29/StdAfx.h b/CPP/7zip/Compress/Shrink/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/Rar29/StdAfx.h
+++ b/CPP/7zip/Compress/Shrink/StdAfx.h
diff --git a/7zip/Crypto/7zAES/StdAfx.cpp b/CPP/7zip/Compress/Z/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Crypto/7zAES/StdAfx.cpp
+++ b/CPP/7zip/Compress/Z/StdAfx.cpp
diff --git a/7zip/Compress/Shrink/StdAfx.h b/CPP/7zip/Compress/Z/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/Shrink/StdAfx.h
+++ b/CPP/7zip/Compress/Z/StdAfx.h
diff --git a/CPP/7zip/Compress/Z/ZDecoder.cpp b/CPP/7zip/Compress/Z/ZDecoder.cpp
new file mode 100755
index 00000000..2415efd8
--- /dev/null
+++ b/CPP/7zip/Compress/Z/ZDecoder.cpp
@@ -0,0 +1,172 @@
+// ZDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "ZDecoder.h"
+
+#include "../../../Common/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;
+
+void CDecoder::Free()
+{
+ 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();
+}
+
+STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
+ ICompressProgressInfo *progress)
+{
+ NStream::NLSBF::CBaseDecoder<CInBuffer> inBuffer;
+ COutBuffer outBuffer;
+
+ if (!inBuffer.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ inBuffer.SetStream(inStream);
+ inBuffer.Init();
+
+ if (!outBuffer.Create(kBufferSize))
+ return E_OUTOFMEMORY;
+ outBuffer.SetStream(outStream);
+ outBuffer.Init();
+
+ int maxbits = _properties & kNumBitsMask;
+ if (maxbits < kNumMinBits || maxbits > kNumMaxBits)
+ 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;
+ _numMaxBits = maxbits;
+ }
+
+ UInt64 prevPos = 0;
+ int numBits = kNumMinBits;
+ UInt32 head = blockMode ? 257 : 256;
+
+ bool needPrev = false;
+
+ int keepBits = 0;
+
+ _parents[256] = 0; // virus protection
+ _suffixes[256] = 0;
+
+ for (;;)
+ {
+ if (keepBits < numBits)
+ keepBits = numBits * 8;
+ UInt32 symbol = inBuffer.ReadBits(numBits);
+ if (inBuffer.ExtraBitsWereRead())
+ break;
+ keepBits -= numBits;
+ if (symbol >= head)
+ return S_FALSE;
+ if (blockMode && symbol == 256)
+ {
+ for (;keepBits > 0; keepBits--)
+ inBuffer.ReadBits(1);
+ numBits = kNumMinBits;
+ head = 257;
+ needPrev = false;
+ continue;
+ }
+ UInt32 cur = symbol;
+ int i = 0;
+ while (cur >= 256)
+ {
+ _stack[i++] = _suffixes[cur];
+ cur = _parents[cur];
+ }
+ _stack[i++] = (Byte)cur;
+ if (needPrev)
+ {
+ _suffixes[head - 1] = (Byte)cur;
+ if (symbol == head - 1)
+ _stack[0] = (Byte)cur;
+ }
+ while (i > 0)
+ outBuffer.WriteByte((_stack[--i]));
+ if (head < numItems)
+ {
+ needPrev = true;
+ _parents[head++] = (UInt16)symbol;
+ if (head > ((UInt32)1 << numBits))
+ {
+ if (numBits < maxbits)
+ {
+ 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();
+}
+
+STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
+ catch(const CInBufferException &e) { return e.ErrorCode; }
+ catch(const COutBufferException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
+{
+ if (size < 1)
+ return E_INVALIDARG;
+ _properties = data[0];
+ return S_OK;
+}
+
+}}
diff --git a/CPP/7zip/Compress/Z/ZDecoder.h b/CPP/7zip/Compress/Z/ZDecoder.h
new file mode 100755
index 00000000..1640c7f4
--- /dev/null
+++ b/CPP/7zip/Compress/Z/ZDecoder.h
@@ -0,0 +1,44 @@
+// ZDecoder.h
+
+#ifndef __COMPRESS_ZDECODER_H
+#define __COMPRESS_ZDECODER_H
+
+#include "../../../Common/MyCom.h"
+#include "../../ICoder.h"
+
+namespace NCompress {
+namespace NZ {
+
+class CDecoder :
+ public ICompressCoder,
+ public ICompressSetDecoderProperties2,
+ public CMyUnknownImp
+{
+ BYTE _properties;
+ int _numMaxBits;
+ UInt16 *_parents;
+ Byte *_suffixes;
+ Byte *_stack;
+
+public:
+ CDecoder(): _properties(0), _numMaxBits(0), _parents(0), _suffixes(0), _stack(0) {};
+ ~CDecoder();
+ void Free();
+ bool Alloc(size_t numItems);
+
+ MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
+
+ STDMETHOD(CodeReal)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Compress/makefile b/CPP/7zip/Compress/makefile
new file mode 100755
index 00000000..7c1387c8
--- /dev/null
+++ b/CPP/7zip/Compress/makefile
@@ -0,0 +1,14 @@
+DIRS = \
+ Branch\~ \
+ ByteSwap\~ \
+ BZip2\~ \
+ Copy\~ \
+ Deflate\~ \
+ LZMA\~ \
+ PPMD\~ \
+ Rar\~ \
+
+all: $(DIRS)
+
+$(DIRS):
+!include "../SubBuild.mak"
diff --git a/7zip/Crypto/7zAES/7zAES.cpp b/CPP/7zip/Crypto/7zAES/7zAES.cpp
index 843d9027..843d9027 100755
--- a/7zip/Crypto/7zAES/7zAES.cpp
+++ b/CPP/7zip/Crypto/7zAES/7zAES.cpp
diff --git a/7zip/Crypto/7zAES/7zAES.dsp b/CPP/7zip/Crypto/7zAES/7zAES.dsp
index 37cd7792..37cd7792 100755
--- a/7zip/Crypto/7zAES/7zAES.dsp
+++ b/CPP/7zip/Crypto/7zAES/7zAES.dsp
diff --git a/7zip/Crypto/7zAES/7zAES.dsw b/CPP/7zip/Crypto/7zAES/7zAES.dsw
index 08efbad8..08efbad8 100755
--- a/7zip/Crypto/7zAES/7zAES.dsw
+++ b/CPP/7zip/Crypto/7zAES/7zAES.dsw
diff --git a/7zip/Crypto/7zAES/7zAES.h b/CPP/7zip/Crypto/7zAES/7zAES.h
index f312f7e6..f312f7e6 100755
--- a/7zip/Crypto/7zAES/7zAES.h
+++ b/CPP/7zip/Crypto/7zAES/7zAES.h
diff --git a/7zip/Crypto/7zAES/DllExports.cpp b/CPP/7zip/Crypto/7zAES/DllExports.cpp
index 8766ded4..8766ded4 100755
--- a/7zip/Crypto/7zAES/DllExports.cpp
+++ b/CPP/7zip/Crypto/7zAES/DllExports.cpp
diff --git a/7zip/Crypto/AES/StdAfx.cpp b/CPP/7zip/Crypto/7zAES/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Crypto/AES/StdAfx.cpp
+++ b/CPP/7zip/Crypto/7zAES/StdAfx.cpp
diff --git a/7zip/Compress/Z/StdAfx.h b/CPP/7zip/Crypto/7zAES/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Compress/Z/StdAfx.h
+++ b/CPP/7zip/Crypto/7zAES/StdAfx.h
diff --git a/7zip/Crypto/7zAES/makefile b/CPP/7zip/Crypto/7zAES/makefile
index c3d9a51d..c3d9a51d 100755
--- a/7zip/Crypto/7zAES/makefile
+++ b/CPP/7zip/Crypto/7zAES/makefile
diff --git a/7zip/Crypto/7zAES/resource.rc b/CPP/7zip/Crypto/7zAES/resource.rc
index 24d428de..24d428de 100755
--- a/7zip/Crypto/7zAES/resource.rc
+++ b/CPP/7zip/Crypto/7zAES/resource.rc
diff --git a/7zip/Crypto/AES/AES.dsp b/CPP/7zip/Crypto/AES/AES.dsp
index d039be77..d039be77 100755
--- a/7zip/Crypto/AES/AES.dsp
+++ b/CPP/7zip/Crypto/AES/AES.dsp
diff --git a/7zip/Crypto/AES/AES.dsw b/CPP/7zip/Crypto/AES/AES.dsw
index 7fa9d07b..7fa9d07b 100755
--- a/7zip/Crypto/AES/AES.dsw
+++ b/CPP/7zip/Crypto/AES/AES.dsw
diff --git a/7zip/Crypto/AES/AES_CBC.h b/CPP/7zip/Crypto/AES/AES_CBC.h
index fa3485a9..fa3485a9 100755
--- a/7zip/Crypto/AES/AES_CBC.h
+++ b/CPP/7zip/Crypto/AES/AES_CBC.h
diff --git a/7zip/Crypto/AES/DllExports.cpp b/CPP/7zip/Crypto/AES/DllExports.cpp
index 7c21ac5c..7c21ac5c 100755
--- a/7zip/Crypto/AES/DllExports.cpp
+++ b/CPP/7zip/Crypto/AES/DllExports.cpp
diff --git a/7zip/Crypto/AES/MyAES.cpp b/CPP/7zip/Crypto/AES/MyAES.cpp
index 359caa25..359caa25 100755
--- a/7zip/Crypto/AES/MyAES.cpp
+++ b/CPP/7zip/Crypto/AES/MyAES.cpp
diff --git a/7zip/Crypto/AES/MyAES.h b/CPP/7zip/Crypto/AES/MyAES.h
index f58913ae..f58913ae 100755
--- a/7zip/Crypto/AES/MyAES.h
+++ b/CPP/7zip/Crypto/AES/MyAES.h
diff --git a/7zip/Crypto/WzAES/StdAfx.cpp b/CPP/7zip/Crypto/AES/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/Crypto/WzAES/StdAfx.cpp
+++ b/CPP/7zip/Crypto/AES/StdAfx.cpp
diff --git a/7zip/Crypto/7zAES/StdAfx.h b/CPP/7zip/Crypto/AES/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Crypto/7zAES/StdAfx.h
+++ b/CPP/7zip/Crypto/AES/StdAfx.h
diff --git a/7zip/Crypto/AES/aes.h b/CPP/7zip/Crypto/AES/aes.h
index 9aaba978..9aaba978 100755
--- a/7zip/Crypto/AES/aes.h
+++ b/CPP/7zip/Crypto/AES/aes.h
diff --git a/7zip/Crypto/AES/aescpp.h b/CPP/7zip/Crypto/AES/aescpp.h
index 93e3c8b0..93e3c8b0 100755
--- a/7zip/Crypto/AES/aescpp.h
+++ b/CPP/7zip/Crypto/AES/aescpp.h
diff --git a/7zip/Crypto/AES/aescrypt.c b/CPP/7zip/Crypto/AES/aescrypt.c
index 095a61c4..095a61c4 100755
--- a/7zip/Crypto/AES/aescrypt.c
+++ b/CPP/7zip/Crypto/AES/aescrypt.c
diff --git a/7zip/Crypto/AES/aeskey.c b/CPP/7zip/Crypto/AES/aeskey.c
index d281e1a8..d281e1a8 100755
--- a/7zip/Crypto/AES/aeskey.c
+++ b/CPP/7zip/Crypto/AES/aeskey.c
diff --git a/7zip/Crypto/AES/aesopt.h b/CPP/7zip/Crypto/AES/aesopt.h
index bcad345f..bcad345f 100755
--- a/7zip/Crypto/AES/aesopt.h
+++ b/CPP/7zip/Crypto/AES/aesopt.h
diff --git a/7zip/Crypto/AES/aestab.c b/CPP/7zip/Crypto/AES/aestab.c
index de1d7eea..de1d7eea 100755
--- a/7zip/Crypto/AES/aestab.c
+++ b/CPP/7zip/Crypto/AES/aestab.c
diff --git a/7zip/Crypto/AES/makefile b/CPP/7zip/Crypto/AES/makefile
index 28f99965..28f99965 100755
--- a/7zip/Crypto/AES/makefile
+++ b/CPP/7zip/Crypto/AES/makefile
diff --git a/7zip/Crypto/AES/resource.rc b/CPP/7zip/Crypto/AES/resource.rc
index 1ea1bfe7..1ea1bfe7 100755
--- a/7zip/Crypto/AES/resource.rc
+++ b/CPP/7zip/Crypto/AES/resource.rc
diff --git a/7zip/Crypto/Codec.def b/CPP/7zip/Crypto/Codec.def
index ebf73a3b..ebf73a3b 100755
--- a/7zip/Crypto/Codec.def
+++ b/CPP/7zip/Crypto/Codec.def
diff --git a/7zip/Crypto/Hash/HmacSha1.cpp b/CPP/7zip/Crypto/Hash/HmacSha1.cpp
index a5c20a75..a5c20a75 100755
--- a/7zip/Crypto/Hash/HmacSha1.cpp
+++ b/CPP/7zip/Crypto/Hash/HmacSha1.cpp
diff --git a/7zip/Crypto/Hash/HmacSha1.h b/CPP/7zip/Crypto/Hash/HmacSha1.h
index bca5bcf8..bca5bcf8 100755
--- a/7zip/Crypto/Hash/HmacSha1.h
+++ b/CPP/7zip/Crypto/Hash/HmacSha1.h
diff --git a/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp
index b11881b7..b11881b7 100755
--- a/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp
+++ b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp
diff --git a/7zip/Crypto/Hash/Pbkdf2HmacSha1.h b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h
index 00a5e009..00a5e009 100755
--- a/7zip/Crypto/Hash/Pbkdf2HmacSha1.h
+++ b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h
diff --git a/7zip/Crypto/Hash/RandGen.cpp b/CPP/7zip/Crypto/Hash/RandGen.cpp
index 480e04ca..480e04ca 100755
--- a/7zip/Crypto/Hash/RandGen.cpp
+++ b/CPP/7zip/Crypto/Hash/RandGen.cpp
diff --git a/7zip/Crypto/Hash/RandGen.h b/CPP/7zip/Crypto/Hash/RandGen.h
index 3b58a032..3b58a032 100755
--- a/7zip/Crypto/Hash/RandGen.h
+++ b/CPP/7zip/Crypto/Hash/RandGen.h
diff --git a/7zip/Crypto/Hash/RotateDefs.h b/CPP/7zip/Crypto/Hash/RotateDefs.h
index 832e7357..832e7357 100755
--- a/7zip/Crypto/Hash/RotateDefs.h
+++ b/CPP/7zip/Crypto/Hash/RotateDefs.h
diff --git a/7zip/Crypto/Hash/Sha1.cpp b/CPP/7zip/Crypto/Hash/Sha1.cpp
index 0e1d2ecf..0e1d2ecf 100755
--- a/7zip/Crypto/Hash/Sha1.cpp
+++ b/CPP/7zip/Crypto/Hash/Sha1.cpp
diff --git a/7zip/Crypto/Hash/Sha1.h b/CPP/7zip/Crypto/Hash/Sha1.h
index ebb11142..ebb11142 100755
--- a/7zip/Crypto/Hash/Sha1.h
+++ b/CPP/7zip/Crypto/Hash/Sha1.h
diff --git a/7zip/Crypto/Hash/Sha256.cpp b/CPP/7zip/Crypto/Hash/Sha256.cpp
index db236058..db236058 100755
--- a/7zip/Crypto/Hash/Sha256.cpp
+++ b/CPP/7zip/Crypto/Hash/Sha256.cpp
diff --git a/7zip/Crypto/Hash/Sha256.h b/CPP/7zip/Crypto/Hash/Sha256.h
index e4788f41..e4788f41 100755
--- a/7zip/Crypto/Hash/Sha256.h
+++ b/CPP/7zip/Crypto/Hash/Sha256.h
diff --git a/7zip/Crypto/AES/StdAfx.h b/CPP/7zip/Crypto/Hash/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Crypto/AES/StdAfx.h
+++ b/CPP/7zip/Crypto/Hash/StdAfx.h
diff --git a/7zip/Crypto/Rar20/Rar20Cipher.cpp b/CPP/7zip/Crypto/Rar20/Rar20Cipher.cpp
index 27ccc493..27ccc493 100755
--- a/7zip/Crypto/Rar20/Rar20Cipher.cpp
+++ b/CPP/7zip/Crypto/Rar20/Rar20Cipher.cpp
diff --git a/7zip/Crypto/Rar20/Rar20Cipher.h b/CPP/7zip/Crypto/Rar20/Rar20Cipher.h
index e2091cda..e2091cda 100755
--- a/7zip/Crypto/Rar20/Rar20Cipher.h
+++ b/CPP/7zip/Crypto/Rar20/Rar20Cipher.h
diff --git a/7zip/Crypto/Rar20/Rar20Crypto.cpp b/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp
index d8be2279..d8be2279 100755
--- a/7zip/Crypto/Rar20/Rar20Crypto.cpp
+++ b/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp
diff --git a/7zip/Crypto/Rar20/Rar20Crypto.h b/CPP/7zip/Crypto/Rar20/Rar20Crypto.h
index 071d01f1..071d01f1 100755
--- a/7zip/Crypto/Rar20/Rar20Crypto.h
+++ b/CPP/7zip/Crypto/Rar20/Rar20Crypto.h
diff --git a/7zip/Crypto/Hash/StdAfx.h b/CPP/7zip/Crypto/Rar20/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Crypto/Hash/StdAfx.h
+++ b/CPP/7zip/Crypto/Rar20/StdAfx.h
diff --git a/7zip/Crypto/RarAES/RarAES.cpp b/CPP/7zip/Crypto/RarAES/RarAES.cpp
index ae22bb2a..ae22bb2a 100755
--- a/7zip/Crypto/RarAES/RarAES.cpp
+++ b/CPP/7zip/Crypto/RarAES/RarAES.cpp
diff --git a/7zip/Crypto/RarAES/RarAES.h b/CPP/7zip/Crypto/RarAES/RarAES.h
index 4b435b5e..4b435b5e 100755
--- a/7zip/Crypto/RarAES/RarAES.h
+++ b/CPP/7zip/Crypto/RarAES/RarAES.h
diff --git a/7zip/Crypto/Rar20/StdAfx.h b/CPP/7zip/Crypto/RarAES/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Crypto/Rar20/StdAfx.h
+++ b/CPP/7zip/Crypto/RarAES/StdAfx.h
diff --git a/7zip/UI/Client7z/StdAfx.cpp b/CPP/7zip/Crypto/WzAES/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/UI/Client7z/StdAfx.cpp
+++ b/CPP/7zip/Crypto/WzAES/StdAfx.cpp
diff --git a/7zip/Crypto/RarAES/StdAfx.h b/CPP/7zip/Crypto/WzAES/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Crypto/RarAES/StdAfx.h
+++ b/CPP/7zip/Crypto/WzAES/StdAfx.h
diff --git a/7zip/Crypto/WzAES/WzAES.cpp b/CPP/7zip/Crypto/WzAES/WzAES.cpp
index 8bf53b43..8bf53b43 100755
--- a/7zip/Crypto/WzAES/WzAES.cpp
+++ b/CPP/7zip/Crypto/WzAES/WzAES.cpp
diff --git a/7zip/Crypto/WzAES/WzAES.h b/CPP/7zip/Crypto/WzAES/WzAES.h
index c27bd326..c27bd326 100755
--- a/7zip/Crypto/WzAES/WzAES.h
+++ b/CPP/7zip/Crypto/WzAES/WzAES.h
diff --git a/7zip/Crypto/WzAES/StdAfx.h b/CPP/7zip/Crypto/Zip/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/7zip/Crypto/WzAES/StdAfx.h
+++ b/CPP/7zip/Crypto/Zip/StdAfx.h
diff --git a/7zip/Crypto/Zip/ZipCipher.cpp b/CPP/7zip/Crypto/Zip/ZipCipher.cpp
index 639776ce..639776ce 100755
--- a/7zip/Crypto/Zip/ZipCipher.cpp
+++ b/CPP/7zip/Crypto/Zip/ZipCipher.cpp
diff --git a/7zip/Crypto/Zip/ZipCipher.h b/CPP/7zip/Crypto/Zip/ZipCipher.h
index d750336c..d750336c 100755
--- a/7zip/Crypto/Zip/ZipCipher.h
+++ b/CPP/7zip/Crypto/Zip/ZipCipher.h
diff --git a/7zip/Crypto/Zip/ZipCrypto.cpp b/CPP/7zip/Crypto/Zip/ZipCrypto.cpp
index 79f0953c..79f0953c 100755
--- a/7zip/Crypto/Zip/ZipCrypto.cpp
+++ b/CPP/7zip/Crypto/Zip/ZipCrypto.cpp
diff --git a/7zip/Crypto/Zip/ZipCrypto.h b/CPP/7zip/Crypto/Zip/ZipCrypto.h
index 6b4ecaaa..6b4ecaaa 100755
--- a/7zip/Crypto/Zip/ZipCrypto.h
+++ b/CPP/7zip/Crypto/Zip/ZipCrypto.h
diff --git a/7zip/Crypto/makefile b/CPP/7zip/Crypto/makefile
index 61f59603..61f59603 100755
--- a/7zip/Crypto/makefile
+++ b/CPP/7zip/Crypto/makefile
diff --git a/7zip/FileManager/7zFM.exe.manifest b/CPP/7zip/FileManager/7zFM.exe.manifest
index 06710e04..06710e04 100755
--- a/7zip/FileManager/7zFM.exe.manifest
+++ b/CPP/7zip/FileManager/7zFM.exe.manifest
diff --git a/7zip/FileManager/7zipLogo.ico b/CPP/7zip/FileManager/7zipLogo.ico
index 973241c8..973241c8 100755
--- a/7zip/FileManager/7zipLogo.ico
+++ b/CPP/7zip/FileManager/7zipLogo.ico
Binary files differ
diff --git a/7zip/FileManager/Add.bmp b/CPP/7zip/FileManager/Add.bmp
index a8577fc7..a8577fc7 100755
--- a/7zip/FileManager/Add.bmp
+++ b/CPP/7zip/FileManager/Add.bmp
Binary files differ
diff --git a/7zip/FileManager/Add2.bmp b/CPP/7zip/FileManager/Add2.bmp
index 252fc253..252fc253 100755
--- a/7zip/FileManager/Add2.bmp
+++ b/CPP/7zip/FileManager/Add2.bmp
Binary files differ
diff --git a/CPP/7zip/FileManager/App.cpp b/CPP/7zip/FileManager/App.cpp
new file mode 100755
index 00000000..28e2ff0f
--- /dev/null
+++ b/CPP/7zip/FileManager/App.cpp
@@ -0,0 +1,759 @@
+// App.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Common/StringConvert.h"
+#include "Windows/FileDir.h"
+#include "Windows/Error.h"
+#include "Windows/COM.h"
+#include "Windows/Thread.h"
+#include "IFolder.h"
+
+#include "App.h"
+
+#include "Resource/CopyDialog/CopyDialog.h"
+
+#include "ExtractCallback.h"
+#include "ViewSettings.h"
+#include "RegistryUtils.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+extern DWORD g_ComCtl32Version;
+extern HINSTANCE g_hInstance;
+
+static LPCWSTR kTempDirPrefix = L"7zE";
+
+void CPanelCallbackImp::OnTab()
+{
+ if (g_App.NumPanels != 1)
+ _app->Panels[1 - _index].SetFocusToList();
+}
+
+void CPanelCallbackImp::SetFocusToPath(int index)
+{
+ int newPanelIndex = index;
+ if (g_App.NumPanels == 1)
+ newPanelIndex = g_App.LastFocusedPanel;
+ _app->Panels[newPanelIndex]._headerComboBox.SetFocus();
+}
+
+
+void CPanelCallbackImp::OnCopy(bool move, bool copyToSame)
+ { _app->OnCopy(move, copyToSame, _index); }
+
+void CPanelCallbackImp::OnSetSameFolder()
+ { _app->OnSetSameFolder(_index); }
+
+void CPanelCallbackImp::OnSetSubFolder()
+ { _app->OnSetSubFolder(_index); }
+
+void CPanelCallbackImp::PanelWasFocused()
+ { _app->SetFocusedPanel(_index); }
+
+void CPanelCallbackImp::DragBegin()
+ { _app->DragBegin(_index); }
+
+void CPanelCallbackImp::DragEnd()
+ { _app->DragEnd(); }
+
+void CApp::SetListSettings()
+{
+ bool showDots = ReadShowDots();
+ bool showRealFileIcons = ReadShowRealFileIcons();
+
+ DWORD extendedStyle = LVS_EX_HEADERDRAGDROP;
+ if (ReadFullRow())
+ extendedStyle |= LVS_EX_FULLROWSELECT;
+ if (ReadShowGrid())
+ extendedStyle |= LVS_EX_GRIDLINES;
+ bool mySelectionMode = ReadAlternativeSelection();
+
+ /*
+ if (ReadSingleClick())
+ {
+ extendedStyle |= LVS_EX_ONECLICKACTIVATE
+ | LVS_EX_TRACKSELECT;
+ if (ReadUnderline())
+ extendedStyle |= LVS_EX_UNDERLINEHOT;
+ }
+ */
+
+ for (int i = 0; i < kNumPanelsMax; i++)
+ {
+ CPanel &panel = Panels[i];
+ panel._mySelectMode = mySelectionMode;
+ panel._showDots = showDots;
+ panel._showRealFileIcons = showRealFileIcons;
+ panel._exStyle = extendedStyle;
+
+ DWORD style = (DWORD)panel._listView.GetStyle();
+ if (mySelectionMode)
+ style |= LVS_SINGLESEL;
+ else
+ style &= ~LVS_SINGLESEL;
+ panel._listView.SetStyle(style);
+ panel.SetExtendedStyle();
+ }
+}
+
+void CApp::SetShowSystemMenu()
+{
+ ShowSystemMenu = ReadShowSystemMenu();
+}
+
+void CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted)
+{
+ if (PanelsCreated[panelIndex])
+ return;
+ m_PanelCallbackImp[panelIndex].Init(this, panelIndex);
+ UString path;
+ if (mainPath.IsEmpty())
+ {
+ if (!::ReadPanelPath(panelIndex, path))
+ path.Empty();
+ }
+ else
+ path = mainPath;
+ int id = 1000 + 100 * panelIndex;
+ Panels[panelIndex].Create(_window, _window,
+ id, path, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted);
+ PanelsCreated[panelIndex] = true;
+}
+
+static void CreateToolbar(
+ HWND parent,
+ NWindows::NControl::CImageList &imageList,
+ NWindows::NControl::CToolBar &toolBar,
+ bool LargeButtons)
+{
+ toolBar.Attach(::CreateWindowEx(0,
+ TOOLBARCLASSNAME,
+ NULL, 0
+ | WS_VISIBLE
+ | TBSTYLE_FLAT
+ | TBSTYLE_TOOLTIPS
+ | WS_CHILD
+ | CCS_NOPARENTALIGN
+ | CCS_NORESIZE
+ | CCS_NODIVIDER
+ // | TBSTYLE_AUTOSIZE
+ // | CCS_ADJUSTABLE
+ ,0,0,0,0, parent, NULL, g_hInstance, NULL));
+
+ // TB_BUTTONSTRUCTSIZE message, which is required for
+ // backward compatibility.
+ toolBar.ButtonStructSize();
+
+ imageList.Create(
+ LargeButtons ? 48: 24,
+ LargeButtons ? 36: 24,
+ ILC_MASK, 0, 0);
+ toolBar.SetImageList(0, imageList);
+}
+
+struct CButtonInfo
+{
+ UINT commandID;
+ UINT BitmapResID;
+ UINT Bitmap2ResID;
+ UINT StringResID;
+ UINT32 LangID;
+ UString GetText()const { return LangString(StringResID, LangID); };
+};
+
+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}
+};
+
+static CButtonInfo g_ArchiveButtons[] =
+{
+ { kAddCommand, IDB_ADD, IDB_ADD2, IDS_ADD, 0x03020400},
+ { kExtractCommand, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT, 0x03020401},
+ { kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402}
+};
+
+bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, UString &s)
+{
+ for (int i = 0; i < numButtons; i++)
+ {
+ const CButtonInfo &b = buttons[i];
+ if (b.commandID == commandID)
+ {
+ s = b.GetText();
+ return true;
+ }
+ }
+ return false;
+}
+
+void SetButtonText(UINT32 commandID, UString &s)
+{
+ if (SetButtonText(commandID, g_StandardButtons,
+ sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s))
+ return;
+ SetButtonText(commandID, g_ArchiveButtons,
+ sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s);
+}
+
+static void AddButton(
+ NControl::CImageList &imageList,
+ NControl::CToolBar &toolBar,
+ CButtonInfo &butInfo,
+ bool showText,
+ bool large)
+{
+ TBBUTTON but;
+ but.iBitmap = 0;
+ but.idCommand = butInfo.commandID;
+ but.fsState = TBSTATE_ENABLED;
+ but.fsStyle = BTNS_BUTTON
+ // | BTNS_AUTOSIZE
+ ;
+ but.dwData = 0;
+
+ UString s = butInfo.GetText();
+ but.iString = 0;
+ if (showText)
+ but.iString = (INT_PTR)(LPCWSTR)s;
+
+ but.iBitmap = imageList.GetImageCount();
+ HBITMAP b = ::LoadBitmap(g_hInstance,
+ large ?
+ MAKEINTRESOURCE(butInfo.BitmapResID):
+ MAKEINTRESOURCE(butInfo.Bitmap2ResID));
+ if (b != 0)
+ {
+ imageList.AddMasked(b, RGB(255, 0, 255));
+ ::DeleteObject(b);
+ }
+ #ifdef _UNICODE
+ toolBar.AddButton(1, &but);
+ #else
+ toolBar.AddButtonW(1, &but);
+ #endif
+}
+
+static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar)
+{
+ SIZE size;
+ toolBar.GetMaxSize(&size);
+
+ RECT rect;
+ toolBar.GetWindowRect(&rect);
+
+ REBARBANDINFO rbBand;
+ rbBand.cbSize = sizeof(REBARBANDINFO); // Required
+ rbBand.fMask = RBBIM_STYLE
+ | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
+ rbBand.fStyle = RBBS_CHILDEDGE; // RBBS_NOGRIPPER;
+ rbBand.cxMinChild = size.cx; // rect.right - rect.left;
+ rbBand.cyMinChild = size.cy; // rect.bottom - rect.top;
+ rbBand.cyChild = rbBand.cyMinChild;
+ rbBand.cx = rbBand.cxMinChild;
+ rbBand.cxIdeal = rbBand.cxMinChild;
+ rbBand.hwndChild = toolBar;
+ reBar.InsertBand(-1, &rbBand);
+}
+
+void CApp::ReloadToolbars()
+{
+ if (!_rebar)
+ return;
+ HWND parent = _rebar;
+
+ while(_rebar.GetBandCount() > 0)
+ _rebar.DeleteBand(0);
+
+ _archiveToolBar.Destroy();
+ _archiveButtonsImageList.Destroy();
+
+ _standardButtonsImageList.Destroy();
+ _standardToolBar.Destroy();
+
+ if (ShowArchiveToolbar)
+ {
+ CreateToolbar(parent, _archiveButtonsImageList, _archiveToolBar, LargeButtons);
+ for (int i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++)
+ AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i],
+ ShowButtonsLables, LargeButtons);
+ AddBand(_rebar, _archiveToolBar);
+ }
+
+ if (ShowStandardToolbar)
+ {
+ CreateToolbar(parent, _standardButtonsImageList, _standardToolBar, LargeButtons);
+ for (int i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++)
+ AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i],
+ ShowButtonsLables, LargeButtons);
+ AddBand(_rebar, _standardToolBar);
+ }
+}
+
+void CApp::ReloadRebar(HWND hwnd)
+{
+ _rebar.Destroy();
+ if (!ShowArchiveToolbar && !ShowStandardToolbar)
+ return;
+ if (g_ComCtl32Version >= MAKELONG(71, 4))
+ {
+ INITCOMMONCONTROLSEX icex;
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ _rebar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
+ REBARCLASSNAME,
+ 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_BANDBORDERS
+ // | RBS_AUTOSIZE
+ ,0,0,0,0, hwnd, NULL, g_hInstance, NULL));
+ }
+ if (_rebar == 0)
+ return;
+ REBARINFO rbi;
+ rbi.cbSize = sizeof(REBARINFO); // Required when using this struct.
+ rbi.fMask = 0;
+ rbi.himl = (HIMAGELIST)NULL;
+ _rebar.SetBarInfo(&rbi);
+ ReloadToolbars();
+}
+
+void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted)
+{
+ ReadToolbar();
+ ReloadRebar(hwnd);
+
+ int i;
+ for (i = 0; i < kNumPanelsMax; i++)
+ PanelsCreated[i] = false;
+
+ _window.Attach(hwnd);
+ AppState.Read();
+ SetListSettings();
+ SetShowSystemMenu();
+ if (LastFocusedPanel >= kNumPanelsMax)
+ LastFocusedPanel = 0;
+
+ CListMode listMode;
+ ReadListMode(listMode);
+ for (i = 0; i < kNumPanelsMax; i++)
+ {
+ Panels[i]._ListViewMode = listMode.Panels[i];
+ Panels[i]._xSize = xSizes[i];
+ }
+ for (i = 0; i < kNumPanelsMax; i++)
+ if (NumPanels > 1 || i == LastFocusedPanel)
+ {
+ if (NumPanels == 1)
+ Panels[i]._xSize = xSizes[0] + xSizes[1];
+ bool archiveIsOpened2 = false;
+ bool encrypted2 = false;
+ bool mainPanel = (i == LastFocusedPanel);
+ CreateOnePanel(i, mainPanel ? mainPath : L"", archiveIsOpened2, encrypted2);
+ if (mainPanel)
+ {
+ archiveIsOpened = archiveIsOpened2;
+ encrypted = encrypted2;
+ }
+ }
+ SetFocusedPanel(LastFocusedPanel);
+ Panels[LastFocusedPanel].SetFocusToList();
+}
+
+extern void MoveSubWindows(HWND hWnd);
+
+void CApp::SwitchOnOffOnePanel()
+{
+ if (NumPanels == 1)
+ {
+ NumPanels++;
+ bool archiveIsOpened, encrypted;
+ CreateOnePanel(1 - LastFocusedPanel, UString(), archiveIsOpened, encrypted);
+ Panels[1 - LastFocusedPanel].Enable(true);
+ Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
+ }
+ else
+ {
+ NumPanels--;
+ Panels[1 - LastFocusedPanel].Enable(false);
+ Panels[1 - LastFocusedPanel].Show(SW_HIDE);
+ }
+ MoveSubWindows(_window);
+}
+
+void CApp::Save()
+{
+ AppState.Save();
+ CListMode listMode;
+ for (int i = 0; i < kNumPanelsMax; i++)
+ {
+ const CPanel &panel = Panels[i];
+ UString path;
+ if (panel._parentFolders.IsEmpty())
+ path = panel._currentFolderPrefix;
+ else
+ path = GetFolderPath(panel._parentFolders[0].ParentFolder);
+ SavePanelPath(i, path);
+ listMode.Panels[i] = panel.GetListViewMode();
+ }
+ SaveListMode(listMode);
+}
+
+void CApp::Release()
+{
+ // 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))
+ return false;
+ return fileInfo.IsDirectory();
+}
+
+// reduces path to part that exists on disk
+static void ReducePathToRealFileSystemPath(UString &path)
+{
+ while(!path.IsEmpty())
+ {
+ if (IsThereFolderOfPath(path))
+ {
+ NName::NormalizeDirPathPrefix(path);
+ break;
+ }
+ int pos = path.ReverseFind('\\');
+ if (pos < 0)
+ path.Empty();
+ else
+ {
+ path = path.Left(pos + 1);
+ if (path.Length() == 3 && path[1] == L':')
+ break;
+ path = path.Left(pos);
+ }
+ }
+}
+
+// return true for dir\, if dir exist
+static bool CheckFolderPath(const UString &path)
+{
+ UString pathReduced = path;
+ ReducePathToRealFileSystemPath(pathReduced);
+ return (pathReduced == path);
+}
+
+static bool IsPathAbsolute(const UString &path)
+{
+ if ((path.Length() >= 1 && path[0] == L'\\') ||
+ (path.Length() >= 3 && path[1] == L':' && path[2] == L'\\'))
+ return true;
+ return false;
+}
+
+void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
+{
+ int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ CPanel &destPanel = Panels[destPanelIndex];
+
+ CPanel::CDisableTimerProcessing disableTimerProcessing1(destPanel);
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(srcPanel);
+
+ if (!srcPanel.DoesItSupportOperations())
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+
+ CRecordVector<UInt32> indices;
+ UString destPath;
+ bool useDestPanel = false;
+
+ {
+ if (copyToSame)
+ {
+ int focusedItem = srcPanel._listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = srcPanel.GetRealItemIndex(focusedItem);
+ if (realIndex == kParentIndex)
+ return;
+ indices.Add(realIndex);
+ destPath = srcPanel.GetItemName(realIndex);
+ }
+ else
+ {
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.Size() == 0)
+ return;
+ destPath = destPanel._currentFolderPrefix;
+ if (NumPanels == 1)
+ ReducePathToRealFileSystemPath(destPath);
+ }
+
+ CCopyDialog copyDialog;
+ UStringVector copyFolders;
+ ReadCopyHistory(copyFolders);
+
+ copyDialog.Strings = copyFolders;
+ copyDialog.Value = destPath;
+
+ copyDialog.Title = move ?
+ LangString(IDS_MOVE, 0x03020202):
+ LangString(IDS_COPY, 0x03020201);
+ copyDialog.Static = move ?
+ LangString(IDS_MOVE_TO, 0x03020204):
+ LangString(IDS_COPY_TO, 0x03020203);
+
+ if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
+ return;
+
+ destPath = copyDialog.Value;
+
+ if (!IsPathAbsolute(destPath))
+ {
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ destPath = srcPanel._currentFolderPrefix + destPath;
+ }
+
+ if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) ||
+ IsThereFolderOfPath(destPath))
+ {
+ NDirectory::CreateComplexDirectory(destPath);
+ NName::NormalizeDirPathPrefix(destPath);
+ if (!CheckFolderPath(destPath))
+ {
+ if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ useDestPanel = true;
+ }
+ }
+ else
+ {
+ int pos = destPath.ReverseFind('\\');
+ if (pos >= 0)
+ {
+ UString prefix = destPath.Left(pos + 1);
+ NDirectory::CreateComplexDirectory(prefix);
+ if (!CheckFolderPath(prefix))
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ }
+ }
+
+ AddUniqueStringToHeadOfList(copyFolders, destPath);
+ while (copyFolders.Size() > 20)
+ copyFolders.DeleteBack();
+ SaveCopyHistory(copyFolders);
+ }
+
+ bool useSrcPanel = (!useDestPanel || !srcPanel.IsFSFolder() || destPanel.IsFSFolder());
+ bool useTemp = useSrcPanel && useDestPanel;
+ NFile::NDirectory::CTempDirectoryW tempDirectory;
+ UString tempDirPrefix;
+ if (useTemp)
+ {
+ tempDirectory.Create(kTempDirPrefix);
+ tempDirPrefix = tempDirectory.GetPath();
+ NFile::NName::NormalizeDirPathPrefix(tempDirPrefix);
+ }
+
+ CSelectedState srcSelState;
+ CSelectedState destSelState;
+ srcPanel.SaveSelectedState(srcSelState);
+ destPanel.SaveSelectedState(destSelState);
+
+ HRESULT result;
+ if (useSrcPanel)
+ {
+ UString folder = useTemp ? tempDirPrefix : destPath;
+ result = srcPanel.CopyTo(indices, folder, move, true, 0);
+ if (result != S_OK)
+ {
+ disableTimerProcessing1.Restore();
+ disableTimerProcessing2.Restore();
+ // For Password:
+ srcPanel.SetFocusToList();
+ if (result != E_ABORT)
+ srcPanel.MessageBoxError(result, L"Error");
+ return;
+ }
+ }
+
+ if (useDestPanel)
+ {
+ UStringVector filePaths;
+ UString folderPrefix;
+ if (useTemp)
+ folderPrefix = tempDirPrefix;
+ else
+ folderPrefix = srcPanel._currentFolderPrefix;
+ filePaths.Reserve(indices.Size());
+ for(int i = 0; i < indices.Size(); i++)
+ filePaths.Add(srcPanel.GetItemRelPath(indices[i]));
+
+ result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0);
+
+ if (result != S_OK)
+ {
+ disableTimerProcessing1.Restore();
+ disableTimerProcessing2.Restore();
+ // For Password:
+ srcPanel.SetFocusToList();
+ if (result != E_ABORT)
+ srcPanel.MessageBoxError(result, L"Error");
+ return;
+ }
+ }
+
+ if (copyToSame || move)
+ {
+ srcPanel.RefreshListCtrl(srcSelState);
+ }
+ if (!copyToSame)
+ {
+ destPanel.RefreshListCtrl(destSelState);
+ srcPanel.KillSelection();
+ }
+ disableTimerProcessing1.Restore();
+ disableTimerProcessing2.Restore();
+ srcPanel.SetFocusToList();
+}
+
+void CApp::OnSetSameFolder(int srcPanelIndex)
+{
+ if (NumPanels <= 1)
+ return;
+ const CPanel &srcPanel = Panels[srcPanelIndex];
+ CPanel &destPanel = Panels[1 - srcPanelIndex];
+ destPanel.BindToPathAndRefresh(srcPanel._currentFolderPrefix);
+}
+
+void CApp::OnSetSubFolder(int srcPanelIndex)
+{
+ if (NumPanels <= 1)
+ return;
+ const CPanel &srcPanel = Panels[srcPanelIndex];
+ CPanel &destPanel = Panels[1 - srcPanelIndex];
+
+ int focusedItem = srcPanel._listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = srcPanel.GetRealItemIndex(focusedItem);
+ if (!srcPanel.IsItemFolder(realIndex))
+ return;
+
+
+ /*
+ UString string = srcPanel._currentFolderPrefix +
+ srcPanel.GetItemName(realIndex) + L'\\';
+ destPanel.BindToFolder(string);
+ */
+ CMyComPtr<IFolderFolder> newFolder;
+ if (realIndex == kParentIndex)
+ {
+ if (srcPanel._folder->BindToParentFolder(&newFolder) != S_OK)
+ return;
+ }
+ else
+ {
+ if (srcPanel._folder->BindToFolder(realIndex, &newFolder) != S_OK)
+ return;
+ }
+ destPanel.CloseOpenFolders();
+ destPanel._folder = newFolder;
+ destPanel.RefreshListCtrl();
+}
+
+/*
+int CApp::GetFocusedPanelIndex() const
+{
+ return LastFocusedPanel;
+ HWND hwnd = ::GetFocus();
+ for (;;)
+ {
+ if (hwnd == 0)
+ return 0;
+ for (int i = 0; i < kNumPanelsMax; i++)
+ {
+ if (PanelsCreated[i] &&
+ ((HWND)Panels[i] == hwnd || Panels[i]._listView == hwnd))
+ return i;
+ }
+ hwnd = GetParent(hwnd);
+ }
+}
+ */
+
+static UString g_ToolTipBuffer;
+static CSysString g_ToolTipBufferSys;
+
+void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
+{
+ if (pnmh->hwndFrom == _rebar)
+ {
+ switch(pnmh->code)
+ {
+ case RBN_HEIGHTCHANGE:
+ {
+ MoveSubWindows(g_HWND);
+ return;
+ }
+ }
+ return ;
+ }
+ else
+ {
+ if (pnmh->code == TTN_GETDISPINFO)
+ {
+ LPNMTTDISPINFO info = (LPNMTTDISPINFO)pnmh;
+ info->hinst = 0;
+ g_ToolTipBuffer.Empty();
+ SetButtonText((UINT32)info->hdr.idFrom, g_ToolTipBuffer);
+ g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
+ info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBufferSys;
+ return;
+ }
+ #ifndef _UNICODE
+ if (pnmh->code == TTN_GETDISPINFOW)
+ {
+ LPNMTTDISPINFOW info = (LPNMTTDISPINFOW)pnmh;
+ info->hinst = 0;
+ g_ToolTipBuffer.Empty();
+ SetButtonText((UINT32)info->hdr.idFrom, g_ToolTipBuffer);
+ info->lpszText = (LPWSTR)(LPCWSTR)g_ToolTipBuffer;
+ return;
+ }
+ #endif
+ }
+}
diff --git a/CPP/7zip/FileManager/App.h b/CPP/7zip/FileManager/App.h
new file mode 100755
index 00000000..faa40afe
--- /dev/null
+++ b/CPP/7zip/FileManager/App.h
@@ -0,0 +1,332 @@
+// App.h
+
+#ifndef __APP_H
+#define __APP_H
+
+#include "Panel.h"
+#include "AppState.h"
+#include "Windows/Control/ImageList.h"
+
+class CApp;
+
+extern CApp g_App;
+extern HWND g_HWND;
+
+const int kNumPanelsMax = 2;
+
+extern void MoveSubWindows(HWND hWnd);
+
+enum
+{
+ kAddCommand = kToolbarStartID,
+ kExtractCommand,
+ kTestCommand
+};
+
+class CPanelCallbackImp: public CPanelCallback
+{
+ CApp *_app;
+ int _index;
+public:
+ void Init(CApp *app, int index)
+ {
+ _app = app;
+ _index = index;
+ }
+ virtual void OnTab();
+ virtual void SetFocusToPath(int index);
+ virtual void OnCopy(bool move, bool copyToSame);
+ virtual void OnSetSameFolder();
+ virtual void OnSetSubFolder();
+ virtual void PanelWasFocused();
+ virtual void DragBegin();
+ virtual void DragEnd();
+};
+
+class CApp;
+
+class CDropTarget:
+ public IDropTarget,
+ public CMyUnknownImp
+{
+ CMyComPtr<IDataObject> m_DataObject;
+ 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.
+ // check it only if m_DropIsAllowed == true
+ int m_SubFolderIndex;
+ UString m_SubFolderName;
+
+ CPanel *m_Panel;
+ bool m_IsAppTarget; // true, if we want to drop to app window (not to panel).
+
+ bool m_SetPathIsOK;
+
+ bool IsItSameDrive() const;
+
+ void QueryGetData(IDataObject *dataObject);
+ bool IsFsFolderPath() const;
+ DWORD GetEffect(DWORD keyState, POINTL pt, DWORD allowedEffect);
+ void RemoveSelection();
+ void PositionCursor(POINTL ptl);
+ UString GetTargetPath() const;
+ bool SetPath(bool enablePath) const;
+ bool SetPath();
+
+public:
+ MY_UNKNOWN_IMP1_MT(IDropTarget)
+ 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,
+ 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),
+ m_SubFolderIndex(-1),
+ m_SetPathIsOK(false) {}
+
+ CApp *App;
+ int SrcPanelIndex; // index of D&D source_panel
+ int TargetPanelIndex; // what panel to use as target_panel of Application
+};
+
+class CApp
+{
+public:
+ NWindows::CWindow _window;
+ bool ShowSystemMenu;
+ int NumPanels;
+ int LastFocusedPanel;
+
+ bool ShowStandardToolbar;
+ bool ShowArchiveToolbar;
+ bool ShowButtonsLables;
+ bool LargeButtons;
+
+ CAppState AppState;
+ CPanelCallbackImp m_PanelCallbackImp[kNumPanelsMax];
+ CPanel Panels[kNumPanelsMax];
+ bool PanelsCreated[kNumPanelsMax];
+
+ NWindows::NControl::CImageList _archiveButtonsImageList;
+ NWindows::NControl::CImageList _standardButtonsImageList;
+
+ NWindows::NControl::CReBar _rebar;
+ NWindows::NControl::CToolBar _archiveToolBar;
+ NWindows::NControl::CToolBar _standardToolBar;
+
+ CDropTarget *_dropTargetSpec;
+ CMyComPtr<IDropTarget> _dropTarget;
+
+ void CreateDragTarget()
+ {
+ _dropTargetSpec = new CDropTarget();
+ _dropTarget = _dropTargetSpec;
+ _dropTargetSpec->App = (this);
+ }
+
+ void SetFocusedPanel(int 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;
+ }
+
+
+ void OnCopy(bool move, bool copyToSame, int srcPanelIndex);
+ 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);
+ void Read();
+ void Save();
+ void Release();
+
+
+ /*
+ void SetFocus(int panelIndex)
+ { Panels[panelIndex].SetFocusToList(); }
+ */
+ void SetFocusToLastItem()
+ { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); }
+
+ int GetFocusedPanelIndex() const { return LastFocusedPanel; }
+
+ bool IsPanelVisible(int index) const { return (NumPanels > 1 || index == LastFocusedPanel); }
+
+ /*
+ void SetCurrentIndex()
+ { CurrentPanel = GetFocusedPanelIndex(); }
+ */
+
+ CApp(): NumPanels(2), LastFocusedPanel(0) {}
+ CPanel &GetFocusedPanel()
+ { return Panels[GetFocusedPanelIndex()]; }
+
+ // File Menu
+ void OpenItem()
+ { GetFocusedPanel().OpenSelectedItems(true); }
+ void OpenItemInside()
+ { GetFocusedPanel().OpenFocusedItemAsInternal(); }
+ void OpenItemOutside()
+ { GetFocusedPanel().OpenSelectedItems(false); }
+ void EditItem()
+ { GetFocusedPanel().EditItem(); }
+ void Rename()
+ { GetFocusedPanel().RenameFile(); }
+ void CopyTo()
+ { OnCopy(false, false, GetFocusedPanelIndex()); }
+ void MoveTo()
+ { OnCopy(true, false, GetFocusedPanelIndex()); }
+ void Delete(bool toRecycleBin)
+ { GetFocusedPanel().DeleteItems(toRecycleBin); }
+ void CalculateCrc();
+ void Split();
+ void Combine();
+ void Properties()
+ { GetFocusedPanel().Properties(); }
+ void Comment()
+ { GetFocusedPanel().ChangeComment(); }
+
+ void CreateFolder()
+ { GetFocusedPanel().CreateFolder(); }
+ void CreateFile()
+ { GetFocusedPanel().CreateFile(); }
+
+ // Edit
+ void EditCopy()
+ { GetFocusedPanel().EditCopy(); }
+ void EditPaste()
+ { GetFocusedPanel().EditPaste(); }
+
+ void SelectAll(bool selectMode)
+ { GetFocusedPanel().SelectAll(selectMode); }
+ void InvertSelection()
+ { GetFocusedPanel().InvertSelection(); }
+ void SelectSpec(bool selectMode)
+ { GetFocusedPanel().SelectSpec(selectMode); }
+ void SelectByType(bool selectMode)
+ { GetFocusedPanel().SelectByType(selectMode); }
+
+ void RefreshStatusBar()
+ { GetFocusedPanel().RefreshStatusBar(); }
+
+ void SetListViewMode(UINT32 index)
+ { GetFocusedPanel().SetListViewMode(index); }
+ UINT32 GetListViewMode()
+ { return GetFocusedPanel().GetListViewMode(); }
+
+ void SortItemsWithPropID(PROPID propID)
+ { GetFocusedPanel().SortItemsWithPropID(propID); }
+
+ void OpenRootFolder()
+ { GetFocusedPanel().OpenDrivesFolder(); }
+ void OpenParentFolder()
+ { GetFocusedPanel().OpenParentFolder(); }
+ void FoldersHistory()
+ { GetFocusedPanel().FoldersHistory(); }
+ void RefreshView()
+ { GetFocusedPanel().OnReload(); }
+ void RefreshAllPanels()
+ {
+ for (int i = 0; i < NumPanels; i++)
+ {
+ int index = i;
+ if (NumPanels == 1)
+ index = LastFocusedPanel;
+ Panels[index].OnReload();
+ }
+ }
+ void SetListSettings();
+ void SetShowSystemMenu();
+ void SwitchOnOffOnePanel();
+ bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); }
+ void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); }
+
+ void OpenBookmark(int index)
+ { GetFocusedPanel().OpenBookmark(index); }
+ void SetBookmark(int index)
+ { GetFocusedPanel().SetBookmark(index); }
+
+ void ReloadRebar(HWND hwnd);
+ void ReloadToolbars();
+ void ReadToolbar()
+ {
+ UINT32 mask = ReadToolbarsMask();
+ ShowButtonsLables = ((mask & 1) != 0);
+ LargeButtons = ((mask & 2) != 0);
+ ShowStandardToolbar = ((mask & 4) != 0);
+ ShowArchiveToolbar = ((mask & 8) != 0);
+ }
+ void SaveToolbar()
+ {
+ UINT32 mask = 0;
+ if (ShowButtonsLables) mask |= 1;
+ if (LargeButtons) mask |= 2;
+ if (ShowStandardToolbar) mask |= 4;
+ if (ShowArchiveToolbar) mask |= 8;
+ 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 OnNotify(int ctrlID, LPNMHDR pnmh);
+};
+
+#endif
diff --git a/7zip/FileManager/AppState.h b/CPP/7zip/FileManager/AppState.h
index 318c0258..318c0258 100755
--- a/7zip/FileManager/AppState.h
+++ b/CPP/7zip/FileManager/AppState.h
diff --git a/7zip/FileManager/ClassDefs.cpp b/CPP/7zip/FileManager/ClassDefs.cpp
index ded9c8d8..ded9c8d8 100755
--- a/7zip/FileManager/ClassDefs.cpp
+++ b/CPP/7zip/FileManager/ClassDefs.cpp
diff --git a/7zip/FileManager/Copy.bmp b/CPP/7zip/FileManager/Copy.bmp
index 0f28a324..0f28a324 100755
--- a/7zip/FileManager/Copy.bmp
+++ b/CPP/7zip/FileManager/Copy.bmp
Binary files differ
diff --git a/7zip/FileManager/Copy2.bmp b/CPP/7zip/FileManager/Copy2.bmp
index ba88ded0..ba88ded0 100755
--- a/7zip/FileManager/Copy2.bmp
+++ b/CPP/7zip/FileManager/Copy2.bmp
Binary files differ
diff --git a/7zip/FileManager/Delete.bmp b/CPP/7zip/FileManager/Delete.bmp
index d1004d82..d1004d82 100755
--- a/7zip/FileManager/Delete.bmp
+++ b/CPP/7zip/FileManager/Delete.bmp
Binary files differ
diff --git a/7zip/FileManager/Delete2.bmp b/CPP/7zip/FileManager/Delete2.bmp
index 60e08c6a..60e08c6a 100755
--- a/7zip/FileManager/Delete2.bmp
+++ b/CPP/7zip/FileManager/Delete2.bmp
Binary files differ
diff --git a/CPP/7zip/FileManager/EnumFormatEtc.cpp b/CPP/7zip/FileManager/EnumFormatEtc.cpp
new file mode 100755
index 00000000..ef9463fb
--- /dev/null
+++ b/CPP/7zip/FileManager/EnumFormatEtc.cpp
@@ -0,0 +1,108 @@
+// EnumFormatEtc.cpp
+
+#include "StdAfx.h"
+
+#include "EnumFormatEtc.h"
+#include "MyCom2.h"
+
+class CEnumFormatEtc :
+public IEnumFORMATETC,
+public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1_MT(IEnumFORMATETC)
+
+ STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched);
+ STDMETHOD(Skip)(ULONG celt);
+ STDMETHOD(Reset)(void);
+ STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc);
+
+ CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats);
+ ~CEnumFormatEtc();
+
+private:
+ LONG m_RefCount;
+ ULONG m_NumFormats;
+ FORMATETC *m_Formats;
+ ULONG m_Index;
+};
+
+static void DeepCopyFormatEtc(FORMATETC *dest, const FORMATETC *src)
+{
+ *dest = *src;
+ if(src->ptd)
+ {
+ dest->ptd = (DVTARGETDEVICE*)CoTaskMemAlloc(sizeof(DVTARGETDEVICE));
+ *(dest->ptd) = *(src->ptd);
+ }
+}
+
+CEnumFormatEtc::CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats)
+{
+ m_RefCount = 1;
+ m_Index = 0;
+ m_NumFormats = 0;
+ m_Formats = new FORMATETC[numFormats];
+ if(m_Formats)
+ {
+ m_NumFormats = numFormats;
+ for(ULONG i = 0; i < numFormats; i++)
+ DeepCopyFormatEtc(&m_Formats[i], &pFormatEtc[i]);
+ }
+}
+
+CEnumFormatEtc::~CEnumFormatEtc()
+{
+ if(m_Formats)
+ {
+ for(ULONG i = 0; i < m_NumFormats; i++)
+ if(m_Formats[i].ptd)
+ CoTaskMemFree(m_Formats[i].ptd);
+ delete[]m_Formats;
+ }
+}
+
+STDMETHODIMP CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pceltFetched)
+{
+ ULONG copied = 0;
+ if(celt == 0 || pFormatEtc == 0)
+ return E_INVALIDARG;
+ while(m_Index < m_NumFormats && copied < celt)
+ {
+ DeepCopyFormatEtc(&pFormatEtc[copied], &m_Formats[m_Index]);
+ copied++;
+ m_Index++;
+ }
+ if(pceltFetched != 0)
+ *pceltFetched = copied;
+ return (copied == celt) ? S_OK : S_FALSE;
+}
+
+STDMETHODIMP CEnumFormatEtc::Skip(ULONG celt)
+{
+ m_Index += celt;
+ return (m_Index <= m_NumFormats) ? S_OK : S_FALSE;
+}
+
+STDMETHODIMP CEnumFormatEtc::Reset(void)
+{
+ m_Index = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc)
+{
+ HRESULT hResult = CreateEnumFormatEtc(m_NumFormats, m_Formats, ppEnumFormatEtc);
+ if(hResult == S_OK)
+ ((CEnumFormatEtc *)*ppEnumFormatEtc)->m_Index = m_Index;
+ return hResult;
+}
+
+// replacement for SHCreateStdEnumFmtEtc
+HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat)
+{
+ if(numFormats == 0 || formats == 0 || enumFormat == 0)
+ return E_INVALIDARG;
+ *enumFormat = new CEnumFormatEtc(formats, numFormats);
+ return (*enumFormat) ? S_OK : E_OUTOFMEMORY;
+}
diff --git a/7zip/FileManager/EnumFormatEtc.h b/CPP/7zip/FileManager/EnumFormatEtc.h
index 6c476f1a..6c476f1a 100755
--- a/7zip/FileManager/EnumFormatEtc.h
+++ b/CPP/7zip/FileManager/EnumFormatEtc.h
diff --git a/7zip/FileManager/Extract.bmp b/CPP/7zip/FileManager/Extract.bmp
index 0aeba923..0aeba923 100755
--- a/7zip/FileManager/Extract.bmp
+++ b/CPP/7zip/FileManager/Extract.bmp
Binary files differ
diff --git a/7zip/FileManager/Extract2.bmp b/CPP/7zip/FileManager/Extract2.bmp
index a7e57753..a7e57753 100755
--- a/7zip/FileManager/Extract2.bmp
+++ b/CPP/7zip/FileManager/Extract2.bmp
Binary files differ
diff --git a/CPP/7zip/FileManager/ExtractCallback.cpp b/CPP/7zip/FileManager/ExtractCallback.cpp
new file mode 100755
index 00000000..d6ea8f8f
--- /dev/null
+++ b/CPP/7zip/FileManager/ExtractCallback.cpp
@@ -0,0 +1,382 @@
+// ExtractCallback.h
+
+#include "StdAfx.h"
+
+#include "ExtractCallback.h"
+
+#include "Windows/FileFind.h"
+#include "Windows/FileDir.h"
+#include "Windows/Error.h"
+
+#include "Resource/OverwriteDialog/OverwriteDialog.h"
+#ifndef _NO_CRYPTO
+#include "Resource/PasswordDialog/PasswordDialog.h"
+#endif
+#include "Resource/MessagesDialog/MessagesDialog.h"
+#include "../UI/Resource/Extract/resource.h"
+#include "../UI/GUI/resource.h"
+
+#include "Common/Wildcard.h"
+#include "Common/StringConvert.h"
+
+#include "FormatUtils.h"
+
+#include "../Common/FilePathAutoRename.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+CExtractCallbackImp::~CExtractCallbackImp()
+{
+ if (ShowMessages && !Messages.IsEmpty())
+ {
+ CMessagesDialog messagesDialog;
+ messagesDialog.Messages = &Messages;
+ messagesDialog.Create(ParentWindow);
+ }
+}
+
+void CExtractCallbackImp::Init()
+{
+ Messages.Clear();
+ NumArchiveErrors = 0;
+}
+
+void CExtractCallbackImp::AddErrorMessage(LPCWSTR message)
+{
+ Messages.Add(message);
+}
+
+STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total)
+{
+ ProgressDialog.ProgressSynch.SetProgress(total, 0);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *completeValue)
+{
+ for (;;)
+ {
+ if(ProgressDialog.ProgressSynch.GetStopped())
+ return E_ABORT;
+ if(!ProgressDialog.ProgressSynch.GetPaused())
+ break;
+ ::Sleep(100);
+ }
+ if (completeValue != NULL)
+ ProgressDialog.ProgressSynch.SetPos(*completeValue);
+ 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,
+ Int32 *answer)
+{
+ COverwriteDialog dialog;
+
+ dialog.OldFileInfo.Time = *existTime;
+ dialog.OldFileInfo.SizeIsDefined = (existSize != NULL);
+ if (dialog.OldFileInfo.SizeIsDefined)
+ dialog.OldFileInfo.Size = *existSize;
+ dialog.OldFileInfo.Name = existName;
+
+ if (newTime == 0)
+ dialog.NewFileInfo.TimeIsDefined = false;
+ else
+ {
+ dialog.NewFileInfo.TimeIsDefined = true;
+ dialog.NewFileInfo.Time = *newTime;
+ }
+
+ dialog.NewFileInfo.SizeIsDefined = (newSize != NULL);
+ if (dialog.NewFileInfo.SizeIsDefined)
+ dialog.NewFileInfo.Size = *newSize;
+ dialog.NewFileInfo.Name = newName;
+
+ /*
+ NOverwriteDialog::NResult::EEnum writeAnswer =
+ NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
+ */
+ INT_PTR writeAnswer = dialog.Create(NULL); // 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:
+ throw 20413;
+ }
+ return S_OK;
+}
+
+
+STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 /* askExtractMode */, const UInt64 * /* position */)
+{
+ return SetCurrentFilePath(name);
+}
+
+STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
+{
+ AddErrorMessage(message);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *message)
+{
+ AddErrorMessage(message);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool encrypted)
+{
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kOK:
+ break;
+ default:
+ {
+ UINT messageID;
+ UInt32 langID;
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
+ messageID = IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD;
+ langID = 0x02000A91;
+ break;
+ case NArchive::NExtract::NOperationResult::kDataError:
+ 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 ?
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED:
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC;
+ langID = encrypted ? 0x02000A95 : 0x02000A93;
+ break;
+ default:
+ return E_FAIL;
+ }
+ if (_needWriteArchivePath)
+ {
+ AddErrorMessage(_currentArchivePath);
+ _needWriteArchivePath = false;
+ }
+ AddErrorMessage(
+ MyFormatNew(messageID,
+ #ifdef LANG
+ langID,
+ #endif
+ _currentFilePath));
+ }
+ }
+ return S_OK;
+}
+
+////////////////////////////////////////
+// IExtractCallbackUI
+
+HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name)
+{
+ #ifndef _SFX
+ ProgressDialog.ProgressSynch.SetTitleFileName(name);
+ #endif
+ _currentArchivePath = name;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path)
+{
+ _currentFilePath = path;
+ #ifndef _SFX
+ ProgressDialog.ProgressSynch.SetCurrentFileName(path);
+ #endif
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, bool encrypted)
+{
+ if (result != S_OK)
+ {
+ MessageError(MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE,
+ #ifdef LANG
+ (encrypted ? 0x0200060A : 0x02000609),
+ #endif
+ name));
+ NumArchiveErrors++;
+ }
+ _currentArchivePath = name;
+ _needWriteArchivePath = true;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::ThereAreNoFiles()
+{
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::ExtractResult(HRESULT result)
+{
+ if (result == S_OK)
+ return result;
+ NumArchiveErrors++;
+ if (result == E_ABORT || result == ERROR_DISK_FULL)
+ return result;
+ MessageError(_currentFilePath);
+ MessageError(NError::MyFormatMessageW(result));
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::SetPassword(const UString &password)
+{
+ PasswordIsDefined = true;
+ Password = password;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
+{
+ 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;
+}
+
+
+// IExtractCallBack3
+STDMETHODIMP CExtractCallbackImp::AskWrite(
+ const wchar_t *srcPath, Int32 srcIsFolder,
+ const FILETIME *srcTime, const UInt64 *srcSize,
+ const wchar_t *destPath,
+ BSTR *destPathResult,
+ Int32 *writeAnswer)
+{
+ UString destPathResultTemp = destPath;
+ /*
+ {
+ CMyComBSTR destPathResultBSTR = destPath;
+ *destPathResult = destPathResultBSTR.Detach();
+ }
+ */
+ *destPathResult = 0;
+ *writeAnswer = BoolToInt(false);
+
+ UString destPathSpec = destPath;
+ UString destPathSys = destPathSpec;
+ bool srcIsFolderSpec = IntToBool(srcIsFolder);
+ CFileInfoW destFileInfo;
+ if (FindFile(destPathSys, destFileInfo))
+ {
+ if (srcIsFolderSpec)
+ {
+ if (!destFileInfo.IsDirectory())
+ {
+ UString message = UString(L"can not replace file \'")
+ + destPathSpec +
+ UString(L"\' with folder with same name");
+ RINOK(MessageError(message));
+ return E_ABORT;
+ }
+ *writeAnswer = BoolToInt(false);
+ return S_OK;
+ }
+ if (destFileInfo.IsDirectory())
+ {
+ UString message = UString(L"can not replace folder \'")
+ + destPathSpec +
+ UString(L"\' with file with same name");
+ RINOK(MessageError(message));
+ return E_FAIL;
+ }
+
+ switch(OverwriteMode)
+ {
+ case NExtract::NOverwriteMode::kSkipExisting:
+ return S_OK;
+ case NExtract::NOverwriteMode::kAskBefore:
+ {
+ Int32 overwiteResult;
+ RINOK(AskOverwrite(
+ destPathSpec,
+ &destFileInfo.LastWriteTime, &destFileInfo.Size,
+ srcPath,
+ srcTime, srcSize,
+ &overwiteResult));
+ switch(overwiteResult)
+ {
+ case NOverwriteAnswer::kCancel:
+ return E_ABORT;
+ case NOverwriteAnswer::kNo:
+ return S_OK;
+ case NOverwriteAnswer::kNoToAll:
+ OverwriteMode = NExtract::NOverwriteMode::kSkipExisting;
+ return S_OK;
+ case NOverwriteAnswer::kYesToAll:
+ OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
+ break;
+ case NOverwriteAnswer::kYes:
+ break;
+ case NOverwriteAnswer::kAutoRename:
+ OverwriteMode = NExtract::NOverwriteMode::kAutoRename;
+ break;
+ default:
+ throw 20413;
+ }
+ }
+ }
+ if (OverwriteMode == NExtract::NOverwriteMode::kAutoRename)
+ {
+ if (!AutoRenamePath(destPathSys))
+ {
+ UString message = UString(L"can not create name of file ")
+ + destPathSys;
+ RINOK(MessageError(message));
+ return E_ABORT;
+ }
+ destPathResultTemp = destPathSys;
+ }
+ else
+ if (!NFile::NDirectory::DeleteFileAlways(destPathSys))
+ {
+ UString message = UString(L"can not delete output file ")
+ + destPathSys;
+ RINOK(MessageError(message));
+ return E_ABORT;
+ }
+ }
+ CMyComBSTR destPathResultBSTR = destPathResultTemp;
+ *destPathResult = destPathResultBSTR.Detach();
+ *writeAnswer = BoolToInt(true);
+ return S_OK;
+}
+
diff --git a/CPP/7zip/FileManager/ExtractCallback.h b/CPP/7zip/FileManager/ExtractCallback.h
new file mode 100755
index 00000000..7bf8864e
--- /dev/null
+++ b/CPP/7zip/FileManager/ExtractCallback.h
@@ -0,0 +1,124 @@
+// ExtractCallback.h
+
+#ifndef __EXTRACTCALLBACK_H
+#define __EXTRACTCALLBACK_H
+
+#include "../UI/Agent/IFolderArchive.h"
+#include "Common/String.h"
+
+#ifdef _SFX
+#include "Resource/ProgressDialog/ProgressDialog.h"
+#else
+#include "Resource/ProgressDialog2/ProgressDialog.h"
+#endif
+
+#include "Windows/ResourceString.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+#ifndef _NO_CRYPTO
+#include "../IPassword.h"
+#endif
+#include "Common/MyCom.h"
+#include "IFolder.h"
+
+class CExtractCallbackImp:
+ public IExtractCallbackUI,
+ public IFolderOperationsExtractCallback,
+ #ifndef _NO_CRYPTO
+ public ICryptoGetTextPassword,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP3(
+ IFolderArchiveExtractCallback,
+ IFolderOperationsExtractCallback,
+ ICryptoGetTextPassword
+ )
+
+ // IProgress
+ STDMETHOD(SetTotal)(UInt64 total);
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue);
+
+ // IFolderArchiveExtractCallback
+ STDMETHOD(AskOverwrite)(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer);
+ STDMETHOD (PrepareOperation)(const wchar_t *name, Int32 askExtractMode, const UInt64 *position);
+
+ STDMETHOD(MessageError)(const wchar_t *message);
+ STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted);
+
+ // IExtractCallbackUI
+
+ 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);
+ #endif
+
+ // IFolderOperationsExtractCallback
+ STDMETHOD(AskWrite)(
+ const wchar_t *srcPath,
+ Int32 srcIsFolder,
+ const FILETIME *srcTime,
+ const UInt64 *srcSize,
+ const wchar_t *destPathRequest,
+ BSTR *destPathResult,
+ Int32 *writeAnswer);
+ STDMETHOD(ShowMessage)(const wchar_t *message);
+ STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath);
+
+ // ICryptoGetTextPassword
+ #ifndef _NO_CRYPTO
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+ #endif
+
+private:
+ // bool _extractMode;
+ UString _currentArchivePath;
+ bool _needWriteArchivePath;
+
+ UString _currentFilePath;
+
+ // void CreateComplexDirectory(const UStringVector &aDirPathParts);
+
+ void AddErrorMessage(LPCWSTR message);
+public:
+ CProgressDialog ProgressDialog;
+ UStringVector Messages;
+ bool ShowMessages;
+ HWND ParentWindow;
+ INT_PTR StartProgressDialog(const UString &title)
+ {
+ return ProgressDialog.Create(title, ParentWindow);
+ }
+ UInt32 NumArchiveErrors;
+ NExtract::NOverwriteMode::EEnum OverwriteMode;
+
+ #ifndef _NO_CRYPTO
+ bool PasswordIsDefined;
+ UString Password;
+ #endif
+
+ CExtractCallbackImp():
+ #ifndef _NO_CRYPTO
+ PasswordIsDefined(false),
+ #endif
+ OverwriteMode(NExtract::NOverwriteMode::kAskBefore),
+ ParentWindow(0),
+ ShowMessages(true)
+ {}
+
+ ~CExtractCallbackImp();
+ void Init();
+};
+
+#endif
diff --git a/CPP/7zip/FileManager/FM.cpp b/CPP/7zip/FileManager/FM.cpp
new file mode 100755
index 00000000..c64f0b51
--- /dev/null
+++ b/CPP/7zip/FileManager/FM.cpp
@@ -0,0 +1,788 @@
+// FAM.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+#include "Panel.h"
+
+#include "Common/Defs.h"
+#include "Common/StringConvert.h"
+#include "Common/Alloc.h"
+// #include "Common/CommandLineParser.h"
+
+#include "Windows/Control/Toolbar.h"
+#include "Windows/Error.h"
+#include "Windows/COM.h"
+#include "Windows/DLL.h"
+#include "Windows/Security.h"
+#include "Windows/MemoryLock.h"
+
+#include "ViewSettings.h"
+#include "../UI/Resource/Extract/resource.h"
+
+#include "App.h"
+#include "StringUtils.h"
+
+#include "MyLoadMenu.h"
+#include "LangUtils.h"
+#include "FormatUtils.h"
+#include "RegistryUtils.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+// using namespace NCommandLineParser;
+
+// NWindows::NCOM::CComInitializer aComInitializer;
+
+#define MAX_LOADSTRING 100
+
+#define MENU_HEIGHT 26
+
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
+HINSTANCE g_hInstance;
+HWND g_HWND;
+bool g_OpenArchive = false;
+static UString g_MainPath;
+
+const int kNumDefaultPanels = 1;
+
+const int kSplitterWidth = 4;
+int kSplitterRateMax = 1 << 16;
+
+// bool OnMenuCommand(HWND hWnd, int id);
+
+static UString GetProgramPath()
+{
+ UString s;
+ NDLL::MyGetModuleFileName(g_hInstance, s);
+ return s;
+}
+
+UString GetProgramFolderPrefix()
+{
+ UString path = GetProgramPath();
+ int pos = path.ReverseFind(L'\\');
+ return path.Left(pos + 1);
+}
+
+
+class CSplitterPos
+{
+ int _ratio; // 10000 is max
+ int _pos;
+ int _fullWidth;
+ void SetRatioFromPos(HWND hWnd)
+ { _ratio = (_pos + kSplitterWidth / 2) * kSplitterRateMax /
+ MyMax(GetWidth(hWnd), 1); }
+public:
+ int GetPos() const
+ { return _pos; }
+ int GetWidth(HWND hWnd) const
+ {
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ return rect.right;
+ }
+ void SetRatio(HWND hWnd, int 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;
+ _pos = pos;
+ }
+ void SetPos(HWND hWnd, int pos)
+ {
+ _fullWidth = GetWidth(hWnd);
+ SetPosPure(hWnd, pos);
+ SetRatioFromPos(hWnd);
+ }
+ void SetPosFromRatio(HWND hWnd)
+ {
+ int fullWidth = GetWidth(hWnd);
+ if (_fullWidth != fullWidth)
+ {
+ _fullWidth = fullWidth;
+ SetPosPure(hWnd, GetWidth(hWnd) * _ratio / kSplitterRateMax - kSplitterWidth / 2);
+ }
+ }
+};
+
+bool g_CanChangeSplitter = false;
+UINT32 g_SplitterPos = 0;
+CSplitterPos g_Splitter;
+bool g_PanelsInfoDefined = false;
+
+int g_StartCaptureMousePos;
+int g_StartCaptureSplitterPos;
+
+CApp g_App;
+
+void MoveSubWindows(HWND hWnd);
+void OnSize(HWND hWnd);
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+const wchar_t *kWindowClass = L"FM";
+
+#ifndef _UNICODE
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+
+// FUNCTION: InitInstance(HANDLE, int)
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+ CWindow wnd;
+
+ g_hInstance = hInstance;
+
+ ReloadLangSmart();
+
+ // LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING);
+
+ // LoadString(hInstance, IDS_APP_TITLE, title, MAX_LOADSTRING);
+ UString title = LangString(IDS_APP_TITLE, 0x03000000);
+
+ /*
+ //If it is already running, then focus on the window
+ hWnd = FindWindow(windowClass, title);
+ if (hWnd)
+ {
+ SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));
+ return 0;
+ }
+ */
+
+ WNDCLASSW wc;
+
+ // wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.style = 0;
+ wc.lpfnWndProc = (WNDPROC) WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FAM));
+
+ // wc.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wc.hCursor = ::LoadCursor(0, IDC_SIZEWE);
+ // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
+
+ wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
+ wc.lpszClassName = kWindowClass;
+
+ MyRegisterClass(&wc);
+
+ // RECT rect;
+ // GetClientRect(hWnd, &rect);
+
+ DWORD style = WS_OVERLAPPEDWINDOW;
+ // DWORD style = 0;
+
+ RECT rect;
+ bool maximized = false;
+ int x , y, xSize, ySize;
+ x = y = xSize = ySize = CW_USEDEFAULT;
+ bool windowPosIsRead = ReadWindowSize(rect, maximized);
+
+ if (windowPosIsRead)
+ {
+ // x = rect.left;
+ // y = rect.top;
+ xSize = rect.right - rect.left;
+ ySize = rect.bottom - rect.top;
+ }
+
+ UINT32 numPanels, currentPanel;
+ g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos);
+ if (g_PanelsInfoDefined)
+ {
+ if (numPanels < 1 || numPanels > 2)
+ numPanels = kNumDefaultPanels;
+ if (currentPanel >= 2)
+ currentPanel = 0;
+ }
+ else
+ {
+ numPanels = kNumDefaultPanels;
+ currentPanel = 0;
+ }
+ g_App.NumPanels = numPanels;
+ g_App.LastFocusedPanel = currentPanel;
+
+ if (!wnd.Create(kWindowClass, title, style,
+ x, y, xSize, ySize, NULL, NULL, hInstance, NULL))
+ return FALSE;
+ g_HWND = (HWND)wnd;
+
+ WINDOWPLACEMENT placement;
+ placement.length = sizeof(placement);
+ if (wnd.GetPlacement(&placement))
+ {
+ if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
+ nCmdShow == SW_SHOWDEFAULT)
+ {
+ if (maximized)
+ placement.showCmd = SW_SHOWMAXIMIZED;
+ else
+ placement.showCmd = SW_SHOWNORMAL;
+ }
+ else
+ placement.showCmd = nCmdShow;
+ if (windowPosIsRead)
+ placement.rcNormalPosition = rect;
+ wnd.SetPlacement(&placement);
+ // window.Show(nCmdShow);
+ }
+ else
+ wnd.Show(nCmdShow);
+ return TRUE;
+}
+
+/*
+static void GetCommands(const UString &aCommandLine, UString &aCommands)
+{
+ UString aProgramName;
+ aCommands.Empty();
+ bool aQuoteMode = false;
+ for (int i = 0; i < aCommandLine.Length(); i++)
+ {
+ wchar_t aChar = aCommandLine[i];
+ if (aChar == L'\"')
+ aQuoteMode = !aQuoteMode;
+ else if (aChar == L' ' && !aQuoteMode)
+ {
+ if (!aQuoteMode)
+ {
+ i++;
+ break;
+ }
+ }
+ else
+ aProgramName += aChar;
+ }
+ aCommands = aCommandLine.Mid(i);
+}
+*/
+
+DWORD GetDllVersion(LPCTSTR lpszDllName)
+{
+ HINSTANCE hinstDll;
+ DWORD dwVersion = 0;
+ hinstDll = LoadLibrary(lpszDllName);
+ if(hinstDll)
+ {
+ DLLGETVERSIONPROC pDllGetVersion;
+ pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
+
+ /*Because some DLLs might not implement this function, you
+ must test for it explicitly. Depending on the particular
+ DLL, the lack of a DllGetVersion function can be a useful
+ indicator of the version.
+ */
+ if(pDllGetVersion)
+ {
+ DLLVERSIONINFO dvi;
+ HRESULT hr;
+
+ ZeroMemory(&dvi, sizeof(dvi));
+ dvi.cbSize = sizeof(dvi);
+
+ hr = (*pDllGetVersion)(&dvi);
+
+ if(SUCCEEDED(hr))
+ {
+ dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
+ }
+ }
+ FreeLibrary(hinstDll);
+ }
+ return dwVersion;
+}
+
+DWORD g_ComCtl32Version;
+
+/*
+#ifndef _WIN64
+typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
+
+static bool IsWow64()
+{
+ LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
+ GetModuleHandle("kernel32"), "IsWow64Process");
+ if (fnIsWow64Process == NULL)
+ return false;
+ BOOL isWow;
+ if (!fnIsWow64Process(GetCurrentProcess(),&isWow))
+ return false;
+ return isWow != FALSE;
+}
+#endif
+*/
+
+bool IsLargePageSupported()
+{
+ #ifdef _WIN64
+ return true;
+ #else
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 5)
+ return false;
+ if (versionInfo.dwMajorVersion > 5)
+ return true;
+ if (versionInfo.dwMinorVersion < 1)
+ return false;
+ if (versionInfo.dwMinorVersion > 1)
+ return true;
+ // return IsWow64();
+ return false;
+ #endif
+}
+
+static void SetMemoryLock()
+{
+ if (!IsLargePageSupported())
+ return;
+ // if (ReadLockMemoryAdd())
+ NSecurity::AddLockMemoryPrivilege();
+
+ if (ReadLockMemoryEnable())
+ NSecurity::EnableLockMemoryPrivilege();
+}
+
+/*
+static const int kNumSwitches = 1;
+
+namespace NKey {
+enum Enum
+{
+ kOpenArachive = 0,
+};
+
+}
+
+static const CSwitchForm kSwitchForms[kNumSwitches] =
+ {
+ { L"SOA", NSwitchType::kSimple, false },
+ };
+*/
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int nCmdShow)
+{
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+
+ InitCommonControls();
+
+ g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
+
+ // OleInitialize is required for drag and drop.
+ OleInitialize(NULL);
+ // Maybe needs CoInitializeEx also ?
+ // NCOM::CComInitializer comInitializer;
+
+ UString programString, commandsString;
+ // MessageBoxW(0, GetCommandLineW(), L"", 0);
+ SplitStringToTwoStrings(GetCommandLineW(), programString, commandsString);
+
+ commandsString.Trim();
+ UString paramString, tailString;
+ SplitStringToTwoStrings(commandsString, paramString, tailString);
+ paramString.Trim();
+
+ if (!paramString.IsEmpty())
+ {
+ g_MainPath = paramString;
+ // MessageBoxW(0, paramString, L"", 0);
+ }
+ /*
+ UStringVector commandStrings;
+ NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
+ NCommandLineParser::CParser parser(kNumSwitches);
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
+ const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
+ if(nonSwitchStrings.Size() > 1)
+ {
+ g_MainPath = nonSwitchStrings[1];
+ // g_OpenArchive = parser[NKey::kOpenArachive].ThereIs;
+ CFileInfoW fileInfo;
+ if (FindFile(g_MainPath, fileInfo))
+ {
+ if (!fileInfo.IsDirectory())
+ g_OpenArchive = true;
+ }
+ }
+ }
+ catch(...) { }
+ */
+
+
+ SetMemoryLock();
+
+ MSG msg;
+ if (!InitInstance (hInstance, nCmdShow))
+ return FALSE;
+
+ MyLoadMenu(g_HWND);
+
+ #ifndef _UNICODE
+ if (g_IsNT)
+ {
+ HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
+ while (GetMessageW(&msg, NULL, 0, 0))
+ {
+ if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
+ {
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+ }
+ }
+ else
+ #endif
+ {
+ HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
+ {
+ // if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
+ // if (!IsDialogMessage(g_Hwnd, &msg))
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ }
+
+ g_HWND = 0;
+ OleUninitialize();
+ return (int)msg.wParam;
+}
+
+static void SaveWindowInfo(HWND aWnd)
+{
+ /*
+ RECT rect;
+ if (!::GetWindowRect(aWnd, &rect))
+ return;
+ */
+ WINDOWPLACEMENT placement;
+ placement.length = sizeof(placement);
+ if (!::GetWindowPlacement(aWnd, &placement))
+ return;
+ SaveWindowSize(placement.rcNormalPosition,
+ BOOLToBool(::IsZoomed(aWnd)));
+ SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel,
+ g_Splitter.GetPos());
+}
+
+void ExecuteCommand(UINT commandID)
+{
+ switch (commandID)
+ {
+ case kAddCommand:
+ g_App.AddToArchive();
+ break;
+ case kExtractCommand:
+ g_App.ExtractArchives();
+ break;
+ case kTestCommand:
+ g_App.TestArchives();
+ break;
+ }
+}
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId, wmEvent;
+ switch (message)
+ {
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+ if ((HWND) lParam != NULL && wmEvent != 0)
+ break;
+ if (wmId >= kToolbarStartID)
+ {
+ ExecuteCommand(wmId);
+ return 0;
+ }
+ if (OnMenuCommand(hWnd, wmId))
+ return 0;
+ break;
+ case WM_INITMENUPOPUP:
+ OnMenuActivating(hWnd, HMENU(wParam), LOWORD(lParam));
+ break;
+
+ /*
+ It doesn't help
+ case WM_EXITMENULOOP:
+ {
+ OnMenuUnActivating(hWnd);
+ break;
+ }
+ case WM_UNINITMENUPOPUP:
+ OnMenuUnActivating(hWnd, HMENU(wParam), lParam);
+ break;
+ */
+
+ case WM_CREATE:
+ {
+
+ /*
+ INITCOMMONCONTROLSEX icex;
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ // Toolbar buttons used to create the first 4 buttons.
+ TBBUTTON tbb [ ] =
+ {
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ // {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ {VIEW_NEWFOLDER, ID_FILE_CREATEFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ };
+
+ 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]),
+ 0, 0, 100, 30, sizeof (TBBUTTON)));
+ */
+ // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
+ // ::SetCursor(cursor);
+
+ if (g_PanelsInfoDefined)
+ g_Splitter.SetPos(hWnd, g_SplitterPos);
+ else
+ {
+ g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
+ g_SplitterPos = g_Splitter.GetPos();
+ }
+
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int xSizes[2];
+ xSizes[0] = g_Splitter.GetPos();
+ xSizes[1] = xSize - kSplitterWidth - xSizes[0];
+ if (xSizes[1] < 0)
+ xSizes[1] = 0;
+
+ g_App.CreateDragTarget();
+ bool archiveIsOpened;
+ bool encrypted;
+ g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted);
+ if (!archiveIsOpened && g_OpenArchive)
+ {
+ UString message;
+ if (encrypted)
+ message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath);
+ else
+ message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath);
+ MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
+ return -1;
+ }
+ // g_SplitterPos = 0;
+
+ // ::DragAcceptFiles(hWnd, TRUE);
+ RegisterDragDrop(hWnd, g_App._dropTarget);
+
+ break;
+ }
+ case WM_DESTROY:
+ {
+ // ::DragAcceptFiles(hWnd, FALSE);
+ RevokeDragDrop(hWnd);
+ g_App._dropTarget.Release();
+
+ g_App.Save();
+ g_App.Release();
+ SaveWindowInfo(hWnd);
+ PostQuitMessage(0);
+ break;
+ }
+ /*
+ case WM_MOVE:
+ {
+ break;
+ }
+ */
+ case WM_LBUTTONDOWN:
+ g_StartCaptureMousePos = LOWORD(lParam);
+ g_StartCaptureSplitterPos = g_Splitter.GetPos();
+ ::SetCapture(hWnd);
+ break;
+ case WM_LBUTTONUP:
+ {
+ ::ReleaseCapture();
+ break;
+ }
+ case WM_MOUSEMOVE:
+ {
+ if ((wParam & MK_LBUTTON) != 0 && ::GetCapture() == hWnd)
+ {
+ g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos +
+ (short)LOWORD(lParam) - g_StartCaptureMousePos);
+ MoveSubWindows(hWnd);
+ }
+ break;
+ }
+
+ case WM_SIZE:
+ {
+ if (g_CanChangeSplitter)
+ g_Splitter.SetPosFromRatio(hWnd);
+ else
+ {
+ g_Splitter.SetPos(hWnd, g_SplitterPos );
+ g_CanChangeSplitter = true;
+ }
+
+ OnSize(hWnd);
+ /*
+ int xSize = LOWORD(lParam);
+ int ySize = HIWORD(lParam);
+ // int xSplitter = 2;
+ int xWidth = g_SplitPos;
+ // int xSplitPos = xWidth;
+ g_Panel[0]._listView.MoveWindow(0, 0, xWidth, ySize);
+ g_Panel[1]._listView.MoveWindow(xSize - xWidth, 0, xWidth, ySize);
+ */
+ return 0;
+ break;
+ }
+ case WM_SETFOCUS:
+ // g_App.SetFocus(g_App.LastFocusedPanel);
+ g_App.SetFocusToLastItem();
+ break;
+ /*
+ case WM_ACTIVATE:
+ {
+ int fActive = LOWORD(wParam);
+ switch (fActive)
+ {
+ case WA_INACTIVE:
+ {
+ // g_FocusIndex = g_App.LastFocusedPanel;
+ // g_App.LastFocusedPanel = g_App.GetFocusedPanelIndex();
+ // return 0;
+ }
+ }
+ break;
+ }
+ */
+ /*
+ case kLangWasChangedMessage:
+ MyLoadMenu(g_HWND);
+ return 0;
+ */
+
+ /*
+ case WM_SETTINGCHANGE:
+ break;
+ */
+ case WM_NOTIFY:
+ {
+ g_App.OnNotify((int)wParam, (LPNMHDR)lParam);
+ break;
+ }
+ /*
+ case WM_DROPFILES:
+ {
+ g_App.GetFocusedPanel().CompressDropFiles((HDROP)wParam);
+ return 0 ;
+ }
+ */
+ }
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(hWnd, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(hWnd, message, wParam, lParam);
+
+}
+
+void OnSize(HWND hWnd)
+{
+ /*
+ if (g_App._rebar)
+ {
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int ySize = rect.bottom;
+ // rect.bottom = 0;
+ // g_App._rebar.SizeToRect(&rect);
+ // g_App._rebar.Move(0, 0, xSize, ySize);
+ }
+ */
+ MoveSubWindows(hWnd);
+}
+
+void MoveSubWindows(HWND hWnd)
+{
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int kHeaderSize = 0;
+ int ySize = MyMax(int(rect.bottom - kHeaderSize), 0);
+ if (g_App._rebar)
+ {
+ RECT barRect;
+ g_App._rebar.GetWindowRect(&barRect);
+ kHeaderSize = barRect.bottom - barRect.top;
+ ySize = MyMax(int(rect.bottom - kHeaderSize), 0);
+ }
+
+ // g_App._headerToolBar.Move(0, 2, xSize, kHeaderSize - 2);
+ RECT rect2 = rect;
+ rect2.bottom = 0;
+ // g_App._headerReBar.SizeToRect(&rect2);
+ if (g_App.NumPanels > 1)
+ {
+ g_App.Panels[0].Move(0, kHeaderSize, g_Splitter.GetPos(), ySize);
+ int xWidth1 = g_Splitter.GetPos() + kSplitterWidth;
+ g_App.Panels[1].Move(xWidth1, kHeaderSize, xSize - xWidth1, ySize);
+ }
+ else
+ {
+ /*
+ int otherPanel = 1 - g_App.LastFocusedPanel;
+ if (g_App.PanelsCreated[otherPanel])
+ g_App.Panels[otherPanel].Move(0, kHeaderSize, 0, ySize);
+ */
+ g_App.Panels[g_App.LastFocusedPanel].Move(0, kHeaderSize, xSize, ySize);
+ }
+}
diff --git a/CPP/7zip/FileManager/FM.dsp b/CPP/7zip/FileManager/FM.dsp
new file mode 100755
index 00000000..75c95ead
--- /dev/null
+++ b/CPP/7zip/FileManager/FM.dsp
@@ -0,0 +1,1251 @@
+# Microsoft Developer Studio Project File - Name="FM" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=FM - Win32 DebugU
+!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 "FM.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 "FM.mak" CFG="FM - Win32 DebugU"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "FM - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "FM - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE "FM - Win32 ReleaseU" (based on "Win32 (x86) Application")
+!MESSAGE "FM - Win32 DebugU" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "FM - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /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 /subsystem:windows /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 comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "FM - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /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 /subsystem:windows /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 comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseU"
+# PROP BASE Intermediate_Dir "ReleaseU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseU"
+# PROP Intermediate_Dir "ReleaseU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /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 comctl32.lib /nologo /subsystem:windows /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 comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-ZIP\7zFMn.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "FM - Win32 DebugU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugU"
+# PROP BASE Intermediate_Dir "DebugU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugU"
+# PROP Intermediate_Dir "DebugU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /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 comctl32.lib /nologo /subsystem:windows /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 comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7zFMn.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "FM - Win32 Release"
+# Name "FM - Win32 Debug"
+# Name "FM - Win32 ReleaseU"
+# Name "FM - Win32 DebugU"
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\Resource\AboutDialog\7zipLogo.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\add.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ClassDefs.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Copy.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Delete.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Extract.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FM.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\Move.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Parent.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Properties.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.rc
+# ADD BASE RSC /l 0x419
+# ADD RSC /l 0x409
+# 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
+# Begin Source File
+
+SOURCE=.\Test.bmp
+# End Source File
+# End Group
+# Begin Group "Archive Interfaces"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Archive\IArchive.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Agent\IFolderArchive.h
+# End Source File
+# End Group
+# Begin Group "Folders"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\FSDrives.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FSDrives.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\FSFolder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FSFolder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\FSFolderCopy.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\IFolder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\NetFolder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\NetFolder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\PhysDriveFolder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PhysDriveFolder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\RootFolder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\RootFolder.h
+# End Source File
+# End Group
+# Begin Group "Registry"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\RegistryAssociations.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\RegistryAssociations.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\RegistryPlugins.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\RegistryPlugins.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\RegistryUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\RegistryUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ViewSettings.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ViewSettings.h
+# End Source File
+# End Group
+# Begin Group "Panel"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\App.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\App.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\AppState.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\EnumFormatEtc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\EnumFormatEtc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\FileFolderPluginOpen.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FileFolderPluginOpen.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Panel.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Panel.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelCopy.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelCrc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelDrag.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelFolderChange.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelItemOpen.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelItems.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelKey.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelListNotify.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelMenu.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelOperations.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelSelect.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelSort.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PanelSplitFile.cpp
+# End Source File
+# End Group
+# Begin Group "Dialog"
+
+# PROP Default_Filter ""
+# Begin Group "Options"
+
+# PROP Default_Filter ""
+# Begin Group "Settings"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\Resource\SettingsPage\SettingsPage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\SettingsPage\SettingsPage.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\Resource\EditPage\EditPage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\EditPage\EditPage.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\LangPage\LangPage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\LangPage\LangPage.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\PluginsPage\PluginsPage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\PluginsPage\PluginsPage.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\SystemPage\SystemPage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\SystemPage\SystemPage.h
+# End Source File
+# End Group
+# Begin Group "Password"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=Resource\PasswordDialog\PasswordDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=Resource\PasswordDialog\PasswordDialog.h
+# End Source File
+# End Group
+# Begin Group "Progress"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\Resource\ProgressDialog2\ProgressDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\ProgressDialog2\ProgressDialog.h
+# End Source File
+# End Group
+# Begin Group "About"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\Resource\AboutDialog\AboutDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\AboutDialog\AboutDialog.h
+# End Source File
+# End Group
+# Begin Group "Benchmark"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\Resource\BenchmarkDialog\BenchmarkDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\BenchmarkDialog\BenchmarkDialog.h
+# End Source File
+# End Group
+# Begin Group "Split"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\Resource\SplitDialog\SplitDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\SplitDialog\SplitDialog.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\Resource\ComboDialog\ComboDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\ComboDialog\ComboDialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\CopyDialog\CopyDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\CopyDialog\CopyDialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\ListViewDialog\ListViewDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource\ListViewDialog\ListViewDialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=Resource\MessagesDialog\MessagesDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=Resource\MessagesDialog\MessagesDialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=Resource\OverwriteDialog\OverwriteDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=Resource\OverwriteDialog\OverwriteDialog.h
+# End Source File
+# End Group
+# Begin Group "FM Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\ExtractCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ExtractCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\FormatUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FormatUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\HelpUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\HelpUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\LangUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\LangUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ProgramLocation.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ProgramLocation.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\UpdateCallback100.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\UpdateCallback100.h
+# End Source File
+# End Group
+# Begin Group "SDK"
+
+# PROP Default_Filter ""
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# Begin Group "Control"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\ComboBox.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\ComboBox.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\CommandBar.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\Dialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\Dialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\Edit.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\ImageList.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\ProgressBar.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\PropertyPage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\PropertyPage.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\ReBar.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\Static.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\StatusBar.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\ToolBar.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\Trackbar.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\Window2.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Control\Window2.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=..\..\Windows\CommonDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\CommonDialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Defs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Device.h
+# End Source File
+# 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\Error.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Error.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\FileDevice.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\FileDevice.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.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\FileName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\FileSystem.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\FileSystem.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Handle.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Memory.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Memory.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\MemoryLock.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\MemoryLock.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Menu.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Menu.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Net.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Net.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Process.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\PropVariantConversions.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\PropVariantConversions.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Registry.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Registry.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\ResourceString.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\ResourceString.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Security.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Security.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Shell.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Shell.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\Thread.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Time.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Timer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Window.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Windows\Window.h
+# End Source File
+# End Group
+# Begin Group "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Buffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\CommandLineParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\CommandLineParser.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\ComTry.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\CRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Defs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\DynamicBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Exception.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\Lang.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Lang.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MyCom.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\Random.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Random.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StdInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StdInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StdOutStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StdOutStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\String.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\String.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
+# Begin Source File
+
+SOURCE=..\..\Common\TextConfig.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\TextConfig.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Types.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\UTFConvert.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\UTFConvert.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Vector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Vector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Wildcard.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\Wildcard.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "UI Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\UI\Common\ArchiveName.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\ArchiveName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\CompressCall.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\CompressCall.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\PropIDUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\PropIDUtils.h
+# End Source File
+# End Group
+# Begin Group "7-Zip Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Common\FilePathAutoRename.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\FilePathAutoRename.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\FileStreams.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\FileStreams.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\StreamObjects.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\StreamObjects.h
+# End Source File
+# End Group
+# Begin Group "C"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\C\Sort.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\C\Sort.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\7zFM.exe.manifest
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zipLogo.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\Add2.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Copy2.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Delete2.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Extract2.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FilePlugins.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FilePlugins.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\FM.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Info.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Info2.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Move2.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\MyCom2.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\MyLoadMenu.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\MyLoadMenu.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\OpenCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\OpenCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\OptionsDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PluginInterface.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\PluginLoader.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\PropertyName.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\PropertyName.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SplitUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SplitUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StringUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StringUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SysIconUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SysIconUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Test2.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\TextPairs.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\TextPairs.h
+# End Source File
+# End Target
+# End Project
diff --git a/7zip/FileManager/FM.dsw b/CPP/7zip/FileManager/FM.dsw
index 1c955d95..1c955d95 100755
--- a/7zip/FileManager/FM.dsw
+++ b/CPP/7zip/FileManager/FM.dsw
diff --git a/7zip/FileManager/FM.ico b/CPP/7zip/FileManager/FM.ico
index 3a0a34da..3a0a34da 100755
--- a/7zip/FileManager/FM.ico
+++ b/CPP/7zip/FileManager/FM.ico
Binary files differ
diff --git a/7zip/FileManager/FSDrives.cpp b/CPP/7zip/FileManager/FSDrives.cpp
index 447ff4dc..447ff4dc 100755
--- a/7zip/FileManager/FSDrives.cpp
+++ b/CPP/7zip/FileManager/FSDrives.cpp
diff --git a/7zip/FileManager/FSDrives.h b/CPP/7zip/FileManager/FSDrives.h
index 496e8fc1..496e8fc1 100755
--- a/7zip/FileManager/FSDrives.h
+++ b/CPP/7zip/FileManager/FSDrives.h
diff --git a/CPP/7zip/FileManager/FSFolder.cpp b/CPP/7zip/FileManager/FSFolder.cpp
new file mode 100755
index 00000000..309128ae
--- /dev/null
+++ b/CPP/7zip/FileManager/FSFolder.cpp
@@ -0,0 +1,655 @@
+// FSFolder.cpp
+
+#include "StdAfx.h"
+
+#include "FSFolder.h"
+
+#include "Common/StringConvert.h"
+#include "Common/StdInStream.h"
+#include "Common/StdOutStream.h"
+#include "Common/UTFConvert.h"
+
+#include "Windows/Defs.h"
+#include "Windows/PropVariant.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileIO.h"
+
+#include "../PropID.h"
+
+#include "SysIconUtils.h"
+#include "FSDrives.h"
+#include "NetFolder.h"
+
+namespace NWindows {
+namespace NFile {
+
+bool GetLongPath(LPCWSTR path, UString &longPath);
+
+}}
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+static STATPROPSTG kProperties[] =
+{
+ { NULL, kpidName, VT_BSTR},
+ // { NULL, kpidIsFolder, 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, kpidComment, VT_BSTR},
+ { NULL, kpidPrefix, VT_BSTR}
+};
+
+HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
+{
+ _parentFolder = parentFolder;
+ _path = path;
+
+ _findChangeNotification.FindFirst(_path, false,
+ FILE_NOTIFY_CHANGE_FILE_NAME |
+ FILE_NOTIFY_CHANGE_DIR_NAME |
+ FILE_NOTIFY_CHANGE_ATTRIBUTES |
+ FILE_NOTIFY_CHANGE_SIZE |
+ FILE_NOTIFY_CHANGE_LAST_WRITE /*|
+ FILE_NOTIFY_CHANGE_LAST_ACCESS |
+ FILE_NOTIFY_CHANGE_CREATION |
+ FILE_NOTIFY_CHANGE_SECURITY */);
+ if (!_findChangeNotification.IsHandleAllocated())
+ {
+ DWORD lastError = GetLastError();
+ CFindFile findFile;
+ CFileInfoW fileInfo;
+ if (!findFile.FindFirst(_path + UString(L"*"), fileInfo))
+ return lastError;
+ }
+ return S_OK;
+}
+
+static HRESULT GetFolderSize(const UString &path, UInt64 &size, IProgress *progress)
+{
+ RINOK(progress->SetCompleted(NULL));
+ size = 0;
+ CEnumeratorW enumerator(path + UString(L"\\*"));
+ CFileInfoW fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ if (fileInfo.IsDirectory())
+ {
+ UInt64 subSize;
+ RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subSize, progress));
+ size += subSize;
+ }
+ else
+ size += fileInfo.Size;
+ }
+ return S_OK;
+}
+
+HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
+{
+ {
+ CEnumeratorW enumerator(path + L"*");
+ CDirItem fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ fileInfo.CompressedSizeIsDefined = false;
+ /*
+ if (!GetCompressedFileSize(_path + fileInfo.Name,
+ fileInfo.CompressedSize))
+ fileInfo.CompressedSize = fileInfo.Size;
+ */
+ if (fileInfo.IsDirectory())
+ {
+ // fileInfo.Size = GetFolderSize(_path + fileInfo.Name);
+ fileInfo.Size = 0;
+ }
+ dirItem.Files.Add(fileInfo);
+ }
+ }
+ if (!_flatMode)
+ return S_OK;
+
+ for (int i = 0; i < dirItem.Files.Size(); i++)
+ {
+ CDirItem &item = dirItem.Files[i];
+ if (item.IsDirectory())
+ LoadSubItems(item, path + item.Name + L'\\');
+ }
+ return S_OK;
+}
+
+void CFSFolder::AddRefs(CDirItem &dirItem)
+{
+ int i;
+ for (i = 0; i < dirItem.Files.Size(); i++)
+ {
+ CDirItem &item = dirItem.Files[i];
+ item.Parent = &dirItem;
+ _refs.Add(&item);
+ }
+ if (!_flatMode)
+ return;
+ for (i = 0; i < dirItem.Files.Size(); i++)
+ {
+ CDirItem &item = dirItem.Files[i];
+ if (item.IsDirectory())
+ AddRefs(item);
+ }
+}
+
+STDMETHODIMP CFSFolder::LoadItems()
+{
+ // OutputDebugString(TEXT("Start\n"));
+ INT32 dummy;
+ WasChanged(&dummy);
+ Clear();
+ RINOK(LoadSubItems(_root, _path));
+ AddRefs(_root);
+
+ // OutputDebugString(TEXT("Finish\n"));
+ _commentsAreLoaded = false;
+ return S_OK;
+}
+
+static const wchar_t *kDescriptionFileName = L"descript.ion";
+
+bool CFSFolder::LoadComments()
+{
+ if (_commentsAreLoaded)
+ return true;
+ _comments.Clear();
+ _commentsAreLoaded = true;
+ NIO::CInFile file;
+ if (!file.Open(_path + kDescriptionFileName))
+ return false;
+ UInt64 length;
+ if (!file.GetLength(length))
+ return false;
+ if (length >= (1 << 28))
+ return false;
+ AString s;
+ char *p = s.GetBuffer((int)((size_t)length + 1));
+ UInt32 processedSize;
+ file.Read(p, (UInt32)length, processedSize);
+ p[length] = 0;
+ s.ReleaseBuffer();
+ s.Replace("\r\n", "\n");
+ if (processedSize != length)
+ return false;
+ file.Close();
+ UString unicodeString;
+ if (!ConvertUTF8ToUnicode(s, unicodeString))
+ return false;
+ return _comments.ReadFromString(unicodeString);
+}
+
+static bool IsAscii(const UString &testString)
+{
+ for (int i = 0; i < testString.Length(); i++)
+ if (testString[i] >= 0x80)
+ return false;
+ return true;
+}
+
+bool CFSFolder::SaveComments()
+{
+ NIO::COutFile file;
+ if (!file.Create(_path + kDescriptionFileName, true))
+ return false;
+ UString unicodeString;
+ _comments.SaveToString(unicodeString);
+ AString utfString;
+ ConvertUnicodeToUTF8(unicodeString, utfString);
+ UInt32 processedSize;
+ if (!IsAscii(unicodeString))
+ {
+ Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A };
+ file.Write(bom , sizeof(bom), processedSize);
+ }
+ utfString.Replace("\n", "\r\n");
+ file.Write(utfString, utfString.Length(), processedSize);
+ _commentsAreLoaded = false;
+ return true;
+}
+
+STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _refs.Size();
+ return S_OK;
+}
+
+/*
+STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
+{
+ UInt32 numSubFoldersLoc = 0;
+ for (int i = 0; i < _files.Size(); i++)
+ if (_files[i].IsDirectory())
+ numSubFoldersLoc++;
+ *numSubFolders = numSubFoldersLoc;
+ return S_OK;
+}
+*/
+
+bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
+{
+ DWORD highPart;
+ DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
+ if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
+ {
+ #ifdef WIN_LONG_PATH
+ {
+ UString longPath;
+ if (GetLongPath(fileName, longPath))
+ lowPart = ::GetCompressedFileSizeW(longPath, &highPart);
+ }
+ #endif
+ if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
+ return false;
+ }
+ size = (UInt64(highPart) << 32) | lowPart;
+ return true;
+}
+
+STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant propVariant;
+ 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:
+ if (!fileInfo.CompressedSizeIsDefined)
+ {
+ fileInfo.CompressedSizeIsDefined = true;
+ if (fileInfo.IsDirectory () ||
+ !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;
+ break;
+ case kpidComment:
+ {
+ LoadComments();
+ UString comment;
+ if (_comments.GetValue(GetRelPath(fileInfo), comment))
+ propVariant = comment;
+ break;
+ }
+ case kpidPrefix:
+ {
+ if (_flatMode)
+ {
+ propVariant = GetPrefix(fileInfo);
+ }
+ break;
+ }
+ }
+ propVariant.Detach(value);
+ return S_OK;
+}
+
+HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ CFSFolder *folderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> subFolder = folderSpec;
+ RINOK(folderSpec->Init(_path + name + UString(L'\\'), 0));
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+}
+
+UString CFSFolder::GetPrefix(const CDirItem &item) const
+{
+ UString path;
+ CDirItem *cur = item.Parent;
+ while (cur->Parent != 0)
+ {
+ path = cur->Name + UString('\\') + path;
+ cur = cur->Parent;
+ }
+ return path;
+}
+
+UString CFSFolder::GetRelPath(const CDirItem &item) const
+{
+ return GetPrefix(item) + item.Name;
+}
+
+STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ const CDirItem &fileInfo = *_refs[index];
+ if (!fileInfo.IsDirectory())
+ return E_INVALIDARG;
+ return BindToFolderSpec(GetRelPath(fileInfo), resultFolder);
+}
+
+STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ return BindToFolderSpec(name, resultFolder);
+}
+
+STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ if (_parentFolder)
+ {
+ CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
+ *resultFolder = parentFolder.Detach();
+ return S_OK;
+ }
+ if (_path.IsEmpty())
+ return E_INVALIDARG;
+ int pos = _path.ReverseFind(L'\\');
+ if (pos < 0 || pos != _path.Length() - 1)
+ return E_FAIL;
+ UString parentPath = _path.Left(pos);
+ pos = parentPath.ReverseFind(L'\\');
+ if (pos < 0)
+ {
+ parentPath.Empty();
+ CFSDrives *drivesFolderSpec = new CFSDrives;
+ CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
+ drivesFolderSpec->Init();
+ *resultFolder = drivesFolder.Detach();
+ return S_OK;
+ }
+ UString parentPathReduced = parentPath.Left(pos);
+ parentPath = parentPath.Left(pos + 1);
+ pos = parentPathReduced.ReverseFind(L'\\');
+ if (pos == 1)
+ {
+ if (parentPath[0] != L'\\')
+ return E_FAIL;
+ CNetFolder *netFolderSpec = new CNetFolder;
+ CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
+ netFolderSpec->Init(parentPath);
+ *resultFolder = netFolder.Detach();
+ return S_OK;
+ }
+ CFSFolder *parentFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
+ RINOK(parentFolderSpec->Init(parentPath, 0));
+ *resultFolder = parentFolder.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetName(BSTR * /* name */)
+{
+ return E_NOTIMPL;
+ /*
+ CMyComBSTR aBSTRName = m_ProxyFolderItem->m_Name;
+ *name = aBSTRName.Detach();
+ return S_OK;
+ */
+}
+
+STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties)
+{
+ *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
+ if (!_flatMode)
+ (*numProperties)--;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
+ return E_INVALIDARG;
+ const STATPROPSTG &prop = kProperties[index];
+ *propID = prop.propid;
+ *varType = prop.vt;
+ *name = 0;
+ return S_OK;
+}
+
+
+STDMETHODIMP CFSFolder::GetTypeID(BSTR *name)
+{
+ CMyComBSTR temp = L"FSFolder";
+ *name = temp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetPath(BSTR *path)
+{
+ CMyComBSTR temp = _path;
+ *path = temp.Detach();
+ return S_OK;
+}
+
+
+STDMETHODIMP CFSFolder::WasChanged(INT32 *wasChanged)
+{
+ bool wasChangedMain = false;
+ for (;;)
+ {
+ if (!_findChangeNotification.IsHandleAllocated())
+ {
+ *wasChanged = BoolToInt(false);
+ return S_OK;
+ }
+
+ DWORD waitResult = ::WaitForSingleObject(_findChangeNotification, 0);
+ bool wasChangedLoc = (waitResult == WAIT_OBJECT_0);
+ if (wasChangedLoc)
+ {
+ _findChangeNotification.FindNext();
+ wasChangedMain = true;
+ }
+ else
+ break;
+ }
+ *wasChanged = BoolToInt(wasChangedMain);
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
+{
+ CFSFolder *fsFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> folderNew = fsFolderSpec;
+ fsFolderSpec->Init(_path, 0);
+ *resultFolder = folderNew.Detach();
+ return S_OK;
+}
+
+HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
+{
+ const CDirItem &fileInfo = *_refs[index];
+ if (fileInfo.IsDirectory())
+ {
+ /*
+ CMyComPtr<IFolderFolder> subFolder;
+ RINOK(BindToFolder(index, &subFolder));
+ CMyComPtr<IFolderReload> aFolderReload;
+ subFolder.QueryInterface(&aFolderReload);
+ aFolderReload->Reload();
+ UInt32 numItems;
+ RINOK(subFolder->GetNumberOfItems(&numItems));
+ CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize;
+ subFolder.QueryInterface(&aGetItemFullSize);
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ UInt64 size;
+ RINOK(aGetItemFullSize->GetItemFullSize(i, &size));
+ *totalSize += size;
+ }
+ */
+ return GetFolderSize(_path + GetRelPath(fileInfo), size, progress);
+ }
+ size = fileInfo.Size;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
+{
+ NCOM::CPropVariant propVariant;
+ if (index >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ UInt64 size = 0;
+ HRESULT result = GetItemFullSize(index, size, progress);
+ propVariant = size;
+ propVariant.Detach(value);
+ return result;
+}
+
+HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
+{
+ UString newName = name;
+ resultPath = _path + newName;
+ if (newName.Length() < 1)
+ return S_OK;
+ if (newName[0] == L'\\')
+ {
+ resultPath = newName;
+ return S_OK;
+ }
+ if (newName.Length() < 2)
+ return S_OK;
+ if (newName[1] == L':')
+ resultPath = newName;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */)
+{
+ UString processedName;
+ RINOK(GetComplexName(name, processedName));
+ if(NDirectory::MyCreateDirectory(processedName))
+ return S_OK;
+ if(::GetLastError() == ERROR_ALREADY_EXISTS)
+ return ::GetLastError();
+ if (!NDirectory::CreateComplexDirectory(processedName))
+ return ::GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */)
+{
+ UString processedName;
+ RINOK(GetComplexName(name, processedName));
+ NIO::COutFile outFile;
+ if (!outFile.Create(processedName, false))
+ return ::GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */)
+{
+ const CDirItem &fileInfo = *_refs[index];
+ const UString fullPrefix = _path + GetPrefix(fileInfo);
+ if (!NDirectory::MyMoveFile(fullPrefix + fileInfo.Name, fullPrefix + newName))
+ return GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress)
+{
+ RINOK(progress->SetTotal(numItems));
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ const CDirItem &fileInfo = *_refs[indices[i]];
+ const UString fullPath = _path + GetRelPath(fileInfo);
+ bool result;
+ if (fileInfo.IsDirectory())
+ result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
+ else
+ result = NDirectory::DeleteFileAlways(fullPath);
+ if (!result)
+ return GetLastError();
+ UInt64 completed = i;
+ RINOK(progress->SetCompleted(&completed));
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
+ const PROPVARIANT *value, IProgress * /* progress */)
+{
+ if (index >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ CDirItem &fileInfo = *_refs[index];
+ if (fileInfo.Parent->Parent != 0)
+ return E_NOTIMPL;
+ switch(propID)
+ {
+ case kpidComment:
+ {
+ UString filename = fileInfo.Name;
+ filename.Trim();
+ if (value->vt == VT_EMPTY)
+ _comments.DeletePair(filename);
+ else if (value->vt == VT_BSTR)
+ {
+ CTextPair pair;
+ pair.ID = filename;
+ pair.ID.Trim();
+ pair.Value = value->bstrVal;
+ pair.Value.Trim();
+ if (pair.Value.IsEmpty())
+ _comments.DeletePair(filename);
+ else
+ _comments.AddPair(pair);
+ }
+ else
+ return E_INVALIDARG;
+ SaveComments();
+ break;
+ }
+ default:
+ return E_NOTIMPL;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
+{
+ if (index >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ const CDirItem &fileInfo = *_refs[index];
+ *iconIndex = 0;
+ int iconIndexTemp;
+ if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attributes, iconIndexTemp) != 0)
+ {
+ *iconIndex = iconIndexTemp;
+ return S_OK;
+ }
+ return GetLastError();
+}
+
+STDMETHODIMP CFSFolder::SetFlatMode(Int32 flatMode)
+{
+ _flatMode = IntToBool(flatMode);
+ return S_OK;
+}
+
+// static const LPCTSTR kInvalidFileChars = TEXT("\\/:*?\"<>|");
+
diff --git a/CPP/7zip/FileManager/FSFolder.h b/CPP/7zip/FileManager/FSFolder.h
new file mode 100755
index 00000000..4641c018
--- /dev/null
+++ b/CPP/7zip/FileManager/FSFolder.h
@@ -0,0 +1,141 @@
+// FSFolder.h
+
+#ifndef __FSFOLDER_H
+#define __FSFOLDER_H
+
+#include "Common/String.h"
+#include "Common/MyCom.h"
+#include "Windows/FileFind.h"
+#include "Windows/PropVariant.h"
+
+#include "IFolder.h"
+
+#include "TextPairs.h"
+
+class CFSFolder;
+
+struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
+{
+ bool CompressedSizeIsDefined;
+ UInt64 CompressedSize;
+};
+
+struct CDirItem;
+
+struct CDirItem: public CFileInfoEx
+{
+ CDirItem *Parent;
+ CObjectVector<CDirItem> Files;
+
+ CDirItem(): Parent(0) {}
+ void Clear()
+ {
+ Files.Clear();
+ Parent = 0;
+ }
+};
+
+class CFSFolder:
+ public IFolderFolder,
+ public IEnumProperties,
+ public IFolderGetTypeID,
+ public IFolderGetPath,
+ public IFolderWasChanged,
+ public IFolderOperations,
+ // public IFolderOperationsDeleteToRecycleBin,
+ public IFolderGetItemFullSize,
+ public IFolderClone,
+ public IFolderGetSystemIconIndex,
+ public IFolderSetFlatMode,
+ public CMyUnknownImp
+{
+ UInt64 GetSizeOfItem(int anIndex) const;
+public:
+ MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_ENTRY(IEnumProperties)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetTypeID)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetPath)
+ MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
+ // MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin)
+ MY_QUERYINTERFACE_ENTRY(IFolderOperations)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize)
+ MY_QUERYINTERFACE_ENTRY(IFolderClone)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex)
+ MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+
+ STDMETHOD(LoadItems)();
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
+ STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value);
+ STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder);
+ STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder);
+ STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder);
+ STDMETHOD(GetName)(BSTR *name);
+
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
+ STDMETHOD(GetPropertyInfo)(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType);
+ STDMETHOD(GetTypeID)(BSTR *name);
+ STDMETHOD(GetPath)(BSTR *path);
+ STDMETHOD(WasChanged)(INT32 *wasChanged);
+ STDMETHOD(Clone)(IFolderFolder **resultFolder);
+ STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
+
+ STDMETHOD(SetFlatMode)(Int32 flatMode);
+
+ // IFolderOperations
+
+ STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress);
+ STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress);
+ STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress);
+ STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress);
+ STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback);
+ STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback);
+ STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath,
+ const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress);
+ STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress);
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
+
+private:
+ UString _path;
+ CDirItem _root;
+ CRecordVector<CDirItem *> _refs;
+
+ CMyComPtr<IFolderFolder> _parentFolder;
+
+ bool _commentsAreLoaded;
+ CPairsStorage _comments;
+
+ bool _flatMode;
+
+ NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
+
+ HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
+ HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
+ HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
+
+ bool LoadComments();
+ bool SaveComments();
+ HRESULT LoadSubItems(CDirItem &dirItem, const UString &path);
+ void AddRefs(CDirItem &dirItem);
+public:
+ HRESULT Init(const UString &path, IFolderFolder *parentFolder);
+
+ CFSFolder() : _flatMode(false) {}
+
+ UString GetPrefix(const CDirItem &item) const;
+ UString GetRelPath(const CDirItem &item) const;
+ UString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
+
+ void Clear()
+ {
+ _root.Clear();
+ _refs.Clear();
+ }
+};
+
+#endif
diff --git a/CPP/7zip/FileManager/FSFolderCopy.cpp b/CPP/7zip/FileManager/FSFolderCopy.cpp
new file mode 100755
index 00000000..7566c8f2
--- /dev/null
+++ b/CPP/7zip/FileManager/FSFolderCopy.cpp
@@ -0,0 +1,490 @@
+// FSFolderCopy.cpp
+
+#include "StdAfx.h"
+
+#include <Winbase.h>
+
+#include "FSFolder.h"
+#include "Windows/FileDir.h"
+#include "Windows/Error.h"
+
+#include "Common/StringConvert.h"
+
+#include "../Common/FilePathAutoRename.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+/*
+static bool IsItWindows2000orHigher()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
+ (versionInfo.dwMajorVersion >= 5);
+}
+*/
+
+struct CProgressInfo
+{
+ UINT64 StartPos;
+ IProgress *Progress;
+};
+
+static DWORD CALLBACK CopyProgressRoutine(
+ LARGE_INTEGER /* TotalFileSize */, // file size
+ LARGE_INTEGER TotalBytesTransferred, // bytes transferred
+ LARGE_INTEGER /* StreamSize */, // bytes in stream
+ LARGE_INTEGER /* StreamBytesTransferred */, // bytes transferred for stream
+ DWORD /* dwStreamNumber */, // current stream
+ DWORD /* dwCallbackReason */, // callback reason
+ HANDLE /* hSourceFile */, // handle to source file
+ HANDLE /* hDestinationFile */, // handle to destination file
+ LPVOID lpData // from CopyFileEx
+)
+{
+ CProgressInfo &progressInfo = *(CProgressInfo *)lpData;
+ UINT64 completed = progressInfo.StartPos + TotalBytesTransferred.QuadPart;
+ if (progressInfo.Progress->SetCompleted(&completed) != S_OK)
+ return PROGRESS_CANCEL;
+ return PROGRESS_CONTINUE;
+}
+
+typedef BOOL (WINAPI * CopyFileExPointer)(
+ IN LPCSTR lpExistingFileName,
+ IN LPCSTR lpNewFileName,
+ IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
+ IN LPVOID lpData OPTIONAL,
+ IN LPBOOL pbCancel OPTIONAL,
+ IN DWORD dwCopyFlags
+ );
+
+typedef BOOL (WINAPI * CopyFileExPointerW)(
+ IN LPCWSTR lpExistingFileName,
+ IN LPCWSTR lpNewFileName,
+ IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
+ IN LPVOID lpData OPTIONAL,
+ IN LPBOOL pbCancel OPTIONAL,
+ IN DWORD dwCopyFlags
+ );
+
+#ifndef _UNICODE
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static CSysString GetSysPath(LPCWSTR sysPath)
+ { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
+#endif
+
+static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile,
+ IProgress *progress, UINT64 &completedSize)
+{
+ CProgressInfo progressInfo;
+ progressInfo.Progress = progress;
+ progressInfo.StartPos = completedSize;
+ BOOL CancelFlag = FALSE;
+ #ifndef _UNICODE
+ if (g_IsNT)
+ #endif
+ {
+ CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
+ ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"),
+ "CopyFileExW");
+ if (copyFunctionW == 0)
+ return false;
+ if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
+ &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ return true;
+ #ifdef WIN_LONG_PATH
+ UString longPathExisting, longPathNew;
+ if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew))
+ return false;
+ if (copyFunctionW(longPathExisting, longPathNew, CopyProgressRoutine,
+ &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ return true;
+ #endif
+ return false;
+ }
+ #ifndef _UNICODE
+ else
+ {
+ CopyFileExPointer copyFunction = (CopyFileExPointer)
+ ::GetProcAddress(::GetModuleHandleA("kernel32.dll"),
+ "CopyFileExA");
+ if (copyFunction != 0)
+ {
+ if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
+ CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ return true;
+ if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ return false;
+ }
+ return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
+ }
+ #endif
+}
+
+typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
+ IN LPCWSTR lpExistingFileName,
+ IN LPCWSTR lpNewFileName,
+ IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
+ IN LPVOID lpData OPTIONAL,
+ IN DWORD dwFlags
+ );
+
+static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile,
+ IProgress *progress, UINT64 &completedSize)
+{
+ // if (IsItWindows2000orHigher())
+ // {
+ CProgressInfo progressInfo;
+ progressInfo.Progress = progress;
+ progressInfo.StartPos = completedSize;
+
+ MoveFileWithProgressPointer moveFunction = (MoveFileWithProgressPointer)
+ ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
+ "MoveFileWithProgressW");
+ if (moveFunction != 0)
+ {
+ if (moveFunction(
+ existingFile, newFile, CopyProgressRoutine,
+ &progressInfo, MOVEFILE_COPY_ALLOWED))
+ return true;
+ if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ {
+ #ifdef WIN_LONG_PATH
+ UString longPathExisting, longPathNew;
+ if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew))
+ return false;
+ if (moveFunction(longPathExisting, longPathNew, CopyProgressRoutine,
+ &progressInfo, MOVEFILE_COPY_ALLOWED))
+ return true;
+ #endif
+ if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ return false;
+ }
+ }
+ // }
+ // else
+ return NDirectory::MyMoveFile(existingFile, newFile);
+}
+
+static HRESULT MyCopyFile(
+ const UString &srcPath,
+ const CFileInfoW &srcFileInfo,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UINT64 &completedSize)
+{
+ UString destPath = destPathSpec;
+ if (destPath.CompareNoCase(srcPath) == 0)
+ {
+ UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+
+ INT32 writeAskResult;
+ CMyComBSTR destPathResult;
+ RINOK(callback->AskWrite(
+ srcPath,
+ BoolToInt(false),
+ &srcFileInfo.LastWriteTime, &srcFileInfo.Size,
+ destPath,
+ &destPathResult,
+ &writeAskResult));
+ if (IntToBool(writeAskResult))
+ {
+ UString destPathNew = UString(destPathResult);
+ RINOK(callback->SetCurrentFilePath(srcPath));
+ if (!::MyCopyFile(srcPath, destPathNew, callback, completedSize))
+ {
+ UString message = NError::MyFormatMessageW(GetLastError()) +
+ UString(L" \'") +
+ UString(destPathNew) +
+ UString(L"\'");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ }
+ completedSize += srcFileInfo.Size;
+ return callback->SetCompleted(&completedSize);
+}
+
+static HRESULT CopyFolder(
+ const UString &srcPath,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UINT64 &completedSize)
+{
+ RINOK(callback->SetCompleted(&completedSize));
+
+ UString destPath = destPathSpec;
+ int len = srcPath.Length();
+ if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
+ {
+ if (destPath.Length() == len || destPath[len] == L'\\')
+ {
+ UString message = UString(L"can not copy folder \'") +
+ destPath + UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ }
+
+ if (!NDirectory::CreateComplexDirectory(destPath))
+ {
+ UString message = UString(L"can not create folder ") + destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ CEnumeratorW enumerator(srcPath + UString(L"\\*"));
+ CFileInfoEx fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name;
+ const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
+ if (fileInfo.IsDirectory())
+ {
+ RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback)
+{
+ if (numItems == 0)
+ return S_OK;
+ UINT64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ int index = indices[i];
+ if (index >= _refs.Size())
+ return E_INVALIDARG;
+ UINT64 size;
+ RINOK(GetItemFullSize(indices[i], size, callback));
+ totalSize += size;
+ }
+
+ callback->SetTotal(totalSize);
+ UString destPath = path;
+ if (destPath.IsEmpty())
+ return E_INVALIDARG;
+ bool directName = (destPath[destPath.Length() - 1] != L'\\');
+ if (directName)
+ {
+ if (numItems > 1)
+ return E_INVALIDARG;
+ }
+ /*
+ // doesn't work in network
+ else
+ if (!NDirectory::CreateComplexDirectory(destPath)))
+ {
+ DWORD lastError = ::GetLastError();
+ UString message = UString(L"can not create folder ") +
+ destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ */
+
+ UINT64 completedSize = 0;
+ RINOK(callback->SetCompleted(&completedSize));
+ for (i = 0; i < numItems; i++)
+ {
+ const CDirItem &fileInfo = *_refs[indices[i]];
+ UString destPath2 = destPath;
+ if (!directName)
+ destPath2 += fileInfo.Name;
+ UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
+ if (fileInfo.IsDirectory())
+ {
+ RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ return S_OK;
+}
+
+/////////////////////////////////////////////////
+// Move Operations
+
+HRESULT MyMoveFile(
+ const UString &srcPath,
+ const CFileInfoW &srcFileInfo,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UINT64 &completedSize)
+{
+ UString destPath = destPathSpec;
+ if (destPath.CompareNoCase(srcPath) == 0)
+ {
+ UString message = UString(L"can not move file \'")
+ + destPath +
+ UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+
+ INT32 writeAskResult;
+ CMyComBSTR destPathResult;
+ RINOK(callback->AskWrite(
+ srcPath,
+ BoolToInt(false),
+ &srcFileInfo.LastWriteTime, &srcFileInfo.Size,
+ destPath,
+ &destPathResult,
+ &writeAskResult));
+ if (IntToBool(writeAskResult))
+ {
+ UString destPathNew = UString(destPathResult);
+ RINOK(callback->SetCurrentFilePath(srcPath));
+ if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
+ {
+ UString message = UString(L"can not move to file ") + destPathNew;
+ RINOK(callback->ShowMessage(message));
+ }
+ }
+ completedSize += srcFileInfo.Size;
+ RINOK(callback->SetCompleted(&completedSize));
+ return S_OK;
+}
+
+HRESULT MyMoveFolder(
+ const UString &srcPath,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UINT64 &completedSize)
+{
+ UString destPath = destPathSpec;
+ int len = srcPath.Length();
+ if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
+ {
+ if (destPath.Length() == len || destPath[len] == L'\\')
+ {
+ UString message = UString(L"can not move folder \'") +
+ destPath + UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ }
+
+ if (MyMoveFile(srcPath, destPath, callback, completedSize))
+ return S_OK;
+
+ if (!NDirectory::CreateComplexDirectory(destPath))
+ {
+ UString message = UString(L"can not create folder ") + destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ {
+ CEnumeratorW enumerator(srcPath + UString(L"\\*"));
+ CFileInfoEx fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name;
+ const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
+ if (fileInfo.IsDirectory())
+ {
+ RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ }
+ if (!NDirectory::MyRemoveDirectory(srcPath))
+ {
+ UString message = UString(L"can not remove folder") + srcPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::MoveTo(
+ const UInt32 *indices,
+ UInt32 numItems,
+ const wchar_t *path,
+ IFolderOperationsExtractCallback *callback)
+{
+ if (numItems == 0)
+ return S_OK;
+
+ UINT64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ int index = indices[i];
+ if (index >= _refs.Size())
+ return E_INVALIDARG;
+ UINT64 size;
+ RINOK(GetItemFullSize(indices[i], size, callback));
+ totalSize += size;
+ }
+ callback->SetTotal(totalSize);
+
+ UString destPath = path;
+ if (destPath.IsEmpty())
+ return E_INVALIDARG;
+ bool directName = (destPath[destPath.Length() - 1] != L'\\');
+ if (directName)
+ {
+ if (numItems > 1)
+ return E_INVALIDARG;
+ }
+ else
+ if (!NDirectory::CreateComplexDirectory(destPath))
+ {
+ UString message = UString(L"can not create folder ") +
+ destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+
+ UINT64 completedSize = 0;
+ RINOK(callback->SetCompleted(&completedSize));
+ for (i = 0; i < numItems; i++)
+ {
+ const CDirItem &fileInfo = *_refs[indices[i]];
+ UString destPath2 = destPath;
+ if (!directName)
+ destPath2 += fileInfo.Name;
+ UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
+ if (fileInfo.IsDirectory())
+ {
+ RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
+ const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
+
diff --git a/CPP/7zip/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/FileManager/FileFolderPluginOpen.cpp
new file mode 100755
index 00000000..3e3f40ba
--- /dev/null
+++ b/CPP/7zip/FileManager/FileFolderPluginOpen.cpp
@@ -0,0 +1,111 @@
+// FileFolderPluginOpen.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+#include "Windows/Defs.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+#include "Windows/DLL.h"
+
+#include "IFolder.h"
+#include "RegistryAssociations.h"
+#include "RegistryPlugins.h"
+
+#include "OpenCallback.h"
+#include "PluginLoader.h"
+
+using namespace NWindows;
+using namespace NRegistryAssociations;
+
+static int FindPlugin(const CObjectVector<CPluginInfo> &plugins,
+ const UString &pluginName)
+{
+ for (int i = 0; i < plugins.Size(); i++)
+ if (plugins[i].Name.CompareNoCase(pluginName) == 0)
+ return i;
+ return -1;
+}
+
+HRESULT OpenFileFolderPlugin(
+ const UString &path,
+ HMODULE *module,
+ IFolderFolder **resultFolder,
+ HWND parentWindow,
+ bool &encrypted)
+{
+ encrypted = false;
+ CObjectVector<CPluginInfo> plugins;
+ ReadFileFolderPluginInfoList(plugins);
+
+ UString extension;
+ UString name, pureName, dot;
+
+ if(!NFile::NDirectory::GetOnlyName(path, name))
+ return E_FAIL;
+ NFile::NName::SplitNameToPureNameAndExtension(name, pureName, dot, extension);
+
+
+ int slashPos = path.ReverseFind(L'\\');
+ UString dirPrefix;
+ UString fileName;
+ if (slashPos >= 0)
+ {
+ dirPrefix = path.Left(slashPos + 1);
+ fileName = path.Mid(slashPos + 1);
+ }
+ else
+ fileName = path;
+
+ if (!extension.IsEmpty())
+ {
+ CExtInfo extInfo;
+ if (ReadInternalAssociation(extension, extInfo))
+ {
+ for (int i = extInfo.Plugins.Size() - 1; i >= 0; i--)
+ {
+ int pluginIndex = FindPlugin(plugins, extInfo.Plugins[i]);
+ if (pluginIndex >= 0)
+ {
+ const CPluginInfo plugin = plugins[pluginIndex];
+ plugins.Delete(pluginIndex);
+ plugins.Insert(0, plugin);
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < plugins.Size(); i++)
+ {
+ const CPluginInfo &plugin = plugins[i];
+ CPluginLibrary library;
+ CMyComPtr<IFolderManager> folderManager;
+ CMyComPtr<IFolderFolder> folder;
+ HRESULT result = library.LoadAndCreateManager(
+ plugin.FilePath, plugin.ClassID, &folderManager);
+ if (result != S_OK)
+ continue;
+
+ COpenArchiveCallback *openCallbackSpec = new COpenArchiveCallback;
+ CMyComPtr<IProgress> openCallback = openCallbackSpec;
+ openCallbackSpec->PasswordIsDefined = false;
+ openCallbackSpec->ParentWindow = parentWindow;
+ openCallbackSpec->LoadFileInfo(dirPrefix, fileName);
+ result = folderManager->OpenFolderFile(path, &folder, openCallback);
+ if (openCallbackSpec->PasswordWasAsked)
+ encrypted = true;
+ if (result == S_OK)
+ {
+ *module = library.Detach();
+ *resultFolder = folder.Detach();
+ return S_OK;
+ }
+ continue;
+
+ /*
+ if (result != S_FALSE)
+ return result;
+ */
+ }
+ return S_FALSE;
+} \ No newline at end of file
diff --git a/CPP/7zip/FileManager/FileFolderPluginOpen.h b/CPP/7zip/FileManager/FileFolderPluginOpen.h
new file mode 100755
index 00000000..295048a9
--- /dev/null
+++ b/CPP/7zip/FileManager/FileFolderPluginOpen.h
@@ -0,0 +1,9 @@
+// FileFolderPluginOpen.h
+
+#ifndef __FILEFOLDERPLUGINOPEN_H
+#define __FILEFOLDERPLUGINOPEN_H
+
+HRESULT OpenFileFolderPlugin(const UString &path,
+ HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted);
+
+#endif
diff --git a/7zip/FileManager/FilePlugins.cpp b/CPP/7zip/FileManager/FilePlugins.cpp
index 524b6aa7..524b6aa7 100755
--- a/7zip/FileManager/FilePlugins.cpp
+++ b/CPP/7zip/FileManager/FilePlugins.cpp
diff --git a/7zip/FileManager/FilePlugins.h b/CPP/7zip/FileManager/FilePlugins.h
index 805cac2a..805cac2a 100755
--- a/7zip/FileManager/FilePlugins.h
+++ b/CPP/7zip/FileManager/FilePlugins.h
diff --git a/7zip/FileManager/FormatUtils.cpp b/CPP/7zip/FileManager/FormatUtils.cpp
index 553d8bcd..553d8bcd 100755
--- a/7zip/FileManager/FormatUtils.cpp
+++ b/CPP/7zip/FileManager/FormatUtils.cpp
diff --git a/7zip/FileManager/FormatUtils.h b/CPP/7zip/FileManager/FormatUtils.h
index f7e9b193..f7e9b193 100755
--- a/7zip/FileManager/FormatUtils.h
+++ b/CPP/7zip/FileManager/FormatUtils.h
diff --git a/7zip/FileManager/HelpUtils.cpp b/CPP/7zip/FileManager/HelpUtils.cpp
index c2bf49a5..c2bf49a5 100755
--- a/7zip/FileManager/HelpUtils.cpp
+++ b/CPP/7zip/FileManager/HelpUtils.cpp
diff --git a/7zip/FileManager/HelpUtils.h b/CPP/7zip/FileManager/HelpUtils.h
index b993f09b..b993f09b 100755
--- a/7zip/FileManager/HelpUtils.h
+++ b/CPP/7zip/FileManager/HelpUtils.h
diff --git a/7zip/FileManager/IFolder.h b/CPP/7zip/FileManager/IFolder.h
index aa50a39d..aa50a39d 100755
--- a/7zip/FileManager/IFolder.h
+++ b/CPP/7zip/FileManager/IFolder.h
diff --git a/7zip/FileManager/Info.bmp b/CPP/7zip/FileManager/Info.bmp
index d769a661..d769a661 100755
--- a/7zip/FileManager/Info.bmp
+++ b/CPP/7zip/FileManager/Info.bmp
Binary files differ
diff --git a/7zip/FileManager/Info2.bmp b/CPP/7zip/FileManager/Info2.bmp
index af724d27..af724d27 100755
--- a/7zip/FileManager/Info2.bmp
+++ b/CPP/7zip/FileManager/Info2.bmp
Binary files differ
diff --git a/7zip/FileManager/LangUtils.cpp b/CPP/7zip/FileManager/LangUtils.cpp
index decff306..decff306 100755
--- a/7zip/FileManager/LangUtils.cpp
+++ b/CPP/7zip/FileManager/LangUtils.cpp
diff --git a/7zip/FileManager/LangUtils.h b/CPP/7zip/FileManager/LangUtils.h
index 40debdfe..40debdfe 100755
--- a/7zip/FileManager/LangUtils.h
+++ b/CPP/7zip/FileManager/LangUtils.h
diff --git a/7zip/FileManager/Move.bmp b/CPP/7zip/FileManager/Move.bmp
index eb5f20f9..eb5f20f9 100755
--- a/7zip/FileManager/Move.bmp
+++ b/CPP/7zip/FileManager/Move.bmp
Binary files differ
diff --git a/7zip/FileManager/Move2.bmp b/CPP/7zip/FileManager/Move2.bmp
index 58679eff..58679eff 100755
--- a/7zip/FileManager/Move2.bmp
+++ b/CPP/7zip/FileManager/Move2.bmp
Binary files differ
diff --git a/7zip/FileManager/MyCom2.h b/CPP/7zip/FileManager/MyCom2.h
index 756a8169..756a8169 100755
--- a/7zip/FileManager/MyCom2.h
+++ b/CPP/7zip/FileManager/MyCom2.h
diff --git a/CPP/7zip/FileManager/MyLoadMenu.cpp b/CPP/7zip/FileManager/MyLoadMenu.cpp
new file mode 100755
index 00000000..8be1e28f
--- /dev/null
+++ b/CPP/7zip/FileManager/MyLoadMenu.cpp
@@ -0,0 +1,694 @@
+// MyLoadMenu
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/Menu.h"
+#include "Windows/Error.h"
+
+#include "../PropID.h"
+
+#include "resource.h"
+#include "App.h"
+#include "Resource/AboutDialog/AboutDialog.h"
+#include "Resource/BenchmarkDialog/BenchmarkDialog.h"
+
+#include "HelpUtils.h"
+#include "LangUtils.h"
+#include "PluginInterface.h"
+
+static const UINT kOpenBookmarkMenuID = 730;
+static const UINT kSetBookmarkMenuID = 740;
+
+extern HINSTANCE g_hInstance;
+
+static LPCWSTR kFMHelpTopic = L"FM/index.htm";
+
+extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance);
+
+using namespace NWindows;
+
+static const int kFileMenuIndex = 0;
+static const int kViewMenuIndex = 2;
+static const int kBookmarksMenuIndex = kViewMenuIndex + 1;
+
+struct CStringLangPair
+{
+ wchar_t *String;
+ UINT32 LangID;
+};
+
+static CStringLangPair kStringLangPairs[] =
+{
+ { L"&File", 0x03000102 },
+ { L"&Edit", 0x03000103 },
+ { L"&View", 0x03000104 },
+ { L"&Bookmarks", 0x03000107 },
+ { L"&Tools", 0x03000105 },
+ { L"&Help", 0x03000106 },
+};
+
+UINT32 kAddToFavoritesLangID = 0x03000710;
+UINT32 kToolbarsLangID = 0x03000451;
+
+/*
+static int FindStringLangItem(const UString &anItem)
+{
+ for (int i = 0; i < sizeof(kStringLangPairs) /
+ sizeof(kStringLangPairs[0]); i++)
+ if (anItem.CompareNoCase(kStringLangPairs[i].String) == 0)
+ return i;
+ return -1;
+}
+*/
+
+static CIDLangPair kIDLangPairs[] =
+{
+ // File
+ { IDM_FILE_OPEN, 0x03000210 },
+ { IDM_FILE_OPEN_INSIDE, 0x03000211 },
+ { IDM_FILE_OPEN_OUTSIDE, 0x03000212 },
+ { IDM_FILE_VIEW, 0x03000220 },
+ { IDM_FILE_EDIT, 0x03000221 },
+ { IDM_RENAME, 0x03000230 },
+ { IDM_COPY_TO, 0x03000231 },
+ { IDM_MOVE_TO, 0x03000232 },
+ { IDM_DELETE, 0x03000233 },
+ { IDM_FILE_PROPERTIES, 0x03000240 },
+ { IDM_FILE_COMMENT, 0x03000241 },
+ { IDM_FILE_CRC, 0x03000242 },
+ { IDM_FILE_SPLIT, 0x03000270 },
+ { IDM_FILE_COMBINE, 0x03000271 },
+ { IDM_CREATE_FOLDER, 0x03000250 },
+ { IDM_CREATE_FILE, 0x03000251 },
+ { IDCLOSE, 0x03000260 },
+
+ // Edit
+ { IDM_EDIT_CUT, 0x03000320 },
+ { IDM_EDIT_COPY, 0x03000321 },
+ { IDM_EDIT_PASTE, 0x03000322 },
+
+ { IDM_SELECT_ALL, 0x03000330 },
+ { IDM_DESELECT_ALL, 0x03000331 },
+ { IDM_INVERT_SELECTION, 0x03000332 },
+ { IDM_SELECT, 0x03000333 },
+ { IDM_DESELECT, 0x03000334 },
+ { IDM_SELECT_BY_TYPE, 0x03000335 },
+ { IDM_DESELECT_BY_TYPE, 0x03000336 },
+
+ { IDM_VIEW_LARGE_ICONS, 0x03000410 },
+ { IDM_VIEW_SMALL_ICONS, 0x03000411 },
+ { IDM_VIEW_LIST, 0x03000412 },
+ { IDM_VIEW_DETAILS, 0x03000413 },
+
+ { IDM_VIEW_ARANGE_BY_NAME, 0x02000204 },
+ { IDM_VIEW_ARANGE_BY_TYPE, 0x02000214 },
+ { IDM_VIEW_ARANGE_BY_DATE, 0x0200020C },
+ { IDM_VIEW_ARANGE_BY_SIZE, 0x02000207 },
+ { IDM_VIEW_ARANGE_NO_SORT, 0x03000420 },
+
+ { IDM_OPEN_ROOT_FOLDER, 0x03000430 },
+ { IDM_OPEN_PARENT_FOLDER, 0x03000431 },
+ { IDM_FOLDERS_HISTORY, 0x03000432 },
+
+ { IDM_VIEW_REFRESH, 0x03000440 },
+
+ { IDM_VIEW_FLAT_VIEW, 0x03000449 },
+ { IDM_VIEW_TWO_PANELS, 0x03000450 },
+ { IDM_VIEW_ARCHIVE_TOOLBAR, 0x03000460 },
+ { IDM_VIEW_STANDARD_TOOLBAR, 0x03000461 },
+ { IDM_VIEW_TOOLBARS_LARGE_BUTTONS, 0x03000462 },
+ { IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, 0x03000463 },
+
+ { IDM_OPTIONS, 0x03000510 },
+ { IDM_BENCHMARK, 0x03000511 },
+
+ { IDM_HELP_CONTENTS, 0x03000610 },
+ { IDM_ABOUT, 0x03000620 }
+};
+
+
+static int FindLangItem(int ControlID)
+{
+ for (int i = 0; i < sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]); i++)
+ if (kIDLangPairs[i].ControlID == ControlID)
+ return i;
+ return -1;
+}
+
+
+/*
+static bool g_IsNew_fMask = true;
+
+class CInit_fMask
+{
+public:
+ CInit_fMask()
+ {
+ g_IsNew_fMask = false;
+ OSVERSIONINFO vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (::GetVersionEx(&vi))
+ {
+ g_IsNew_fMask = (vi.dwMajorVersion > 4 ||
+ (vi.dwMajorVersion == 4 && vi.dwMinorVersion > 0));
+ }
+ g_IsNew_fMask = false;
+ }
+} g_Init_fMask;
+
+// it's hack for supporting Windows NT
+// constants are from WinUser.h
+
+#if(WINVER < 0x0500)
+#define MIIM_STRING 0x00000040
+#define MIIM_BITMAP 0x00000080
+#define MIIM_FTYPE 0x00000100
+#endif
+
+static UINT Get_fMaskForString()
+{
+ return g_IsNew_fMask ? MIIM_STRING : MIIM_TYPE;
+}
+
+static UINT Get_fMaskForFTypeAndString()
+{
+ return g_IsNew_fMask ? (MIIM_STRING | MIIM_FTYPE) : MIIM_TYPE;
+}
+*/
+
+static UINT Get_fMaskForString()
+{
+ return MIIM_TYPE;
+}
+
+static UINT Get_fMaskForFTypeAndString()
+{
+ return MIIM_TYPE;
+}
+
+
+
+static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
+{
+ CMenu menu;
+ menu.Attach(menuLoc);
+ for (int i = 0; i < menu.GetItemCount(); i++)
+ {
+ CMenuItem item;
+ item.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID;
+ item.fType = MFT_STRING;
+ if (menu.GetItem(i, true, item))
+ {
+ UString newString;
+ if (item.hSubMenu)
+ {
+ if (level == 1 && menuIndex == kBookmarksMenuIndex)
+ newString = LangString(kAddToFavoritesLangID);
+ else
+ {
+ MyChangeMenu(item.hSubMenu, level + 1, i);
+ if (level == 1 && menuIndex == kViewMenuIndex)
+ {
+ newString = LangString(kToolbarsLangID);
+ }
+ else
+ {
+ if (level == 0 && i < sizeof(kStringLangPairs) /
+ sizeof(kStringLangPairs[0]))
+ newString = LangString(kStringLangPairs[i].LangID);
+ else
+ continue;
+ }
+ }
+ if (newString.IsEmpty())
+ continue;
+ }
+ else
+ {
+ int langPos = FindLangItem(item.wID);
+ if (langPos < 0)
+ continue;
+ newString = LangString(kIDLangPairs[langPos].LangID);
+ if (newString.IsEmpty())
+ continue;
+ UString shorcutString = item.StringValue;
+ int tabPos = shorcutString.ReverseFind(wchar_t('\t'));
+ if (tabPos >= 0)
+ newString += shorcutString.Mid(tabPos);
+ }
+ {
+ item.StringValue = newString;
+ item.fMask = Get_fMaskForString();
+ item.fType = MFT_STRING;
+ menu.SetItem(i, true, item);
+ }
+ }
+ }
+}
+
+CMenu g_FileMenu;
+
+class CFileMenuDestroyer
+{
+public:
+ ~CFileMenuDestroyer()
+ {
+ if ((HMENU)g_FileMenu != 0)
+ g_FileMenu.Destroy();
+ }
+} g_FileMenuDestroyer;
+
+
+void MyLoadMenu(HWND hWnd)
+{
+ if ((HMENU)g_FileMenu != 0)
+ g_FileMenu.Destroy();
+ HMENU oldMenu = ::GetMenu(hWnd);
+ HMENU baseMenu = ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU));
+ ::SetMenu(hWnd, baseMenu);
+ ::DestroyMenu(oldMenu);
+ if (!g_LangID.IsEmpty())
+ {
+ HMENU menuOld = ::GetMenu(hWnd);
+ MyChangeMenu(menuOld, 0, 0);
+ }
+ ::DrawMenuBar(hWnd);
+}
+
+extern HWND g_HWND;
+void MyLoadMenu()
+{
+ MyLoadMenu(g_HWND);
+}
+
+static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
+{
+ CMenu srcMenu;
+ srcMenu.Attach(srcMenuSpec);
+ CMenu destMenu;
+ destMenu.Attach(destMenuSpec);
+ int startPos = 0;
+ for (int i = 0; i < srcMenu.GetItemCount(); i++)
+ {
+ CMenuItem item;
+ item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
+ item.fType = MFT_STRING;
+ if (srcMenu.GetItem(i, true, item))
+ if (destMenu.InsertItem(startPos, true, item))
+ startPos++;
+ }
+}
+
+void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
+{
+ if (::GetSubMenu(::GetMenu(g_HWND), position) != hMenu)
+ return;
+ if (position == kFileMenuIndex)
+ {
+ if ((HMENU)g_FileMenu == 0)
+ {
+ g_FileMenu.CreatePopup();
+ CopyMenu(hMenu, g_FileMenu);
+ }
+ CMenu menu;
+ menu.Attach(hMenu);
+ while (menu.GetItemCount() > 0)
+ {
+ if (!menu.RemoveItem(0, MF_BYPOSITION))
+ break;
+ }
+ // CopyMenu(g_FileMenu, hMenu);
+ g_App.GetFocusedPanel().CreateFileMenu(hMenu);
+
+ }
+ else if (position == kViewMenuIndex)
+ {
+ // View;
+ CMenu menu;
+ menu.Attach(hMenu);
+ 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));
+ menu.CheckItem(IDM_VIEW_FLAT_VIEW, MF_BYCOMMAND |
+ ((g_App.GetFlatMode()) ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, MF_BYCOMMAND |
+ (g_App.ShowArchiveToolbar ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_STANDARD_TOOLBAR, MF_BYCOMMAND |
+ (g_App.ShowStandardToolbar ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, MF_BYCOMMAND |
+ (g_App.LargeButtons ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, MF_BYCOMMAND |
+ (g_App.ShowButtonsLables ? MF_CHECKED : MF_UNCHECKED));
+ }
+ else if (position == kBookmarksMenuIndex)
+ {
+ CMenu menu;
+ menu.Attach(hMenu);
+
+ CMenu subMenu;
+ subMenu.Attach(menu.GetSubMenu(0));
+ while (subMenu.GetItemCount() > 0)
+ subMenu.RemoveItem(subMenu.GetItemCount() - 1, MF_BYPOSITION);
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ UString s = LangString(IDS_BOOKMARK, 0x03000720);
+ s += L" ";
+ wchar_t c = (wchar_t)(L'0' + i);
+ s += c;
+ s += L"\tAlt+Shift+";
+ s += c;
+ subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s);
+ }
+
+ while (menu.GetItemCount() > 2)
+ menu.RemoveItem(menu.GetItemCount() - 1, MF_BYPOSITION);
+
+ for (i = 0; i < 10; i++)
+ {
+ UString path = g_App.AppState.FastFolders.GetString(i);
+ const int kMaxSize = 100;
+ const int kFirstPartSize = kMaxSize / 2;
+ if (path.Length() > kMaxSize)
+ {
+ path = path.Left(kFirstPartSize) + UString(L" ... ") +
+ path.Right(kMaxSize - kFirstPartSize);
+ }
+ UString s = path;
+ if (s.IsEmpty())
+ s = L"-";
+ s += L"\tAlt+";
+ s += (wchar_t)(L'0' + i);
+ menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
+ }
+ }
+}
+
+/*
+It doesn't help
+void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id)
+{
+ if (::GetSubMenu(::GetMenu(g_HWND), 0) != hMenu)
+ return;
+ // g_App.GetFocusedPanel()._contextMenu.Release();
+}
+
+void OnMenuUnActivating(HWND hWnd)
+{
+}
+*/
+
+
+void LoadFileMenu(HMENU hMenu, int startPos, bool /* forFileMode */, bool programMenu)
+{
+ {
+ CMenu srcMenu;
+ srcMenu.Attach(::GetSubMenu(::GetMenu(g_HWND), 0));
+ if ((HMENU)g_FileMenu == 0)
+ {
+ g_FileMenu.CreatePopup();
+ CopyMenu(srcMenu, g_FileMenu);
+ }
+ }
+
+ CMenu destMenu;
+ destMenu.Attach(hMenu);
+
+ for (int i = 0; i < g_FileMenu.GetItemCount(); i++)
+ {
+ CMenuItem item;
+
+ item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
+ item.fType = MFT_STRING;
+ if (g_FileMenu.GetItem(i, true, item))
+ {
+ if (!programMenu)
+ if (item.wID == IDCLOSE)
+ continue;
+ /*
+ bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE);
+ if (forFileMode)
+ {
+ if (createItem)
+ continue;
+ }
+ else
+ {
+ if (!createItem)
+ continue;
+ }
+ */
+ if (destMenu.InsertItem(startPos, true, item))
+ startPos++;
+ }
+ }
+ while (destMenu.GetItemCount() > 0)
+ {
+ CMenuItem item;
+ item.fMask = MIIM_TYPE;
+ item.fType = 0;
+ // item.dwTypeData = 0;
+ int lastIndex = destMenu.GetItemCount() - 1;
+ if (!destMenu.GetItem(lastIndex, true, item))
+ break;
+ if(item.fType != MFT_SEPARATOR)
+ break;
+ if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION))
+ break;
+ }
+}
+
+bool ExecuteFileCommand(int id)
+{
+ if (id >= kPluginMenuStartID)
+ {
+ g_App.GetFocusedPanel().InvokePluginCommand(id);
+ g_App.GetFocusedPanel()._sevenZipContextMenu.Release();
+ g_App.GetFocusedPanel()._systemContextMenu.Release();
+ return true;
+ }
+
+ switch (id)
+ {
+ // File
+ case IDM_FILE_OPEN:
+ g_App.OpenItem();
+ break;
+ case IDM_FILE_OPEN_INSIDE:
+ g_App.OpenItemInside();
+ break;
+ case IDM_FILE_OPEN_OUTSIDE:
+ g_App.OpenItemOutside();
+ break;
+ case IDM_FILE_VIEW:
+ break;
+ case IDM_FILE_EDIT:
+ g_App.EditItem();
+ break;
+ case IDM_RENAME:
+ g_App.Rename();
+ break;
+ case IDM_COPY_TO:
+ g_App.CopyTo();
+ break;
+ case IDM_MOVE_TO:
+ g_App.MoveTo();
+ break;
+ case IDM_DELETE:
+ {
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ g_App.Delete(!shift);
+ break;
+ }
+ case IDM_FILE_CRC:
+ g_App.CalculateCrc();
+ break;
+ case IDM_FILE_SPLIT:
+ g_App.Split();
+ break;
+ case IDM_FILE_COMBINE:
+ g_App.Combine();
+ break;
+ case IDM_FILE_PROPERTIES:
+ g_App.Properties();
+ break;
+ case IDM_FILE_COMMENT:
+ g_App.Comment();
+ break;
+
+ case IDM_CREATE_FOLDER:
+ g_App.CreateFolder();
+ break;
+ case IDM_CREATE_FILE:
+ g_App.CreateFile();
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+bool OnMenuCommand(HWND hWnd, int id)
+{
+ if (ExecuteFileCommand(id))
+ return true;
+
+ switch (id)
+ {
+ // File
+ case IDCLOSE:
+ SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
+ SendMessage (hWnd, WM_CLOSE, 0, 0);
+ break;
+
+ // Edit
+ case IDM_EDIT_COPY:
+ g_App.EditCopy();
+ break;
+ case IDM_EDIT_PASTE:
+ g_App.EditPaste();
+ break;
+ case IDM_SELECT_ALL:
+ g_App.SelectAll(true);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_DESELECT_ALL:
+ g_App.SelectAll(false);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_INVERT_SELECTION:
+ g_App.InvertSelection();
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_SELECT:
+ g_App.SelectSpec(true);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_DESELECT:
+ g_App.SelectSpec(false);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_SELECT_BY_TYPE:
+ g_App.SelectByType(true);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_DESELECT_BY_TYPE:
+ g_App.SelectByType(false);
+ g_App.RefreshStatusBar();
+ break;
+
+ //View
+ case IDM_VIEW_LARGE_ICONS:
+ case IDM_VIEW_SMALL_ICONS:
+ case IDM_VIEW_LIST:
+ case IDM_VIEW_DETAILS:
+ {
+ UINT index = id - IDM_VIEW_LARGE_ICONS;
+ if (index < 4)
+ {
+ g_App.SetListViewMode(index);
+ /*
+ CMenu menu;
+ menu.Attach(::GetSubMenu(::GetMenu(hWnd), kViewMenuIndex));
+ menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
+ id, MF_BYCOMMAND);
+ */
+ }
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_NAME:
+ {
+ g_App.SortItemsWithPropID(kpidName);
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_TYPE:
+ {
+ g_App.SortItemsWithPropID(kpidExtension);
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_DATE:
+ {
+ g_App.SortItemsWithPropID(kpidLastWriteTime);
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_SIZE:
+ {
+ g_App.SortItemsWithPropID(kpidSize);
+ break;
+ }
+ case IDM_VIEW_ARANGE_NO_SORT:
+ {
+ g_App.SortItemsWithPropID(kpidNoProperty);
+ break;
+ }
+
+ case IDM_OPEN_ROOT_FOLDER:
+ g_App.OpenRootFolder();
+ break;
+ case IDM_OPEN_PARENT_FOLDER:
+ g_App.OpenParentFolder();
+ break;
+ case IDM_FOLDERS_HISTORY:
+ g_App.FoldersHistory();
+ break;
+ case IDM_VIEW_REFRESH:
+ g_App.RefreshView();
+ break;
+ case IDM_VIEW_FLAT_VIEW:
+ g_App.ChangeFlatMode();
+ break;
+ case IDM_VIEW_TWO_PANELS:
+ g_App.SwitchOnOffOnePanel();
+ break;
+ case IDM_VIEW_STANDARD_TOOLBAR:
+ g_App.SwitchStandardToolbar();
+ break;
+ case IDM_VIEW_ARCHIVE_TOOLBAR:
+ g_App.SwitchArchiveToolbar();
+ break;
+ case IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT:
+ g_App.SwitchButtonsLables();
+ break;
+ case IDM_VIEW_TOOLBARS_LARGE_BUTTONS:
+ g_App.SwitchLargeButtons();
+ break;
+
+ // Tools
+ case IDM_OPTIONS:
+ OptionsDialog(hWnd, g_hInstance);
+ break;
+
+ case IDM_BENCHMARK:
+ Benchmark(hWnd);
+ break;
+ // Help
+ case IDM_HELP_CONTENTS:
+ ShowHelpWindow(NULL, kFMHelpTopic);
+ break;
+ case IDM_ABOUT:
+ {
+ CAboutDialog dialog;
+ dialog.Create(hWnd);
+ break;
+ }
+ default:
+ {
+ if (id >= kOpenBookmarkMenuID && id <= kOpenBookmarkMenuID + 9)
+ {
+ g_App.OpenBookmark(id - kOpenBookmarkMenuID);
+ return true;
+ }
+ else if (id >= kSetBookmarkMenuID && id <= kSetBookmarkMenuID + 9)
+ {
+ g_App.SetBookmark(id - kSetBookmarkMenuID);
+ return true;
+ }
+ return false;
+ }
+ }
+ return true;
+}
+
diff --git a/7zip/FileManager/MyLoadMenu.h b/CPP/7zip/FileManager/MyLoadMenu.h
index 490dc6d8..490dc6d8 100755
--- a/7zip/FileManager/MyLoadMenu.h
+++ b/CPP/7zip/FileManager/MyLoadMenu.h
diff --git a/7zip/FileManager/NetFolder.cpp b/CPP/7zip/FileManager/NetFolder.cpp
index a5cd379a..a5cd379a 100755
--- a/7zip/FileManager/NetFolder.cpp
+++ b/CPP/7zip/FileManager/NetFolder.cpp
diff --git a/7zip/FileManager/NetFolder.h b/CPP/7zip/FileManager/NetFolder.h
index f23c7e4e..f23c7e4e 100755
--- a/7zip/FileManager/NetFolder.h
+++ b/CPP/7zip/FileManager/NetFolder.h
diff --git a/CPP/7zip/FileManager/OpenCallback.cpp b/CPP/7zip/FileManager/OpenCallback.cpp
new file mode 100755
index 00000000..a69de62c
--- /dev/null
+++ b/CPP/7zip/FileManager/OpenCallback.cpp
@@ -0,0 +1,113 @@
+// OpenCallback.cpp
+
+#include "StdAfx.h"
+
+#include "OpenCallback.h"
+
+#include "Common/StringConvert.h"
+#include "Resource/PasswordDialog/PasswordDialog.h"
+#include "Windows/PropVariant.h"
+#include "../Common/FileStreams.h"
+
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 * /* numFiles */, const UINT64 * /* numBytes */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 * /* numFiles */, const UINT64 * /* numBytes */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 /* total */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 * /* completed */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant propVariant;
+ if (_subArchiveMode)
+ {
+ switch(propID)
+ {
+ case kpidName:
+ propVariant = _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;
+ }
+ propVariant.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
+ IInStream **inStream)
+{
+ *inStream = NULL;
+ if (_subArchiveMode)
+ return S_FALSE;
+
+ NWindows::NFile::NFind::CFileInfoW fileInfo;
+
+ UString fullPath = _folderPrefix + name;
+ if (!NWindows::NFile::NFind::FindFile(fullPath, fileInfo))
+ return S_FALSE;
+ _fileInfo = fileInfo;
+ if (_fileInfo.IsDirectory())
+ return S_FALSE;
+ CInFileStream *inFile = new CInFileStream;
+ CMyComPtr<IInStream> inStreamTemp = inFile;
+ if (!inFile->Open(fullPath))
+ return ::GetLastError();
+ *inStream = inStreamTemp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::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;
+}
diff --git a/CPP/7zip/FileManager/OpenCallback.h b/CPP/7zip/FileManager/OpenCallback.h
new file mode 100755
index 00000000..853c0e44
--- /dev/null
+++ b/CPP/7zip/FileManager/OpenCallback.h
@@ -0,0 +1,85 @@
+// OpenCallback.h
+
+#ifndef __OPENCALLBACK_H
+#define __OPENCALLBACK_H
+
+#include "Common/String.h"
+#include "Common/MyCom.h"
+#include "Windows/FileFind.h"
+
+#include "../IPassword.h"
+
+#include "../Archive/IArchive.h"
+
+class COpenArchiveCallback:
+ public IArchiveOpenCallback,
+ public IArchiveOpenVolumeCallback,
+ public IArchiveOpenSetSubArchiveName,
+ public IProgress,
+ public ICryptoGetTextPassword,
+ public CMyUnknownImp
+{
+ UString _folderPrefix;
+ NWindows::NFile::NFind::CFileInfoW _fileInfo;
+public:
+ bool PasswordIsDefined;
+ UString Password;
+ bool PasswordWasAsked;
+ HWND ParentWindow;
+
+ bool _subArchiveMode;
+ UString _subArchiveName;
+
+public:
+ MY_UNKNOWN_IMP5(
+ IArchiveOpenCallback,
+ IArchiveOpenVolumeCallback,
+ IArchiveOpenSetSubArchiveName,
+ 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);
+
+ // ICryptoGetTextPassword
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+
+ STDMETHOD(SetSubArchiveName(const wchar_t *name))
+ {
+ _subArchiveMode = true;
+ _subArchiveName = name;
+ return S_OK;
+ }
+
+ COpenArchiveCallback()
+ {
+ _subArchiveMode = false;
+ PasswordIsDefined = false;
+ PasswordWasAsked = false;
+ }
+ /*
+ void Init()
+ {
+ PasswordIsDefined = false;
+ _subArchiveMode = false;
+ }
+ */
+ void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
+ {
+ _folderPrefix = folderPrefix;
+ if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo))
+ throw 1;
+ }
+ void ShowMessage(const UINT64 *completed);
+};
+
+#endif
diff --git a/7zip/FileManager/OptionsDialog.cpp b/CPP/7zip/FileManager/OptionsDialog.cpp
index 7413bafc..7413bafc 100755
--- a/7zip/FileManager/OptionsDialog.cpp
+++ b/CPP/7zip/FileManager/OptionsDialog.cpp
diff --git a/CPP/7zip/FileManager/Panel.cpp b/CPP/7zip/FileManager/Panel.cpp
new file mode 100755
index 00000000..fcc33edf
--- /dev/null
+++ b/CPP/7zip/FileManager/Panel.cpp
@@ -0,0 +1,856 @@
+// Panel.cpp
+
+#include "StdAfx.h"
+
+#include <Windowsx.h>
+
+#include "Common/Defs.h"
+#include "Common/StringConvert.h"
+#include "Windows/Error.h"
+#include "Windows/PropVariant.h"
+
+#include "../PropID.h"
+
+#include "Panel.h"
+#include "RootFolder.h"
+#include "FSFolder.h"
+#include "FormatUtils.h"
+#include "App.h"
+
+#include "../UI/Common/CompressCall.h"
+#include "../UI/Common/ArchiveName.h"
+
+using namespace NWindows;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+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;
+// static const UINT kFileChangeNotifyMessage = WM_APP;
+
+extern HINSTANCE g_hInstance;
+extern DWORD g_ComCtl32Version;
+
+void CPanel::Release()
+{
+ // It's for unloading COM dll's: don't change it.
+ CloseOpenFolders();
+ _sevenZipContextMenu.Release();
+ _systemContextMenu.Release();
+}
+
+CPanel::~CPanel()
+{
+ CloseOpenFolders();
+}
+
+static LPCWSTR kClassName = L"7-Zip::Panel";
+
+
+LRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
+ const UString &currentFolderPrefix, CPanelCallback *panelCallback, CAppState *appState,
+ bool &archiveIsOpened, bool &encrypted)
+{
+ _mainWindow = mainWindow;
+ _processTimer = true;
+ _processNotify = true;
+
+ _panelCallback = panelCallback;
+ _appState = appState;
+ // _index = index;
+ _baseID = id;
+ _comboBoxID = _baseID + 3;
+ _statusBarID = _comboBoxID + 1;
+
+ UString cfp = currentFolderPrefix;
+
+ if (!currentFolderPrefix.IsEmpty())
+ if (currentFolderPrefix[0] == L'.')
+ if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp))
+ cfp = currentFolderPrefix;
+ BindToPath(cfp, archiveIsOpened, encrypted);
+
+ 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;
+}
+
+LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message)
+ {
+ case kShiftSelectMessage:
+ OnShiftSelectMessage();
+ return 0;
+ case kReLoadMessage:
+ RefreshListCtrl(_selectedState);
+ return 0;
+ case kSetFocusToListView:
+ _listView.SetFocus();
+ return 0;
+ case kOpenItemChanged:
+ return OnOpenItemChanged(lParam);
+ case kRefreshStatusBar:
+ OnRefreshStatusBar();
+ return 0;
+ case WM_TIMER:
+ OnTimer();
+ return 0;
+ case WM_CONTEXTMENU:
+ if (OnContextMenu(HANDLE(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))
+ return 0;
+ break;
+ /*
+ case WM_DROPFILES:
+ CompressDropFiles(HDROP(wParam));
+ return 0;
+ */
+ }
+ return CWindow2::OnMessage(message, wParam, 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)
+{
+ if (message == WM_CHAR)
+ {
+ UINT scanCode = (UINT)((lParam >> 16) & 0xFF);
+ bool extended = ((lParam & 0x1000000) != 0);
+ UINT virtualKey = MapVirtualKey(scanCode, 1);
+ if (virtualKey == VK_MULTIPLY || virtualKey == VK_ADD ||
+ virtualKey == VK_SUBTRACT)
+ return 0;
+ if ((wParam == '/' && extended)
+ || wParam == '\\' || wParam == '/')
+ {
+ _panel->OpenDrivesFolder();
+ return 0;
+ }
+ }
+ else if (message == WM_SYSCHAR)
+ {
+ // For Alt+Enter Beep disabling
+ UINT scanCode = (UINT)(lParam >> 16) & 0xFF;
+ UINT virtualKey = MapVirtualKey(scanCode, 1);
+ if (virtualKey == VK_RETURN || virtualKey == VK_MULTIPLY ||
+ virtualKey == VK_ADD || virtualKey == VK_SUBTRACT)
+ return 0;
+ }
+ /*
+ else if (message == WM_SYSKEYDOWN)
+ {
+ // return 0;
+ }
+ */
+ else if (message == WM_KEYDOWN)
+ {
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
+ // bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ switch(wParam)
+ {
+ case VK_RETURN:
+ {
+ if (shift && !alt && !ctrl)
+ {
+ _panel->OpenSelectedItems(false);
+ return 0;
+ }
+ break;
+ }
+ case VK_NEXT:
+ {
+ if (ctrl && !alt && !shift)
+ {
+ _panel->OpenFocusedItemAsInternal();
+ return 0;
+ }
+ break;
+ }
+ case VK_PRIOR:
+ if (ctrl && !alt && !shift)
+ {
+ _panel->OpenParentFolder();
+ return 0;
+ }
+ }
+ }
+ else if (message == WM_SETFOCUS)
+ {
+ _panel->_lastFocusedIsList = true;
+ _panel->_panelCallback->PanelWasFocused();
+ }
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ else
+ #endif
+ return CallWindowProc(_origWindowProc, *this, message, wParam, 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);
+}
+*/
+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:
+ {
+ // check ALT
+ if ((lParam & (1<<29)) == 0)
+ break;
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ if (alt && !ctrl && !shift)
+ {
+ _panel->_panelCallback->SetFocusToPath(wParam == VK_F1 ? 0 : 1);
+ return 0;
+ }
+ break;
+ }
+ }
+ break;
+ case WM_KEYDOWN:
+ switch (wParam)
+ {
+ case VK_TAB:
+ // SendMessage(hwndMain, WM_ENTER, 0, 0);
+ _panel->SetFocusToList();
+ return 0;
+ case VK_F9:
+ {
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ if (!alt && !ctrl && !shift)
+ {
+ g_App.SwitchOnOffOnePanel();;
+ return 0;
+ }
+ break;
+ }
+ }
+ break;
+ case WM_CHAR:
+ switch (wParam)
+ {
+ case VK_TAB:
+ case VK_ESCAPE:
+ return 0;
+ }
+ }
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ else
+ #endif
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+}
+
+bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
+{
+ // _virtualMode = false;
+ // _sortIndex = 0;
+ _sortID = kpidName;
+ _ascending = true;
+ _lastFocusedIsList = true;
+
+ DWORD style = WS_CHILD | WS_VISIBLE; // | WS_BORDER ; // | LVS_SHAREIMAGELISTS; // | LVS_SHOWSELALWAYS;;
+
+ style |= LVS_SHAREIMAGELISTS;
+ // style |= LVS_AUTOARRANGE;
+ style |= WS_CLIPCHILDREN;
+ style |= WS_CLIPSIBLINGS;
+
+ const UINT32 kNumListModes = sizeof(kStyles) / sizeof(kStyles[0]);
+ if (_ListViewMode >= kNumListModes)
+ _ListViewMode = kNumListModes - 1;
+
+ style |= kStyles[_ListViewMode]
+ | WS_TABSTOP
+ | LVS_EDITLABELS;
+ if (_mySelectMode)
+ style |= LVS_SINGLESEL;
+
+ /*
+ if (_virtualMode)
+ style |= LVS_OWNERDATA;
+ */
+
+ DWORD exStyle;
+ exStyle = WS_EX_CLIENTEDGE;
+
+ if (!_listView.CreateEx(exStyle, style, 0, 0, 116, 260,
+ HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL))
+ return false;
+
+ _listView.SetUnicodeFormat(true);
+
+ _listView.SetUserDataLongPtr(LONG_PTR(&_listView));
+ _listView._panel = this;
+
+ #ifndef _UNICODE
+ if(g_IsNT)
+ _listView._origWindowProc =
+ (WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
+ else
+ #endif
+ _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);
+
+ // _exStyle |= LVS_EX_HEADERDRAGDROP;
+ // DWORD extendedStyle = _listView.GetExtendedListViewStyle();
+ // extendedStyle |= _exStyle;
+ // _listView.SetExtendedListViewStyle(extendedStyle);
+ SetExtendedStyle();
+
+ _listView.Show(SW_SHOW);
+ _listView.InvalidateRect(NULL, true);
+ _listView.Update();
+
+ // Ensure that the common control DLL is loaded.
+ INITCOMMONCONTROLSEX icex;
+
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ TBBUTTON tbb [ ] =
+ {
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ // {VIEW_NEWFOLDER, kCreateFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ };
+
+ if (g_ComCtl32Version >= MAKELONG(71, 4))
+ {
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ _headerReBar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
+ REBARCLASSNAME,
+ NULL, WS_VISIBLE | WS_BORDER | WS_CHILD |
+ WS_CLIPCHILDREN | WS_CLIPSIBLINGS
+ | CCS_NODIVIDER
+ | CCS_NOPARENTALIGN
+ | CCS_TOP
+ | RBS_VARHEIGHT
+ | RBS_BANDBORDERS
+ ,0,0,0,0, HWND(*this), NULL, g_hInstance, NULL));
+ }
+
+ DWORD toolbarStyle = WS_CHILD | WS_VISIBLE ;
+ if (_headerReBar)
+ {
+ toolbarStyle |= 0
+ // | WS_CLIPCHILDREN
+ // | WS_CLIPSIBLINGS
+
+ | TBSTYLE_TOOLTIPS
+ | CCS_NODIVIDER
+ | CCS_NORESIZE
+ | TBSTYLE_FLAT
+ ;
+ }
+
+ _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);
+ icex.dwICC = ICC_USEREX_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
+ WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
+ 0, 0, 100, 20,
+ ((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
+ (HMENU)(UINT_PTR)(_comboBoxID),
+ g_hInstance, NULL);
+ // _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
+
+ _headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
+
+ /*
+ _headerComboBox.SetUserDataLongPtr(LONG_PTR(&_headerComboBox));
+ _headerComboBox._panel = this;
+ _headerComboBox._origWindowProc =
+ (WNDPROC)_headerComboBox.SetLongPtr(GWLP_WNDPROC,
+ LONG_PTR(ComboBoxSubclassProc));
+ */
+ _comboBoxEdit.Attach(_headerComboBox.GetEditControl());
+
+ // _comboBoxEdit.SendMessage(CCM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
+ _comboBoxEdit.SetUserDataLongPtr(LONG_PTR(&_comboBoxEdit));
+ _comboBoxEdit._panel = this;
+ #ifndef _UNICODE
+ if(g_IsNT)
+ _comboBoxEdit._origWindowProc =
+ (WNDPROC)_comboBoxEdit.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
+ else
+ #endif
+ _comboBoxEdit._origWindowProc =
+ (WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
+
+
+
+ if (_headerReBar)
+ {
+ REBARINFO rbi;
+ rbi.cbSize = sizeof(REBARINFO); // Required when using this struct.
+ rbi.fMask = 0;
+ 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);
+ SIZE size;
+ _headerToolBar.GetMaxSize(&size);
+
+ REBARBANDINFO rbBand;
+ rbBand.cbSize = sizeof(REBARBANDINFO); // Required
+ rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
+ rbBand.fStyle = RBBS_NOGRIPPER;
+ rbBand.cxMinChild = size.cx;
+ rbBand.cyMinChild = size.cy;
+ rbBand.cyChild = size.cy;
+ rbBand.cx = size.cx;
+ rbBand.hwndChild = _headerToolBar;
+ _headerReBar.InsertBand(-1, &rbBand);
+
+ RECT rc;
+ ::GetWindowRect(_headerComboBox, &rc);
+ rbBand.cxMinChild = 30;
+ rbBand.cyMinChild = rc.bottom - rc.top;
+ rbBand.cx = 1000;
+ rbBand.hwndChild = _headerComboBox;
+ _headerReBar.InsertBand(-1, &rbBand);
+ // _headerReBar.MaximizeBand(1, false);
+ }
+
+ _statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
+ // _statusBar2.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID + 1);
+
+ int sizes[] = {150, 200, 250, -1};
+ _statusBar.SetParts(4, sizes);
+ // _statusBar2.SetParts(5, sizes);
+
+ /*
+ RECT rect;
+ GetClientRect(&rect);
+ OnSize(0, rect.right - rect.left, rect.top - rect.bottom);
+ */
+
+ SetTimer(kTimerID, kTimerElapse);
+
+ // InitListCtrl();
+ RefreshListCtrl();
+ RefreshStatusBar();
+
+ return true;
+}
+
+void CPanel::OnDestroy()
+{
+ SaveListViewInfo();
+ CWindow2::OnDestroy();
+}
+
+void CPanel::ChangeWindowSize(int xSize, int ySize)
+{
+ int kHeaderSize;
+ int kStatusBarSize;
+ // int kStatusBar2Size;
+ RECT rect;
+ if (_headerReBar)
+ _headerReBar.GetWindowRect(&rect);
+ else
+ _headerToolBar.GetWindowRect(&rect);
+
+ kHeaderSize = rect.bottom - rect.top;
+
+ _statusBar.GetWindowRect(&rect);
+ kStatusBarSize = rect.bottom - rect.top;
+
+ // _statusBar2.GetWindowRect(&rect);
+ // kStatusBar2Size = rect.bottom - rect.top;
+
+ int yListViewSize = MyMax(ySize - kHeaderSize - kStatusBarSize, 0);
+ const int kStartXPos = 32;
+ if (_headerReBar)
+ {
+ }
+ else
+ {
+ _headerToolBar.Move(0, 0, xSize, 0);
+ _headerComboBox.Move(kStartXPos, 2,
+ MyMax(xSize - kStartXPos - 10, kStartXPos), 0);
+ }
+ _listView.Move(0, kHeaderSize, xSize, yListViewSize);
+ _statusBar.Move(0, kHeaderSize + yListViewSize, xSize, kStatusBarSize);
+ // _statusBar2.MoveWindow(0, kHeaderSize + yListViewSize + kStatusBarSize, xSize, kStatusBar2Size);
+ // _statusBar.MoveWindow(0, 100, xSize, kStatusBarSize);
+ // _statusBar2.MoveWindow(0, 200, xSize, kStatusBar2Size);
+}
+
+bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
+{
+ if (_headerReBar)
+ _headerReBar.Move(0, 0, xSize, 0);
+ ChangeWindowSize(xSize, ySize);
+ return true;
+}
+
+bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */)
+{
+ switch(header->code)
+ {
+ case RBN_HEIGHTCHANGE:
+ {
+ RECT rect;
+ GetWindowRect(&rect);
+ ChangeWindowSize(rect.right - rect.left, rect.bottom - rect.top);
+ return false;
+ }
+ }
+ return false;
+}
+
+bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
+{
+ if (!_processNotify)
+ return false;
+ if (header->hwndFrom == _headerComboBox)
+ return OnNotifyComboBox(header, result);
+ else if (header->hwndFrom == _headerReBar)
+ return OnNotifyReBar(header, result);
+ // if (header->hwndFrom == _listView)
+ else if (header->hwndFrom == _listView)
+ return OnNotifyList(header, result);
+ else if (::GetParent(header->hwndFrom) == _listView &&
+ header->code == NM_RCLICK)
+ return OnRightClick((LPNMITEMACTIVATE)header, result);
+ return false;
+}
+
+bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result)
+{
+ if (itemID == kParentFolderID)
+ {
+ OpenParentFolder();
+ result = 0;
+ return true;
+ }
+ /*
+ if (itemID == kCreateFolderID)
+ {
+ CreateFolder();
+ result = 0;
+ return true;
+ }
+ */
+ if (itemID == _comboBoxID)
+ {
+ OnComboBoxCommand(code, lParam);
+ }
+ return CWindow2::OnCommand(code, itemID, lParam, result);
+}
+
+void CPanel::MessageBoxInfo(LPCWSTR message, LPCWSTR caption)
+ { ::MessageBoxW(HWND(*this), message, caption, MB_OK); }
+void CPanel::MessageBox(LPCWSTR message, LPCWSTR caption)
+ { ::MessageBoxW(HWND(*this), message, caption, MB_OK | MB_ICONSTOP); }
+void CPanel::MessageBox(LPCWSTR message)
+ { MessageBox(message, L"7-Zip"); }
+void CPanel::MessageBoxMyError(LPCWSTR message)
+ { MessageBox(message, L"Error"); }
+void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption)
+ { MessageBox(NError::MyFormatMessageW(errorCode), caption); }
+void CPanel::MessageBoxError(HRESULT errorCode)
+ { MessageBoxError(errorCode, L"7-Zip"); }
+void CPanel::MessageBoxLastError(LPCWSTR caption)
+ { MessageBoxError(::GetLastError(), caption); }
+void CPanel::MessageBoxLastError()
+ { MessageBoxLastError(L"Error"); }
+
+void CPanel::SetFocusToList()
+{
+ _listView.SetFocus();
+ // SetCurrentPathText();
+}
+
+void CPanel::SetFocusToLastRememberedItem()
+{
+ if (_lastFocusedIsList)
+ SetFocusToList();
+ else
+ _headerComboBox.SetFocus();
+}
+
+UString CPanel::GetFolderTypeID() const
+{
+ CMyComPtr<IFolderGetTypeID> folderGetTypeID;
+ if(_folder.QueryInterface(IID_IFolderGetTypeID, &folderGetTypeID) != S_OK)
+ return L"";
+ CMyComBSTR typeID;
+ folderGetTypeID->GetTypeID(&typeID);
+ return (wchar_t *)typeID;
+}
+
+bool CPanel::IsRootFolder() const
+{
+ return (GetFolderTypeID() == L"RootFolder");
+}
+
+bool CPanel::IsFSFolder() const
+{
+ return (GetFolderTypeID() == L"FSFolder");
+}
+
+bool CPanel::IsFSDrivesFolder() const
+{
+ return (GetFolderTypeID() == L"FSDrives");
+}
+
+UString CPanel::GetFsPath() const
+{
+ if (IsFSDrivesFolder())
+ return UString();
+ return _currentFolderPrefix;
+}
+
+UString CPanel::GetDriveOrNetworkPrefix() const
+{
+ if (!IsFSFolder())
+ return UString();
+ UString drive = GetFsPath();
+ if (drive.Length() < 3)
+ return UString();
+ if (drive[0] == L'\\' && drive[1] == L'\\')
+ {
+ // if network
+ int pos = drive.Find(L'\\', 2);
+ if (pos < 0)
+ return UString();
+ pos = drive.Find(L'\\', pos + 1);
+ if (pos < 0)
+ return UString();
+ return drive.Left(pos + 1);
+ }
+ if (drive[1] != L':' || drive[2] != L'\\')
+ return UString();
+ return drive.Left(3);
+}
+
+bool CPanel::DoesItSupportOperations() const
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ return _folder.QueryInterface(IID_IFolderOperations, &folderOperations) == S_OK;
+}
+
+void CPanel::SetListViewMode(UINT32 index)
+{
+ if (index >= 4)
+ return;
+ _ListViewMode = index;
+ DWORD oldStyle = (DWORD)_listView.GetStyle();
+ DWORD newStyle = kStyles[index];
+ if ((oldStyle & LVS_TYPEMASK) != newStyle)
+ _listView.SetStyle((oldStyle & ~LVS_TYPEMASK) | newStyle);
+ // RefreshListCtrlSaveFocused();
+}
+
+void CPanel::ChangeFlatMode()
+{
+ _flatMode = !_flatMode;
+ RefreshListCtrlSaveFocused();
+}
+
+
+void CPanel::RefreshStatusBar()
+{
+ PostMessage(kRefreshStatusBar);
+}
+
+void CPanel::AddToArchive()
+{
+ CRecordVector<UINT32> indices;
+ GetOperatedItemIndices(indices);
+ if (!IsFSFolder())
+ {
+ MessageBox(L"Compress operation is not supported for that folder");
+ return;
+ }
+ if (indices.Size() == 0)
+ {
+ MessageBox(kSelectFiles);
+ return;
+ }
+ UStringVector names;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ int index = indices[i];
+ names.Add(_currentFolderPrefix + GetItemRelPath(index));
+ }
+ const UString archiveName = CreateArchiveName(
+ names.Front(), (names.Size() > 1), false);
+ HRESULT res = CompressFiles(_currentFolderPrefix, archiveName, L"", names, false, true, false);
+ if (res != S_OK)
+ {
+ if (_currentFolderPrefix.Length() >= MAX_PATH)
+ MessageBox(L"Can't call this operation for file with long path");
+ else
+ MessageBoxError(res, L"Error");
+ }
+ // KillSelection();
+}
+
+static UString GetSubFolderNameForExtract(const UString &archiveName)
+{
+ int slashPos = archiveName.ReverseFind(L'\\');
+ int dotPos = archiveName.ReverseFind(L'.');
+ if (dotPos < 0 || slashPos > dotPos)
+ return archiveName + UString(L"~");
+ UString res = archiveName.Left(dotPos);
+ res.TrimRight();
+ return res;
+}
+
+void CPanel::ExtractArchives()
+{
+ if (_parentFolders.Size() > 0)
+ {
+ _panelCallback->OnCopy(false, false);
+ return;
+ }
+ CRecordVector<UINT32> indices;
+ GetOperatedItemIndices(indices);
+ UStringVector paths;
+ if (indices.Size() == 0)
+ {
+ MessageBox(kSelectOneFile);
+ 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]));
+ else
+ folderName = L"*";
+ ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(L"\\"), true);
+}
+
+void CPanel::TestArchives()
+{
+ CRecordVector<UINT32> indices;
+ GetOperatedItemIndices(indices);
+ if (!IsFSFolder())
+ {
+ MessageBox(L"Test archive operation is not supported for that folder");
+ return;
+ }
+ UStringVector paths;
+ if (indices.Size() == 0)
+ {
+ MessageBox(kSelectOneFile);
+ 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/FileManager/Panel.h b/CPP/7zip/FileManager/Panel.h
new file mode 100755
index 00000000..ba0e0884
--- /dev/null
+++ b/CPP/7zip/FileManager/Panel.h
@@ -0,0 +1,510 @@
+// Panel.h
+
+#ifndef __PANEL_H
+#define __PANEL_H
+
+#include "Common/MyCom.h"
+
+#include "Windows/DLL.h"
+#include "Windows/FileFind.h"
+#include "Windows/FileDir.h"
+#include "Windows/Synchronization.h"
+#include "Windows/Handle.h"
+
+#include "Windows/Control/ToolBar.h"
+#include "Windows/Control/ReBar.h"
+#include "Windows/Control/ListView.h"
+#include "Windows/Control/Static.h"
+#include "Windows/Control/Edit.h"
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Control/Window2.h"
+#include "Windows/Control/StatusBar.h"
+
+#include "SysIconUtils.h"
+#include "IFolder.h"
+#include "ViewSettings.h"
+#include "AppState.h"
+#include "MyCom2.h"
+
+const int kParentFolderID = 100;
+const int kPluginMenuStartID = 1000;
+const int kToolbarStartID = 2000;
+
+const int kParentIndex = -1;
+
+class CPanelCallback
+{
+public:
+ virtual void OnTab() = 0;
+ virtual void SetFocusToPath(int index) = 0;
+ virtual void OnCopy(bool move, bool copyToSame) = 0;
+ virtual void OnSetSameFolder() = 0;
+ virtual void OnSetSubFolder() = 0;
+ virtual void PanelWasFocused() = 0;
+ virtual void DragBegin() = 0;
+ virtual void DragEnd() = 0;
+};
+
+void PanelCopyItems();
+
+struct CItemProperty
+{
+ UString Name;
+ PROPID ID;
+ VARTYPE Type;
+ int Order;
+ bool IsVisible;
+ UInt32 Width;
+};
+
+inline bool operator<(const CItemProperty &a1, const CItemProperty &a2)
+ { return (a1.Order < a2.Order); }
+
+inline bool operator==(const CItemProperty &a1, const CItemProperty &a2)
+ { return (a1.Order == a2.Order); }
+
+class CItemProperties: public CObjectVector<CItemProperty>
+{
+public:
+ int FindItemWithID(PROPID id)
+ {
+ for (int i = 0; i < Size(); i++)
+ if ((*this)[i].ID == id)
+ return i;
+ return -1;
+ }
+};
+
+struct CTempFileInfo
+{
+ UString ItemName;
+ UString FolderPath;
+ UString FilePath;
+ NWindows::NFile::NFind::CFileInfoW FileInfo;
+ void DeleteDirAndFile()
+ {
+ NWindows::NFile::NDirectory::DeleteFileAlways(FilePath);
+ NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath);
+ }
+};
+
+struct CFolderLink: public CTempFileInfo
+{
+ NWindows::NDLL::CLibrary Library;
+ CMyComPtr<IFolderFolder> ParentFolder;
+};
+
+enum MyMessages
+{
+ kShiftSelectMessage = WM_USER + 1,
+ kReLoadMessage,
+ kSetFocusToListView,
+ kOpenItemChanged,
+ kRefreshStatusBar
+};
+
+UString GetFolderPath(IFolderFolder * folder);
+
+class CPanel;
+
+class CMyListView: public NWindows::NControl::CListView
+{
+public:
+ WNDPROC _origWindowProc;
+ CPanel *_panel;
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+};
+
+/*
+class CMyComboBox: public NWindows::NControl::CComboBoxEx
+{
+public:
+ WNDPROC _origWindowProc;
+ CPanel *_panel;
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+};
+*/
+class CMyComboBoxEdit: public NWindows::NControl::CEdit
+{
+public:
+ WNDPROC _origWindowProc;
+ CPanel *_panel;
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+};
+
+struct CSelectedState
+{
+ int FocusedItem;
+ UString FocusedName;
+ bool SelectFocused;
+ UStringVector SelectedNames;
+ CSelectedState(): FocusedItem(-1), SelectFocused(false) {}
+};
+
+class CPanel:public NWindows::NControl::CWindow2
+{
+ HWND _mainWindow;
+
+ CExtToIconMap _extToIconMap;
+ UINT _baseID;
+ int _comboBoxID;
+ UINT _statusBarID;
+
+ CAppState *_appState;
+
+ bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result);
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual bool OnCreate(CREATESTRUCT *createStruct);
+ 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);
+ bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
+ #ifndef _UNICODE
+ bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
+ #endif
+ bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result);
+ bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result);
+ void OnItemChanged(NMLISTVIEW *item);
+ bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
+ void OnDrag(LPNMLISTVIEW nmListView);
+ bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
+ BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
+ BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
+ void OnColumnClick(LPNMLISTVIEW info);
+ bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
+
+public:
+ CPanelCallback *_panelCallback;
+
+ void DeleteItems(bool toRecycleBin);
+ void DeleteItemsInternal(CRecordVector<UInt32> &indices);
+ void CreateFolder();
+ void CreateFile();
+
+private:
+
+ void ChangeWindowSize(int xSize, int ySize);
+
+ void InitColumns();
+ // void InitColumns2(PROPID sortID);
+ void InsertColumn(int index);
+
+ void SetFocusedSelectedItem(int index, bool select);
+ void RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
+ const UStringVector &selectedNames);
+
+ void OnShiftSelectMessage();
+ void OnArrowWithShift();
+
+ void OnInsert();
+ // void OnUpWithShift();
+ // void OnDownWithShift();
+public:
+ void UpdateSelection();
+ void SelectSpec(bool selectMode);
+ void SelectByType(bool selectMode);
+ void SelectAll(bool selectMode);
+ void InvertSelection();
+private:
+
+ // UString GetFileType(UInt32 index);
+ LRESULT SetItemText(LVITEMW &item);
+
+ // CRecordVector<PROPID> m_ColumnsPropIDs;
+
+public:
+ NWindows::NControl::CReBar _headerReBar;
+ NWindows::NControl::CToolBar _headerToolBar;
+ NWindows::NControl::CComboBoxEx _headerComboBox;
+ // CMyComboBox _headerComboBox;
+ CMyComboBoxEdit _comboBoxEdit;
+ CMyListView _listView;
+ NWindows::NControl::CStatusBar _statusBar;
+ bool _lastFocusedIsList;
+ // NWindows::NControl::CStatusBar _statusBar2;
+
+ DWORD _exStyle;
+ bool _showDots;
+ bool _showRealFileIcons;
+ // bool _virtualMode;
+ // CUIntVector _realIndices;
+ bool _enableItemChangeNotify;
+ bool _mySelectMode;
+ CBoolVector _selectedStatusVector;
+
+ CSelectedState _selectedState;
+
+ UInt32 GetRealIndex(const LVITEMW &item) const
+ {
+ /*
+ if (_virtualMode)
+ return _realIndices[item.iItem];
+ */
+ return (UInt32)item.lParam;
+ }
+ int GetRealItemIndex(int indexInListView) const
+ {
+ /*
+ if (_virtualMode)
+ return indexInListView;
+ */
+ LPARAM param;
+ if (!_listView.GetItemParam(indexInListView, param))
+ throw 1;
+ return (int)param;
+ }
+
+ UInt32 _ListViewMode;
+ int _xSize;
+
+ bool _flatMode;
+
+ bool _dontShowMode;
+
+
+ UString _currentFolderPrefix;
+
+ CObjectVector<CFolderLink> _parentFolders;
+ NWindows::NDLL::CLibrary _library;
+ CMyComPtr<IFolderFolder> _folder;
+ // CMyComPtr<IFolderGetSystemIconIndex> _folderGetSystemIconIndex;
+
+ UStringVector _fastFolders;
+
+ void GetSelectedNames(UStringVector &selectedNames);
+ void SaveSelectedState(CSelectedState &s);
+ void RefreshListCtrl(const CSelectedState &s);
+ void RefreshListCtrlSaveFocused();
+
+ UString GetItemName(int itemIndex) const;
+ UString GetItemPrefix(int itemIndex) const;
+ UString GetItemRelPath(int itemIndex) const;
+ bool IsItemFolder(int itemIndex) const;
+ UInt64 GetItemSize(int itemIndex) const;
+
+ ////////////////////////
+ // PanelFolderChange.cpp
+
+ void SetToRootFolder();
+ HRESULT BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted); // can be prefix
+ HRESULT BindToPathAndRefresh(const UString &path);
+ void OpenDrivesFolder();
+
+ void SetBookmark(int index);
+ void OpenBookmark(int index);
+
+ void LoadFullPath();
+ void LoadFullPathAndShow();
+ void FoldersHistory();
+ void OpenParentFolder();
+ void CloseOpenFolders();
+ void OpenRootFolder();
+
+
+ LRESULT Create(HWND mainWindow, HWND parentWindow,
+ UINT id,
+ const UString &currentFolderPrefix,
+ CPanelCallback *panelCallback,
+ CAppState *appState, bool &archiveIsOpened, bool &encrypted);
+ void SetFocusToList();
+ void SetFocusToLastRememberedItem();
+
+
+ void ReadListViewInfo();
+ void SaveListViewInfo();
+
+ CPanel() :
+ // _virtualMode(flase),
+ _exStyle(0),
+ _showDots(false),
+ _showRealFileIcons(false),
+ _needSaveInfo(false),
+ _startGroupSelect(0),
+ _selectionIsDefined(false),
+ _ListViewMode(3),
+ _flatMode(false),
+ _xSize(300),
+ _mySelectMode(false),
+ _enableItemChangeNotify(true),
+ _dontShowMode(false)
+ {}
+
+ void SetExtendedStyle()
+ {
+ if (_listView != 0)
+ _listView.SetExtendedListViewStyle(_exStyle);
+ }
+
+
+ bool _needSaveInfo;
+ UString _typeIDString;
+ CListViewInfo _listViewInfo;
+ CItemProperties _properties;
+ CItemProperties _visibleProperties;
+
+ PROPID _sortID;
+ // int _sortIndex;
+ bool _ascending;
+
+ void Release();
+ ~CPanel();
+ void OnLeftClick(LPNMITEMACTIVATE itemActivate);
+ bool OnRightClick(LPNMITEMACTIVATE itemActivate, LRESULT &result);
+
+ void OnTimer();
+ void OnReload();
+ bool OnContextMenu(HANDLE windowHandle, int xPos, int yPos);
+
+ CMyComPtr<IContextMenu> _sevenZipContextMenu;
+ CMyComPtr<IContextMenu> _systemContextMenu;
+ HRESULT CreateShellContextMenu(
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu);
+ void CreateSystemMenu(HMENU menu,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu);
+ void CreateSevenZipMenu(HMENU menu,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &sevenZipContextMenu);
+ 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,
+ IContextMenu *systemContextMenu);
+
+ void InvokeSystemCommand(const char *command);
+ void Properties();
+ void EditCopy();
+ void EditPaste();
+
+ int _startGroupSelect;
+
+ bool _selectionIsDefined;
+ bool _selectMark;
+ int _prevFocusedItem;
+
+
+ // void SortItems(int index);
+ void SortItemsWithPropID(PROPID propID);
+
+ void GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const;
+ void GetOperatedItemIndices(CRecordVector<UInt32> &indices) const;
+ // void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const;
+ void KillSelection();
+
+ UString GetFolderTypeID() const;
+ bool IsRootFolder() const;
+ bool IsFSFolder() const;
+ bool IsFSDrivesFolder() const;
+
+ UString GetFsPath() const;
+ UString GetDriveOrNetworkPrefix() const;
+
+ bool DoesItSupportOperations() const;
+
+ bool _processTimer;
+ bool _processNotify;
+
+ class CDisableTimerProcessing
+ {
+ bool _processTimerMem;
+ bool _processNotifyMem;
+
+ CPanel &_panel;
+ public:
+
+ CDisableTimerProcessing(CPanel &panel): _panel(panel)
+ {
+ Disable();
+ }
+ void Disable()
+ {
+ _processTimerMem = _panel._processTimer;
+ _processNotifyMem = _panel._processNotify;
+ _panel._processTimer = false;
+ _panel._processNotify = false;
+ }
+ void Restore()
+ {
+ _panel._processTimer = _processTimerMem;
+ _panel._processNotify = _processNotifyMem;
+ }
+ ~CDisableTimerProcessing()
+ {
+ Restore();
+ }
+ CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
+ };
+
+ // bool _passwordIsDefined;
+ // UString _password;
+
+ void RefreshListCtrl();
+
+ void MessageBoxInfo(LPCWSTR message, LPCWSTR caption);
+ void MessageBox(LPCWSTR message);
+ void MessageBox(LPCWSTR message, LPCWSTR caption);
+ void MessageBoxMyError(LPCWSTR message);
+ void MessageBoxError(HRESULT errorCode, LPCWSTR caption);
+ void MessageBoxError(HRESULT errorCode);
+ void MessageBoxLastError(LPCWSTR caption);
+ void MessageBoxLastError();
+
+
+ void OpenFocusedItemAsInternal();
+ void OpenSelectedItems(bool internal);
+
+ void OpenFolderExternal(int index);
+
+ void OpenFolder(int index);
+ HRESULT OpenParentArchiveFolder();
+ HRESULT OpenItemAsArchive(const UString &name,
+ const UString &folderPath,
+ const UString &filePath, bool &encrypted);
+ HRESULT OpenItemAsArchive(const UString &aName);
+ HRESULT OpenItemAsArchive(int index);
+ void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
+ bool editMode);
+ HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName);
+ LRESULT OnOpenItemChanged(LPARAM lParam);
+
+ void OpenItem(int index, bool tryInternal, bool tryExternal);
+ void EditItem();
+ void EditItem(int index);
+
+ void RenameFile();
+ void ChangeComment();
+
+ void SetListViewMode(UInt32 index);
+ UInt32 GetListViewMode() const { return _ListViewMode; };
+
+ void ChangeFlatMode();
+ bool GetFlatMode() const { return _flatMode; };
+
+ void RefreshStatusBar();
+ void OnRefreshStatusBar();
+
+ void AddToArchive();
+ void ExtractArchives();
+ void TestArchives();
+
+ HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages);
+
+ HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
+ bool showErrorMessages, UStringVector *messages);
+
+ void CopyFrom(const UStringVector &filePaths);
+
+ // empty folderPath means create new Archive to path of first fileName.
+ void DropObject(IDataObject * dataObject, const UString &folderPath);
+
+ // empty folderPath means create new Archive to path of first fileName.
+ void CompressDropFiles(const UStringVector &fileNames, const UString &folderPath);
+};
+
+#endif
diff --git a/CPP/7zip/FileManager/PanelCopy.cpp b/CPP/7zip/FileManager/PanelCopy.cpp
new file mode 100755
index 00000000..4b62b878
--- /dev/null
+++ b/CPP/7zip/FileManager/PanelCopy.cpp
@@ -0,0 +1,208 @@
+// PanelExtract.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/COM.h"
+
+#include "Panel.h"
+#include "resource.h"
+#include "LangUtils.h"
+#include "ExtractCallback.h"
+#include "Windows/Thread.h"
+////////////////////////////////////////////////////////////////
+
+#include "UpdateCallback100.h"
+
+using namespace NWindows;
+
+struct CThreadExtractInArchive2
+{
+ CMyComPtr<IFolderOperations> FolderOperations;
+ CRecordVector<UInt32> Indices;
+ UString DestPath;
+ CExtractCallbackImp *ExtractCallbackSpec;
+ CMyComPtr<IFolderOperationsExtractCallback> ExtractCallback;
+ HRESULT Result;
+ bool MoveMode;
+
+ CThreadExtractInArchive2(): MoveMode(false) {}
+
+ DWORD Extract()
+ {
+ // NCOM::CComInitializer comInitializer;
+ ExtractCallbackSpec->ProgressDialog.WaitCreating();
+ if (MoveMode)
+ Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(),
+ DestPath, ExtractCallback);
+ else
+ Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(),
+ DestPath, ExtractCallback);
+ ExtractCallbackSpec->ProgressDialog.MyClose();
+ return 0;
+ }
+
+ static DWORD WINAPI MyThreadFunction(void *param)
+ {
+ return ((CThreadExtractInArchive2 *)param)->Extract();
+ }
+};
+
+HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ if (showErrorMessages)
+ MessageBox(errorMessage);
+ else if (messages != 0)
+ messages->Add(errorMessage);
+ return E_FAIL;
+ }
+
+ CThreadExtractInArchive2 extracter;
+
+ extracter.ExtractCallbackSpec = new CExtractCallbackImp;
+ extracter.ExtractCallback = extracter.ExtractCallbackSpec;
+ extracter.ExtractCallbackSpec->ParentWindow = GetParent();
+ extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages;
+
+ UString title = moveMode ?
+ LangString(IDS_MOVING, 0x03020206):
+ LangString(IDS_COPYING, 0x03020205);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+
+ extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent();
+ extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
+ extracter.ExtractCallbackSpec->ProgressDialog.MainAddTitle = title + L" ";
+
+ extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
+ extracter.ExtractCallbackSpec->Init();
+ extracter.Indices = indices;
+ extracter.DestPath = folder;
+ extracter.FolderOperations = folderOperations;
+ extracter.MoveMode = moveMode;
+
+ CThread extractThread;
+ if (!extractThread.Create(CThreadExtractInArchive2::MyThreadFunction, &extracter))
+ throw 271824;
+ extracter.ExtractCallbackSpec->StartProgressDialog(title);
+
+ if (messages != 0)
+ *messages = extracter.ExtractCallbackSpec->Messages;
+ return extracter.Result;
+}
+
+
+struct CThreadUpdate
+{
+ CMyComPtr<IFolderOperations> FolderOperations;
+ UString FolderPrefix;
+ UStringVector FileNames;
+ CRecordVector<const wchar_t *> FileNamePointers;
+ CMyComPtr<IFolderArchiveUpdateCallback> UpdateCallback;
+ CUpdateCallback100Imp *UpdateCallbackSpec;
+ HRESULT Result;
+
+ DWORD Process()
+ {
+ NCOM::CComInitializer comInitializer;
+ UpdateCallbackSpec->ProgressDialog.WaitCreating();
+ Result = FolderOperations->CopyFrom(
+ FolderPrefix,
+ &FileNamePointers.Front(),
+ FileNamePointers.Size(),
+ UpdateCallback);
+ UpdateCallbackSpec->ProgressDialog.MyClose();
+ return 0;
+ }
+
+ static DWORD WINAPI MyThreadFunction(void *param)
+ {
+ return ((CThreadUpdate *)param)->Process();
+ }
+};
+
+
+HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
+ bool showErrorMessages, UStringVector *messages)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ if (showErrorMessages)
+ MessageBox(errorMessage);
+ else if (messages != 0)
+ messages->Add(errorMessage);
+ return E_FAIL;
+ }
+
+ CThreadUpdate updater;
+ updater.UpdateCallbackSpec = new CUpdateCallback100Imp;
+ updater.UpdateCallback = updater.UpdateCallbackSpec;
+
+ UString title = LangString(IDS_COPYING, 0x03020205);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+
+ updater.UpdateCallbackSpec->ProgressDialog.MainWindow = GetParent();
+ updater.UpdateCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle;
+ updater.UpdateCallbackSpec->ProgressDialog.MainAddTitle = title + UString(L" ");
+
+ updater.UpdateCallbackSpec->Init((HWND)*this, false, L"");
+ updater.FolderOperations = folderOperations;
+ updater.FolderPrefix = folderPrefix;
+ updater.FileNames.Reserve(filePaths.Size());
+ int i;
+ for(i = 0; i < filePaths.Size(); i++)
+ updater.FileNames.Add(filePaths[i]);
+ updater.FileNamePointers.Reserve(updater.FileNames.Size());
+ for(i = 0; i < updater.FileNames.Size(); i++)
+ updater.FileNamePointers.Add(updater.FileNames[i]);
+
+ CThread thread;
+ if (!thread.Create(CThreadUpdate::MyThreadFunction, &updater))
+ throw 271824;
+ updater.UpdateCallbackSpec->StartProgressDialog(title);
+
+ if (messages != 0)
+ *messages = updater.UpdateCallbackSpec->Messages;
+
+ return updater.Result;
+}
+
+void CPanel::CopyFrom(const UStringVector &filePaths)
+{
+ UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222);
+ UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223);
+ message += L"\n\'";
+ message += _currentFolderPrefix;
+ message += L"\' ?";
+ int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION | MB_SYSTEMMODAL);
+ if (res != IDYES)
+ return;
+
+ CDisableTimerProcessing disableTimerProcessing(*this);
+
+ CSelectedState srcSelState;
+ SaveSelectedState(srcSelState);
+
+ HRESULT result = CopyFrom(L"", filePaths, true, 0);
+
+ if (result != S_OK)
+ {
+ disableTimerProcessing.Restore();
+ // For Password:
+ SetFocusToList();
+ if (result != E_ABORT)
+ MessageBoxError(result);
+ return;
+ }
+
+ RefreshListCtrl(srcSelState);
+
+ disableTimerProcessing.Restore();
+ SetFocusToList();
+}
+
diff --git a/7zip/FileManager/PanelCrc.cpp b/CPP/7zip/FileManager/PanelCrc.cpp
index 12dcee55..12dcee55 100755
--- a/7zip/FileManager/PanelCrc.cpp
+++ b/CPP/7zip/FileManager/PanelCrc.cpp
diff --git a/CPP/7zip/FileManager/PanelDrag.cpp b/CPP/7zip/FileManager/PanelDrag.cpp
new file mode 100755
index 00000000..24f1def0
--- /dev/null
+++ b/CPP/7zip/FileManager/PanelDrag.cpp
@@ -0,0 +1,796 @@
+// PanelDrag.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/Memory.h"
+#include "Windows/FileDir.h"
+#include "Windows/Shell.h"
+
+#include "../UI/Common/ArchiveName.h"
+#include "../UI/Common/CompressCall.h"
+
+#include "Resource/MessagesDialog/MessagesDialog.h"
+
+#include "App.h"
+#include "EnumFormatEtc.h"
+
+using namespace NWindows;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+static wchar_t *kTempDirPrefix = L"7zE";
+static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
+
+////////////////////////////////////////////////////////
+
+class CDataObject:
+ public IDataObject,
+ public CMyUnknownImp
+{
+private:
+ FORMATETC m_Etc;
+ UINT m_SetFolderFormat;
+
+public:
+ MY_UNKNOWN_IMP1_MT(IDataObject)
+
+ STDMETHODIMP GetData(LPFORMATETC pformatetcIn, LPSTGMEDIUM medium);
+ STDMETHODIMP GetDataHere(LPFORMATETC pformatetc, LPSTGMEDIUM medium);
+ STDMETHODIMP QueryGetData(LPFORMATETC pformatetc );
+
+ STDMETHODIMP GetCanonicalFormatEtc ( LPFORMATETC /* pformatetc */, LPFORMATETC pformatetcOut)
+ { pformatetcOut->ptd = NULL; return ResultFromScode(E_NOTIMPL); }
+
+ STDMETHODIMP SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL release);
+ STDMETHODIMP EnumFormatEtc(DWORD drection, LPENUMFORMATETC *enumFormatEtc);
+
+ STDMETHODIMP DAdvise(FORMATETC * /* etc */, DWORD /* advf */, LPADVISESINK /* pAdvSink */, DWORD * /* pdwConnection */)
+ { return OLE_E_ADVISENOTSUPPORTED; }
+ STDMETHODIMP DUnadvise(DWORD /* dwConnection */) { return OLE_E_ADVISENOTSUPPORTED; }
+ STDMETHODIMP EnumDAdvise( LPENUMSTATDATA * /* ppenumAdvise */) { return OLE_E_ADVISENOTSUPPORTED; }
+
+ CDataObject();
+
+ NMemory::CGlobal hGlobal;
+ UString Path;
+};
+
+CDataObject::CDataObject()
+{
+ m_SetFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat);
+ m_Etc.cfFormat = CF_HDROP;
+ m_Etc.ptd = NULL;
+ m_Etc.dwAspect = DVASPECT_CONTENT;
+ m_Etc.lindex = -1;
+ m_Etc.tymed = TYMED_HGLOBAL;
+}
+
+STDMETHODIMP CDataObject::SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL /* release */)
+{
+ 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;
+ size_t size = GlobalSize(medium->hGlobal) / sizeof(wchar_t);
+ const wchar_t *src = (const wchar_t *)GlobalLock(medium->hGlobal);
+ if (src != 0)
+ {
+ for (size_t i = 0; i < size; i++)
+ {
+ wchar_t c = src[i];
+ if (c == 0)
+ break;
+ Path += c;
+ }
+ GlobalUnlock(medium->hGlobal);
+ return S_OK;
+ }
+ }
+ return E_NOTIMPL;
+}
+
+static HGLOBAL DuplicateGlobalMem(HGLOBAL srcGlobal)
+{
+ SIZE_T size = GlobalSize(srcGlobal);
+ const void *src = GlobalLock(srcGlobal);
+ if (src == 0)
+ return 0;
+ HGLOBAL destGlobal = GlobalAlloc(GHND | GMEM_SHARE, size);
+ if (destGlobal != 0)
+ {
+ void *dest = GlobalLock(destGlobal);
+ if (dest == 0)
+ {
+ GlobalFree(destGlobal);
+ destGlobal = 0;
+ }
+ else
+ {
+ memcpy(dest, src, size);
+ GlobalUnlock(destGlobal);
+ }
+ }
+ GlobalUnlock(srcGlobal);
+ return destGlobal;
+}
+
+STDMETHODIMP CDataObject::GetData(LPFORMATETC etc, LPSTGMEDIUM medium)
+{
+ RINOK(QueryGetData(etc));
+ medium->tymed = m_Etc.tymed;
+ medium->pUnkForRelease = 0;
+ medium->hGlobal = DuplicateGlobalMem(hGlobal);
+ if (medium->hGlobal == 0)
+ return E_OUTOFMEMORY;
+ return S_OK;
+}
+
+STDMETHODIMP CDataObject::GetDataHere(LPFORMATETC /* etc */, LPSTGMEDIUM /* medium */)
+{
+ // Seems Windows doesn't call it, so we will not implement it.
+ return E_UNEXPECTED;
+}
+
+
+STDMETHODIMP CDataObject::QueryGetData(LPFORMATETC etc)
+{
+ if ((m_Etc.tymed & etc->tymed) &&
+ m_Etc.cfFormat == etc->cfFormat &&
+ m_Etc.dwAspect == etc->dwAspect)
+ return S_OK;
+ return DV_E_FORMATETC;
+}
+
+STDMETHODIMP CDataObject::EnumFormatEtc(DWORD direction, LPENUMFORMATETC FAR* enumFormatEtc)
+{
+ if(direction != DATADIR_GET)
+ return E_NOTIMPL;
+ return CreateEnumFormatEtc(1, &m_Etc, enumFormatEtc);
+}
+
+////////////////////////////////////////////////////////
+
+class CDropSource:
+ public IDropSource,
+ public CMyUnknownImp
+{
+ DWORD m_Effect;
+public:
+ MY_UNKNOWN_IMP1_MT(IDropSource)
+ STDMETHOD(QueryContinueDrag)(BOOL escapePressed, DWORD keyState);
+ STDMETHOD(GiveFeedback)(DWORD effect);
+
+
+ bool NeedExtract;
+ CPanel *Panel;
+ CRecordVector<UInt32> Indices;
+ UString Folder;
+ CDataObject *DataObjectSpec;
+ CMyComPtr<IDataObject> DataObject;
+
+ bool NeedPostCopy;
+ HRESULT Result;
+ UStringVector Messages;
+
+ CDropSource(): NeedPostCopy(false), Panel(0), Result(S_OK), m_Effect(DROPEFFECT_NONE) {}
+};
+
+STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState)
+{
+ if(escapePressed == TRUE)
+ return DRAGDROP_S_CANCEL;
+ if((keyState & MK_LBUTTON) == 0)
+ {
+ if (m_Effect == DROPEFFECT_NONE)
+ return DRAGDROP_S_CANCEL;
+ Result = S_OK;
+ bool needExtract = NeedExtract;
+ // MoveMode = (((keyState & MK_SHIFT) != 0) && MoveIsAllowed);
+ if (!DataObjectSpec->Path.IsEmpty())
+ {
+ needExtract = false;
+ NeedPostCopy = true;
+ }
+ if (needExtract)
+ {
+ Result = Panel->CopyTo(Indices, Folder,
+ false, // moveMode,
+ false, // showMessages
+ &Messages);
+ if (Result != S_OK || !Messages.IsEmpty())
+ return DRAGDROP_S_CANCEL;
+ }
+ return DRAGDROP_S_DROP;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CDropSource::GiveFeedback(DWORD effect)
+{
+ m_Effect = effect;
+ return DRAGDROP_S_USEDEFAULTCURSORS;
+}
+
+static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &names)
+{
+ size_t totalLength = 1;
+
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ AStringVector namesA;
+ int i;
+ for (i = 0; i < names.Size(); i++)
+ namesA.Add(GetSystemString(names[i]));
+ for (i = 0; i < names.Size(); i++)
+ totalLength += namesA[i].Length() + 1;
+
+ if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(CHAR) + sizeof(DROPFILES)))
+ return false;
+
+ NMemory::CGlobalLock dropLock(hgDrop);
+ DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
+ if (dropFiles == 0)
+ return false;
+ dropFiles->fNC = FALSE;
+ dropFiles->pt.x = 0;
+ dropFiles->pt.y = 0;
+ dropFiles->pFiles = sizeof(DROPFILES);
+ dropFiles->fWide = FALSE;
+ CHAR *p = (CHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
+ for (i = 0; i < names.Size(); i++)
+ {
+ const AString &s = namesA[i];
+ int fullLength = s.Length() + 1;
+ MyStringCopy(p, (const char *)s);
+ p += fullLength;
+ totalLength -= fullLength;
+ }
+ *p = 0;
+ }
+ else
+ #endif
+ {
+ int i;
+ for (i = 0; i < names.Size(); i++)
+ totalLength += names[i].Length() + 1;
+
+ if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(WCHAR) + sizeof(DROPFILES)))
+ return false;
+
+ NMemory::CGlobalLock dropLock(hgDrop);
+ DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
+ if (dropFiles == 0)
+ return false;
+ dropFiles->fNC = FALSE;
+ dropFiles->pt.x = 0;
+ dropFiles->pt.y = 0;
+ dropFiles->pFiles = sizeof(DROPFILES);
+ dropFiles->fWide = TRUE;
+ WCHAR *p = (WCHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
+ for (i = 0; i < names.Size(); i++)
+ {
+ const UString &s = names[i];
+ int fullLength = s.Length() + 1;
+ MyStringCopy(p, (const WCHAR *)s);
+ p += fullLength;
+ totalLength -= fullLength;
+ }
+ *p = 0;
+ }
+ return true;
+}
+
+void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
+{
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ if (!DoesItSupportOperations())
+ return;
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ if (indices.Size() == 0)
+ return;
+
+ // CSelectedState selState;
+ // SaveSelectedState(selState);
+
+ UString dirPrefix;
+ NFile::NDirectory::CTempDirectoryW tempDirectory;
+
+ bool isFSFolder = IsFSFolder();
+ if (isFSFolder)
+ dirPrefix = _currentFolderPrefix;
+ else
+ {
+ tempDirectory.Create(kTempDirPrefix);
+ dirPrefix = tempDirectory.GetPath();
+ NFile::NName::NormalizeDirPathPrefix(dirPrefix);
+ }
+
+ CDataObject *dataObjectSpec = new CDataObject;
+ CMyComPtr<IDataObject> dataObject = dataObjectSpec;
+
+ {
+ UStringVector names;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ UInt32 index = indices[i];
+ UString s;
+ if (isFSFolder)
+ s = GetItemRelPath(index);
+ else
+ s = GetItemName(index);
+ names.Add(dirPrefix + s);
+ }
+ if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names))
+ return;
+ }
+
+ CDropSource *dropSourceSpec = new CDropSource;
+ CMyComPtr<IDropSource> dropSource = dropSourceSpec;
+ dropSourceSpec->NeedExtract = !isFSFolder;
+ dropSourceSpec->Panel = this;
+ dropSourceSpec->Indices = indices;
+ dropSourceSpec->Folder = dirPrefix;
+ dropSourceSpec->DataObjectSpec = dataObjectSpec;
+ dropSourceSpec->DataObject = dataObjectSpec;
+
+ bool moveIsAllowed = isFSFolder;
+
+ DWORD effectsOK = DROPEFFECT_COPY;
+ if (moveIsAllowed)
+ effectsOK |= DROPEFFECT_MOVE;
+ DWORD effect;
+ _panelCallback->DragBegin();
+ HRESULT res = DoDragDrop(dataObject, dropSource, effectsOK, &effect);
+ _panelCallback->DragEnd();
+ bool canceled = (res == DRAGDROP_S_CANCEL);
+ if (res == DRAGDROP_S_DROP)
+ {
+ res = dropSourceSpec->Result;
+ if (dropSourceSpec->NeedPostCopy)
+ if (!dataObjectSpec->Path.IsEmpty())
+ {
+ NFile::NName::NormalizeDirPathPrefix(dataObjectSpec->Path);
+ res = CopyTo(indices, dataObjectSpec->Path,
+ (effect == DROPEFFECT_MOVE),// dropSourceSpec->MoveMode,
+ false, // showErrorMessages
+ &dropSourceSpec->Messages);
+ }
+ /*
+ if (effect == DROPEFFECT_MOVE)
+ RefreshListCtrl(selState);
+ */
+ }
+ else
+ {
+ if (res != DRAGDROP_S_CANCEL && res != S_OK)
+ MessageBoxError(res);
+ res = dropSourceSpec->Result;
+ }
+
+ if (!dropSourceSpec->Messages.IsEmpty())
+ {
+ CMessagesDialog messagesDialog;
+ messagesDialog.Messages = &dropSourceSpec->Messages;
+ messagesDialog.Create((*this));
+ }
+ if (res != S_OK && res != E_ABORT)
+ MessageBoxError(res);
+ if (res == S_OK && dropSourceSpec->Messages.IsEmpty() && !canceled)
+ KillSelection();
+}
+
+void CDropTarget::QueryGetData(IDataObject *dataObject)
+{
+ FORMATETC etc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+ m_DropIsAllowed = (dataObject->QueryGetData(&etc) == S_OK);
+
+}
+
+static void MySetDropHighlighted(HWND hWnd, int index, bool enable)
+{
+ LVITEM item;
+ item.mask = LVIF_STATE;
+ item.iItem = index;
+ item.iSubItem = 0;
+ item.state = enable ? LVIS_DROPHILITED : 0;
+ item.stateMask = LVIS_DROPHILITED;
+ item.pszText = 0;
+ ListView_SetItem(hWnd, &item);
+}
+
+void CDropTarget::RemoveSelection()
+{
+ if (m_SelectionIndex >= 0 && m_Panel != 0)
+ MySetDropHighlighted(m_Panel->_listView, m_SelectionIndex, false);
+ m_SelectionIndex = -1;
+}
+
+void CDropTarget::PositionCursor(POINTL ptl)
+{
+ m_SubFolderIndex = -1;
+ POINT pt;
+ pt.x = ptl.x;
+ pt.y = ptl.y;
+
+ RemoveSelection();
+ m_IsAppTarget = true;
+ m_Panel = NULL;
+
+ m_PanelDropIsAllowed = true;
+ if (!m_DropIsAllowed)
+ return;
+ {
+ POINT pt2 = pt;
+ App->_window.ScreenToClient(&pt2);
+ for (int i = 0; i < kNumPanelsMax; i++)
+ if (App->IsPanelVisible(i))
+ if (App->Panels[i].IsEnabled())
+ if (ChildWindowFromPointEx(App->_window, pt2,
+ CWP_SKIPINVISIBLE | CWP_SKIPDISABLED) == (HWND)App->Panels[i])
+ {
+ m_Panel = &App->Panels[i];
+ m_IsAppTarget = false;
+ if (i == SrcPanelIndex)
+ {
+ m_PanelDropIsAllowed = false;
+ return;
+ }
+ break;
+ }
+ if (m_IsAppTarget)
+ {
+ if (TargetPanelIndex >= 0)
+ m_Panel = &App->Panels[TargetPanelIndex];
+ return;
+ }
+ }
+
+ /*
+ m_PanelDropIsAllowed = m_Panel->DoesItSupportOperations();
+ if (!m_PanelDropIsAllowed)
+ return;
+ */
+
+ if (!m_Panel->IsFSFolder() && !m_Panel->IsFSDrivesFolder())
+ return;
+
+ if (WindowFromPoint(pt) != (HWND)m_Panel->_listView)
+ return;
+
+ LVHITTESTINFO info;
+ m_Panel->_listView.ScreenToClient(&pt);
+ info.pt = pt;
+ int index = ListView_HitTest(m_Panel->_listView, &info);
+ if (index < 0)
+ return;
+ int realIndex = m_Panel->GetRealItemIndex(index);
+ if (realIndex == kParentIndex)
+ return;
+ if (!m_Panel->IsItemFolder(realIndex))
+ return;
+ m_SubFolderIndex = realIndex;
+ m_SubFolderName = m_Panel->GetItemName(m_SubFolderIndex);
+ MySetDropHighlighted(m_Panel->_listView, index, true);
+ m_SelectionIndex = index;
+}
+
+bool CDropTarget::IsFsFolderPath() const
+{
+ if (!m_IsAppTarget && m_Panel != 0)
+ return (m_Panel->IsFSFolder() || (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0));
+ return false;
+}
+
+static void ReadUnicodeStrings(const wchar_t *p, size_t size, UStringVector &names)
+{
+ names.Clear();
+ UString name;
+ for (;size > 0; size--)
+ {
+ wchar_t c = *p++;
+ if (c == 0)
+ {
+ if (name.IsEmpty())
+ break;
+ names.Add(name);
+ name.Empty();
+ }
+ else
+ name += c;
+ }
+}
+
+static void ReadAnsiStrings(const char *p, size_t size, UStringVector &names)
+{
+ names.Clear();
+ AString name;
+ for (;size > 0; size--)
+ {
+ char c = *p++;
+ if (c == 0)
+ {
+ if (name.IsEmpty())
+ break;
+ names.Add(GetUnicodeString(name));
+ name.Empty();
+ }
+ else
+ name += c;
+ }
+}
+
+static void GetNamesFromDataObject(IDataObject *dataObject, UStringVector &names)
+{
+ names.Clear();
+ FORMATETC etc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+ STGMEDIUM medium;
+ HRESULT res = dataObject->GetData(&etc, &medium);
+ if (res != S_OK)
+ return;
+ if (medium.tymed != TYMED_HGLOBAL)
+ return;
+ {
+ NMemory::CGlobal global;
+ global.Attach(medium.hGlobal);
+ size_t blockSize = GlobalSize(medium.hGlobal);
+ NMemory::CGlobalLock dropLock(medium.hGlobal);
+ const DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer();
+ if (dropFiles == 0)
+ return;
+ if (blockSize < dropFiles->pFiles)
+ return;
+ size_t size = blockSize - dropFiles->pFiles;
+ const void *namesData = (const Byte *)dropFiles + dropFiles->pFiles;
+ if (dropFiles->fWide)
+ ReadUnicodeStrings((const wchar_t *)namesData, size / sizeof(wchar_t), names);
+ else
+ ReadAnsiStrings((const char *)namesData, size, names);
+ }
+}
+
+bool CDropTarget::IsItSameDrive() const
+{
+ if (m_Panel == 0)
+ return false;
+ if (!IsFsFolderPath())
+ return false;
+ UString drive;
+ if (m_Panel->IsFSFolder())
+ {
+ drive = m_Panel->GetDriveOrNetworkPrefix();
+ if (drive.IsEmpty())
+ return false;
+ }
+ else if (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0)
+ drive = m_SubFolderName + L'\\';
+ else
+ return false;
+
+ if (m_SourcePaths.Size() == 0)
+ return false;
+ for (int i = 0; i < m_SourcePaths.Size(); i++)
+ {
+ const UString &path = m_SourcePaths[i];
+ if (drive.CompareNoCase(path.Left(drive.Length())) != 0)
+ return false;
+ }
+ return true;
+
+}
+
+DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffect)
+{
+ if (!m_DropIsAllowed || !m_PanelDropIsAllowed)
+ return DROPEFFECT_NONE;
+
+ if (!IsFsFolderPath())
+ allowedEffect &= ~DROPEFFECT_MOVE;
+
+ if (!m_SetPathIsOK)
+ allowedEffect &= ~DROPEFFECT_MOVE;
+
+ DWORD effect = 0;
+ if (keyState & MK_CONTROL)
+ effect = allowedEffect & DROPEFFECT_COPY;
+ else if (keyState & MK_SHIFT)
+ effect = allowedEffect & DROPEFFECT_MOVE;
+ if(effect == 0)
+ {
+ if(allowedEffect & DROPEFFECT_COPY)
+ effect = DROPEFFECT_COPY;
+ if(allowedEffect & DROPEFFECT_MOVE)
+ {
+ if (IsItSameDrive())
+ effect = DROPEFFECT_MOVE;
+ }
+ }
+ if(effect == 0)
+ return DROPEFFECT_NONE;
+ return effect;
+}
+
+UString CDropTarget::GetTargetPath() const
+{
+ if (!IsFsFolderPath())
+ return UString();
+ UString path = m_Panel->_currentFolderPrefix;
+ if (m_Panel->IsFSDrivesFolder())
+ path.Empty();
+ if (m_SubFolderIndex >= 0 && !m_SubFolderName.IsEmpty())
+ {
+ path += m_SubFolderName;
+ path += L"\\";
+ }
+ return path;
+}
+
+bool CDropTarget::SetPath(bool enablePath) const
+{
+ UINT setFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat);
+
+ FORMATETC etc = { (CLIPFORMAT)setFolderFormat, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+ STGMEDIUM medium;
+ medium.tymed = etc.tymed;
+ medium.pUnkForRelease = 0;
+ UString path;
+ if (enablePath)
+ path = GetTargetPath();
+ size_t size = path.Length() + 1;
+ medium.hGlobal = GlobalAlloc(GHND | GMEM_SHARE, size * sizeof(wchar_t));
+ if (medium.hGlobal == 0)
+ return false;
+ wchar_t *dest = (wchar_t *)GlobalLock(medium.hGlobal);
+ if (dest == 0)
+ {
+ GlobalUnlock(medium.hGlobal);
+ return false;
+ }
+ MyStringCopy(dest, (const wchar_t *)path);
+ GlobalUnlock(medium.hGlobal);
+ bool res = m_DataObject->SetData(&etc, &medium, FALSE) == S_OK;
+ GlobalFree(medium.hGlobal);
+ return res;
+}
+
+bool CDropTarget::SetPath()
+{
+ m_SetPathIsOK = SetPath(m_DropIsAllowed && m_PanelDropIsAllowed && IsFsFolderPath());
+ return m_SetPathIsOK;
+}
+
+STDMETHODIMP CDropTarget::DragEnter(IDataObject * dataObject, DWORD keyState,
+ POINTL pt, DWORD *effect)
+{
+ GetNamesFromDataObject(dataObject, m_SourcePaths);
+ QueryGetData(dataObject);
+ m_DataObject = dataObject;
+ return DragOver(keyState, pt, effect);
+}
+
+
+STDMETHODIMP CDropTarget::DragOver(DWORD keyState, POINTL pt, DWORD *effect)
+{
+ PositionCursor(pt);
+ SetPath();
+ *effect = GetEffect(keyState, pt, *effect);
+ return S_OK;
+}
+
+
+STDMETHODIMP CDropTarget::DragLeave()
+{
+ RemoveSelection();
+ SetPath(false);
+ m_DataObject.Release();
+ return S_OK;
+}
+
+// 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,
+ POINTL pt, DWORD * effect)
+{
+ QueryGetData(dataObject);
+ PositionCursor(pt);
+ m_DataObject = dataObject;
+ bool needDrop = true;
+ if(m_DropIsAllowed && m_PanelDropIsAllowed)
+ if (IsFsFolderPath())
+ needDrop = !SetPath();
+ *effect = GetEffect(keyState, pt, *effect);
+ if(m_DropIsAllowed && m_PanelDropIsAllowed)
+ {
+ if (needDrop)
+ {
+ UString path = GetTargetPath();
+ if (m_IsAppTarget && m_Panel)
+ if (m_Panel->IsFSFolder())
+ path = m_Panel->_currentFolderPrefix;
+ m_Panel->DropObject(dataObject, path);
+ }
+ }
+ RemoveSelection();
+ m_DataObject.Release();
+ return S_OK;
+}
+
+void CPanel::DropObject(IDataObject *dataObject, const UString &folderPath)
+{
+ UStringVector names;
+ GetNamesFromDataObject(dataObject, names);
+ CompressDropFiles(names, folderPath);
+}
+
+/*
+void CPanel::CompressDropFiles(HDROP dr)
+{
+ UStringVector fileNames;
+ {
+ NShell::CDrop drop(true);
+ drop.Attach(dr);
+ drop.QueryFileNames(fileNames);
+ }
+ CompressDropFiles(fileNamesUnicode);
+}
+*/
+
+static bool IsFolderInTemp(const UString &path)
+{
+ UString tempPath;
+ if (!NFile::NDirectory::MyGetTempPath(tempPath))
+ return false;
+ if (tempPath.IsEmpty())
+ return false;
+ return (tempPath.CompareNoCase(path.Left(tempPath.Length())) == 0);
+}
+
+static bool AreThereNamesFromTemp(const UStringVector &fileNames)
+{
+ UString tempPath;
+ if (!NFile::NDirectory::MyGetTempPath(tempPath))
+ return false;
+ if (tempPath.IsEmpty())
+ return false;
+ for (int i = 0; i < fileNames.Size(); i++)
+ if (tempPath.CompareNoCase(fileNames[i].Left(tempPath.Length())) == 0)
+ return true;
+ return false;
+}
+
+void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &folderPath)
+{
+ if (fileNames.Size() == 0)
+ return;
+ const UString archiveName = CreateArchiveName(fileNames.Front(),
+ (fileNames.Size() > 1), false);
+ bool createNewArchive = true;
+ if (!IsFSFolder())
+ createNewArchive = !DoesItSupportOperations();
+
+ if (createNewArchive)
+ {
+ UString folderPath2 = folderPath;
+ if (folderPath2.IsEmpty())
+ {
+ NFile::NDirectory::GetOnlyDirPrefix(fileNames.Front(), folderPath2);
+ if (IsFolderInTemp(folderPath2))
+ folderPath2 = L"C:\\"; // fix it
+ }
+ CompressFiles(folderPath2, archiveName, L"", fileNames,
+ false, // email
+ true, // showDialog
+ AreThereNamesFromTemp(fileNames) // waitFinish
+ );
+ }
+ else
+ CopyFrom(fileNames);
+}
diff --git a/CPP/7zip/FileManager/PanelFolderChange.cpp b/CPP/7zip/FileManager/PanelFolderChange.cpp
new file mode 100755
index 00000000..29841f54
--- /dev/null
+++ b/CPP/7zip/FileManager/PanelFolderChange.cpp
@@ -0,0 +1,414 @@
+// PanelFolderChange.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+#include "Common/Wildcard.h"
+#include "Windows/FileDir.h"
+
+#include "Panel.h"
+#include "Resource/ListViewDialog/ListViewDialog.h"
+#include "RootFolder.h"
+#include "ViewSettings.h"
+#include "FSDrives.h"
+#include "LangUtils.h"
+#include "resource.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+void CPanel::SetToRootFolder()
+{
+ _folder.Release();
+ _library.Free();
+ CRootFolder *rootFolderSpec = new CRootFolder;
+ _folder = rootFolderSpec;
+ rootFolderSpec->Init();
+}
+
+HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted)
+{
+ archiveIsOpened = false;
+ encrypted = false;
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ CloseOpenFolders();
+ UString sysPath = fullPath;
+ CFileInfoW fileInfo;
+ UStringVector reducedParts;
+ while(!sysPath.IsEmpty())
+ {
+ if (FindFile(sysPath, fileInfo))
+ break;
+ int pos = sysPath.ReverseFind(L'\\');
+ if (pos < 0)
+ sysPath.Empty();
+ else
+ {
+ if (reducedParts.Size() > 0 || pos < sysPath.Length() - 1)
+ reducedParts.Add(sysPath.Mid(pos + 1));
+ sysPath = sysPath.Left(pos);
+ }
+ }
+ SetToRootFolder();
+ CMyComPtr<IFolderFolder> newFolder;
+ if (sysPath.IsEmpty())
+ {
+ if (_folder->BindToFolder(fullPath, &newFolder) == S_OK)
+ _folder = newFolder;
+ }
+ else if (fileInfo.IsDirectory())
+ {
+ NName::NormalizeDirPathPrefix(sysPath);
+ if (_folder->BindToFolder(sysPath, &newFolder) == S_OK)
+ _folder = newFolder;
+ }
+ else
+ {
+ UString dirPrefix;
+ if (!NDirectory::GetOnlyDirPrefix(sysPath, dirPrefix))
+ dirPrefix.Empty();
+ if (_folder->BindToFolder(dirPrefix, &newFolder) == S_OK)
+ {
+ _folder = newFolder;
+ LoadFullPath();
+ UString fileName;
+ if (NDirectory::GetOnlyName(sysPath, fileName))
+ {
+ if (OpenItemAsArchive(fileName, _currentFolderPrefix,
+ _currentFolderPrefix + fileName, encrypted) == S_OK)
+ {
+ archiveIsOpened = true;
+ for (int i = reducedParts.Size() - 1; i >= 0; i--)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToFolder(reducedParts[i], &newFolder);
+ if (!newFolder)
+ break;
+ _folder = newFolder;
+ }
+ }
+ }
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CPanel::BindToPathAndRefresh(const UString &path)
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ bool archiveIsOpened, encrypted;
+ RINOK(BindToPath(path, archiveIsOpened, encrypted));
+ RefreshListCtrl(UString(), -1, true, UStringVector());
+ return S_OK;
+}
+
+void CPanel::SetBookmark(int index)
+{
+ _appState->FastFolders.SetString(index, _currentFolderPrefix);
+}
+
+void CPanel::OpenBookmark(int index)
+{
+ BindToPathAndRefresh(_appState->FastFolders.GetString(index));
+}
+
+UString GetFolderPath(IFolderFolder * folder)
+{
+ CMyComPtr<IFolderGetPath> folderGetPath;
+ if (folder->QueryInterface(IID_IFolderGetPath, (void **)&folderGetPath) == S_OK)
+ {
+ CMyComBSTR path;
+ if (folderGetPath->GetPath(&path) == S_OK)
+ return (const wchar_t *)path;
+ }
+ return UString();
+}
+
+void CPanel::LoadFullPath()
+{
+ _currentFolderPrefix.Empty();
+ for (int i = 0; i < _parentFolders.Size(); i++)
+ {
+ const CFolderLink &folderLink = _parentFolders[i];
+ _currentFolderPrefix += GetFolderPath(folderLink.ParentFolder);
+ _currentFolderPrefix += folderLink.ItemName;
+ _currentFolderPrefix += L'\\';
+ }
+ if (_folder)
+ _currentFolderPrefix += GetFolderPath(_folder);
+}
+
+void CPanel::LoadFullPathAndShow()
+{
+ LoadFullPath();
+ _appState->FolderHistory.AddString(_currentFolderPrefix);
+
+ // _headerComboBox.SendMessage(CB_RESETCONTENT, 0, 0);
+ _headerComboBox.SetText(_currentFolderPrefix);
+
+ /*
+ for (int i = 0; i < g_Folders.m_Strings.Size(); i++)
+ {
+ UString string = g_Folders.m_Strings[i];
+ COMBOBOXEXITEM item;
+ item.mask = CBEIF_TEXT;
+ item.iItem = i;
+ item.pszText = (LPTSTR)(LPCTSTR)string;
+ _headerComboBox.InsertItem(&item);
+ }
+ */
+}
+
+bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result)
+{
+ if (info->iWhy == CBENF_ESCAPE)
+ {
+ _headerComboBox.SetText(_currentFolderPrefix);
+ PostMessage(kSetFocusToListView);
+ result = FALSE;
+ return true;
+ }
+ if (info->iWhy == CBENF_DROPDOWN)
+ {
+ result = FALSE;
+ return true;
+ }
+
+ if (info->iWhy == CBENF_RETURN)
+ {
+ 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);
+ return true;
+ }
+ return false;
+}
+
+#ifndef _UNICODE
+bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
+{
+ if (info->iWhy == CBENF_ESCAPE)
+ {
+ _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);
+ return true;
+ }
+ return false;
+}
+#endif
+
+void CPanel::OnComboBoxCommand(UINT /* code */, LPARAM & /* param */)
+{
+ /*
+ if (code == CBN_SELENDOK)
+ {
+ 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);
+ }
+ */
+}
+
+bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result)
+{
+ switch(header->code)
+ {
+ case CBEN_BEGINEDIT:
+ {
+ _lastFocusedIsList = false;
+ _panelCallback->PanelWasFocused();
+ }
+ #ifndef _UNICODE
+ case CBEN_ENDEDIT:
+ {
+ return OnNotifyComboBoxEndEdit((PNMCBEENDEDIT)header, result);
+ }
+ #endif
+ case CBEN_ENDEDITW:
+ {
+ return OnNotifyComboBoxEndEdit((PNMCBEENDEDITW)header, result);
+ }
+ }
+ return false;
+}
+
+
+void CPanel::FoldersHistory()
+{
+ CListViewDialog listViewDialog;
+ listViewDialog.DeleteIsAllowed = true;
+ listViewDialog.Title = LangString(IDS_FOLDERS_HISTORY, 0x03020260);
+ _appState->FolderHistory.GetList(listViewDialog.Strings);
+ if (listViewDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ UString selectString;
+ if (listViewDialog.StringsWereChanged)
+ {
+ _appState->FolderHistory.RemoveAll();
+ for (int i = listViewDialog.Strings.Size() - 1; i >= 0; i--)
+ _appState->FolderHistory.AddString(listViewDialog.Strings[i]);
+ if (listViewDialog.FocusedItemIndex >= 0)
+ selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
+ }
+ else
+ {
+ if (listViewDialog.FocusedItemIndex >= 0)
+ selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
+ }
+ if (listViewDialog.FocusedItemIndex >= 0)
+ BindToPathAndRefresh(selectString);
+}
+
+void CPanel::OpenParentFolder()
+{
+ LoadFullPath(); // Maybe we don't need it ??
+ UString focucedName;
+ if (!_currentFolderPrefix.IsEmpty())
+ {
+ UString string = _currentFolderPrefix;
+ string.Delete(string.Length() - 1);
+ int pos = string.ReverseFind(L'\\');
+ if (pos < 0)
+ pos = 0;
+ else
+ pos++;
+ focucedName = string.Mid(pos);
+ }
+
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToParentFolder(&newFolder);
+ if (newFolder)
+ _folder = newFolder;
+ else
+ {
+ if (_parentFolders.IsEmpty())
+ {
+ SetToRootFolder();
+ if (focucedName.IsEmpty())
+ focucedName = GetItemName(0);
+ }
+ else
+ {
+ _folder.Release();
+ _library.Free();
+ CFolderLink &link = _parentFolders.Back();
+ _folder = link.ParentFolder;
+ _library.Attach(link.Library.Detach());
+ focucedName = link.ItemName;
+ if (_parentFolders.Size () > 1)
+ OpenParentArchiveFolder();
+ _parentFolders.DeleteBack();
+ }
+ }
+
+ UStringVector selectedItems;
+ /*
+ if (!focucedName.IsEmpty())
+ selectedItems.Add(focucedName);
+ */
+ LoadFullPath();
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
+ RefreshListCtrl(focucedName, -1, true, selectedItems);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+ RefreshStatusBar();
+}
+
+void CPanel::CloseOpenFolders()
+{
+ while(_parentFolders.Size() > 0)
+ {
+ _folder.Release();
+ _library.Free();
+ _folder = _parentFolders.Back().ParentFolder;
+ _library.Attach(_parentFolders.Back().Library.Detach());
+ if (_parentFolders.Size () > 1)
+ OpenParentArchiveFolder();
+ _parentFolders.DeleteBack();
+ }
+ _folder.Release();
+ _library.Free();
+}
+
+void CPanel::OpenRootFolder()
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ _parentFolders.Clear();
+ SetToRootFolder();
+ RefreshListCtrl(UString(), -1, true, UStringVector());
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
+ /*
+ BeforeChangeFolder();
+ _currentFolderPrefix.Empty();
+ AfterChangeFolder();
+ SetCurrentPathText();
+ RefreshListCtrl(UString(), 0, UStringVector());
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+ */
+}
+
+void CPanel::OpenDrivesFolder()
+{
+ CloseOpenFolders();
+ CFSDrives *fsFolderSpec = new CFSDrives;
+ _folder = fsFolderSpec;
+ fsFolderSpec->Init();
+ RefreshListCtrl();
+}
+
+void CPanel::OpenFolder(int index)
+{
+ if (index == kParentIndex)
+ {
+ OpenParentFolder();
+ return;
+ }
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToFolder(index, &newFolder);
+ if (!newFolder)
+ return;
+ _folder = newFolder;
+ LoadFullPath();
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
+ RefreshListCtrl();
+ UINT state = LVIS_SELECTED;
+ _listView.SetItemState(_listView.GetFocusedItem(), state, state);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+}
diff --git a/CPP/7zip/FileManager/PanelItemOpen.cpp b/CPP/7zip/FileManager/PanelItemOpen.cpp
new file mode 100755
index 00000000..be2d9024
--- /dev/null
+++ b/CPP/7zip/FileManager/PanelItemOpen.cpp
@@ -0,0 +1,546 @@
+// PanelItemOpen.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Common/StringConvert.h"
+#include "Common/Random.h"
+#include "Common/StringConvert.h"
+#include "Common/AutoPtr.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/Thread.h"
+#include "Windows/Synchronization.h"
+#include "Windows/Error.h"
+#include "Windows/COM.h"
+
+#include "ExtractCallback.h"
+#include "IFolder.h"
+#include "FileFolderPluginOpen.h"
+#include "FormatUtils.h"
+#include "Panel.h"
+#include "RegistryUtils.h"
+
+using namespace NWindows;
+using namespace NSynchronization;
+using namespace NFile;
+using namespace NDirectory;
+
+extern HWND g_HWND;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+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)
+{
+ return (name.Find(L" ") >= 0);
+}
+
+struct CTmpProcessInfo: public CTempFileInfo
+{
+ HANDLE ProcessHandle;
+ HWND Window;
+ UString FullPathFolderPrefix;
+};
+
+class CTmpProcessInfoRelease
+{
+ CTmpProcessInfo *_tmpProcessInfo;
+public:
+ bool _needDelete;
+ CTmpProcessInfoRelease(CTmpProcessInfo &tmpProcessInfo):
+ _tmpProcessInfo(&tmpProcessInfo), _needDelete(true) {}
+ ~CTmpProcessInfoRelease()
+ {
+ if (_needDelete)
+ _tmpProcessInfo->DeleteDirAndFile();
+ }
+};
+
+HRESULT CPanel::OpenItemAsArchive(const UString &name,
+ const UString &folderPath, const UString &filePath, bool &encrypted)
+{
+ encrypted = false;
+ CFolderLink folderLink;
+ if (!NFile::NFind::FindFile(filePath, folderLink.FileInfo))
+ return E_FAIL;
+ if (folderLink.FileInfo.IsDirectory())
+ return S_FALSE;
+
+ folderLink.FilePath = filePath;
+ folderLink.FolderPath = folderPath;
+
+ CMyComPtr<IFolderFolder> newFolder;
+
+ // _passwordIsDefined = false;
+ // _password.Empty();
+
+ NDLL::CLibrary library;
+ RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent(), encrypted));
+
+ folderLink.ParentFolder = _folder;
+ folderLink.ItemName = name;
+ _parentFolders.Add(folderLink);
+ _parentFolders.Back().Library.Attach(_library.Detach());
+
+ _folder.Release();
+ _library.Free();
+ _folder = newFolder;
+ _library.Attach(library.Detach());
+
+ return S_OK;
+}
+
+HRESULT CPanel::OpenItemAsArchive(const UString &name)
+{
+ bool encrypted;
+ return OpenItemAsArchive(name, _currentFolderPrefix, _currentFolderPrefix + name, encrypted);
+}
+
+HRESULT CPanel::OpenItemAsArchive(int index)
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ RINOK(OpenItemAsArchive(GetItemRelPath(index)));
+ RefreshListCtrl();
+ return S_OK;
+}
+
+HRESULT CPanel::OpenParentArchiveFolder()
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ if (_parentFolders.Size() < 2)
+ return S_OK;
+ CFolderLink &folderLink = _parentFolders.Back();
+ NFind::CFileInfoW newFileInfo;
+ if (NFind::FindFile(folderLink.FilePath, newFileInfo))
+ {
+ if (newFileInfo.Size != folderLink.FileInfo.Size ||
+ CompareFileTime(&newFileInfo.LastWriteTime,
+ &folderLink.FileInfo.LastWriteTime) != 0)
+ {
+ 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)
+ {
+ ::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
+ 0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ return S_OK;
+ }
+ }
+ }
+ }
+ folderLink.DeleteDirAndFile();
+ return S_OK;
+}
+
+static const wchar_t *kStartExtensions[] =
+{
+ L"exe",
+ L"bat",
+ L"com",
+ L"chm",
+ L"msi",
+ L"doc",
+ L"odt",
+ L"pdf",
+ L"xls"
+};
+
+static bool DoItemAlwaysStart(const UString &name)
+{
+ int extPos = name.ReverseFind('.');
+ if (extPos < 0)
+ return false;
+ UString ext = name.Mid(extPos + 1);
+ ext.MakeLower();
+ for (int i = 0; i < sizeof(kStartExtensions) / sizeof(kStartExtensions[0]); i++)
+ if (ext.Compare(kStartExtensions[i]) == 0)
+ return true;
+ return false;
+}
+
+static HANDLE StartEditApplication(const UString &path, HWND window)
+{
+ UString command;
+ ReadRegEditor(command);
+ if (command.IsEmpty())
+ {
+ if (!MyGetWindowsDirectory(command))
+ return 0;
+ NFile::NName::NormalizeDirPathPrefix(command);
+ command += L"notepad.exe";
+ }
+ command = UString(L"\"") + command + UString(L"\"");
+ command += L" \"";
+ command += UString(path);
+ command += L"\"";
+
+ PROCESS_INFORMATION processInformation;
+ BOOL result;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ STARTUPINFOA startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command),
+ NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+ else
+ #endif
+ {
+ STARTUPINFOW startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command,
+ NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+
+ if (result != FALSE)
+ {
+ ::CloseHandle(processInformation.hThread);
+ return processInformation.hProcess;
+ }
+ ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282),
+ L"7-Zip", MB_OK | MB_ICONSTOP);
+ return 0;
+}
+
+#ifndef _UNICODE
+typedef BOOL (WINAPI * ShellExecuteExWP)(LPSHELLEXECUTEINFOW lpExecInfo);
+#endif
+
+static HANDLE StartApplication(const UString &path, HWND window)
+{
+ UINT32 result;
+ HANDLE hProcess;
+ #ifndef _UNICODE
+ if (g_IsNT)
+ {
+ SHELLEXECUTEINFOW execInfo;
+ execInfo.cbSize = sizeof(execInfo);
+ execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
+ execInfo.hwnd = NULL;
+ execInfo.lpVerb = NULL;
+ execInfo.lpFile = path;
+ execInfo.lpParameters = NULL;
+ execInfo.lpDirectory = NULL;
+ execInfo.nShow = SW_SHOWNORMAL;
+ execInfo.hProcess = 0;
+ ShellExecuteExWP shellExecuteExW = (ShellExecuteExWP)
+ ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "ShellExecuteExW");
+ if (shellExecuteExW == 0)
+ return 0;
+ shellExecuteExW(&execInfo);
+ result = (UINT32)(UINT_PTR)execInfo.hInstApp;
+ hProcess = execInfo.hProcess;
+ }
+ else
+ #endif
+ {
+ SHELLEXECUTEINFO execInfo;
+ execInfo.cbSize = sizeof(execInfo);
+ execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
+ execInfo.hwnd = NULL;
+ execInfo.lpVerb = NULL;
+ const CSysString sysPath = GetSystemString(path);
+ execInfo.lpFile = sysPath;
+ execInfo.lpParameters = NULL;
+ execInfo.lpDirectory = NULL;
+ execInfo.nShow = SW_SHOWNORMAL;
+ execInfo.hProcess = 0;
+ ::ShellExecuteEx(&execInfo);
+ result = (UINT32)(UINT_PTR)execInfo.hInstApp;
+ hProcess = execInfo.hProcess;
+ }
+ if(result <= 32)
+ {
+ switch(result)
+ {
+ case SE_ERR_NOASSOC:
+ ::MessageBoxW(window,
+ NError::MyFormatMessageW(::GetLastError()),
+ // L"There is no application associated with the given file name extension",
+ L"7-Zip", MB_OK | MB_ICONSTOP);
+ }
+ }
+ return hProcess;
+}
+
+void CPanel::EditItem(int index)
+{
+ if (!_parentFolders.IsEmpty())
+ {
+ OpenItemInArchive(index, false, true, true);
+ return;
+ }
+ HANDLE hProcess = StartEditApplication(_currentFolderPrefix + GetItemRelPath(index), (HWND)*this);
+ if (hProcess != 0)
+ ::CloseHandle(hProcess);
+}
+
+void CPanel::OpenFolderExternal(int index)
+{
+ HANDLE hProcess = StartApplication(GetFsPath() + GetItemRelPath(index), (HWND)*this);
+ if (hProcess != 0)
+ ::CloseHandle(hProcess);
+}
+
+void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal)
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ if (!_parentFolders.IsEmpty())
+ {
+ OpenItemInArchive(index, tryInternal, tryExternal, false);
+ return;
+ }
+ UString name = GetItemRelPath(index);
+ if (IsNameVirus(name))
+ {
+ MessageBoxMyError(virusMessage);
+ return;
+ }
+ UString fullPath = _currentFolderPrefix + name;
+ if (tryInternal)
+ if (!tryExternal || !DoItemAlwaysStart(name))
+ if (OpenItemAsArchive(index) == S_OK)
+ return;
+ if (tryExternal)
+ {
+ NDirectory::MySetCurrentDirectory(_currentFolderPrefix);
+ HANDLE hProcess = StartApplication(fullPath, (HWND)*this);
+ if (hProcess != 0)
+ ::CloseHandle(hProcess);
+ }
+}
+
+HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return E_FAIL;
+ }
+ UStringVector fileNames;
+ CRecordVector<const wchar_t *> fileNamePointers;
+ fileNames.Add(itemName);
+ fileNamePointers.Add(fileNames[0]);
+
+ UString pathPrefix = folderPath;
+ NName::NormalizeDirPathPrefix(pathPrefix);
+ return folderOperations->CopyFrom(pathPrefix, &fileNamePointers.Front(),fileNamePointers.Size(), NULL);
+}
+
+LRESULT CPanel::OnOpenItemChanged(LPARAM lParam)
+{
+ CTmpProcessInfo &tmpProcessInfo = *(CTmpProcessInfo *)lParam;
+ // LoadCurrentPath()
+ if (tmpProcessInfo.FullPathFolderPrefix != _currentFolderPrefix)
+ return 0;
+
+ CSelectedState state;
+ SaveSelectedState(state);
+
+ HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName);
+ if (result != S_OK)
+ return 0;
+ RefreshListCtrl(state);
+ return 1;
+}
+
+/*
+class CTmpProcessInfoList
+{
+public:
+ CObjectVector<CTmpProcessInfo> _items;
+} g_TmpProcessInfoList;
+*/
+
+class CExitEventLauncher
+{
+public:
+ CManualResetEvent _exitEvent;
+ CExitEventLauncher(): _exitEvent(false) {};
+ ~CExitEventLauncher() { _exitEvent.Set(); }
+} g_ExitEventLauncher;
+
+static DWORD WINAPI MyThreadFunction(void *param)
+{
+ CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr((CTmpProcessInfo *)param);
+ CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
+
+ HANDLE hProcess = tmpProcessInfo->ProcessHandle;
+ HANDLE events[2] = { g_ExitEventLauncher._exitEvent, hProcess};
+ DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
+ ::CloseHandle(hProcess);
+ if (waitResult == WAIT_OBJECT_0 + 0)
+ return 0;
+ if (waitResult != WAIT_OBJECT_0 + 1)
+ return 1;
+ Sleep(200);
+ NFind::CFileInfoW newFileInfo;
+ if (NFind::FindFile(tmpProcessInfo->FilePath, newFileInfo))
+ {
+ if (newFileInfo.Size != tmpProcessInfo->FileInfo.Size ||
+ CompareFileTime(&newFileInfo.LastWriteTime,
+ &tmpProcessInfo->FileInfo.LastWriteTime) != 0)
+ {
+ 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,
+ 0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ return 0;
+ }
+ }
+ }
+ }
+ tmpProcessInfo->DeleteDirAndFile();
+ return 0;
+}
+
+void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
+ bool editMode)
+{
+ const UString name = GetItemName(index);
+ if (IsNameVirus(name))
+ {
+ MessageBoxMyError(virusMessage);
+ return;
+ }
+
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+
+ NFile::NDirectory::CTempDirectoryW tempDirectory;
+ tempDirectory.Create(kTempDirPrefix);
+ UString tempDir = tempDirectory.GetPath();
+ UString tempDirNorm = tempDir;
+ NFile::NName::NormalizeDirPathPrefix(tempDirNorm);
+
+ CRecordVector<UInt32> indices;
+ indices.Add(index);
+
+ UStringVector messages;
+ HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages);
+
+ if (!messages.IsEmpty())
+ return;
+ if (result != S_OK)
+ {
+ if (result != E_ABORT)
+ MessageBoxError(result);
+ return;
+ }
+
+ UString tempFilePath = tempDirNorm + name;
+
+ CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo());
+ CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
+ tmpProcessInfo->FolderPath = tempDir;
+ tmpProcessInfo->FilePath = tempFilePath;
+ if (!NFind::FindFile(tempFilePath, tmpProcessInfo->FileInfo))
+ return;
+
+ if (tryInternal)
+ {
+ if (!tryExternal || !DoItemAlwaysStart(name))
+ {
+ bool encrypted;
+ if (OpenItemAsArchive(name, tempDir, tempFilePath, encrypted) == S_OK)
+ {
+ RefreshListCtrl();
+ return;
+ }
+ }
+ }
+
+ CTmpProcessInfoRelease tmpProcessInfoRelease(*tmpProcessInfo);
+
+ if (!tryExternal)
+ return;
+
+ HANDLE hProcess;
+ if (editMode)
+ hProcess = StartEditApplication(tempFilePath, (HWND)*this);
+ else
+ hProcess = StartApplication(tempFilePath, (HWND)*this);
+
+ if (hProcess == 0)
+ return;
+
+ tmpProcessInfo->Window = (HWND)(*this);
+ tmpProcessInfo->FullPathFolderPrefix = _currentFolderPrefix;
+ tmpProcessInfo->ItemName = name;
+ tmpProcessInfo->ProcessHandle = hProcess;
+
+ CThread thread;
+ if (!thread.Create(MyThreadFunction, tmpProcessInfo))
+ throw 271824;
+ tempDirectory.DisableDeleting();
+ tmpProcessInfoPtr.release();
+ tmpProcessInfoRelease._needDelete = false;
+}
+
+/*
+static const UINT64 kTimeLimit = UINT64(10000000) * 3600 * 24;
+
+static bool CheckDeleteItem(UINT64 currentFileTime, UINT64 folderFileTime)
+{
+ return (currentFileTime - folderFileTime > kTimeLimit &&
+ folderFileTime - currentFileTime > kTimeLimit);
+}
+
+void DeleteOldTempFiles()
+{
+ UString tempPath;
+ if(!NFile::NDirectory::MyGetTempPath(tempPath))
+ throw 1;
+
+ SYSTEMTIME systemTime;
+ ::GetSystemTime(&systemTime);
+ UINT64 currentFileTime;
+ if(!::SystemTimeToFileTime(&systemTime, (FILETIME *)&currentFileTime))
+ throw 2;
+ UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
+ searchWildCard += WCHAR(NName::kAnyStringWildcard);
+ NFind::CEnumeratorW enumerator(searchWildCard);
+ NFind::CFileInfoW fileInfo;
+ while(enumerator.Next(fileInfo))
+ {
+ if (!fileInfo.IsDirectory())
+ continue;
+ const UINT64 &creationTime = *(const UINT64 *)(&fileInfo.CreationTime);
+ if(CheckDeleteItem(creationTime, currentFileTime))
+ RemoveDirectoryWithSubItems(tempPath + fileInfo.Name);
+ }
+}
+*/
diff --git a/CPP/7zip/FileManager/PanelItems.cpp b/CPP/7zip/FileManager/PanelItems.cpp
new file mode 100755
index 00000000..16c8d29a
--- /dev/null
+++ b/CPP/7zip/FileManager/PanelItems.cpp
@@ -0,0 +1,822 @@
+// PanelItems.cpp
+
+#include "StdAfx.h"
+
+#include "Common/String.h"
+#include "Common/StringConvert.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"
+
+extern "C"
+{
+ #include "../../../C/Sort.h"
+}
+
+using namespace NWindows;
+
+static int GetColumnAlign(PROPID propID, VARTYPE varType)
+{
+ switch(propID)
+ {
+ case kpidCreationTime:
+ case kpidLastAccessTime:
+ case kpidLastWriteTime:
+ return LVCFMT_LEFT;
+ }
+ switch(varType)
+ {
+ case VT_UI1:
+ case VT_I2:
+ case VT_UI2:
+ case VT_I4:
+ case VT_INT:
+ case VT_UI4:
+ case VT_UINT:
+ case VT_I8:
+ case VT_UI8:
+ case VT_BOOL:
+ return LVCFMT_RIGHT;
+
+ case VT_EMPTY:
+ case VT_I1:
+ case VT_FILETIME:
+ case VT_BSTR:
+ return LVCFMT_LEFT;
+
+ default:
+ return LVCFMT_CENTER;
+ }
+}
+
+void CPanel::InitColumns()
+{
+ if (_needSaveInfo)
+ SaveListViewInfo();
+
+ _listView.DeleteAllItems();
+ _selectedStatusVector.Clear();
+
+ ReadListViewInfo();
+
+
+ PROPID sortID;
+ /*
+ if (_listViewInfo.SortIndex >= 0)
+ sortID = _listViewInfo.Columns[_listViewInfo.SortIndex].PropID;
+ */
+ sortID = _listViewInfo.SortID;
+
+ _ascending = _listViewInfo.Ascending;
+
+ _properties.Clear();
+
+ CMyComPtr<IEnumProperties> enumProperties;
+ // CMyComPtr<IEnumSTATPROPSTG> enumSTATPROPSTG;
+ /*
+ if (m_ArchiveHandler)
+ {
+ if (m_ArchiveHandler->EnumProperties(&enumSTATPROPSTG) != S_OK)
+ throw 1;
+ }
+ else
+ */
+ {
+ if (_folder.QueryInterface(IID_IEnumProperties, &enumProperties) != S_OK)
+ throw 1;
+ /*
+ if (enumProperties->EnumProperties(&enumSTATPROPSTG)!= S_OK)
+ throw 1;
+ */
+ }
+
+ _needSaveInfo = true;
+
+ UINT32 numProperties;
+ enumProperties->GetNumberOfProperties(&numProperties);
+ int i;
+ for (i = 0; i < (int)numProperties; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE varType;
+
+ if (enumProperties->GetPropertyInfo(i, &name, &propID, &varType) != S_OK)
+ throw 1;
+
+ CItemProperty destProperty;
+ destProperty.Type = varType;
+ destProperty.ID = propID;
+ if (propID == kpidIsFolder)
+ 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);
+ }
+ // InitColumns2(sortID);
+
+ for (;;)
+ if (!_listView.DeleteColumn(0))
+ break;
+
+ int order = 0;
+ for(i = 0; i < _listViewInfo.Columns.Size(); i++)
+ {
+ const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
+ int index = _properties.FindItemWithID(columnInfo.PropID);
+ if (index >= 0)
+ {
+ CItemProperty &item = _properties[index];
+ item.IsVisible = columnInfo.IsVisible;
+ item.Width = columnInfo.Width;
+ if (columnInfo.IsVisible)
+ item.Order = order++;
+ continue;
+ }
+ }
+ for(i = 0; i < _properties.Size(); i++)
+ {
+ CItemProperty &item = _properties[i];
+ if (item.Order < 0)
+ item.Order = order++;
+ }
+
+ _visibleProperties.Clear();
+ for (i = 0; i < _properties.Size(); i++)
+ {
+ const CItemProperty &property = _properties[i];
+ if (property.IsVisible)
+ _visibleProperties.Add(property);
+ }
+
+ // _sortIndex = 0;
+ _sortID = kpidName;
+ /*
+ if (_listViewInfo.SortIndex >= 0)
+ {
+ int sortIndex = _properties.FindItemWithID(sortID);
+ if (sortIndex >= 0)
+ _sortIndex = sortIndex;
+ }
+ */
+ _sortID = _listViewInfo.SortID;
+
+ for (i = 0; i < _visibleProperties.Size(); i++)
+ {
+ InsertColumn(i);
+ }
+}
+
+void CPanel::InsertColumn(int index)
+{
+ const CItemProperty &property = _visibleProperties[index];
+ LV_COLUMNW column;
+ column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
+ column.cx = property.Width;
+ 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;
+ _listView.InsertColumn(index, &column);
+}
+
+void CPanel::RefreshListCtrl()
+{
+ RefreshListCtrl(UString(), -1, true, UStringVector());
+}
+
+int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
+
+
+void CPanel::GetSelectedNames(UStringVector &selectedNames)
+{
+ selectedNames.Clear();
+
+ CRecordVector<UINT32> indices;
+ GetSelectedItemsIndices(indices);
+ selectedNames.Reserve(indices.Size());
+ for (int i = 0; i < indices.Size(); i++)
+ selectedNames.Add(GetItemRelPath(indices[i]));
+
+ /*
+ for (int i = 0; i < _listView.GetItemCount(); i++)
+ {
+ const int kSize = 1024;
+ WCHAR name[kSize + 1];
+ LVITEMW item;
+ item.iItem = i;
+ item.pszText = name;
+ item.cchTextMax = kSize;
+ item.iSubItem = 0;
+ item.mask = LVIF_TEXT | LVIF_PARAM;
+ if (!_listView.GetItem(&item))
+ continue;
+ int realIndex = GetRealIndex(item);
+ if (realIndex == kParentIndex)
+ continue;
+ if (_selectedStatusVector[realIndex])
+ selectedNames.Add(item.pszText);
+ }
+ */
+ selectedNames.Sort();
+}
+
+void CPanel::SaveSelectedState(CSelectedState &s)
+{
+ s.FocusedName.Empty();
+ s.SelectedNames.Clear();
+ s.FocusedItem = _listView.GetFocusedItem();
+ {
+ if (s.FocusedItem >= 0)
+ {
+ int realIndex = GetRealItemIndex(s.FocusedItem);
+ if (realIndex != kParentIndex)
+ s.FocusedName = GetItemRelPath(realIndex);
+ /*
+ const int kSize = 1024;
+ WCHAR name[kSize + 1];
+ LVITEMW item;
+ item.iItem = focusedItem;
+ item.pszText = name;
+ item.cchTextMax = kSize;
+ item.iSubItem = 0;
+ item.mask = LVIF_TEXT;
+ if (_listView.GetItem(&item))
+ focusedName = item.pszText;
+ */
+ }
+ }
+ GetSelectedNames(s.SelectedNames);
+}
+
+void CPanel::RefreshListCtrl(const CSelectedState &s)
+{
+ bool selectFocused = s.SelectFocused;
+ if (_mySelectMode)
+ selectFocused = true;
+ RefreshListCtrl(s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
+}
+
+void CPanel::RefreshListCtrlSaveFocused()
+{
+ CSelectedState state;
+ SaveSelectedState(state);
+ RefreshListCtrl(state);
+}
+
+void CPanel::SetFocusedSelectedItem(int index, bool select)
+{
+ UINT state = LVIS_FOCUSED;
+ if (select)
+ state |= LVIS_SELECTED;
+ _listView.SetItemState(index, state, state);
+ if (!_mySelectMode && select)
+ {
+ int realIndex = GetRealItemIndex(index);
+ if (realIndex != kParentIndex)
+ _selectedStatusVector[realIndex] = true;
+ }
+}
+
+void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
+ const UStringVector &selectedNames)
+{
+ _dontShowMode = false;
+ LoadFullPathAndShow();
+ // OutputDebugStringA("=======\n");
+ // OutputDebugStringA("s1 \n");
+ CDisableTimerProcessing timerProcessing(*this);
+
+ if (focusedPos < 0)
+ focusedPos = 0;
+
+ _listView.SetRedraw(false);
+ // m_RedrawEnabled = false;
+
+ LVITEMW item;
+ ZeroMemory(&item, sizeof(item));
+
+ _listView.DeleteAllItems();
+ _selectedStatusVector.Clear();
+ // _realIndices.Clear();
+ _startGroupSelect = 0;
+
+ _selectionIsDefined = false;
+
+ // m_Files.Clear();
+ // _folder.Release();
+
+ if (!_folder)
+ {
+ // throw 1;
+ SetToRootFolder();
+ }
+
+ _headerToolBar.EnableButton(kParentFolderID, !IsRootFolder());
+
+ CMyComPtr<IFolderSetFlatMode> folderSetFlatMode;
+ _folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode);
+ if (folderSetFlatMode)
+ folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
+
+ if (_folder->LoadItems() != S_OK)
+ return;
+
+ InitColumns();
+
+
+ // OutputDebugString(TEXT("Start Dir\n"));
+ UINT32 numItems;
+ _folder->GetNumberOfItems(&numItems);
+
+ bool showDots = _showDots && !IsRootFolder();
+
+ _listView.SetItemCount(numItems + (showDots ? 1 : 0));
+
+ _selectedStatusVector.Reserve(numItems);
+ int cursorIndex = -1;
+
+ CMyComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
+ if (!IsFSFolder() || _showRealFileIcons)
+ _folder.QueryInterface(IID_IFolderGetSystemIconIndex, &folderGetSystemIconIndex);
+
+ if (showDots)
+ {
+ UString itemName = L"..";
+ item.iItem = _listView.GetItemCount();
+ if (itemName.CompareNoCase(focusedName) == 0)
+ cursorIndex = item.iItem;
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ int subItem = 0;
+ item.iSubItem = subItem++;
+ item.lParam = kParentIndex;
+ item.pszText = (wchar_t *)(const wchar_t *)itemName;
+ UINT32 attributes = FILE_ATTRIBUTE_DIRECTORY;
+ item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
+ if (item.iImage < 0)
+ item.iImage = 0;
+ if(_listView.InsertItem(&item) == -1)
+ return;
+ }
+
+ // OutputDebugStringA("S1\n");
+
+ for(UInt32 i = 0; i < numItems; i++)
+ {
+ UString itemName = GetItemName(i);
+ const UString relPath = GetItemRelPath(i);
+ if (relPath.CompareNoCase(focusedName) == 0)
+ cursorIndex = _listView.GetItemCount();
+ bool selected = false;
+ if (selectedNames.FindInSorted(relPath) >= 0)
+ selected = true;
+ _selectedStatusVector.Add(selected);
+
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+
+ if (!_mySelectMode)
+ if (selected)
+ {
+ item.mask |= LVIF_STATE;
+ item.state = LVIS_SELECTED;
+ }
+
+ int subItem = 0;
+ item.iItem = _listView.GetItemCount();
+
+ item.iSubItem = subItem++;
+ item.lParam = i;
+
+ UString correctedName;
+ if (itemName.Find(L" ") >= 0)
+ {
+ int pos = 0;
+ for (;;)
+ {
+ int posNew = itemName.Find(L" ", pos);
+ if (posNew < 0)
+ {
+ correctedName += itemName.Mid(pos);
+ break;
+ }
+ correctedName += itemName.Mid(pos, posNew - pos);
+ correctedName += L" ... ";
+ pos = posNew;
+ while (itemName[++pos] == ' ');
+ }
+ item.pszText = (wchar_t *)(const wchar_t *)correctedName;
+ }
+ else
+ item.pszText = (wchar_t *)(const wchar_t *)itemName;
+
+ NCOM::CPropVariant propVariant;
+ _folder->GetProperty(i, kpidAttributes, &propVariant);
+ UINT32 attributes = 0;
+ if (propVariant.vt == VT_UI4)
+ attributes = propVariant.ulVal;
+ else
+ {
+ if (IsItemFolder(i))
+ attributes |= FILE_ATTRIBUTE_DIRECTORY;
+ }
+
+ bool defined = false;
+
+ if (folderGetSystemIconIndex)
+ {
+ folderGetSystemIconIndex->GetSystemIconIndex(i, &item.iImage);
+ defined = (item.iImage > 0);
+ }
+ if (!defined)
+ {
+ if (_currentFolderPrefix.IsEmpty())
+ {
+ int iconIndexTemp;
+ GetRealIconIndex(itemName + L"\\", attributes, iconIndexTemp);
+ item.iImage = iconIndexTemp;
+ }
+ else
+ {
+ item.iImage = _extToIconMap.GetIconIndex(attributes, itemName);
+ }
+ }
+ if (item.iImage < 0)
+ item.iImage = 0;
+
+ if(_listView.InsertItem(&item) == -1)
+ return; // error
+ }
+ // OutputDebugStringA("End2\n");
+
+ if(_listView.GetItemCount() > 0 && cursorIndex >= 0)
+ SetFocusedSelectedItem(cursorIndex, selectFocused);
+ _listView.SortItems(CompareItems, (LPARAM)this);
+ if (cursorIndex < 0 && _listView.GetItemCount() > 0)
+ {
+ if (focusedPos >= _listView.GetItemCount())
+ focusedPos = _listView.GetItemCount() - 1;
+ SetFocusedSelectedItem(focusedPos, true);
+ }
+ // m_RedrawEnabled = true;
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+ _listView.SetRedraw(true);
+ _listView.InvalidateRect(NULL, true);
+ // OutputDebugStringA("End1\n");
+ /*
+ _listView.UpdateWindow();
+ */
+}
+
+void CPanel::GetSelectedItemsIndices(CRecordVector<UINT32> &indices) const
+{
+ indices.Clear();
+ /*
+ int itemIndex = -1;
+ while ((itemIndex = _listView.GetNextItem(itemIndex, LVNI_SELECTED)) != -1)
+ {
+ LPARAM param;
+ if (_listView.GetItemParam(itemIndex, param))
+ indices.Add(param);
+ }
+ */
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (_selectedStatusVector[i])
+ indices.Add(i);
+ HeapSort(&indices.Front(), indices.Size());
+}
+
+void CPanel::GetOperatedItemIndices(CRecordVector<UINT32> &indices) const
+{
+ GetSelectedItemsIndices(indices);
+ if (!indices.IsEmpty())
+ return;
+ if (_listView.GetSelectedCount() == 0)
+ return;
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem >= 0)
+ {
+ if(_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
+ {
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex != kParentIndex)
+ indices.Add(realIndex);
+ }
+ }
+}
+
+/*
+void CPanel::GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const
+{
+ indices.Clear();
+ int numItems = _listView.GetItemCount();
+ for (int i = 0; i < numItems; i++)
+ {
+ int realIndex = GetRealItemIndex(i);
+ if (realIndex >= 0)
+ if (_selectedStatusVector[realIndex])
+ indices.Add(i);
+ }
+ if (indices.IsEmpty())
+ {
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem >= 0)
+ indices.Add(focusedItem);
+ }
+}
+*/
+
+void CPanel::EditItem()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex == kParentIndex)
+ return;
+ if (!IsItemFolder(realIndex))
+ EditItem(realIndex);
+}
+
+void CPanel::OpenFocusedItemAsInternal()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (IsItemFolder(realIndex))
+ OpenFolder(realIndex);
+ else
+ OpenItem(realIndex, true, false);
+}
+
+void CPanel::OpenSelectedItems(bool tryInternal)
+{
+ CRecordVector<UINT32> indices;
+ GetOperatedItemIndices(indices);
+ if (indices.Size() > 20)
+ {
+ MessageBox(LangString(IDS_TOO_MANY_ITEMS, 0x02000606));
+ return;
+ }
+
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem >= 0)
+ {
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0))
+ indices.Insert(0, realIndex);
+ }
+
+ bool dirIsStarted = false;
+ for(int i = 0; i < indices.Size(); i++)
+ {
+ UINT32 index = indices[i];
+ // CFileInfo &aFile = m_Files[index];
+ if (IsItemFolder(index))
+ {
+ if (!dirIsStarted)
+ {
+ if (tryInternal)
+ {
+ OpenFolder(index);
+ dirIsStarted = true;
+ break;
+ }
+ else
+ OpenFolderExternal(index);
+ }
+ }
+ else
+ OpenItem(index, (tryInternal && indices.Size() == 1), true);
+ }
+}
+
+UString CPanel::GetItemName(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return L"..";
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(itemIndex, kpidName, &propVariant) != S_OK)
+ throw 2723400;
+ if (propVariant.vt != VT_BSTR)
+ throw 2723401;
+ return (propVariant.bstrVal);
+}
+
+UString CPanel::GetItemPrefix(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return UString();
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(itemIndex, kpidPrefix, &propVariant) != S_OK)
+ throw 2723400;
+ UString prefix;
+ if (propVariant.vt == VT_BSTR)
+ prefix = propVariant.bstrVal;
+ return prefix;
+}
+
+UString CPanel::GetItemRelPath(int itemIndex) const
+{
+ return GetItemPrefix(itemIndex) + GetItemName(itemIndex);
+}
+
+
+bool CPanel::IsItemFolder(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return true;
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(itemIndex, kpidIsFolder, &propVariant) != S_OK)
+ throw 2723400;
+ if (propVariant.vt == VT_BOOL)
+ return VARIANT_BOOLToBool(propVariant.boolVal);
+ if (propVariant.vt == VT_EMPTY)
+ return false;
+ return false;
+}
+
+UINT64 CPanel::GetItemSize(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return 0;
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(itemIndex, kpidSize, &propVariant) != S_OK)
+ throw 2723400;
+ if (propVariant.vt == VT_EMPTY)
+ return 0;
+ return ConvertPropVariantToUInt64(propVariant);
+}
+
+void CPanel::ReadListViewInfo()
+{
+ CMyComPtr<IFolderGetTypeID> folderGetTypeID;
+ if(_folder.QueryInterface(IID_IFolderGetTypeID, &folderGetTypeID) != S_OK)
+ return;
+ CMyComBSTR typeID;
+ folderGetTypeID->GetTypeID(&typeID);
+ _typeIDString = typeID;
+ ::ReadListViewInfo(_typeIDString, _listViewInfo);
+}
+
+void CPanel::SaveListViewInfo()
+{
+ int i;
+ for(i = 0; i < _visibleProperties.Size(); i++)
+ {
+ CItemProperty &property = _visibleProperties[i];
+ LVCOLUMN winColumnInfo;
+ winColumnInfo.mask = LVCF_ORDER | LVCF_WIDTH;
+ if (!_listView.GetColumn(i, &winColumnInfo))
+ throw 1;
+ property.Order = winColumnInfo.iOrder;
+ property.Width = winColumnInfo.cx;
+ }
+
+ CListViewInfo viewInfo;
+
+ // PROPID sortPropID = _properties[_sortIndex].ID;
+ PROPID sortPropID = _sortID;
+
+ _visibleProperties.Sort();
+ for(i = 0; i < _visibleProperties.Size(); i++)
+ {
+ const CItemProperty &property = _visibleProperties[i];
+ CColumnInfo columnInfo;
+ columnInfo.IsVisible = property.IsVisible;
+ columnInfo.PropID = property.ID;
+ columnInfo.Width = property.Width;
+ viewInfo.Columns.Add(columnInfo);
+ }
+ for(i = 0; i < _properties.Size(); i++)
+ {
+ const CItemProperty &property = _properties[i];
+ if (!property.IsVisible)
+ {
+ CColumnInfo columnInfo;
+ columnInfo.IsVisible = property.IsVisible;
+ columnInfo.PropID = property.ID;
+ columnInfo.Width = property.Width;
+ viewInfo.Columns.Add(columnInfo);
+ }
+ }
+
+ // viewInfo.SortIndex = viewInfo.FindColumnWithID(sortPropID);
+ viewInfo.SortID = sortPropID;
+
+ viewInfo.Ascending = _ascending;
+ if (!_listViewInfo.IsEqual(viewInfo))
+ {
+ ::SaveListViewInfo(_typeIDString, viewInfo);
+ _listViewInfo = viewInfo;
+ }
+}
+
+bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result)
+{
+ if(itemActiveate->hdr.hwndFrom == HWND(_listView))
+ return false;
+
+ POINT point;
+ ::GetCursorPos(&point);
+
+ CMenu menu;
+ CMenuDestroyer menuDestroyer(menu);
+
+ menu.CreatePopup();
+
+ const int kCommandStart = 100;
+ for(int i = 0; i < _properties.Size(); i++)
+ {
+ const CItemProperty &property = _properties[i];
+ UINT flags = MF_STRING;
+ if (property.IsVisible)
+ flags |= MF_CHECKED;
+ if (i == 0)
+ flags |= MF_GRAYED;
+ menu.AppendItem(flags, kCommandStart + i, GetSystemString(property.Name));
+ }
+ int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY,
+ point.x, point.y, _listView);
+ if (menuResult >= kCommandStart && menuResult <= kCommandStart + _properties.Size())
+ {
+ int index = menuResult - kCommandStart;
+ CItemProperty &property = _properties[index];
+ property.IsVisible = !property.IsVisible;
+
+ if (property.IsVisible)
+ {
+ int prevVisibleSize = _visibleProperties.Size();
+ property.Order = prevVisibleSize;
+ _visibleProperties.Add(property);
+ InsertColumn(prevVisibleSize);
+ }
+ else
+ {
+ int visibleIndex = _visibleProperties.FindItemWithID(property.ID);
+ _visibleProperties.Delete(visibleIndex);
+ /*
+ if (_sortIndex == index)
+ {
+ _sortIndex = 0;
+ _ascending = true;
+ }
+ */
+ if (_sortID == property.ID)
+ {
+ _sortID = kpidName;
+ _ascending = true;
+ }
+
+ _listView.DeleteColumn(visibleIndex);
+ }
+ }
+ result = TRUE;
+ return true;
+}
+
+void CPanel::OnReload()
+{
+ RefreshListCtrlSaveFocused();
+ OnRefreshStatusBar();
+}
+
+void CPanel::OnTimer()
+{
+ if (!_processTimer)
+ return;
+ CMyComPtr<IFolderWasChanged> folderWasChanged;
+ if (_folder.QueryInterface(IID_IFolderWasChanged, &folderWasChanged) != S_OK)
+ return;
+ INT32 wasChanged;
+ if (folderWasChanged->WasChanged(&wasChanged) != S_OK)
+ return;
+ if (wasChanged == 0)
+ return;
+ OnReload();
+}
+
diff --git a/7zip/FileManager/PanelKey.cpp b/CPP/7zip/FileManager/PanelKey.cpp
index 9c6ddac1..9c6ddac1 100755
--- a/7zip/FileManager/PanelKey.cpp
+++ b/CPP/7zip/FileManager/PanelKey.cpp
diff --git a/7zip/FileManager/PanelListNotify.cpp b/CPP/7zip/FileManager/PanelListNotify.cpp
index 44bb3e8b..44bb3e8b 100755
--- a/7zip/FileManager/PanelListNotify.cpp
+++ b/CPP/7zip/FileManager/PanelListNotify.cpp
diff --git a/7zip/FileManager/PanelMenu.cpp b/CPP/7zip/FileManager/PanelMenu.cpp
index 64db53ee..64db53ee 100755
--- a/7zip/FileManager/PanelMenu.cpp
+++ b/CPP/7zip/FileManager/PanelMenu.cpp
diff --git a/CPP/7zip/FileManager/PanelOperations.cpp b/CPP/7zip/FileManager/PanelOperations.cpp
new file mode 100755
index 00000000..66993f39
--- /dev/null
+++ b/CPP/7zip/FileManager/PanelOperations.cpp
@@ -0,0 +1,396 @@
+// PanelOperations.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Panel.h"
+
+#include "Common/StringConvert.h"
+#include "Common/DynamicBuffer.h"
+#include "Windows/FileDir.h"
+#include "Windows/ResourceString.h"
+#include "Windows/Thread.h"
+#include "Windows/COM.h"
+
+#include "Resource/ComboDialog/ComboDialog.h"
+
+#include "FSFolder.h"
+#include "LangUtils.h"
+#include "FormatUtils.h"
+
+#include "UpdateCallback100.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+struct CThreadDelete
+{
+ CMyComPtr<IFolderOperations> FolderOperations;
+ CRecordVector<UInt32> Indices;
+ CMyComPtr<IFolderArchiveUpdateCallback> UpdateCallback;
+ CUpdateCallback100Imp *UpdateCallbackSpec;
+ HRESULT Result;
+
+ DWORD Process()
+ {
+ NCOM::CComInitializer comInitializer;
+ UpdateCallbackSpec->ProgressDialog.WaitCreating();
+ Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback);
+ UpdateCallbackSpec->ProgressDialog.MyClose();
+ return 0;
+ }
+
+ static DWORD WINAPI MyThreadFunction(void *param)
+ {
+ return ((CThreadDelete *)param)->Process();
+ }
+};
+
+#ifndef _UNICODE
+typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp);
+#endif
+
+void CPanel::DeleteItems(bool toRecycleBin)
+{
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+ CSelectedState state;
+ SaveSelectedState(state);
+ bool useInternalDelete = false;
+ if (IsFSFolder() && toRecycleBin)
+ {
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ CDynamicBuffer<CHAR> buffer;
+ size_t size = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ const AString path = GetSystemString(GetFsPath() + GetItemRelPath(indices[i]));
+ buffer.EnsureCapacity(size + path.Length() + 1);
+ memmove(((CHAR *)buffer) + size, (const CHAR *)path, (path.Length() + 1) * sizeof(CHAR));
+ size += path.Length() + 1;
+ }
+ buffer.EnsureCapacity(size + 1);
+ ((CHAR *)buffer)[size] = 0;
+ SHFILEOPSTRUCTA fo;
+ fo.hwnd = GetParent();
+ fo.wFunc = FO_DELETE;
+ fo.pFrom = (const CHAR *)buffer;
+ fo.pTo = 0;
+ fo.fFlags = 0;
+ if (toRecycleBin)
+ fo.fFlags |= FOF_ALLOWUNDO;
+ // fo.fFlags |= FOF_NOCONFIRMATION;
+ // fo.fFlags |= FOF_NOERRORUI;
+ // fo.fFlags |= FOF_SILENT;
+ // fo.fFlags |= FOF_WANTNUKEWARNING;
+ fo.fAnyOperationsAborted = FALSE;
+ fo.hNameMappings = 0;
+ fo.lpszProgressTitle = 0;
+ /* int res = */ ::SHFileOperationA(&fo);
+ }
+ else
+ #endif
+ {
+ CDynamicBuffer<WCHAR> buffer;
+ size_t size = 0;
+ int maxLen = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ // L"\\\\?\\") doesn't work here.
+ const UString path = GetFsPath() + GetItemRelPath(indices[i]);
+ if (path.Length() > maxLen)
+ maxLen = path.Length();
+ buffer.EnsureCapacity(size + path.Length() + 1);
+ memmove(((WCHAR *)buffer) + size, (const WCHAR *)path, (path.Length() + 1) * sizeof(WCHAR));
+ size += path.Length() + 1;
+ }
+ buffer.EnsureCapacity(size + 1);
+ ((WCHAR *)buffer)[size] = 0;
+ if (maxLen >= MAX_PATH)
+ {
+ if (toRecycleBin)
+ {
+ MessageBoxMyError(L"You can't send file with long path to Recycle Bin");
+ return;
+ }
+ useInternalDelete = true;
+ }
+ else
+ {
+ SHFILEOPSTRUCTW fo;
+ fo.hwnd = GetParent();
+ fo.wFunc = FO_DELETE;
+ fo.pFrom = (const WCHAR *)buffer;
+ fo.pTo = 0;
+ fo.fFlags = 0;
+ if (toRecycleBin)
+ fo.fFlags |= FOF_ALLOWUNDO;
+ fo.fAnyOperationsAborted = FALSE;
+ fo.hNameMappings = 0;
+ fo.lpszProgressTitle = 0;
+ int res;
+ #ifdef _UNICODE
+ res = ::SHFileOperationW(&fo);
+ #else
+ SHFileOperationWP shFileOperationW = (SHFileOperationWP)
+ ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHFileOperationW");
+ if (shFileOperationW == 0)
+ return;
+ res = shFileOperationW(&fo);
+ #endif
+ }
+ }
+ /*
+ if (fo.fAnyOperationsAborted)
+ MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
+ */
+ }
+ else
+ useInternalDelete = true;
+ if (useInternalDelete)
+ DeleteItemsInternal(indices);
+ RefreshListCtrl(state);
+}
+
+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));
+ return;
+ }
+
+ UString title;
+ UString message;
+ if (indices.Size() == 1)
+ {
+ int index = indices[0];
+ const UString itemName = GetItemRelPath(index);
+ if (IsItemFolder(index))
+ {
+ title = LangString(IDS_CONFIRM_FOLDER_DELETE, 0x03020211);
+ message = MyFormatNew(IDS_WANT_TO_DELETE_FOLDER, 0x03020214, itemName);
+ }
+ else
+ {
+ title = LangString(IDS_CONFIRM_FILE_DELETE, 0x03020210);
+ message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName);
+ }
+ }
+ else
+ {
+ title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
+ 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;
+
+ CThread thread;
+ if (!thread.Create(CThreadDelete::MyThreadFunction, &deleter))
+ throw 271824;
+ deleter.UpdateCallbackSpec->StartProgressDialog(progressTitle);
+
+ HRESULT result = deleter.Result;
+ if (result != S_OK)
+ MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
+}
+
+BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
+{
+ int realIndex = GetRealIndex(lpnmh->item);
+ if (realIndex == kParentIndex)
+ return TRUE;
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ return TRUE;
+ return FALSE;
+}
+
+BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
+{
+ if (lpnmh->item.pszText == NULL)
+ return FALSE;
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxMyError(L"Renaming is not supported");
+ return FALSE;
+ }
+ const UString newName = lpnmh->item.pszText;
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+
+ SaveSelectedState(_selectedState);
+
+ int realIndex = GetRealIndex(lpnmh->item);
+ 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;
+ }
+ // Can't use RefreshListCtrl here.
+ // RefreshListCtrlSaveFocused();
+ _selectedState.FocusedName = prefix + newName;
+ _selectedState.SelectFocused = true;
+
+ // 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)
+ // so we can't delete items.
+
+ _dontShowMode = true;
+
+ PostMessage(kReLoadMessage);
+ return TRUE;
+}
+
+void CPanel::CreateFolder()
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ CSelectedState state;
+ SaveSelectedState(state);
+ CComboDialog comboDialog;
+ comboDialog.Title = LangString(IDS_CREATE_FOLDER, 0x03020230);
+ comboDialog.Static = LangString(IDS_CREATE_FOLDER_NAME, 0x03020231);
+ comboDialog.Value = LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ UString newName = comboDialog.Value;
+ HRESULT result = folderOperations->CreateFolder(newName, 0);
+ if (result != S_OK)
+ {
+ MessageBoxError(result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
+ return;
+ }
+ int pos = newName.Find(L'\\');
+ if (pos >= 0)
+ newName = newName.Left(pos);
+ if (!_mySelectMode)
+ state.SelectedNames.Clear();
+ state.FocusedName = newName;
+ state.SelectFocused = true;
+ RefreshListCtrl(state);
+}
+
+void CPanel::CreateFile()
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ CSelectedState state;
+ SaveSelectedState(state);
+ CComboDialog comboDialog;
+ comboDialog.Title = LangString(IDS_CREATE_FILE, 0x03020240);
+ comboDialog.Static = LangString(IDS_CREATE_FILE_NAME, 0x03020241);
+ comboDialog.Value = LangString(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ UString newName = comboDialog.Value;
+ HRESULT result = folderOperations->CreateFile(newName, 0);
+ if (result != S_OK)
+ {
+ MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243));
+ return;
+ }
+ int pos = newName.Find(L'\\');
+ if (pos >= 0)
+ newName = newName.Left(pos);
+ if (!_mySelectMode)
+ state.SelectedNames.Clear();
+ state.FocusedName = newName;
+ state.SelectFocused = true;
+ RefreshListCtrl(state);
+}
+
+void CPanel::RenameFile()
+{
+ int index = _listView.GetFocusedItem();
+ if (index >= 0)
+ _listView.EditLabel(index);
+}
+
+void CPanel::ChangeComment()
+{
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ int index = _listView.GetFocusedItem();
+ if (index < 0)
+ return;
+ int realIndex = GetRealItemIndex(index);
+ if (realIndex == kParentIndex)
+ return;
+ CSelectedState state;
+ SaveSelectedState(state);
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+
+ UString comment;
+ {
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(realIndex, kpidComment, &propVariant) != S_OK)
+ return;
+ if (propVariant.vt == VT_BSTR)
+ comment = propVariant.bstrVal;
+ else if (propVariant.vt != VT_EMPTY)
+ return;
+ }
+ UString name = GetItemRelPath(realIndex);
+ CComboDialog comboDialog;
+ comboDialog.Title = name + L" " + LangString(IDS_COMMENT, 0x03020290);
+ comboDialog.Value = comment;
+ comboDialog.Static = LangString(IDS_COMMENT2, 0x03020291);
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ NCOM::CPropVariant propVariant = comboDialog.Value;
+
+ HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);
+ if (result != S_OK)
+ {
+ MessageBoxError(result, L"Set Comment Error");
+ }
+ RefreshListCtrl(state);
+}
+
diff --git a/7zip/FileManager/PanelSelect.cpp b/CPP/7zip/FileManager/PanelSelect.cpp
index e769195f..e769195f 100755
--- a/7zip/FileManager/PanelSelect.cpp
+++ b/CPP/7zip/FileManager/PanelSelect.cpp
diff --git a/7zip/FileManager/PanelSort.cpp b/CPP/7zip/FileManager/PanelSort.cpp
index fd9027b9..fd9027b9 100755
--- a/7zip/FileManager/PanelSort.cpp
+++ b/CPP/7zip/FileManager/PanelSort.cpp
diff --git a/CPP/7zip/FileManager/PanelSplitFile.cpp b/CPP/7zip/FileManager/PanelSplitFile.cpp
new file mode 100755
index 00000000..8e095628
--- /dev/null
+++ b/CPP/7zip/FileManager/PanelSplitFile.cpp
@@ -0,0 +1,477 @@
+// PanelSplitFile.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Common/Alloc.h"
+#include "Common/Types.h"
+#include "Common/IntToString.h"
+
+#include "Windows/COM.h"
+#include "Windows/FileIO.h"
+#include "Windows/FileFind.h"
+#include "Windows/Thread.h"
+#include "Resource/ProgressDialog2/ProgressDialog.h"
+#include "Resource/SplitDialog/SplitDialog.h"
+#include "Resource/CopyDialog/CopyDialog.h"
+
+#include "../UI/Resource/Extract/resource.h"
+
+#include "SplitUtils.h"
+#include "App.h"
+#include "FormatUtils.h"
+#include "LangUtils.h"
+
+using namespace NWindows;
+
+class CMyBuffer
+{
+ void *_data;
+public:
+ CMyBuffer(): _data(0) {}
+ operator void *() { return _data; }
+ bool Allocate(size_t size)
+ {
+ if (_data != 0)
+ return false;
+ _data = ::MidAlloc(size);
+ return _data != 0;
+ }
+ ~CMyBuffer() { ::MidFree(_data); }
+};
+
+struct CVolSeqName
+{
+ UString UnchangedPart;
+ UString ChangedPart;
+ CVolSeqName(): ChangedPart(L"000") {};
+
+ bool ParseName(const UString &name)
+ {
+ if (name.Right(2) != L"01")
+ return false;
+ int numLetters = 2;
+ while (numLetters < name.Length())
+ {
+ if (name[name.Length() - numLetters - 1] != '0')
+ break;
+ numLetters++;
+ }
+ UnchangedPart = name.Left(name.Length() - numLetters);
+ ChangedPart = name.Right(numLetters);
+ return true;
+ }
+
+ UString GetNextName()
+ {
+ UString newName;
+ 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 = c + newName;
+ i--;
+ for (; i >= 0; i--)
+ newName = ChangedPart[i] + newName;
+ break;
+ }
+ ChangedPart = newName;
+ return UnchangedPart + ChangedPart;
+ }
+};
+
+static const UInt32 kBufSize = (1 << 20);
+
+struct CThreadSplit
+{
+ // HRESULT Result;
+ // CPanel *Panel;
+ CProgressDialog *ProgressDialog;
+ UString FilePath;
+ UString VolBasePath;
+ CRecordVector<UInt64> VolumeSizes;
+ UString Error;
+
+ void Process2()
+ {
+ // NCOM::CComInitializer comInitializer;
+ ProgressDialog->WaitCreating();
+ NFile::NIO::CInFile inFile;
+ if (!inFile.Open(FilePath))
+ throw L"Can not open file";
+ NFile::NIO::COutFile outFile;
+ CMyBuffer bufferObject;
+ if (!bufferObject.Allocate(kBufSize))
+ throw L"Can not allocate buffer";
+ Byte *buffer = (Byte *)(void *)bufferObject;
+ UInt64 curVolSize = 0;
+ CVolSeqName seqName;
+ UInt64 length;
+ if (!inFile.GetLength(length))
+ throw "error";
+
+ ProgressDialog->ProgressSynch.SetProgress(length, 0);
+ UInt64 pos = 0;
+
+ int volIndex = 0;
+
+ for (;;)
+ {
+ UInt64 volSize;
+ if (volIndex < VolumeSizes.Size())
+ volSize = VolumeSizes[volIndex];
+ else
+ volSize = VolumeSizes.Back();
+
+ UInt32 needSize = (UInt32)(MyMin((UInt64)kBufSize, volSize - curVolSize));
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, needSize, processedSize))
+ throw L"Can not read input file";
+ if (processedSize == 0)
+ break;
+ needSize = processedSize;
+ if (curVolSize == 0)
+ {
+ UString name = VolBasePath;
+ name += L".";
+ name += seqName.GetNextName();
+ if (!outFile.Create(name, false))
+ throw L"Can not create output file";
+ ProgressDialog->ProgressSynch.SetCurrentFileName(name);
+ }
+ if (!outFile.Write(buffer, needSize, processedSize))
+ throw L"Can not write output file";
+ if (needSize != processedSize)
+ throw L"Can not write output file";
+ curVolSize += processedSize;
+ if (curVolSize == volSize)
+ {
+ outFile.Close();
+ if (volIndex < VolumeSizes.Size())
+ volIndex++;
+ curVolSize = 0;
+ }
+ pos += processedSize;
+ HRESULT res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos);
+ if (res != S_OK)
+ return;
+ }
+ }
+ DWORD Process()
+ {
+ try { Process2(); }
+ catch(const wchar_t *s) { Error = s; }
+ catch(...) { Error = L"Error"; }
+ ProgressDialog->MyClose();
+ return 0;
+ }
+
+ static DWORD WINAPI MyThreadFunction(void *param)
+ {
+ return ((CThreadSplit *)param)->Process();
+ }
+};
+
+void CApp::Split()
+{
+ int srcPanelIndex = GetFocusedPanelIndex();
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+ if (indices.Size() != 1)
+ {
+ srcPanel.MessageBox(L"Select one file");
+ return;
+ }
+ int index = indices[0];
+ if (srcPanel.IsItemFolder(index))
+ {
+ srcPanel.MessageBox(L"Select one file");
+ return;
+ }
+ const UString itemName = srcPanel.GetItemName(index);
+
+ UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index);
+ UString path = srcPath;
+ int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
+ CPanel &destPanel = Panels[destPanelIndex];
+ if (NumPanels > 1)
+ if (destPanel.IsFSFolder())
+ path = destPanel._currentFolderPrefix;
+ CSplitDialog splitDialog;
+ splitDialog.FilePath = srcPanel.GetItemRelPath(index);
+ splitDialog.Path = path;
+ if (splitDialog.Create(srcPanel.GetParent()) == IDCANCEL)
+ return;
+
+ NFile::NFind::CFileInfoW fileInfo;
+ if (!NFile::NFind::FindFile(srcPath + itemName, fileInfo))
+ {
+ srcPanel.MessageBoxMyError(L"Can not find file");
+ return;
+ }
+ if (fileInfo.Size <= splitDialog.VolumeSizes.Front())
+ {
+ srcPanel.MessageBoxMyError(LangString(IDS_SPLIT_VOL_MUST_BE_SMALLER, 0x03020522));
+ return;
+ }
+ const UInt64 numVolumes = GetNumberOfVolumes(fileInfo.Size, splitDialog.VolumeSizes);
+ if (numVolumes >= 100)
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString(numVolumes, s);
+ if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s),
+ LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520),
+ MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES)
+ return;
+ }
+
+ path = splitDialog.Path;
+ NFile::NName::NormalizeDirPathPrefix(path);
+ if (!NFile::NDirectory::CreateComplexDirectory(path))
+ {
+ srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
+ return;
+ }
+
+ CThreadSplit spliter;
+ // spliter.Panel = this;
+
+ CProgressDialog progressDialog;
+ spliter.ProgressDialog = &progressDialog;
+
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_SPLITTING, 0x03020510);
+
+ progressDialog.MainWindow = _window;
+ progressDialog.MainTitle = progressWindowTitle;
+ progressDialog.MainAddTitle = title + UString(L" ");
+ progressDialog.ProgressSynch.SetTitleFileName(itemName);
+
+
+ spliter.FilePath = srcPath + itemName;
+ spliter.VolBasePath = path + itemName;
+ spliter.VolumeSizes = splitDialog.VolumeSizes;
+
+ // if (splitDialog.VolumeSizes.Size() == 0) return;
+
+ // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
+ // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
+
+ CThread thread;
+ if (!thread.Create(CThreadSplit::MyThreadFunction, &spliter))
+ throw 271824;
+ progressDialog.Create(title, _window);
+
+ if (!spliter.Error.IsEmpty())
+ srcPanel.MessageBoxMyError(spliter.Error);
+ // disableTimerProcessing1.Restore();
+ // disableTimerProcessing2.Restore();
+ // srcPanel.SetFocusToList();
+ // srcPanel.RefreshListCtrlSaveFocused();
+}
+
+
+struct CThreadCombine
+{
+ CProgressDialog *ProgressDialog;
+ UString InputDirPrefix;
+ UString FirstVolumeName;
+ UString OutputDirPrefix;
+ UString Error;
+
+ 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::NFind::CFileInfoW fileInfo;
+ if (!NFile::NFind::FindFile(nextName, fileInfo))
+ break;
+ if (fileInfo.IsDirectory())
+ break;
+ totalSize += fileInfo.Size;
+ nextName = InputDirPrefix + volSeqName.GetNextName();
+ }
+ 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";
+
+ 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 (;;)
+ {
+ if (needOpen)
+ {
+ 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;
+ }
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, kBufSize, processedSize))
+ throw L"Can not read input file";
+ if (processedSize == 0)
+ {
+ needOpen = true;
+ continue;
+ }
+ 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()
+ {
+ try { Process2(); }
+ catch(const wchar_t *s) { Error = s; }
+ catch(...) { Error = L"Error";}
+ ProgressDialog->MyClose();
+ return 0;
+ }
+
+ static DWORD WINAPI MyThreadFunction(void *param)
+ {
+ return ((CThreadCombine *)param)->Process();
+ }
+};
+
+void CApp::Combine()
+{
+ int srcPanelIndex = GetFocusedPanelIndex();
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+ int index = indices[0];
+ if (indices.Size() != 1 || srcPanel.IsItemFolder(index))
+ {
+ srcPanel.MessageBox(LangString(IDS_COMBINE_SELECT_ONE_FILE, 0x03020620));
+ return;
+ }
+ const UString itemName = srcPanel.GetItemName(index);
+
+ UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index);
+ UString path = srcPath;
+ int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
+ CPanel &destPanel = Panels[destPanelIndex];
+ 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;
+
+ CThreadCombine combiner;
+ // combiner.Panel = this;
+
+ 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" ");
+
+ 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);
+
+ CThread thread;
+ if (!thread.Create(CThreadCombine::MyThreadFunction, &combiner))
+ throw 271824;
+ progressDialog.Create(title, _window);
+
+ if (!combiner.Error.IsEmpty())
+ srcPanel.MessageBoxMyError(combiner.Error);
+ // disableTimerProcessing1.Restore();
+ // disableTimerProcessing2.Restore();
+ // srcPanel.SetFocusToList();
+ // srcPanel.RefreshListCtrlSaveFocused();
+}
diff --git a/7zip/FileManager/PhysDriveFolder.cpp b/CPP/7zip/FileManager/PhysDriveFolder.cpp
index b69d3cb3..b69d3cb3 100755
--- a/7zip/FileManager/PhysDriveFolder.cpp
+++ b/CPP/7zip/FileManager/PhysDriveFolder.cpp
diff --git a/7zip/FileManager/PhysDriveFolder.h b/CPP/7zip/FileManager/PhysDriveFolder.h
index 076b0718..076b0718 100755
--- a/7zip/FileManager/PhysDriveFolder.h
+++ b/CPP/7zip/FileManager/PhysDriveFolder.h
diff --git a/7zip/FileManager/PluginInterface.h b/CPP/7zip/FileManager/PluginInterface.h
index 249f5644..249f5644 100755
--- a/7zip/FileManager/PluginInterface.h
+++ b/CPP/7zip/FileManager/PluginInterface.h
diff --git a/7zip/FileManager/PluginLoader.h b/CPP/7zip/FileManager/PluginLoader.h
index 598a874b..598a874b 100755
--- a/7zip/FileManager/PluginLoader.h
+++ b/CPP/7zip/FileManager/PluginLoader.h
diff --git a/7zip/FileManager/ProgramLocation.cpp b/CPP/7zip/FileManager/ProgramLocation.cpp
index 88c18d5e..88c18d5e 100755
--- a/7zip/FileManager/ProgramLocation.cpp
+++ b/CPP/7zip/FileManager/ProgramLocation.cpp
diff --git a/7zip/FileManager/ProgramLocation.h b/CPP/7zip/FileManager/ProgramLocation.h
index 8a8dcf7d..8a8dcf7d 100755
--- a/7zip/FileManager/ProgramLocation.h
+++ b/CPP/7zip/FileManager/ProgramLocation.h
diff --git a/7zip/FileManager/PropertyName.cpp b/CPP/7zip/FileManager/PropertyName.cpp
index 848a8855..848a8855 100755
--- a/7zip/FileManager/PropertyName.cpp
+++ b/CPP/7zip/FileManager/PropertyName.cpp
diff --git a/7zip/FileManager/PropertyName.h b/CPP/7zip/FileManager/PropertyName.h
index c99fe933..c99fe933 100755
--- a/7zip/FileManager/PropertyName.h
+++ b/CPP/7zip/FileManager/PropertyName.h
diff --git a/7zip/FileManager/RegistryAssociations.cpp b/CPP/7zip/FileManager/RegistryAssociations.cpp
index b4b35c67..b4b35c67 100755
--- a/7zip/FileManager/RegistryAssociations.cpp
+++ b/CPP/7zip/FileManager/RegistryAssociations.cpp
diff --git a/7zip/FileManager/RegistryAssociations.h b/CPP/7zip/FileManager/RegistryAssociations.h
index c225aca4..c225aca4 100755
--- a/7zip/FileManager/RegistryAssociations.h
+++ b/CPP/7zip/FileManager/RegistryAssociations.h
diff --git a/7zip/FileManager/RegistryPlugins.cpp b/CPP/7zip/FileManager/RegistryPlugins.cpp
index cad3b43d..cad3b43d 100755
--- a/7zip/FileManager/RegistryPlugins.cpp
+++ b/CPP/7zip/FileManager/RegistryPlugins.cpp
diff --git a/7zip/FileManager/RegistryPlugins.h b/CPP/7zip/FileManager/RegistryPlugins.h
index 4a30857c..4a30857c 100755
--- a/7zip/FileManager/RegistryPlugins.h
+++ b/CPP/7zip/FileManager/RegistryPlugins.h
diff --git a/7zip/FileManager/RegistryUtils.cpp b/CPP/7zip/FileManager/RegistryUtils.cpp
index 22869c46..22869c46 100755
--- a/7zip/FileManager/RegistryUtils.cpp
+++ b/CPP/7zip/FileManager/RegistryUtils.cpp
diff --git a/7zip/FileManager/RegistryUtils.h b/CPP/7zip/FileManager/RegistryUtils.h
index 0fec6f80..0fec6f80 100755
--- a/7zip/FileManager/RegistryUtils.h
+++ b/CPP/7zip/FileManager/RegistryUtils.h
diff --git a/7zip/FileManager/Resource/AboutDialog/7zipLogo.ico b/CPP/7zip/FileManager/Resource/AboutDialog/7zipLogo.ico
index 973241c8..973241c8 100755
--- a/7zip/FileManager/Resource/AboutDialog/7zipLogo.ico
+++ b/CPP/7zip/FileManager/Resource/AboutDialog/7zipLogo.ico
Binary files differ
diff --git a/7zip/FileManager/Resource/AboutDialog/AboutDialog.cpp b/CPP/7zip/FileManager/Resource/AboutDialog/AboutDialog.cpp
index e4dd2313..e4dd2313 100755
--- a/7zip/FileManager/Resource/AboutDialog/AboutDialog.cpp
+++ b/CPP/7zip/FileManager/Resource/AboutDialog/AboutDialog.cpp
diff --git a/7zip/FileManager/Resource/AboutDialog/AboutDialog.h b/CPP/7zip/FileManager/Resource/AboutDialog/AboutDialog.h
index 278d7c82..278d7c82 100755
--- a/7zip/FileManager/Resource/AboutDialog/AboutDialog.h
+++ b/CPP/7zip/FileManager/Resource/AboutDialog/AboutDialog.h
diff --git a/7zip/FileManager/Resource/AboutDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/AboutDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/AboutDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/AboutDialog/StdAfx.h
diff --git a/7zip/FileManager/Resource/AboutDialog/resource.h b/CPP/7zip/FileManager/Resource/AboutDialog/resource.h
index 54475484..54475484 100755
--- a/7zip/FileManager/Resource/AboutDialog/resource.h
+++ b/CPP/7zip/FileManager/Resource/AboutDialog/resource.h
diff --git a/7zip/FileManager/Resource/AboutDialog/resource.rc b/CPP/7zip/FileManager/Resource/AboutDialog/resource.rc
index b93fdd41..b93fdd41 100755
--- a/7zip/FileManager/Resource/AboutDialog/resource.rc
+++ b/CPP/7zip/FileManager/Resource/AboutDialog/resource.rc
diff --git a/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp b/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp
new file mode 100755
index 00000000..1083fc4c
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp
@@ -0,0 +1,976 @@
+// BenchmarkDialog.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringToInt.h"
+#include "Common/Exception.h"
+#include "Common/Alloc.h"
+#include "Windows/Thread.h"
+#include "Windows/PropVariant.h"
+#include "Windows/Error.h"
+#include "Windows/DLL.h"
+#include "Windows/FileFind.h"
+#include "../../ProgramLocation.h"
+#include "../../HelpUtils.h"
+#include "../../../Common/StreamObjects.h"
+#include "resource.h"
+#include "BenchmarkDialog.h"
+#include "Common/CRC.h"
+
+using namespace NWindows;
+
+static LPCWSTR kHelpTopic = L"fm/benchmark.htm";
+
+static const UINT_PTR kTimerID = 4;
+static const UINT kTimerElapse = 1000;
+
+static const UInt32 kAdditionalSize = (6 << 20);
+static const UInt32 kCompressedAdditionalSize = (1 << 10);
+static const int kSubBits = 8;
+
+#ifdef LANG
+#include "../../LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_BENCHMARK_DICTIONARY, 0x02000D0C },
+ { IDC_BENCHMARK_MEMORY, 0x03080001 },
+ { IDC_BENCHMARK_MULTITHREADING, 0x02000D09 },
+ { IDC_BENCHMARK_SPEED_LABEL, 0x03080004 },
+ { IDC_BENCHMARK_RATING_LABEL, 0x03080005 },
+ { IDC_BENCHMARK_COMPRESSING, 0x03080002 },
+ { IDC_BENCHMARK_DECOMPRESSING, 0x03080003 },
+ { IDC_BENCHMARK_CURRENT, 0x03080007 },
+ { IDC_BENCHMARK_RESULTING, 0x03080008 },
+ { IDC_BENCHMARK_CURRENT2, 0x03080007 },
+ { IDC_BENCHMARK_RESULTING2, 0x03080008 },
+ { IDC_BENCHMARK_TOTAL_RATING, 0x03080006 },
+ { IDC_BENCHMARK_ELAPSED, 0x02000C01 },
+ { IDC_BENCHMARK_SIZE, 0x02000C03 },
+ { IDC_BENCHMARK_PASSES, 0x03080009 },
+ { IDC_BENCHMARK_ERRORS, 0x0308000A },
+ { IDC_BUTTON_STOP, 0x02000714 },
+ { IDC_BUTTON_RESTART, 0x02000715 },
+ { IDHELP, 0x02000720 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+static void MyMessageBoxError(HWND hwnd, LPCWSTR message)
+{
+ MessageBoxW(hwnd, message, L"7-Zip", MB_ICONERROR);
+}
+
+UInt64 GetTimeCount()
+{
+ return GetTickCount();
+ /*
+ LARGE_INTEGER value;
+ if (::QueryPerformanceCounter(&value))
+ return value.QuadPart;
+ return GetTickCount();
+ */
+}
+
+UInt64 GetFreq()
+{
+ return 1000;
+ /*
+ LARGE_INTEGER value;
+ if (::QueryPerformanceFrequency(&value))
+ return value.QuadPart;
+ return 1000;
+ */
+}
+
+class CRandomGenerator
+{
+ UInt32 A1;
+ UInt32 A2;
+public:
+ CRandomGenerator() { Init(); }
+ void Init() { A1 = 362436069; A2 = 521288629;}
+ UInt32 GetRnd()
+ {
+ return
+ ((A1 = 36969 * (A1 & 0xffff) + (A1 >> 16)) << 16) ^
+ ((A2 = 18000 * (A2 & 0xffff) + (A2 >> 16)) );
+ }
+};
+
+class CBitRandomGenerator
+{
+ CRandomGenerator RG;
+ UInt32 Value;
+ int NumBits;
+public:
+ void Init()
+ {
+ Value = 0;
+ NumBits = 0;
+ }
+ UInt32 GetRnd(int numBits)
+ {
+ if (NumBits > numBits)
+ {
+ UInt32 result = Value & ((1 << numBits) - 1);
+ Value >>= numBits;
+ NumBits -= numBits;
+ return result;
+ }
+ numBits -= NumBits;
+ UInt32 result = (Value << numBits);
+ Value = RG.GetRnd();
+ result |= Value & ((1 << numBits) - 1);
+ Value >>= numBits;
+ NumBits = 32 - numBits;
+ return result;
+ }
+};
+
+class CBenchRandomGenerator
+{
+ CBitRandomGenerator RG;
+ UInt32 Pos;
+ UInt32 Rep0;
+public:
+ UInt32 BufferSize;
+ Byte *Buffer;
+ CBenchRandomGenerator(): Buffer(0) {}
+ ~CBenchRandomGenerator() { Free(); }
+ void Free()
+ {
+ ::MidFree(Buffer);
+ Buffer = 0;
+ }
+ bool Alloc(UInt32 bufferSize)
+ {
+ if (Buffer != 0 && BufferSize == bufferSize)
+ return true;
+ Free();
+ Buffer = (Byte *)::MidAlloc(bufferSize);
+ Pos = 0;
+ BufferSize = bufferSize;
+ return (Buffer != 0);
+ }
+ UInt32 GetRndBit() { return RG.GetRnd(1); }
+ /*
+ UInt32 GetLogRand(int maxLen)
+ {
+ UInt32 len = GetRnd() % (maxLen + 1);
+ return GetRnd() & ((1 << len) - 1);
+ }
+ */
+ UInt32 GetLogRandBits(int numBits)
+ {
+ UInt32 len = RG.GetRnd(numBits);
+ return RG.GetRnd(len);
+ }
+ UInt32 GetOffset()
+ {
+ if (GetRndBit() == 0)
+ return GetLogRandBits(4);
+ return (GetLogRandBits(4) << 10) | RG.GetRnd(10);
+ }
+ UInt32 GetLen1() { return RG.GetRnd(1 + RG.GetRnd(2)); }
+ UInt32 GetLen2() { return RG.GetRnd(2 + RG.GetRnd(2)); }
+ void Generate()
+ {
+ RG.Init();
+ Rep0 = 1;
+ while(Pos < BufferSize)
+ {
+ if (GetRndBit() == 0 || Pos < 1)
+ Buffer[Pos++] = Byte(RG.GetRnd(8));
+ else
+ {
+ UInt32 len;
+ if (RG.GetRnd(3) == 0)
+ len = 1 + GetLen1();
+ else
+ {
+ do
+ Rep0 = GetOffset();
+ while (Rep0 >= Pos);
+ Rep0++;
+ len = 2 + GetLen2();
+ }
+ for (UInt32 i = 0; i < len && Pos < BufferSize; i++, Pos++)
+ Buffer[Pos] = Buffer[Pos - Rep0];
+ }
+ }
+ }
+};
+
+const LPCTSTR kProcessingString = TEXT("...");
+const LPCTSTR kMB = TEXT(" MB");
+const LPCTSTR kMIPS = TEXT(" MIPS");
+const LPCTSTR kKBs = TEXT(" KB/s");
+
+bool CBenchmarkDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x03080000);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+
+ m_Dictionary.Attach(GetItem(IDC_BENCHMARK_COMBO_DICTIONARY));
+ for (int i = kNumBenchDictionaryBitsStart; i <= 30; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ UInt32 dictionary = (1 << i) + (j << (i - 1));
+ if(dictionary >
+ #ifdef _WIN64
+ (1 << 30)
+ #else
+ (1 << 27)
+ #endif
+ )
+ continue;
+ TCHAR s[40];
+ ConvertUInt64ToString((dictionary >> 20), s);
+ lstrcat(s, kMB);
+ int index = (int)m_Dictionary.AddString(s);
+ m_Dictionary.SetItemData(index, dictionary);
+ }
+ m_Dictionary.SetCurSel(0);
+ OnChangeSettings();
+
+ _syncInfo.Init();
+ _syncInfo.InitSettings();
+
+ _syncInfo._startEvent.Set();
+ _timer = SetTimer(kTimerID, kTimerElapse);
+ return CModalDialog::OnInit();
+}
+
+static UInt64 GetLZMAUsage(UInt32 dictionary)
+{
+ UInt32 hs = dictionary - 1;
+ hs |= (hs >> 1);
+ hs |= (hs >> 2);
+ hs |= (hs >> 4);
+ hs |= (hs >> 8);
+ hs >>= 1;
+ hs |= 0xFFFF;
+ if (hs > (1 << 24))
+ hs >>= 1;
+ hs++;
+ return ((hs + (1 << 16)) + (UInt64)dictionary * 2) * 4 + (UInt64)dictionary * 3 / 2 + (1 << 20);
+}
+
+static UInt64 GetMemoryUsage(UInt32 dictionary, bool mtMode)
+{
+ const UInt32 kBufferSize = dictionary + kAdditionalSize;
+ const UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
+ return (mtMode ? (6 << 20) : 0 )+ kBufferSize + kCompressedBufferSize +
+ GetLZMAUsage(dictionary) + dictionary + (2 << 20);
+}
+
+UInt32 CBenchmarkDialog::OnChangeDictionary()
+{
+ UInt32 dictionary = (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
+ UInt64 memUsage = GetMemoryUsage(dictionary, IsButtonCheckedBool(IDC_BENCHMARK_MULTITHREADING));
+ memUsage = (memUsage + (1 << 20) - 1) >> 20;
+ TCHAR s[40];
+ ConvertUInt64ToString(memUsage, s);
+ lstrcat(s, kMB);
+ SetItemText(IDC_BENCHMARK_MEMORY_VALUE, s);
+ return dictionary;
+}
+
+void CBenchmarkDialog::OnChangeSettings()
+{
+ EnableItem(IDC_BUTTON_STOP, true);
+ UInt32 dictionary = OnChangeDictionary();
+ SetItemText(IDC_BENCHMARK_COMPRESSING_SPEED, kProcessingString);
+ SetItemText(IDC_BENCHMARK_COMPRESSING_SPEED2, kProcessingString);
+ SetItemText(IDC_BENCHMARK_COMPRESSING_RATING, kProcessingString);
+ SetItemText(IDC_BENCHMARK_COMPRESSING_RATING2, kProcessingString);
+ SetItemText(IDC_BENCHMARK_DECOMPRESSING_SPEED, kProcessingString);
+ SetItemText(IDC_BENCHMARK_DECOMPRESSING_SPEED2, kProcessingString);
+ SetItemText(IDC_BENCHMARK_DECOMPRESSING_RATING, kProcessingString);
+ SetItemText(IDC_BENCHMARK_DECOMPRESSING_RATING2, kProcessingString);
+ SetItemText(IDC_BENCHMARK_TOTAL_RATING_VALUE, kProcessingString);
+ _startTime = GetTickCount();
+ PrintTime();
+ NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
+ _syncInfo.Init();
+ _syncInfo.DictionarySize = dictionary;
+ _syncInfo.Changed = true;
+ _syncInfo.MultiThread = IsButtonCheckedBool(IDC_BENCHMARK_MULTITHREADING);
+}
+
+void CBenchmarkDialog::OnRestartButton()
+{
+ OnChangeSettings();
+}
+
+void CBenchmarkDialog::OnStopButton()
+{
+ EnableItem(IDC_BUTTON_STOP, false);
+ _syncInfo.Pause();
+}
+
+void CBenchmarkDialog::OnHelp()
+{
+ ShowHelpWindow(NULL, kHelpTopic);
+}
+
+void CBenchmarkDialog::OnCancel()
+{
+ _syncInfo.Stop();
+ KillTimer(_timer);
+ CModalDialog::OnCancel();
+}
+
+static void GetTimeString(UInt64 timeValue, TCHAR *s)
+{
+ wsprintf(s, TEXT("%02d:%02d:%02d"),
+ UInt32(timeValue / 3600),
+ UInt32((timeValue / 60) % 60),
+ UInt32(timeValue % 60));
+}
+
+void CBenchmarkDialog::PrintTime()
+{
+ UInt32 curTime = ::GetTickCount();
+ UInt32 elapsedTime = (curTime - _startTime);
+ UInt32 elapsedSec = elapsedTime / 1000;
+ TCHAR s[40];
+ GetTimeString(elapsedSec, s);
+ SetItemText(IDC_BENCHMARK_ELAPSED_VALUE, s);
+}
+
+static UInt32 GetLogSize(UInt32 size)
+{
+ for (int i = kSubBits; i < 32; i++)
+ for (UInt32 j = 0; j < (1 << kSubBits); j++)
+ if (size <= (((UInt32)1) << i) + (j << (i - kSubBits)))
+ return (i << kSubBits) + j;
+ return (32 << kSubBits);
+}
+
+static UInt64 GetCompressRating(UInt32 dictionarySize,
+ UInt64 elapsedTime, UInt64 size)
+{
+ if (elapsedTime == 0)
+ elapsedTime = 1;
+ UInt64 t = GetLogSize(dictionarySize) - (18 << kSubBits);
+ UInt64 numCommandsForOne = 1060 + ((t * t * 10) >> (2 * kSubBits));
+ UInt64 numCommands = (UInt64)(size) * numCommandsForOne;
+ return numCommands * GetFreq() / elapsedTime;
+}
+
+static UInt64 GetDecompressRating(UInt64 elapsedTime,
+ UInt64 outSize, UInt64 inSize)
+{
+ if (elapsedTime == 0)
+ elapsedTime = 1;
+ UInt64 numCommands = inSize * 220 + outSize * 20;
+ return numCommands * GetFreq() / elapsedTime;
+}
+
+static UInt64 GetTotalRating(
+ UInt32 dictionarySize,
+ UInt64 elapsedTimeEn, UInt64 sizeEn,
+ UInt64 elapsedTimeDe,
+ UInt64 inSizeDe, UInt64 outSizeDe)
+{
+ return (GetCompressRating(dictionarySize, elapsedTimeEn, sizeEn) +
+ GetDecompressRating(elapsedTimeDe, inSizeDe, outSizeDe)) / 2;
+}
+
+void CBenchmarkDialog::PrintRating(UInt64 rating, UINT controlID)
+{
+ TCHAR s[40];
+ ConvertUInt64ToString(rating / 1000000, s);
+ lstrcat(s, kMIPS);
+ SetItemText(controlID, s);
+}
+
+void CBenchmarkDialog::PrintResults(
+ UInt32 dictionarySize,
+ UInt64 elapsedTime,
+ UInt64 size, UINT speedID, UINT ratingID,
+ bool decompressMode, UInt64 secondSize)
+{
+ TCHAR s[40];
+ UInt64 speed = size * GetFreq() / elapsedTime;
+ ConvertUInt64ToString(speed / 1024, s);
+ lstrcat(s, kKBs);
+ SetItemText(speedID, s);
+ UInt64 rating;
+ if (decompressMode)
+ rating = GetDecompressRating(elapsedTime, size, secondSize);
+ else
+ rating = GetCompressRating(dictionarySize, elapsedTime, size);
+ PrintRating(rating, ratingID);
+}
+
+bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
+{
+ PrintTime();
+ NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
+
+ TCHAR s[40];
+ ConvertUInt64ToString((_syncInfo.ProcessedSize >> 20), s);
+ lstrcat(s, kMB);
+ SetItemText(IDC_BENCHMARK_SIZE_VALUE, s);
+
+ ConvertUInt64ToString(_syncInfo.NumPasses, s);
+ SetItemText(IDC_BENCHMARK_PASSES_VALUE, s);
+
+ ConvertUInt64ToString(_syncInfo.NumErrors, s);
+ SetItemText(IDC_BENCHMARK_ERRORS_VALUE, s);
+
+ UInt64 elapsedTime = _syncInfo.CompressingInfoTemp.Time;
+ if (elapsedTime >= 1)
+ {
+ UInt32 dicSizeTemp = (UInt32)MyMax(_syncInfo.ProcessedSize, UInt64(1) << 20);
+ dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize),
+ PrintResults(dicSizeTemp, elapsedTime,
+ _syncInfo.CompressingInfoTemp.InSize,
+ IDC_BENCHMARK_COMPRESSING_SPEED,
+ IDC_BENCHMARK_COMPRESSING_RATING);
+ }
+
+ if (_syncInfo.CompressingInfo.Time >= 1)
+ {
+ PrintResults(
+ _syncInfo.DictionarySize,
+ _syncInfo.CompressingInfo.Time,
+ _syncInfo.CompressingInfo.InSize,
+ IDC_BENCHMARK_COMPRESSING_SPEED2,
+ IDC_BENCHMARK_COMPRESSING_RATING2);
+ }
+
+ if (_syncInfo.DecompressingInfoTemp.Time >= 1)
+ {
+ PrintResults(
+ _syncInfo.DictionarySize,
+ _syncInfo.DecompressingInfoTemp.Time,
+ _syncInfo.DecompressingInfoTemp.OutSize,
+ IDC_BENCHMARK_DECOMPRESSING_SPEED,
+ IDC_BENCHMARK_DECOMPRESSING_RATING,
+ true,
+ _syncInfo.DecompressingInfoTemp.InSize);
+ }
+ if (_syncInfo.DecompressingInfo.Time >= 1)
+ {
+ PrintResults(
+ _syncInfo.DictionarySize,
+ _syncInfo.DecompressingInfo.Time,
+ _syncInfo.DecompressingInfo.OutSize,
+ IDC_BENCHMARK_DECOMPRESSING_SPEED2,
+ IDC_BENCHMARK_DECOMPRESSING_RATING2,
+ true,
+ _syncInfo.DecompressingInfo.InSize);
+ if (_syncInfo.CompressingInfo.Time >= 1)
+ {
+ PrintRating(GetTotalRating(
+ _syncInfo.DictionarySize,
+ _syncInfo.CompressingInfo.Time,
+ _syncInfo.CompressingInfo.InSize,
+ _syncInfo.DecompressingInfo.Time,
+ _syncInfo.DecompressingInfo.OutSize,
+ _syncInfo.DecompressingInfo.InSize),
+ IDC_BENCHMARK_TOTAL_RATING_VALUE);
+ }
+ }
+ return true;
+}
+
+bool CBenchmarkDialog::OnCommand(int code, int itemID, LPARAM lParam)
+{
+ if (code == CBN_SELCHANGE && itemID == IDC_BENCHMARK_COMBO_DICTIONARY)
+ {
+ OnChangeSettings();
+ return true;
+ }
+ return CModalDialog::OnCommand(code, itemID, lParam);
+}
+
+bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_BUTTON_RESTART:
+ OnRestartButton();
+ return true;
+ case IDC_BUTTON_STOP:
+ OnStopButton();
+ return true;
+ case IDC_BENCHMARK_MULTITHREADING:
+ OnChangeSettings();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+class CBenchmarkInStream:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+ const Byte *Data;
+ UInt32 Pos;
+ UInt32 Size;
+public:
+ MY_UNKNOWN_IMP
+ void Init(const Byte *data, UInt32 size)
+ {
+ Data = data;
+ Size = size;
+ Pos = 0;
+ }
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+};
+
+STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 remain = Size - Pos;
+ if (size > remain)
+ size = remain;
+ for (UInt32 i = 0; i < size; i++)
+ {
+ ((Byte *)data)[i] = Data[Pos + i];
+ }
+ Pos += size;
+ if(processedSize != NULL)
+ *processedSize = size;
+ return S_OK;
+}
+
+class CBenchmarkOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ UInt32 BufferSize;
+public:
+ UInt32 Pos;
+ Byte *Buffer;
+ CBenchmarkOutStream(): Buffer(0) {}
+ ~CBenchmarkOutStream() { Free(); }
+ void Free()
+ {
+ ::MidFree(Buffer);
+ Buffer = 0;
+ }
+
+ bool Alloc(UInt32 bufferSize)
+ {
+ if (Buffer != 0 && BufferSize == bufferSize)
+ return true;
+ Free();
+ Buffer = (Byte *)::MidAlloc(bufferSize);
+ Init();
+ BufferSize = bufferSize;
+ return (Buffer != 0);
+ }
+
+ void Init()
+ {
+ Pos = 0;
+ }
+
+ MY_UNKNOWN_IMP
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ UInt32 i;
+ for (i = 0; i < size && Pos < BufferSize; i++)
+ Buffer[Pos++] = ((const Byte *)data)[i];
+ if(processedSize != NULL)
+ *processedSize = i;
+ if (i != size)
+ {
+ MessageBoxW(0, L"Buffer is full", L"7-zip error", 0);
+ return E_FAIL;
+ }
+ return S_OK;
+}
+
+class CCompareOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+public:
+ CCRC CRC;
+ MY_UNKNOWN_IMP
+ void Init() { CRC.Init(); }
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+};
+
+STDMETHODIMP CCompareOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ CRC.Update(data, size);
+ if(processedSize != NULL)
+ *processedSize = size;
+ return S_OK;
+}
+
+typedef UInt32 (WINAPI * CreateObjectPointer)(const GUID *clsID,
+ const GUID *interfaceID, void **outObject);
+
+struct CDecoderProgressInfo:
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+ CProgressSyncInfo *SyncInfo;
+ MY_UNKNOWN_IMP
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+};
+
+STDMETHODIMP CDecoderProgressInfo::SetRatioInfo(
+ const UInt64 * /* inSize */, const UInt64 * /* outSize */)
+{
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (SyncInfo->Changed)
+ return E_ABORT;
+ return S_OK;
+}
+
+struct CThreadBenchmark:
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+ CProgressSyncInfo *SyncInfo;
+ UInt64 _startTime;
+ UInt64 _approvedStart;
+ NDLL::CLibrary Library;
+ CMyComPtr<ICompressCoder> Encoder;
+ CMyComPtr<ICompressCoder> Decoder;
+ HRESULT Process();
+ HRESULT Result;
+ static DWORD WINAPI MyThreadFunction(void *param)
+ {
+ ((CThreadBenchmark *)param)->Result = ((CThreadBenchmark *)param)->Process();
+ return 0;
+ }
+ MY_UNKNOWN_IMP
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+};
+
+HRESULT CThreadBenchmark::Process()
+{
+ try
+ {
+ SyncInfo->WaitCreating();
+ CBenchRandomGenerator randomGenerator;
+ CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
+ Encoder.QueryInterface(IID_ICompressWriteCoderProperties,
+ &writeCoderProperties);
+ CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
+ Decoder.QueryInterface(
+ IID_ICompressSetDecoderProperties2, &compressSetDecoderProperties);
+ CSequentialOutStreamImp *propStreamSpec = 0;
+ CMyComPtr<ISequentialOutStream> propStream;
+ if (writeCoderProperties != NULL)
+ {
+ propStreamSpec = new CSequentialOutStreamImp;
+ propStream = propStreamSpec;
+ }
+
+ CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
+ Encoder.QueryInterface(IID_ICompressSetCoderProperties,
+ &setCoderProperties);
+
+ CDecoderProgressInfo *decoderProgressInfoSpec = new
+ CDecoderProgressInfo;
+ CMyComPtr<ICompressProgressInfo> decoderProgress = decoderProgressInfoSpec;
+ decoderProgressInfoSpec->SyncInfo = SyncInfo;
+
+ for (;;)
+ {
+ if (SyncInfo->WasStopped())
+ return 0;
+ if (SyncInfo->WasPaused())
+ {
+ Sleep(200);
+ continue;
+ }
+ UInt32 dictionarySize;
+ bool multiThread;
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ dictionarySize = SyncInfo->DictionarySize;
+ multiThread = SyncInfo->MultiThread;
+ if (SyncInfo->Changed)
+ SyncInfo->Init();
+ }
+
+ const UInt32 kBufferSize = dictionarySize + kAdditionalSize;
+ const UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
+
+ if (setCoderProperties)
+ {
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kDictionarySize,
+ NCoderPropID::kMultiThread
+ };
+ const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
+ NWindows::NCOM::CPropVariant properties[kNumProps];
+ properties[0] = UInt32(dictionarySize);
+ properties[1] = bool(multiThread);
+ HRESULT res = setCoderProperties->SetCoderProperties(propIDs,
+ properties, kNumProps);
+ if (res != S_OK)
+ {
+ // SyncInfo->Pause();
+ MessageBox(0, NError::MyFormatMessage(res), TEXT("7-Zip"), MB_ICONERROR);
+ return res;
+ }
+ }
+
+ if (propStream)
+ {
+ propStreamSpec->Init();
+ writeCoderProperties->WriteCoderProperties(propStream);
+ }
+
+ if (!randomGenerator.Alloc(kBufferSize))
+ return E_OUTOFMEMORY;
+
+ randomGenerator.Generate();
+ CCRC crc;
+
+ // randomGenerator.BufferSize
+ crc.Update(randomGenerator.Buffer, randomGenerator.BufferSize);
+
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (SyncInfo->Changed)
+ continue;
+ }
+
+ CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
+ CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
+ CBenchmarkOutStream *outStreamSpec = new CBenchmarkOutStream;
+ CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
+ if (!outStreamSpec->Alloc(kCompressedBufferSize))
+ return E_OUTOFMEMORY;
+
+ {
+ // this code is for reducing time of memory allocationg
+ inStreamSpec->Init(randomGenerator.Buffer, MyMin((UInt32)1, randomGenerator.BufferSize));
+ outStreamSpec->Init();
+ /* HRESULT result = */ Encoder->Code(inStream, outStream, 0, 0, NULL);
+ }
+
+ inStreamSpec->Init(randomGenerator.Buffer, randomGenerator.BufferSize);
+ outStreamSpec->Init();
+
+ _approvedStart = dictionarySize;
+ _startTime = ::GetTimeCount();
+ HRESULT result = Encoder->Code(inStream, outStream, 0, 0, this);
+ UInt64 tickCount = ::GetTimeCount() - _startTime;
+ UInt32 compressedSize = outStreamSpec->Pos;
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (result == S_OK)
+ {
+ if (SyncInfo->ApprovedInfo.InSize != 0)
+ {
+ SyncInfo->CompressingInfoTemp.InSize = kBufferSize - SyncInfo->ApprovedInfo.InSize;
+ SyncInfo->CompressingInfoTemp.OutSize = compressedSize - SyncInfo->ApprovedInfo.OutSize;
+ SyncInfo->CompressingInfoTemp.Time = tickCount - SyncInfo->ApprovedInfo.Time;
+ if (SyncInfo->CompressingInfo.Time == 0)
+ SyncInfo->CompressingInfo = SyncInfo->CompressingInfoTemp;
+ }
+ }
+ SyncInfo->ApprovedInfo.Init();
+ }
+ if(result != S_OK)
+ {
+ if (result != E_ABORT)
+ {
+ SyncInfo->Pause();
+ MessageBox(0, NError::MyFormatMessage(result), TEXT("7-Zip"), MB_ICONERROR);
+ }
+ continue;
+ }
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ SyncInfo->NumPasses++;
+ }
+
+ ///////////////////////
+ // Decompressing
+
+
+ CCompareOutStream *outCompareStreamSpec = new CCompareOutStream;
+ CMyComPtr<ISequentialOutStream> outCompareStream = outCompareStreamSpec;
+
+ for (int i = 0; i < 2; i++)
+ {
+ inStreamSpec->Init(outStreamSpec->Buffer, compressedSize);
+ outCompareStreamSpec->Init();
+
+ if (compressSetDecoderProperties)
+ {
+ RINOK(compressSetDecoderProperties->SetDecoderProperties2(
+ propStreamSpec->GetBuffer(), (UInt32)propStreamSpec->GetSize()));
+ }
+
+ UInt64 outSize = kBufferSize;
+ UInt64 startTime = ::GetTimeCount();
+ result = Decoder->Code(inStream, outCompareStream, 0, &outSize, decoderProgress);
+ tickCount = ::GetTimeCount() - startTime;
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (result == S_OK)
+ {
+ SyncInfo->DecompressingInfoTemp.InSize = compressedSize;
+ SyncInfo->DecompressingInfoTemp.OutSize = kBufferSize;
+ SyncInfo->DecompressingInfoTemp.Time = tickCount;
+ if (SyncInfo->DecompressingInfo.Time == 0 && i >= 1)
+ SyncInfo->DecompressingInfo = SyncInfo->DecompressingInfoTemp;
+ if (outCompareStreamSpec->CRC.GetDigest() != crc.GetDigest())
+ {
+ SyncInfo->NumErrors++;
+ break;
+ }
+ }
+ else
+ {
+ if(result != E_ABORT)
+ {
+ SyncInfo->NumErrors++;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch(CSystemException &e)
+ {
+ MessageBox(0, NError::MyFormatMessage(e.ErrorCode), TEXT("7-Zip"), MB_ICONERROR);
+ return E_FAIL;
+ }
+ catch(...)
+ {
+ MyMessageBoxError(0, L"Some error");
+ return E_FAIL;
+ }
+}
+
+STDMETHODIMP CThreadBenchmark::SetRatioInfo(
+ const UInt64 *inSize, const UInt64 *outSize)
+{
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (SyncInfo->Changed || SyncInfo->WasPaused() || SyncInfo->WasStopped())
+ return E_ABORT;
+ CProgressInfo ci;
+ ci.InSize = *inSize;
+ ci.OutSize = *outSize;
+ ci.Time = ::GetTimeCount() - _startTime;
+ SyncInfo->ProcessedSize = *inSize;
+
+ UInt64 deltaTime = ci.Time - SyncInfo->CompressingInfoPrev.Time;
+ if (deltaTime >= GetFreq())
+ {
+ SyncInfo->CompressingInfoTemp.Time = deltaTime;
+ SyncInfo->CompressingInfoTemp.InSize = ci.InSize - SyncInfo->CompressingInfoPrev.InSize;
+ SyncInfo->CompressingInfoTemp.OutSize = ci.InSize - SyncInfo->CompressingInfoPrev.OutSize;
+ SyncInfo->CompressingInfoPrev = ci;
+ }
+ if (*inSize >= _approvedStart && SyncInfo->ApprovedInfo.InSize == 0)
+ SyncInfo->ApprovedInfo = ci;
+ return S_OK;
+}
+
+static bool GetCoderPath(UString &path)
+{
+ if (!GetProgramFolderPath(path))
+ return false;
+ path += L"Codecs\\LZMA.dll";
+ return true;
+}
+
+typedef UInt32 (WINAPI *GetMethodPropertyFunc)(
+ UInt32 index, PROPID propID, PROPVARIANT *value);
+
+static bool LoadCoder(
+ const UString &filePath,
+ NWindows::NDLL::CLibrary &library,
+ CLSID &encoder, CLSID &decoder)
+{
+ if (!library.Load(filePath))
+ return false;
+ GetMethodPropertyFunc getMethodProperty = (GetMethodPropertyFunc)
+ library.GetProcAddress("GetMethodProperty");
+ if (getMethodProperty == NULL)
+ return false;
+
+ NWindows::NCOM::CPropVariant propVariant;
+ if (getMethodProperty (0, NMethodPropID::kEncoder, &propVariant) != S_OK)
+ return false;
+ if (propVariant.vt != VT_BSTR)
+ return false;
+ encoder = *(const GUID *)propVariant.bstrVal;
+ propVariant.Clear();
+
+ if (getMethodProperty (0, NMethodPropID::kDecoder, &propVariant) != S_OK)
+ return false;
+ if (propVariant.vt != VT_BSTR)
+ return false;
+ decoder = *(const GUID *)propVariant.bstrVal;
+ propVariant.Clear();
+ return true;
+}
+
+void Benchmark(HWND hwnd)
+{
+ UString path;
+ if (!GetCoderPath(path))
+ {
+ MyMessageBoxError(hwnd, L"Can't find LZMA.dll");
+ return;
+ }
+ CLSID encoder;
+ CLSID decoder;
+ CThreadBenchmark benchmarker;
+ if (!LoadCoder(path, benchmarker.Library, encoder, decoder))
+ {
+ MyMessageBoxError(hwnd, L"Can't load LZMA.dll");
+ return;
+ }
+
+ CreateObjectPointer createObject = (CreateObjectPointer)
+ benchmarker.Library.GetProcAddress("CreateObject");
+ if (createObject == NULL)
+ {
+ MyMessageBoxError(hwnd, L"Incorrect LZMA.dll");
+ return;
+ }
+ if (createObject(&encoder, &IID_ICompressCoder, (void **)&benchmarker.Encoder) != S_OK)
+ {
+ MyMessageBoxError(hwnd, L"Can't create codec");
+ return;
+ }
+ if (createObject(&decoder, &IID_ICompressCoder, (void **)&benchmarker.Decoder) != S_OK)
+ {
+ MyMessageBoxError(hwnd, L"Can't create codec");
+ return;
+ }
+
+ CBenchmarkDialog benchmarkDialog;
+ benchmarker.SyncInfo = &benchmarkDialog._syncInfo;
+ CThread thread;
+ if (!thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker))
+ {
+ MyMessageBoxError(hwnd, L"error");
+ return;
+ }
+ benchmarkDialog.Create(hwnd);
+ WaitForSingleObject(thread, INFINITE);
+}
diff --git a/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h b/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h
new file mode 100755
index 00000000..244e7fe5
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h
@@ -0,0 +1,136 @@
+// BenchmarkDialog.h
+
+#ifndef __BENCHMARKDIALOG_H
+#define __BENCHMARKDIALOG_H
+
+#include "resource.h"
+
+#include "Common/MyCom.h"
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Synchronization.h"
+#include "../../../ICoder.h"
+
+const int kNumBenchDictionaryBitsStart = 21;
+
+struct CProgressInfo
+{
+ UINT64 InSize;
+ UINT64 OutSize;
+ UINT64 Time;
+ void Init()
+ {
+ InSize = 0;
+ OutSize = 0;
+ Time = 0;
+ }
+};
+
+class CProgressSyncInfo
+{
+ bool Stopped;
+ bool Paused;
+public:
+ bool Changed;
+ UINT32 DictionarySize;
+ bool MultiThread;
+ UINT64 NumPasses;
+ UINT64 NumErrors;
+ NWindows::NSynchronization::CManualResetEvent _startEvent;
+ NWindows::NSynchronization::CCriticalSection CS;
+
+ CProgressInfo ApprovedInfo;
+ CProgressInfo CompressingInfoPrev;
+ CProgressInfo CompressingInfoTemp;
+ CProgressInfo CompressingInfo;
+ UINT64 ProcessedSize;
+
+ CProgressInfo DecompressingInfoTemp;
+ CProgressInfo DecompressingInfo;
+
+ void Init()
+ {
+ Changed = false;
+ ApprovedInfo.Init();
+ CompressingInfoPrev.Init();
+ CompressingInfoTemp.Init();
+ CompressingInfo.Init();
+ ProcessedSize = 0;
+
+ DecompressingInfoTemp.Init();
+ DecompressingInfo.Init();
+
+ Stopped = false;
+ Paused = false;
+ NumPasses = 0;
+ NumErrors = 0;
+ }
+ void InitSettings()
+ {
+ DictionarySize = (1 << kNumBenchDictionaryBitsStart);
+ MultiThread = false;
+ }
+ void Stop()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ Stopped = true;
+ }
+ bool WasStopped()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ return Stopped;
+ }
+ void Pause()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ Paused = true;
+ }
+ void Start()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ Paused = false;
+ }
+ bool WasPaused()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ return Paused;
+ }
+ void WaitCreating() { _startEvent.Lock(); }
+};
+
+class CBenchmarkDialog:
+ public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox m_Dictionary;
+ UINT_PTR _timer;
+ UINT32 _startTime;
+
+ bool OnTimer(WPARAM timerID, LPARAM callback);
+ virtual bool OnInit();
+ void OnRestartButton();
+ void OnStopButton();
+ void OnHelp();
+ virtual void OnCancel();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ bool OnCommand(int code, int itemID, LPARAM lParam);
+
+ void PrintTime();
+ void PrintRating(UINT64 rating, UINT controlID);
+ void PrintResults(
+ UINT32 dictionarySize,
+ UINT64 elapsedTime,
+ UINT64 size, UINT speedID, UINT ratingID,
+ bool decompressMode = false, UINT64 secondSize = 0);
+
+ UINT32 OnChangeDictionary();
+ void OnChangeSettings();
+public:
+ CProgressSyncInfo _syncInfo;
+
+ CBenchmarkDialog(): _timer(0) {}
+ INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
+};
+
+void Benchmark(HWND hwnd);
+
+#endif
diff --git a/7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h
diff --git a/7zip/FileManager/Resource/BenchmarkDialog/resource.h b/CPP/7zip/FileManager/Resource/BenchmarkDialog/resource.h
index d720058d..d720058d 100755
--- a/7zip/FileManager/Resource/BenchmarkDialog/resource.h
+++ b/CPP/7zip/FileManager/Resource/BenchmarkDialog/resource.h
diff --git a/7zip/FileManager/Resource/BenchmarkDialog/resource.rc b/CPP/7zip/FileManager/Resource/BenchmarkDialog/resource.rc
index 5ab220e5..5ab220e5 100755
--- a/7zip/FileManager/Resource/BenchmarkDialog/resource.rc
+++ b/CPP/7zip/FileManager/Resource/BenchmarkDialog/resource.rc
diff --git a/7zip/FileManager/Resource/ComboDialog/ComboDialog.cpp b/CPP/7zip/FileManager/Resource/ComboDialog/ComboDialog.cpp
index 2dc42ee0..2dc42ee0 100755
--- a/7zip/FileManager/Resource/ComboDialog/ComboDialog.cpp
+++ b/CPP/7zip/FileManager/Resource/ComboDialog/ComboDialog.cpp
diff --git a/7zip/FileManager/Resource/ComboDialog/ComboDialog.h b/CPP/7zip/FileManager/Resource/ComboDialog/ComboDialog.h
index 1838783d..1838783d 100755
--- a/7zip/FileManager/Resource/ComboDialog/ComboDialog.h
+++ b/CPP/7zip/FileManager/Resource/ComboDialog/ComboDialog.h
diff --git a/7zip/FileManager/Resource/ComboDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/ComboDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/ComboDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/ComboDialog/StdAfx.h
diff --git a/7zip/FileManager/Resource/ComboDialog/resource.h b/CPP/7zip/FileManager/Resource/ComboDialog/resource.h
index b5111ddf..b5111ddf 100755
--- a/7zip/FileManager/Resource/ComboDialog/resource.h
+++ b/CPP/7zip/FileManager/Resource/ComboDialog/resource.h
diff --git a/7zip/FileManager/Resource/ComboDialog/resource.rc b/CPP/7zip/FileManager/Resource/ComboDialog/resource.rc
index 7bf25365..7bf25365 100755
--- a/7zip/FileManager/Resource/ComboDialog/resource.rc
+++ b/CPP/7zip/FileManager/Resource/ComboDialog/resource.rc
diff --git a/CPP/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp b/CPP/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp
new file mode 100755
index 00000000..c0bcf2bc
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/CopyDialog/CopyDialog.cpp
@@ -0,0 +1,81 @@
+// CopyDialog.cpp
+
+#include "StdAfx.h"
+#include "CopyDialog.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/Control/Static.h"
+#include "Windows/Shell.h"
+#include "Windows/FileName.h"
+
+#ifdef LANG
+#include "../../LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+bool CCopyDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _path.Attach(GetItem(IDC_COPY_COMBO));
+ SetText(Title);
+
+ NControl::CStatic staticContol;
+ staticContol.Attach(GetItem(IDC_COPY_STATIC));
+ staticContol.SetText(Static);
+ for(int i = 0; i < Strings.Size(); i++)
+ _path.AddString(Strings[i]);
+ _path.SetText(Value);
+ return CModalDialog::OnInit();
+}
+
+bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_COPY_SET_PATH:
+ OnButtonSetPath();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CCopyDialog::OnButtonSetPath()
+{
+ UString currentPath;
+ _path.GetText(currentPath);
+
+ /*
+ #ifdef LANG
+ UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
+ #else
+ UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
+ #endif
+ */
+ UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209);
+ // UString title = L"Specify a location for output folder";
+
+ UString resultPath;
+ if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
+ return;
+ NFile::NName::NormalizeDirPathPrefix(resultPath);
+ _path.SetCurSel(-1);
+ _path.SetText(resultPath);
+}
+
+void CCopyDialog::OnOK()
+{
+ _path.GetText(Value);
+ CModalDialog::OnOK();
+}
diff --git a/7zip/FileManager/Resource/CopyDialog/CopyDialog.h b/CPP/7zip/FileManager/Resource/CopyDialog/CopyDialog.h
index 353f6807..353f6807 100755
--- a/7zip/FileManager/Resource/CopyDialog/CopyDialog.h
+++ b/CPP/7zip/FileManager/Resource/CopyDialog/CopyDialog.h
diff --git a/7zip/FileManager/Resource/CopyDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/CopyDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/CopyDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/CopyDialog/StdAfx.h
diff --git a/CPP/7zip/FileManager/Resource/CopyDialog/resource.h b/CPP/7zip/FileManager/Resource/CopyDialog/resource.h
new file mode 100755
index 00000000..7ec6162a
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/CopyDialog/resource.h
@@ -0,0 +1,7 @@
+#define IDD_DIALOG_COPY 202
+
+#define IDC_COPY_STATIC 1000
+#define IDC_COPY_COMBO 1001
+#define IDC_COPY_SET_PATH 1002
+
+#define IDS_SET_FOLDER 210
diff --git a/CPP/7zip/FileManager/Resource/CopyDialog/resource.rc b/CPP/7zip/FileManager/Resource/CopyDialog/resource.rc
new file mode 100755
index 00000000..156b56cf
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/CopyDialog/resource.rc
@@ -0,0 +1,28 @@
+#include "resource.h"
+#include "../../../GuiCommon.rc"
+
+#define xSize2 346
+#define ySize2 57
+
+#define xSize (xSize2 + marg + marg)
+#define ySize (ySize2 + marg + marg)
+
+#define bYPos (ySize - marg - bYSize)
+#define b1XPos (xSize - marg - bXSize)
+#define b2XPos (b1XPos - 10 - bXSize)
+
+IDD_DIALOG_COPY DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
+CAPTION "Copy"
+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
+ DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize
+ PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_SET_FOLDER "Specify a location for output folder."
+END
diff --git a/7zip/FileManager/Resource/EditPage/EditPage.cpp b/CPP/7zip/FileManager/Resource/EditPage/EditPage.cpp
index 0e6e1d71..0e6e1d71 100755
--- a/7zip/FileManager/Resource/EditPage/EditPage.cpp
+++ b/CPP/7zip/FileManager/Resource/EditPage/EditPage.cpp
diff --git a/7zip/FileManager/Resource/EditPage/EditPage.h b/CPP/7zip/FileManager/Resource/EditPage/EditPage.h
index 26999dcf..26999dcf 100755
--- a/7zip/FileManager/Resource/EditPage/EditPage.h
+++ b/CPP/7zip/FileManager/Resource/EditPage/EditPage.h
diff --git a/7zip/FileManager/Resource/EditPage/StdAfx.h b/CPP/7zip/FileManager/Resource/EditPage/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/EditPage/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/EditPage/StdAfx.h
diff --git a/7zip/FileManager/Resource/EditPage/resource.h b/CPP/7zip/FileManager/Resource/EditPage/resource.h
index a2de1970..a2de1970 100755
--- a/7zip/FileManager/Resource/EditPage/resource.h
+++ b/CPP/7zip/FileManager/Resource/EditPage/resource.h
diff --git a/7zip/FileManager/Resource/EditPage/resource.rc b/CPP/7zip/FileManager/Resource/EditPage/resource.rc
index d4d8b9cd..d4d8b9cd 100755
--- a/7zip/FileManager/Resource/EditPage/resource.rc
+++ b/CPP/7zip/FileManager/Resource/EditPage/resource.rc
diff --git a/7zip/FileManager/Resource/LangPage/LangPage.cpp b/CPP/7zip/FileManager/Resource/LangPage/LangPage.cpp
index 9974759a..9974759a 100755
--- a/7zip/FileManager/Resource/LangPage/LangPage.cpp
+++ b/CPP/7zip/FileManager/Resource/LangPage/LangPage.cpp
diff --git a/7zip/FileManager/Resource/LangPage/LangPage.h b/CPP/7zip/FileManager/Resource/LangPage/LangPage.h
index b28d6984..b28d6984 100755
--- a/7zip/FileManager/Resource/LangPage/LangPage.h
+++ b/CPP/7zip/FileManager/Resource/LangPage/LangPage.h
diff --git a/7zip/FileManager/Resource/LangPage/StdAfx.h b/CPP/7zip/FileManager/Resource/LangPage/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/LangPage/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/LangPage/StdAfx.h
diff --git a/7zip/FileManager/Resource/LangPage/resource.h b/CPP/7zip/FileManager/Resource/LangPage/resource.h
index 39571e53..39571e53 100755
--- a/7zip/FileManager/Resource/LangPage/resource.h
+++ b/CPP/7zip/FileManager/Resource/LangPage/resource.h
diff --git a/7zip/FileManager/Resource/LangPage/resource.rc b/CPP/7zip/FileManager/Resource/LangPage/resource.rc
index abaa9481..abaa9481 100755
--- a/7zip/FileManager/Resource/LangPage/resource.rc
+++ b/CPP/7zip/FileManager/Resource/LangPage/resource.rc
diff --git a/7zip/FileManager/Resource/ListBoxDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/ListBoxDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/ListBoxDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/ListBoxDialog/StdAfx.h
diff --git a/7zip/FileManager/Resource/ListBoxDialog/resource.h b/CPP/7zip/FileManager/Resource/ListBoxDialog/resource.h
index 507e17bd..507e17bd 100755
--- a/7zip/FileManager/Resource/ListBoxDialog/resource.h
+++ b/CPP/7zip/FileManager/Resource/ListBoxDialog/resource.h
diff --git a/7zip/FileManager/Resource/ListBoxDialog/resource.rc b/CPP/7zip/FileManager/Resource/ListBoxDialog/resource.rc
index 728aaa94..728aaa94 100755
--- a/7zip/FileManager/Resource/ListBoxDialog/resource.rc
+++ b/CPP/7zip/FileManager/Resource/ListBoxDialog/resource.rc
diff --git a/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp b/CPP/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp
index ca7b7935..ca7b7935 100755
--- a/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp
+++ b/CPP/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.cpp
diff --git a/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h b/CPP/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h
index ad107eba..ad107eba 100755
--- a/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h
+++ b/CPP/7zip/FileManager/Resource/ListViewDialog/ListViewDialog.h
diff --git a/7zip/FileManager/Resource/ListViewDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/ListViewDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/ListViewDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/ListViewDialog/StdAfx.h
diff --git a/7zip/FileManager/Resource/ListViewDialog/resource.h b/CPP/7zip/FileManager/Resource/ListViewDialog/resource.h
index 440d14b0..440d14b0 100755
--- a/7zip/FileManager/Resource/ListViewDialog/resource.h
+++ b/CPP/7zip/FileManager/Resource/ListViewDialog/resource.h
diff --git a/7zip/FileManager/Resource/ListViewDialog/resource.rc b/CPP/7zip/FileManager/Resource/ListViewDialog/resource.rc
index 5c0bdbcd..5c0bdbcd 100755
--- a/7zip/FileManager/Resource/ListViewDialog/resource.rc
+++ b/CPP/7zip/FileManager/Resource/ListViewDialog/resource.rc
diff --git a/CPP/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp b/CPP/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp
new file mode 100755
index 00000000..d156f823
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.cpp
@@ -0,0 +1,100 @@
+// MessagesDialog.cpp
+
+#include "StdAfx.h"
+#include "MessagesDialog.h"
+#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
+#include "Windows/ResourceString.h"
+
+#ifdef LANG
+#include "../../LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000713 }
+};
+#endif
+
+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);
+}
+
+void CMessagesDialog::AddMessage(LPCWSTR message)
+{
+ UString s = message;
+ while (!s.IsEmpty())
+ {
+ int pos = s.Find(L'\n');
+ if (pos < 0)
+ break;
+ AddMessageDirect(s.Left(pos));
+ s.Delete(0, pos + 1);
+ }
+ AddMessageDirect(s);
+}
+
+bool CMessagesDialog::OnInit()
+{
+ #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
+
+ columnInfo.pszText = (LPWSTR)(LPCWSTR)s;
+ columnInfo.iSubItem = 1;
+ columnInfo.cx = 600;
+
+ _messageList.InsertColumn(1, &columnInfo);
+
+ for(int i = 0; i < Messages->Size(); i++)
+ AddMessage((*Messages)[i]);
+
+ /*
+ if(_messageList.GetItemCount() > 0)
+ {
+ UINT aState = LVIS_SELECTED | LVIS_FOCUSED;
+ _messageList.SetItemState(0, aState, aState);
+ }
+ */
+ return CModalDialog::OnInit();
+}
diff --git a/CPP/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h b/CPP/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h
new file mode 100755
index 00000000..2ec22d80
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/MessagesDialog/MessagesDialog.h
@@ -0,0 +1,22 @@
+// MessagesDialog.h
+
+#ifndef __MESSAGESDIALOG_H
+#define __MESSAGESDIALOG_H
+
+#include "resource.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ListView.h"
+
+class CMessagesDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CListView _messageList;
+ void AddMessageDirect(LPCWSTR message);
+ void AddMessage(LPCWSTR message);
+ virtual bool OnInit();
+public:
+ const UStringVector *Messages;
+ INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_MESSAGES, parent); }
+};
+
+#endif
diff --git a/7zip/FileManager/Resource/MessagesDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/MessagesDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/MessagesDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/MessagesDialog/StdAfx.h
diff --git a/7zip/FileManager/Resource/MessagesDialog/resource.h b/CPP/7zip/FileManager/Resource/MessagesDialog/resource.h
index 39d49f57..39d49f57 100755
--- a/7zip/FileManager/Resource/MessagesDialog/resource.h
+++ b/CPP/7zip/FileManager/Resource/MessagesDialog/resource.h
diff --git a/CPP/7zip/FileManager/Resource/MessagesDialog/resource.rc b/CPP/7zip/FileManager/Resource/MessagesDialog/resource.rc
new file mode 100755
index 00000000..eae00bf0
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/MessagesDialog/resource.rc
@@ -0,0 +1,25 @@
+#include "resource.h"
+#include "../../../GuiCommon.rc"
+
+#define xSize2 430
+#define ySize2 140
+#define xSize (xSize2 + marg + marg)
+#define ySize (ySize2 + marg + marg)
+#define bXPos (xSize - marg - bXSize)
+#define bYPos (ySize - marg - bYSize)
+
+
+IDD_DIALOG_MESSAGES DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
+CAPTION "7-Zip: Diagnostic messages"
+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,
+ marg, marg, xSize2, ySize2 - bYSize - 6
+END
+
+STRINGTABLE
+BEGIN
+ IDS_MESSAGES_DIALOG_MESSAGE_COLUMN "Message"
+END
diff --git a/CPP/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp b/CPP/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp
new file mode 100755
index 00000000..8f13a43a
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.cpp
@@ -0,0 +1,124 @@
+// OverwriteDialog.cpp
+
+#include "StdAfx.h"
+
+#include "OverwriteDialog.h"
+
+#include "Common/StringConvert.h"
+#include "Windows/FileName.h"
+#include "Windows/Defs.h"
+#include "Windows/ResourceString.h"
+#include "Windows/Control/Static.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../FormatUtils.h"
+
+// #include "../resource.h"
+
+#ifdef LANG
+#include "../../LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_OVERWRITE_HEADER, 0x02000901},
+ { IDC_STATIC_OVERWRITE_QUESTION_BEGIN, 0x02000902 },
+ { IDC_STATIC_OVERWRITE_QUESTION_END, 0x02000903 },
+ { IDYES, 0x02000705 },
+ { IDC_BUTTON_OVERWRITE_YES_TO_ALL, 0x02000707 },
+ { IDNO, 0x02000709 },
+ { IDC_BUTTON_OVERWRITE_NO_TO_ALL,0x0200070B },
+ { IDC_BUTTON_OVERWRITE_AUTO_RENAME, 0x02000911 },
+ { IDCANCEL, 0x02000711 }
+};
+#endif
+
+void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
+ const NOverwriteDialog::CFileInfo &fileInfo)
+{
+ UString sizeString;
+ if (fileInfo.SizeIsDefined)
+ sizeString = MyFormatNew(IDS_FILE_SIZE,
+ #ifdef LANG
+ 0x02000982,
+ #endif
+ NumberToString(fileInfo.Size));
+
+ UString reducedName;
+ const int kLineSize = 88;
+ for (int i = 0; i < fileInfo.Name.Length();)
+ {
+ reducedName += fileInfo.Name.Mid(i, kLineSize);
+ reducedName += L" ";
+ i += kLineSize;
+ }
+
+ UString fullString = reducedName;
+ fullString += L"\n";
+ fullString += sizeString;
+ fullString += L"\n";
+
+ if (fileInfo.TimeIsDefined)
+ {
+ UString timeString;
+ FILETIME localFileTime;
+ if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
+ throw 4190402;
+ timeString = ConvertFileTimeToString(localFileTime);
+
+ fullString +=
+ #ifdef LANG
+ LangString(IDS_FILE_MODIFIED, 0x02000983);
+ #else
+ MyLoadStringW(IDS_FILE_MODIFIED);
+ #endif
+
+ fullString += L" ";
+ fullString += timeString;
+ }
+
+ NWindows::NControl::CDialogChildControl control;
+ control.Init(*this, textID);
+ control.SetText(fullString);
+
+ SHFILEINFO shellFileInfo;
+ if (::SHGetFileInfo(
+ GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo,
+ sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON))
+ {
+ NControl::CStatic staticContol;
+ staticContol.Attach(GetItem(iconID));
+ staticContol.SetIcon(shellFileInfo.hIcon);
+ }
+}
+
+bool COverwriteDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000900);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME,
+ IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo);
+ 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)
+{
+ switch(buttonID)
+ {
+ case IDYES:
+ case IDC_BUTTON_OVERWRITE_YES_TO_ALL:
+ case IDNO:
+ case IDC_BUTTON_OVERWRITE_NO_TO_ALL:
+ case IDC_BUTTON_OVERWRITE_AUTO_RENAME:
+ End(buttonID);
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
diff --git a/CPP/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h b/CPP/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h
new file mode 100755
index 00000000..193efb85
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/OverwriteDialog/OverwriteDialog.h
@@ -0,0 +1,34 @@
+// OverwriteDialog.h
+
+#ifndef __OVERWRITEDIALOG_H
+#define __OVERWRITEDIALOG_H
+
+#include "resource.h"
+#include "Windows/Control/Dialog.h"
+
+namespace NOverwriteDialog
+{
+ struct CFileInfo
+ {
+ bool SizeIsDefined;
+ UINT64 Size;
+ bool TimeIsDefined;
+ FILETIME Time;
+ UString Name;
+ };
+}
+
+class COverwriteDialog: public NWindows::NControl::CModalDialog
+{
+ void SetFileInfoControl(int textID, int iconID,
+ const NOverwriteDialog::CFileInfo &fileInfo);
+ virtual bool OnInit();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+public:
+ INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_OVERWRITE, parent); }
+
+ NOverwriteDialog::CFileInfo OldFileInfo;
+ NOverwriteDialog::CFileInfo NewFileInfo;
+};
+
+#endif
diff --git a/7zip/FileManager/Resource/OverwriteDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/OverwriteDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/OverwriteDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/OverwriteDialog/StdAfx.h
diff --git a/7zip/FileManager/Resource/OverwriteDialog/resource.h b/CPP/7zip/FileManager/Resource/OverwriteDialog/resource.h
index 66710f84..66710f84 100755
--- a/7zip/FileManager/Resource/OverwriteDialog/resource.h
+++ b/CPP/7zip/FileManager/Resource/OverwriteDialog/resource.h
diff --git a/7zip/FileManager/Resource/OverwriteDialog/resource.rc b/CPP/7zip/FileManager/Resource/OverwriteDialog/resource.rc
index 1a907955..1a907955 100755
--- a/7zip/FileManager/Resource/OverwriteDialog/resource.rc
+++ b/CPP/7zip/FileManager/Resource/OverwriteDialog/resource.rc
diff --git a/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp b/CPP/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp
index 4f09f7f7..4f09f7f7 100755
--- a/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp
+++ b/CPP/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.cpp
diff --git a/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h b/CPP/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h
index f77cd2be..f77cd2be 100755
--- a/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h
+++ b/CPP/7zip/FileManager/Resource/PasswordDialog/PasswordDialog.h
diff --git a/7zip/FileManager/Resource/PasswordDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/PasswordDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/PasswordDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/PasswordDialog/StdAfx.h
diff --git a/7zip/FileManager/Resource/PasswordDialog/resource.h b/CPP/7zip/FileManager/Resource/PasswordDialog/resource.h
index e0b42661..e0b42661 100755
--- a/7zip/FileManager/Resource/PasswordDialog/resource.h
+++ b/CPP/7zip/FileManager/Resource/PasswordDialog/resource.h
diff --git a/7zip/FileManager/Resource/PasswordDialog/resource.rc b/CPP/7zip/FileManager/Resource/PasswordDialog/resource.rc
index 7e2658c7..7e2658c7 100755
--- a/7zip/FileManager/Resource/PasswordDialog/resource.rc
+++ b/CPP/7zip/FileManager/Resource/PasswordDialog/resource.rc
diff --git a/7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp b/CPP/7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp
index 0ccdf07e..0ccdf07e 100755
--- a/7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp
+++ b/CPP/7zip/FileManager/Resource/PluginsPage/PluginsPage.cpp
diff --git a/7zip/FileManager/Resource/PluginsPage/PluginsPage.h b/CPP/7zip/FileManager/Resource/PluginsPage/PluginsPage.h
index 78e81dbb..78e81dbb 100755
--- a/7zip/FileManager/Resource/PluginsPage/PluginsPage.h
+++ b/CPP/7zip/FileManager/Resource/PluginsPage/PluginsPage.h
diff --git a/7zip/FileManager/Resource/PluginsPage/StdAfx.h b/CPP/7zip/FileManager/Resource/PluginsPage/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/PluginsPage/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/PluginsPage/StdAfx.h
diff --git a/7zip/FileManager/Resource/PluginsPage/resource.h b/CPP/7zip/FileManager/Resource/PluginsPage/resource.h
index 8fc923ee..8fc923ee 100755
--- a/7zip/FileManager/Resource/PluginsPage/resource.h
+++ b/CPP/7zip/FileManager/Resource/PluginsPage/resource.h
diff --git a/7zip/FileManager/Resource/PluginsPage/resource.rc b/CPP/7zip/FileManager/Resource/PluginsPage/resource.rc
index 7b74107b..7b74107b 100755
--- a/7zip/FileManager/Resource/PluginsPage/resource.rc
+++ b/CPP/7zip/FileManager/Resource/PluginsPage/resource.rc
diff --git a/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp b/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
new file mode 100755
index 00000000..ea0f6fd6
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
@@ -0,0 +1,175 @@
+// ProgressDialog.cpp
+
+#include "StdAfx.h"
+#include "resource.h"
+#include "ProgressDialog.h"
+#include "Common/IntToString.h"
+#include "Common/IntToString.h"
+
+using namespace NWindows;
+
+static const UINT_PTR kTimerID = 3;
+static const UINT kTimerElapse = 50;
+
+#ifdef LANG
+#include "../../LangUtils.h"
+#endif
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDCANCEL, 0x02000711 }
+};
+#endif
+
+#ifndef _SFX
+CProgressDialog::~CProgressDialog()
+{
+ AddToTitle(TEXT(""));
+}
+void CProgressDialog::AddToTitle(LPCWSTR s)
+{
+ if (MainWindow != 0)
+ ::MySetWindowText(MainWindow, UString(s) + MainTitle);
+}
+#endif
+
+
+
+bool CProgressDialog::OnInit()
+{
+ _range = UINT64(-1);
+ _prevPercentValue = -1;
+
+ #ifdef LANG
+ // LangSetWindowText(HWND(*this), 0x02000C00);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+
+ m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
+ _timer = SetTimer(kTimerID, kTimerElapse);
+ _dialogCreatedEvent.Set();
+ SetText(_title);
+ return CModalDialog::OnInit();
+}
+
+void CProgressDialog::OnCancel()
+{
+ ProgressSynch.SetStopped(true);
+}
+
+void CProgressDialog::SetRange(UINT64 range)
+{
+ _range = range;
+ _peviousPos = (UInt64)(Int64)-1;
+ _converter.Init(range);
+ m_ProgressBar.SetRange32(0 , _converter.Count(range)); // Test it for 100%
+}
+
+void CProgressDialog::SetPos(UINT64 pos)
+{
+ bool redraw = true;
+ if (pos < _range && pos > _peviousPos)
+ {
+ UINT64 posDelta = pos - _peviousPos;
+ if (posDelta < (_range >> 10))
+ redraw = false;
+ }
+ if(redraw)
+ {
+ m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100%
+ _peviousPos = pos;
+ }
+}
+
+bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
+{
+ if (ProgressSynch.GetPaused())
+ return true;
+ UINT64 total, completed;
+ ProgressSynch.GetProgress(total, completed);
+ if (total != _range)
+ SetRange(total);
+ SetPos(completed);
+
+ if (total == 0)
+ total = 1;
+
+ int percentValue = (int)(completed * 100 / total);
+ if (percentValue != _prevPercentValue)
+ {
+ wchar_t s[64];
+ ConvertUInt64ToString(percentValue, s);
+ UString title = s;
+ title += L"% ";
+ SetText(title + _title);
+ #ifndef _SFX
+ AddToTitle(title + MainAddTitle);
+ #endif
+ _prevPercentValue = percentValue;
+ }
+ return true;
+}
+
+
+////////////////////
+// CU64ToI32Converter
+
+static const UINT64 kMaxIntValue = 0x7FFFFFFF;
+
+void CU64ToI32Converter::Init(UINT64 range)
+{
+ _numShiftBits = 0;
+ while(range > kMaxIntValue)
+ {
+ range >>= 1;
+ _numShiftBits++;
+ }
+}
+
+int CU64ToI32Converter::Count(UINT64 aValue)
+{
+ return int(aValue >> _numShiftBits);
+}
+
+const UINT CProgressDialog::kCloseMessage = WM_USER + 1;
+
+bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message)
+ {
+ case kCloseMessage:
+ {
+ KillTimer(_timer);
+ _timer = 0;
+ End(0);
+ return true;
+ }
+ case WM_SETTEXT:
+ {
+ if (_timer == 0)
+ return true;
+ }
+ }
+ return CModalDialog::OnMessage(message, wParam, lParam);
+}
+
+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?",
+ _title, MB_YESNOCANCEL);
+ ProgressSynch.SetPaused(paused);
+ if (res == IDCANCEL || res == IDNO)
+ return true;
+ break;
+ }
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
diff --git a/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h b/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h
new file mode 100755
index 00000000..e11ffc51
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h
@@ -0,0 +1,129 @@
+// ProgressDialog.h
+
+#ifndef __PROGRESSDIALOG_H
+#define __PROGRESSDIALOG_H
+
+#include "resource.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ProgressBar.h"
+#include "Windows/Synchronization.h"
+
+class CProgressSynch
+{
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+ bool _stopped;
+ bool _paused;
+ UINT64 _total;
+ UINT64 _completed;
+public:
+ CProgressSynch(): _stopped(false), _paused(false), _total(1), _completed(0) {}
+
+ bool GetStopped()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ return _stopped;
+ }
+ void SetStopped(bool value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ _stopped = value;
+ }
+ bool GetPaused()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ return _paused;
+ }
+ void SetPaused(bool value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ _paused = value;
+ }
+ void SetProgress(UINT64 total, UINT64 completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ _total = total;
+ _completed = completed;
+ }
+ void SetPos(UINT64 completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ _completed = completed;
+ }
+ void GetProgress(UINT64 &total, UINT64 &completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ total = _total;
+ completed = _completed;
+ }
+};
+
+class CU64ToI32Converter
+{
+ UINT64 _numShiftBits;
+public:
+ void Init(UINT64 _range);
+ int Count(UINT64 aValue);
+};
+
+// class CProgressDialog: public NWindows::NControl::CModelessDialog
+
+class CProgressDialog: public NWindows::NControl::CModalDialog
+{
+private:
+ UINT_PTR _timer;
+
+ UString _title;
+ CU64ToI32Converter _converter;
+ UINT64 _peviousPos;
+ UINT64 _range;
+ NWindows::NControl::CProgressBar m_ProgressBar;
+
+ int _prevPercentValue;
+
+ bool OnTimer(WPARAM timerID, LPARAM callback);
+ void SetRange(UINT64 range);
+ void SetPos(UINT64 pos);
+ virtual bool OnInit();
+ virtual void OnCancel();
+ NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
+ #ifndef _SFX
+ void AddToTitle(LPCWSTR string);
+ #endif
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+public:
+ CProgressSynch ProgressSynch;
+
+ #ifndef _SFX
+ HWND MainWindow;
+ UString MainTitle;
+ UString MainAddTitle;
+ ~CProgressDialog();
+ #endif
+
+ CProgressDialog(): _timer(0)
+ #ifndef _SFX
+ ,MainWindow(0)
+ #endif
+ {}
+
+ void WaitCreating() { _dialogCreatedEvent.Lock(); }
+
+
+ INT_PTR Create(const UString &title, HWND wndParent = 0)
+ {
+ _title = title;
+ return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
+ }
+
+ static const UINT kCloseMessage;
+
+ virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+
+ void MyClose()
+ {
+ PostMessage(kCloseMessage);
+ };
+};
+
+#endif
diff --git a/7zip/FileManager/Resource/ProgressDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/ProgressDialog/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/ProgressDialog/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog/StdAfx.h
diff --git a/7zip/FileManager/Resource/ProgressDialog/resource.h b/CPP/7zip/FileManager/Resource/ProgressDialog/resource.h
index 97e47228..97e47228 100755
--- a/7zip/FileManager/Resource/ProgressDialog/resource.h
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog/resource.h
diff --git a/7zip/FileManager/Resource/ProgressDialog/resource.rc b/CPP/7zip/FileManager/Resource/ProgressDialog/resource.rc
index a6b375ed..a6b375ed 100755
--- a/7zip/FileManager/Resource/ProgressDialog/resource.rc
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog/resource.rc
diff --git a/CPP/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp b/CPP/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp
new file mode 100755
index 00000000..e5a496bd
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.cpp
@@ -0,0 +1,432 @@
+// ProgressDialog.cpp
+
+#include "StdAfx.h"
+#include "resource.h"
+#include "ProgressDialog.h"
+#include "Common/IntToString.h"
+#include "Common/IntToString.h"
+
+using namespace NWindows;
+
+static const UINT_PTR kTimerID = 3;
+static const UINT kTimerElapse = 50;
+
+#ifdef LANG
+#include "../../LangUtils.h"
+#endif
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDCANCEL, 0x02000C00 },
+ { IDC_PROGRESS_ELAPSED, 0x02000C01 },
+ { IDC_PROGRESS_REMAINING, 0x02000C02 },
+ { IDC_PROGRESS_TOTAL, 0x02000C03 },
+ { IDC_PROGRESS_SPEED, 0x02000C04 },
+ { IDC_BUTTON_PROGRESS_PRIORITY, 0x02000C10 },
+ { IDC_BUTTON_PAUSE, 0x02000C12 },
+ { IDCANCEL, 0x02000711 },
+};
+#endif
+
+HRESULT CProgressSynch::SetPosAndCheckPaused(UInt64 completed)
+{
+ for (;;)
+ {
+ if(GetStopped())
+ return E_ABORT;
+ if(!GetPaused())
+ break;
+ ::Sleep(100);
+ }
+ SetPos(completed);
+ return S_OK;
+}
+
+#ifndef _SFX
+CProgressDialog::~CProgressDialog()
+{
+ AddToTitle(L"");
+}
+void CProgressDialog::AddToTitle(LPCWSTR s)
+{
+ if (MainWindow != 0)
+ {
+ CWindow window(MainWindow);
+ window.SetText(s + UString(MainTitle));
+ }
+}
+
+static const int kTitleFileNameSizeLimit = 36;
+static const int kCurrentFileNameSizeLimit = 68;
+
+static void ReduceString(UString &s, int size)
+{
+ if (s.Length() > size)
+ s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2);
+}
+#endif
+
+bool CProgressDialog::OnInit()
+{
+ _range = (UInt64)(Int64)(-1);
+ _prevPercentValue = UInt32(-1);
+ _prevElapsedSec = UInt32(-1);
+ _prevRemainingSec = UInt32(-1);
+ _prevSpeed = UInt32(-1);
+ _prevMode = kSpeedBytes;
+ _prevTime = ::GetTickCount();
+ _elapsedTime = 0;
+ _foreground = true;
+
+ #ifdef LANG
+ // LangSetWindowText(HWND(*this), 0x02000C00);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+
+
+ CWindow window(GetItem(IDC_BUTTON_PROGRESS_PRIORITY));
+ window.GetText(backgroundString);
+ backgroundedString = backgroundString;
+ backgroundedString.Replace(L"&", L"");
+
+ window = GetItem(IDC_BUTTON_PAUSE);
+ window.GetText(pauseString);
+
+ foregroundString = LangString(IDS_PROGRESS_FOREGROUND, 0x02000C11);
+ continueString = LangString(IDS_PROGRESS_CONTINUE, 0x02000C13);
+ pausedString = LangString(IDS_PROGRESS_PAUSED, 0x02000C20);
+
+ m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
+ _timer = SetTimer(kTimerID, kTimerElapse);
+ _dialogCreatedEvent.Set();
+ SetText(_title);
+ SetPauseText();
+ SetPriorityText();
+ return CModalDialog::OnInit();
+}
+
+void CProgressDialog::OnCancel()
+{
+ ProgressSynch.SetStopped(true);
+}
+
+static void ConvertSizeToString(UInt64 value, wchar_t *s)
+{
+ const wchar_t *kModif = L" KMGTP";
+ for (int i = 0; ; i++)
+ if (i == 5 || value < (UInt64(10000) << (i * 10)))
+ {
+ ConvertUInt64ToString(value >> (i * 10), s);
+ s += wcslen(s);
+ *s++ = ' ';
+ if (i != 0)
+ *s++ = kModif[i];
+ *s++ = L'B';
+ *s++ = L'\0';
+ return;
+ }
+}
+
+void CProgressDialog::SetRange(UInt64 range)
+{
+ _range = range;
+ _previousPos = (UInt64)(Int64)-1;
+ _converter.Init(range);
+ m_ProgressBar.SetRange32(0 , _converter.Count(range)); // Test it for 100%
+
+ wchar_t s[32];
+ ConvertSizeToString(_range, s);
+ SetItemText(IDC_PROGRESS_SPEED_TOTAL_VALUE, s);
+}
+
+void CProgressDialog::SetPos(UInt64 pos)
+{
+ bool redraw = true;
+ if (pos < _range && pos > _previousPos)
+ {
+ if (pos - _previousPos < (_range >> 10))
+ redraw = false;
+ }
+ if(redraw)
+ {
+ m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100%
+ _previousPos = pos;
+ }
+}
+
+static void GetTimeString(UInt64 timeValue, TCHAR *s)
+{
+ wsprintf(s, TEXT("%02d:%02d:%02d"),
+ UInt32(timeValue / 3600),
+ UInt32((timeValue / 60) % 60),
+ UInt32(timeValue % 60));
+}
+
+bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
+{
+ if (ProgressSynch.GetPaused())
+ return true;
+ UInt64 total, completed;
+ ProgressSynch.GetProgress(total, completed);
+
+ UInt32 curTime = ::GetTickCount();
+
+ if (total != _range)
+ SetRange(total);
+ if (total == (UInt64)(Int64)-1)
+ {
+ SetPos(0);
+ SetRange(completed);
+ }
+ else
+ SetPos(completed);
+
+ _elapsedTime += (curTime - _prevTime);
+ _prevTime = curTime;
+
+ UInt32 elapsedSec = _elapsedTime / 1000;
+
+ bool elapsedChanged = false;
+ if (elapsedSec != _prevElapsedSec)
+ {
+ TCHAR s[40];
+ GetTimeString(elapsedSec, s);
+ SetItemText(IDC_PROGRESS_ELAPSED_VALUE, s);
+ _prevElapsedSec = elapsedSec;
+ elapsedChanged = true;
+ }
+
+ if (completed != 0 && elapsedChanged)
+ {
+ if (total == (UInt64)(Int64)-1)
+ {
+ SetItemText(IDC_PROGRESS_REMAINING_VALUE, L"");
+ }
+ else
+ {
+ UInt64 remainingTime = 0;
+ if (completed < total)
+ remainingTime = _elapsedTime * (total - completed) / completed;
+ UInt64 remainingSec = remainingTime / 1000;
+ if (remainingSec != _prevRemainingSec)
+ {
+ TCHAR s[40];
+ GetTimeString(remainingSec, s);
+ SetItemText(IDC_PROGRESS_REMAINING_VALUE, s);
+ _prevRemainingSec = remainingSec;
+ }
+ }
+ // if (elapsedChanged)
+ {
+ UInt64 speedB = (completed * 1000) / _elapsedTime;
+ UInt64 speedKB = speedB / 1024;
+ UInt64 speedMB = speedKB / 1024;
+ const UInt32 kLimit1 = 10;
+ TCHAR s[40];
+ bool needRedraw = false;
+ if (speedMB >= kLimit1)
+ {
+ if (_prevMode != kSpeedMBytes || speedMB != _prevSpeed)
+ {
+ ConvertUInt64ToString(speedMB, s);
+ lstrcat(s, TEXT(" MB/s"));
+ _prevMode = kSpeedMBytes;
+ _prevSpeed = speedMB;
+ needRedraw = true;
+ }
+ }
+ else if (speedKB >= kLimit1)
+ {
+ if (_prevMode != kSpeedKBytes || speedKB != _prevSpeed)
+ {
+ ConvertUInt64ToString(speedKB, s);
+ lstrcat(s, TEXT(" KB/s"));
+ _prevMode = kSpeedKBytes;
+ _prevSpeed = speedKB;
+ needRedraw = true;
+ }
+ }
+ else
+ {
+ if (_prevMode != kSpeedBytes || speedB != _prevSpeed)
+ {
+ ConvertUInt64ToString(speedB, s);
+ lstrcat(s, TEXT(" B/s"));
+ _prevMode = kSpeedBytes;
+ _prevSpeed = speedB;
+ needRedraw = true;
+ }
+ }
+ if (needRedraw)
+ SetItemText(IDC_PROGRESS_SPEED_VALUE, s);
+ }
+ }
+
+ if (total == 0)
+ total = 1;
+ UInt32 percentValue = (UInt32)(completed * 100 / total);
+ UString titleName;
+ ProgressSynch.GetTitleFileName(titleName);
+ if (percentValue != _prevPercentValue || _prevTitleName != titleName)
+ {
+ _prevPercentValue = percentValue;
+ SetTitleText();
+ _prevTitleName = titleName;
+ }
+ UString fileName;
+ ProgressSynch.GetCurrentFileName(fileName);
+ if (_prevFileName != fileName)
+ {
+ ReduceString(fileName, kCurrentFileNameSizeLimit);
+ SetItemText(IDC_PROGRESS_FILE_NAME, fileName);
+ _prevFileName == fileName;
+ }
+
+ return true;
+}
+
+
+////////////////////
+// CU64ToI32Converter
+
+static const UInt64 kMaxIntValue = 0x7FFFFFFF;
+
+void CU64ToI32Converter::Init(UInt64 range)
+{
+ _numShiftBits = 0;
+ while(range > kMaxIntValue)
+ {
+ range >>= 1;
+ _numShiftBits++;
+ }
+}
+
+int CU64ToI32Converter::Count(UInt64 aValue)
+{
+ return int(aValue >> _numShiftBits);
+}
+
+const UINT CProgressDialog::kCloseMessage = WM_USER + 1;
+
+bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message)
+ {
+ case kCloseMessage:
+ {
+ KillTimer(_timer);
+ _timer = 0;
+ End(0);
+ return true;
+ }
+ case WM_SETTEXT:
+ {
+ if (_timer == 0)
+ return true;
+ }
+ }
+ return CModalDialog::OnMessage(message, wParam, lParam);
+}
+
+void CProgressDialog::SetTitleText()
+{
+ UString title;
+ if (ProgressSynch.GetPaused())
+ {
+ title = pausedString;
+ title += L" ";
+ }
+ if (_prevPercentValue != UInt32(-1))
+ {
+ wchar_t s[64];
+ ConvertUInt64ToString(_prevPercentValue, s);
+ title += s;
+ title += L"%";
+ }
+ if (!_foreground)
+ {
+ title += L" ";
+ title += backgroundedString;
+ }
+ title += L" ";
+ UString totalTitle = title + _title;
+ UString fileName;
+ ProgressSynch.GetTitleFileName(fileName);
+ if (!fileName.IsEmpty())
+ {
+ ReduceString(fileName, kTitleFileNameSizeLimit);
+ totalTitle += L" ";
+ totalTitle += fileName;
+ }
+ SetText(totalTitle);
+ #ifndef _SFX
+ AddToTitle(title + MainAddTitle);
+ #endif
+}
+
+void CProgressDialog::SetPauseText()
+{
+ SetItemText(IDC_BUTTON_PAUSE, ProgressSynch.GetPaused() ?
+ continueString : pauseString);
+ SetTitleText();
+}
+
+void CProgressDialog::OnPauseButton()
+{
+ bool paused = !ProgressSynch.GetPaused();
+ ProgressSynch.SetPaused(paused);
+ UInt32 curTime = ::GetTickCount();
+ if (paused)
+ _elapsedTime += (curTime - _prevTime);
+ _prevTime = curTime;
+ SetPauseText();
+}
+
+void CProgressDialog::SetPriorityText()
+{
+ SetItemText(IDC_BUTTON_PROGRESS_PRIORITY, _foreground ?
+ backgroundString :
+ foregroundString);
+ SetTitleText();
+}
+
+void CProgressDialog::OnPriorityButton()
+{
+ _foreground = !_foreground;
+ SetPriorityClass(GetCurrentProcess(), _foreground ?
+ NORMAL_PRIORITY_CLASS: IDLE_PRIORITY_CLASS);
+ SetPriorityText();
+}
+
+bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDCANCEL:
+ {
+ bool paused = ProgressSynch.GetPaused();;
+ // ProgressSynch.SetPaused(true);
+ if (!paused)
+ OnPauseButton();
+ int res = ::MessageBoxW(HWND(*this),
+ LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30),
+ _title, MB_YESNOCANCEL);
+ // ProgressSynch.SetPaused(paused);
+ if (!paused)
+ OnPauseButton();
+ if (res == IDCANCEL || res == IDNO)
+ return true;
+ break;
+ }
+ case IDC_BUTTON_PAUSE:
+ OnPauseButton();
+ return true;
+ case IDC_BUTTON_PROGRESS_PRIORITY:
+ {
+ OnPriorityButton();
+ return true;
+ }
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
diff --git a/CPP/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h b/CPP/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h
new file mode 100755
index 00000000..0625eadd
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog2/ProgressDialog.h
@@ -0,0 +1,184 @@
+// ProgressDialog.h
+
+#ifndef __PROGRESSDIALOG_H
+#define __PROGRESSDIALOG_H
+
+#include "resource.h"
+
+#include "Common/Types.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ProgressBar.h"
+#include "Windows/Synchronization.h"
+
+class CProgressSynch
+{
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+ bool _stopped;
+ bool _paused;
+ UInt64 _total;
+ UInt64 _completed;
+ UString TitleFileName;
+ UString CurrentFileName;
+public:
+ CProgressSynch(): _stopped(false), _paused(false), _total((UInt64)(Int64)-1), _completed(0) {}
+
+ bool GetStopped()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ return _stopped;
+ }
+ void SetStopped(bool value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ _stopped = value;
+ }
+ bool GetPaused()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ return _paused;
+ }
+ void SetPaused(bool value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ _paused = value;
+ }
+ void SetProgress(UInt64 total, UInt64 completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ _total = total;
+ _completed = completed;
+ }
+ void SetPos(UInt64 completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ _completed = completed;
+ }
+ HRESULT SetPosAndCheckPaused(UInt64 completed);
+ void GetProgress(UInt64 &total, UInt64 &completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ total = _total;
+ completed = _completed;
+ }
+ void SetTitleFileName(const UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ TitleFileName = fileName;
+ }
+ void GetTitleFileName(UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ fileName = TitleFileName;
+ }
+ void SetCurrentFileName(const UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ CurrentFileName = fileName;
+ }
+ void GetCurrentFileName(UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ fileName = CurrentFileName;
+ }
+};
+
+class CU64ToI32Converter
+{
+ UInt64 _numShiftBits;
+public:
+ void Init(UInt64 _range);
+ int Count(UInt64 aValue);
+};
+
+// class CProgressDialog: public NWindows::NControl::CModelessDialog
+
+enum ESpeedMode
+{
+ kSpeedBytes,
+ kSpeedKBytes,
+ kSpeedMBytes
+};
+
+class CProgressDialog: public NWindows::NControl::CModalDialog
+{
+ UString _prevFileName;
+ UString _prevTitleName;
+private:
+ UString backgroundString;
+ UString backgroundedString;
+ UString foregroundString;
+ UString pauseString;
+ UString continueString;
+ UString pausedString;
+
+
+
+ UINT_PTR _timer;
+
+ UString _title;
+ CU64ToI32Converter _converter;
+ UInt64 _previousPos;
+ UInt64 _range;
+ NWindows::NControl::CProgressBar m_ProgressBar;
+
+ UInt32 _prevPercentValue;
+ UInt32 _prevTime;
+ UInt32 _elapsedTime;
+ UInt32 _prevElapsedSec;
+ UInt64 _prevRemainingSec;
+ ESpeedMode _prevMode;
+ UInt64 _prevSpeed;
+
+ bool _foreground;
+
+ bool OnTimer(WPARAM timerID, LPARAM callback);
+ void SetRange(UInt64 range);
+ void SetPos(UInt64 pos);
+ virtual bool OnInit();
+ virtual void OnCancel();
+ NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
+ #ifndef _SFX
+ void AddToTitle(LPCWSTR string);
+ #endif
+
+ void SetPauseText();
+ void SetPriorityText();
+ void OnPauseButton();
+ void OnPriorityButton();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+
+ void SetTitleText();
+public:
+ CProgressSynch ProgressSynch;
+
+ #ifndef _SFX
+ HWND MainWindow;
+ UString MainTitle;
+ UString MainAddTitle;
+ ~CProgressDialog();
+ #endif
+
+ CProgressDialog(): _timer(0)
+ #ifndef _SFX
+ ,MainWindow(0)
+ #endif
+ {}
+
+ void WaitCreating() { _dialogCreatedEvent.Lock(); }
+
+
+ INT_PTR Create(const UString &title, HWND wndParent = 0)
+ {
+ _title = title;
+ return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
+ }
+
+ static const UINT kCloseMessage;
+
+ virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+
+ void MyClose() { PostMessage(kCloseMessage); };
+};
+
+#endif
diff --git a/7zip/FileManager/Resource/ProgressDialog2/StdAfx.h b/CPP/7zip/FileManager/Resource/ProgressDialog2/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/ProgressDialog2/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog2/StdAfx.h
diff --git a/7zip/FileManager/Resource/ProgressDialog2/resource.h b/CPP/7zip/FileManager/Resource/ProgressDialog2/resource.h
index be1da4ad..be1da4ad 100755
--- a/7zip/FileManager/Resource/ProgressDialog2/resource.h
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog2/resource.h
diff --git a/CPP/7zip/FileManager/Resource/ProgressDialog2/resource.rc b/CPP/7zip/FileManager/Resource/ProgressDialog2/resource.rc
new file mode 100755
index 00000000..9f395bff
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog2/resource.rc
@@ -0,0 +1,56 @@
+#include "resource.h"
+#include "../../../GuiCommon.rc"
+
+#define xSize2 290
+#define ySize2 76
+
+#define xSize (xSize2 + marg + marg)
+#define ySize (ySize2 + marg + marg)
+
+#define bYPos (ySize - marg - bYSize)
+
+#undef bXSize
+#define bXSize 72
+
+#define bXPos1 (xSize - marg - bXSize)
+#define bXPos2 (bXPos1 - 10 - bXSize)
+#define bXPos3 (bXPos2 - 10 - bXSize)
+
+#define valSize 42
+#define timeSize 91
+#define labelPos 178
+#define valPos1 (marg + timeSize)
+#define valPos2 (xSize - marg - valSize)
+#define labelSize (valPos2 - labelPos)
+
+#undef yPos
+#define yPos (marg + 11)
+
+
+IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
+CAPTION "Progress"
+MY_FONT
+BEGIN
+ PUSHBUTTON "&Background", IDC_BUTTON_PROGRESS_PRIORITY, bXPos3, bYPos, bXSize, bYSize
+ PUSHBUTTON "&Pause", IDC_BUTTON_PAUSE, bXPos2, bYPos, bXSize, bYSize
+ PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize
+ LTEXT "Elapsed time:", IDC_PROGRESS_ELAPSED, marg, marg, timeSize, 8
+ LTEXT "Remaining time:", IDC_PROGRESS_REMAINING, marg, yPos, timeSize, 8
+ LTEXT "Size:", IDC_PROGRESS_TOTAL, labelPos, marg, labelSize, 8
+ LTEXT "Speed:", IDC_PROGRESS_SPEED, labelPos, yPos, labelSize, 8
+ RTEXT "00:00:00", IDC_PROGRESS_ELAPSED_VALUE, valPos1, marg, valSize, 8
+ RTEXT "", IDC_PROGRESS_REMAINING_VALUE, valPos1, yPos, valSize, 8
+ RTEXT "", IDC_PROGRESS_SPEED_TOTAL_VALUE, valPos2, marg, valSize, 8
+ RTEXT "", IDC_PROGRESS_SPEED_VALUE, valPos2, yPos, valSize, 8
+ LTEXT "", IDC_PROGRESS_FILE_NAME, marg, yPos + 16, xSize2, 8, SS_NOPREFIX
+ CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, marg, bYPos - 20, xSize2, 13
+END
+
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_PROGRESS_PAUSED "Paused"
+ IDS_PROGRESS_FOREGROUND "&Foreground"
+ IDS_PROGRESS_CONTINUE "&Continue"
+ IDS_PROGRESS_ASK_CANCEL "Are you sure you want to cancel?"
+END
diff --git a/7zip/FileManager/Resource/PropertyName/resource.h b/CPP/7zip/FileManager/Resource/PropertyName/resource.h
index f3d56ef3..f3d56ef3 100755
--- a/7zip/FileManager/Resource/PropertyName/resource.h
+++ b/CPP/7zip/FileManager/Resource/PropertyName/resource.h
diff --git a/7zip/FileManager/Resource/PropertyName/resource.rc b/CPP/7zip/FileManager/Resource/PropertyName/resource.rc
index 3f517aff..3f517aff 100755
--- a/7zip/FileManager/Resource/PropertyName/resource.rc
+++ b/CPP/7zip/FileManager/Resource/PropertyName/resource.rc
diff --git a/7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp b/CPP/7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp
index 6a681fbc..6a681fbc 100755
--- a/7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp
+++ b/CPP/7zip/FileManager/Resource/SettingsPage/SettingsPage.cpp
diff --git a/7zip/FileManager/Resource/SettingsPage/SettingsPage.h b/CPP/7zip/FileManager/Resource/SettingsPage/SettingsPage.h
index e5fe6e67..e5fe6e67 100755
--- a/7zip/FileManager/Resource/SettingsPage/SettingsPage.h
+++ b/CPP/7zip/FileManager/Resource/SettingsPage/SettingsPage.h
diff --git a/7zip/FileManager/Resource/SettingsPage/StdAfx.h b/CPP/7zip/FileManager/Resource/SettingsPage/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/SettingsPage/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/SettingsPage/StdAfx.h
diff --git a/7zip/FileManager/Resource/SettingsPage/resource.h b/CPP/7zip/FileManager/Resource/SettingsPage/resource.h
index 8932dc0e..8932dc0e 100755
--- a/7zip/FileManager/Resource/SettingsPage/resource.h
+++ b/CPP/7zip/FileManager/Resource/SettingsPage/resource.h
diff --git a/7zip/FileManager/Resource/SettingsPage/resource.rc b/CPP/7zip/FileManager/Resource/SettingsPage/resource.rc
index 69afeba7..69afeba7 100755
--- a/7zip/FileManager/Resource/SettingsPage/resource.rc
+++ b/CPP/7zip/FileManager/Resource/SettingsPage/resource.rc
diff --git a/CPP/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp b/CPP/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp
new file mode 100755
index 00000000..383fa48a
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/SplitDialog/SplitDialog.cpp
@@ -0,0 +1,89 @@
+// SplitDialog.cpp
+
+#include "StdAfx.h"
+#include "SplitDialog.h"
+
+#include "Common/StringToInt.h"
+#include "Windows/Shell.h"
+#include "Windows/FileName.h"
+
+#include "../../SplitUtils.h"
+#ifdef LANG
+#include "../../LangUtils.h"
+#endif
+
+#include "../CopyDialog/resource.h"
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_SPLIT_PATH, 0x03020501 },
+ { IDC_STATIC_SPLIT_VOLUME, 0x02000D40 },
+};
+#endif
+
+
+bool CSplitDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x03020500);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _pathCombo.Attach(GetItem(IDC_COMBO_SPLIT_PATH));
+ _volumeCombo.Attach(GetItem(IDC_COMBO_SPLIT_VOLUME));
+
+ if (!FilePath.IsEmpty())
+ {
+ UString title;
+ GetText(title);
+ title += L' ';
+ title += FilePath;
+ SetText(title);
+ }
+ _pathCombo.SetText(Path);
+ AddVolumeItems(_volumeCombo);
+ _volumeCombo.SetCurSel(0);
+ return CModalDialog::OnInit();
+}
+
+bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_BUTTON_SPLIT_PATH:
+ OnButtonSetPath();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CSplitDialog::OnButtonSetPath()
+{
+ UString currentPath;
+ _pathCombo.GetText(currentPath);
+ // UString title = L"Specify a location for output folder";
+ UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209);
+
+ UString resultPath;
+ if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
+ return;
+ NFile::NName::NormalizeDirPathPrefix(resultPath);
+ _pathCombo.SetCurSel(-1);
+ _pathCombo.SetText(resultPath);
+}
+
+void CSplitDialog::OnOK()
+{
+ _pathCombo.GetText(Path);
+ UString volumeString;
+ _volumeCombo.GetText(volumeString);
+ volumeString.Trim();
+ if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0)
+ {
+ ::MessageBoxW(*this, LangString(IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0);
+ return;
+ }
+ CModalDialog::OnOK();
+}
diff --git a/7zip/FileManager/Resource/SplitDialog/SplitDialog.h b/CPP/7zip/FileManager/Resource/SplitDialog/SplitDialog.h
index d73dcbca..d73dcbca 100755
--- a/7zip/FileManager/Resource/SplitDialog/SplitDialog.h
+++ b/CPP/7zip/FileManager/Resource/SplitDialog/SplitDialog.h
diff --git a/CPP/7zip/FileManager/Resource/SplitDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/SplitDialog/StdAfx.h
new file mode 100755
index 00000000..eb2ba641
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/SplitDialog/StdAfx.h
@@ -0,0 +1,18 @@
+// stdafx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#define _WIN32_WINNT 0x0400
+
+// it's for Windows NT supporting (MENUITEMINFOW)
+#define WINVER 0x0400
+
+#include <windows.h>
+#include <commctrl.h>
+
+// #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+#include "Common/NewHandler.h"
+
+#endif
diff --git a/CPP/7zip/FileManager/Resource/SplitDialog/resource.h b/CPP/7zip/FileManager/Resource/SplitDialog/resource.h
new file mode 100755
index 00000000..019b7029
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/SplitDialog/resource.h
@@ -0,0 +1,8 @@
+#define IDD_DIALOG_SPLIT 504
+#define IDC_STATIC_SPLIT_PATH 1000
+#define IDC_COMBO_SPLIT_PATH 1001
+#define IDC_BUTTON_SPLIT_PATH 1002
+#define IDC_STATIC_SPLIT_VOLUME 1010
+#define IDC_COMBO_SPLIT_VOLUME 1011
+
+#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95
diff --git a/CPP/7zip/FileManager/Resource/SplitDialog/resource.rc b/CPP/7zip/FileManager/Resource/SplitDialog/resource.rc
new file mode 100755
index 00000000..5282ee7d
--- /dev/null
+++ b/CPP/7zip/FileManager/Resource/SplitDialog/resource.rc
@@ -0,0 +1,32 @@
+#include "resource.h"
+#include "../../../GuiCommon.rc"
+
+#define xSize2 223
+#define ySize2 89
+
+#define xSize (xSize2 + marg + marg)
+#define ySize (ySize2 + marg + marg)
+
+#define bYPos (ySize - marg - bYSize)
+#define b1XPos (xSize - marg - bXSize)
+#define b2XPos (b1XPos - 10 - bXSize)
+
+
+
+IDD_DIALOG_SPLIT DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
+CAPTION "Split File"
+MY_FONT
+BEGIN
+ LTEXT "&Split to:", IDC_STATIC_SPLIT_PATH, marg, marg, xSize2, 8
+ COMBOBOX IDC_COMBO_SPLIT_PATH, marg, 18, xSize2 - bDotsSize - 12, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "...", IDC_BUTTON_SPLIT_PATH, xSize - marg - bDotsSize, 17, bDotsSize, bYSize, WS_GROUP
+ LTEXT "Split to &volumes, bytes:", IDC_STATIC_SPLIT_VOLUME, marg, 38, xSize2, 8
+ COMBOBOX IDC_COMBO_SPLIT_VOLUME, marg, 50, 120, 52, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize
+ PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize
+END
+
+STRINGTABLE
+BEGIN
+ IDS_COMPRESS_INCORRECT_VOLUME_SIZE "Incorrect volume size"
+END
diff --git a/7zip/FileManager/Resource/SystemPage/StdAfx.h b/CPP/7zip/FileManager/Resource/SystemPage/StdAfx.h
index a444ca31..a444ca31 100755
--- a/7zip/FileManager/Resource/SystemPage/StdAfx.h
+++ b/CPP/7zip/FileManager/Resource/SystemPage/StdAfx.h
diff --git a/7zip/FileManager/Resource/SystemPage/SystemPage.cpp b/CPP/7zip/FileManager/Resource/SystemPage/SystemPage.cpp
index ca3b7432..ca3b7432 100755
--- a/7zip/FileManager/Resource/SystemPage/SystemPage.cpp
+++ b/CPP/7zip/FileManager/Resource/SystemPage/SystemPage.cpp
diff --git a/7zip/FileManager/Resource/SystemPage/SystemPage.h b/CPP/7zip/FileManager/Resource/SystemPage/SystemPage.h
index 3798f640..3798f640 100755
--- a/7zip/FileManager/Resource/SystemPage/SystemPage.h
+++ b/CPP/7zip/FileManager/Resource/SystemPage/SystemPage.h
diff --git a/7zip/FileManager/Resource/SystemPage/resource.h b/CPP/7zip/FileManager/Resource/SystemPage/resource.h
index 8dce778b..8dce778b 100755
--- a/7zip/FileManager/Resource/SystemPage/resource.h
+++ b/CPP/7zip/FileManager/Resource/SystemPage/resource.h
diff --git a/7zip/FileManager/Resource/SystemPage/resource.rc b/CPP/7zip/FileManager/Resource/SystemPage/resource.rc
index cf19d11b..cf19d11b 100755
--- a/7zip/FileManager/Resource/SystemPage/resource.rc
+++ b/CPP/7zip/FileManager/Resource/SystemPage/resource.rc
diff --git a/7zip/FileManager/RootFolder.cpp b/CPP/7zip/FileManager/RootFolder.cpp
index 4ff0660b..4ff0660b 100755
--- a/7zip/FileManager/RootFolder.cpp
+++ b/CPP/7zip/FileManager/RootFolder.cpp
diff --git a/7zip/FileManager/RootFolder.h b/CPP/7zip/FileManager/RootFolder.h
index 16bac250..16bac250 100755
--- a/7zip/FileManager/RootFolder.h
+++ b/CPP/7zip/FileManager/RootFolder.h
diff --git a/CPP/7zip/FileManager/SplitUtils.cpp b/CPP/7zip/FileManager/SplitUtils.cpp
new file mode 100755
index 00000000..3a7635fa
--- /dev/null
+++ b/CPP/7zip/FileManager/SplitUtils.cpp
@@ -0,0 +1,85 @@
+// SplitUtils.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringToInt.h"
+
+#include "SplitUtils.h"
+#include "StringUtils.h"
+
+bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values)
+{
+ values.Clear();
+ UStringVector destStrings;
+ SplitString(s, destStrings);
+ bool prevIsNumber = false;
+ for (int i = 0; i < destStrings.Size(); i++)
+ {
+ UString subString = destStrings[i];
+ subString.MakeUpper();
+ if (subString.IsEmpty())
+ return false;
+ if (subString == L"-")
+ return true;
+ if (prevIsNumber)
+ {
+ wchar_t c = subString[0];
+ UInt64 &value = values.Back();
+ prevIsNumber = false;
+ switch(c)
+ {
+ case L'B':
+ continue;
+ case L'K':
+ value <<= 10;
+ continue;
+ case L'M':
+ value <<= 20;
+ continue;
+ case L'G':
+ value <<= 30;
+ continue;
+ }
+ }
+ const wchar_t *start = subString;
+ const wchar_t *end;
+ UInt64 value = ConvertStringToUInt64(start, &end);
+ if (start == end)
+ return false;
+ if (value == 0)
+ return false;
+ values.Add(value);
+ prevIsNumber = true;
+ UString rem = subString.Mid((int)(end - start));
+ if (!rem.IsEmpty())
+ destStrings.Insert(i + 1, rem);
+ }
+ return true;
+}
+
+void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo)
+{
+ volumeCombo.AddString(TEXT("1457664 - 3.5\" floppy"));
+ volumeCombo.AddString(TEXT("650M - CD"));
+ volumeCombo.AddString(TEXT("700M - CD"));
+ volumeCombo.AddString(TEXT("4480M - DVD"));
+}
+
+UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector<UInt64> &volSizes)
+{
+ if (size == 0 || volSizes.Size() == 0)
+ return 1;
+ UInt64 numVolumes = 0;
+ for (int i = 0; i < volSizes.Size(); i++)
+ {
+ UInt64 volSize = volSizes[i];
+ numVolumes++;
+ if (volSize >= size)
+ return numVolumes;
+ size -= volSize;
+ }
+ UInt64 volSize = volSizes.Back();
+ if (volSize == 0)
+ return (UInt64)(Int64)-1;
+ return numVolumes + (size - 1) / volSize + 1;
+}
diff --git a/CPP/7zip/FileManager/SplitUtils.h b/CPP/7zip/FileManager/SplitUtils.h
new file mode 100755
index 00000000..fe359f04
--- /dev/null
+++ b/CPP/7zip/FileManager/SplitUtils.h
@@ -0,0 +1,15 @@
+// SplitUtils.h
+
+#ifndef __SPLITUTILS_H
+#define __SPLITUTILS_H
+
+#include "Common/String.h"
+#include "Common/Types.h"
+#include "Windows/Control/ComboBox.h"
+
+bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values);
+void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo);
+
+UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector<UInt64> &volSizes);
+
+#endif
diff --git a/7zip/UI/Console/StdAfx.cpp b/CPP/7zip/FileManager/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/UI/Console/StdAfx.cpp
+++ b/CPP/7zip/FileManager/StdAfx.cpp
diff --git a/CPP/7zip/FileManager/StdAfx.h b/CPP/7zip/FileManager/StdAfx.h
new file mode 100755
index 00000000..b09de592
--- /dev/null
+++ b/CPP/7zip/FileManager/StdAfx.h
@@ -0,0 +1,23 @@
+// stdafx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#define _WIN32_WINNT 0x0400
+
+// it's for Windows NT supporting (MENUITEMINFOW)
+#define WINVER 0x0400
+
+#include <windows.h>
+#include <stdio.h>
+#include <commctrl.h>
+#include <ShlObj.h>
+#include <limits.h>
+#include <tchar.h>
+#include <shlwapi.h>
+
+// #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+#include "Common/NewHandler.h"
+
+#endif
diff --git a/7zip/FileManager/StringUtils.cpp b/CPP/7zip/FileManager/StringUtils.cpp
index 63eebdba..63eebdba 100755
--- a/7zip/FileManager/StringUtils.cpp
+++ b/CPP/7zip/FileManager/StringUtils.cpp
diff --git a/7zip/FileManager/StringUtils.h b/CPP/7zip/FileManager/StringUtils.h
index 376a3024..376a3024 100755
--- a/7zip/FileManager/StringUtils.h
+++ b/CPP/7zip/FileManager/StringUtils.h
diff --git a/7zip/FileManager/SysIconUtils.cpp b/CPP/7zip/FileManager/SysIconUtils.cpp
index 0d337550..0d337550 100755
--- a/7zip/FileManager/SysIconUtils.cpp
+++ b/CPP/7zip/FileManager/SysIconUtils.cpp
diff --git a/7zip/FileManager/SysIconUtils.h b/CPP/7zip/FileManager/SysIconUtils.h
index 51294751..51294751 100755
--- a/7zip/FileManager/SysIconUtils.h
+++ b/CPP/7zip/FileManager/SysIconUtils.h
diff --git a/7zip/FileManager/Test.bmp b/CPP/7zip/FileManager/Test.bmp
index ef85ba23..ef85ba23 100755
--- a/7zip/FileManager/Test.bmp
+++ b/CPP/7zip/FileManager/Test.bmp
Binary files differ
diff --git a/7zip/FileManager/Test2.bmp b/CPP/7zip/FileManager/Test2.bmp
index 99b7dbf0..99b7dbf0 100755
--- a/7zip/FileManager/Test2.bmp
+++ b/CPP/7zip/FileManager/Test2.bmp
Binary files differ
diff --git a/7zip/FileManager/TextPairs.cpp b/CPP/7zip/FileManager/TextPairs.cpp
index 76c97b8c..76c97b8c 100755
--- a/7zip/FileManager/TextPairs.cpp
+++ b/CPP/7zip/FileManager/TextPairs.cpp
diff --git a/7zip/FileManager/TextPairs.h b/CPP/7zip/FileManager/TextPairs.h
index 247a92d9..247a92d9 100755
--- a/7zip/FileManager/TextPairs.h
+++ b/CPP/7zip/FileManager/TextPairs.h
diff --git a/7zip/FileManager/UpdateCallback100.cpp b/CPP/7zip/FileManager/UpdateCallback100.cpp
index ddd2e55d..ddd2e55d 100755
--- a/7zip/FileManager/UpdateCallback100.cpp
+++ b/CPP/7zip/FileManager/UpdateCallback100.cpp
diff --git a/7zip/FileManager/UpdateCallback100.h b/CPP/7zip/FileManager/UpdateCallback100.h
index 4cce5b52..4cce5b52 100755
--- a/7zip/FileManager/UpdateCallback100.h
+++ b/CPP/7zip/FileManager/UpdateCallback100.h
diff --git a/7zip/FileManager/ViewSettings.cpp b/CPP/7zip/FileManager/ViewSettings.cpp
index 9102cc4e..9102cc4e 100755
--- a/7zip/FileManager/ViewSettings.cpp
+++ b/CPP/7zip/FileManager/ViewSettings.cpp
diff --git a/7zip/FileManager/ViewSettings.h b/CPP/7zip/FileManager/ViewSettings.h
index 4894a6f9..4894a6f9 100755
--- a/7zip/FileManager/ViewSettings.h
+++ b/CPP/7zip/FileManager/ViewSettings.h
diff --git a/CPP/7zip/FileManager/makefile b/CPP/7zip/FileManager/makefile
new file mode 100755
index 00000000..42619e0a
--- /dev/null
+++ b/CPP/7zip/FileManager/makefile
@@ -0,0 +1,187 @@
+PROG = 7zFM.exe
+LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib shell32.lib ole32.lib comctl32.lib htmlhelp.lib Mpr.lib Gdi32.lib comdlg32.lib
+CFLAGS = $(CFLAGS) -I../../ -DLANG -DWIN_LONG_PATH
+
+FM_OBJS = \
+ $O\App.obj \
+ $O\ClassDefs.obj \
+ $O\EnumFormatEtc.obj \
+ $O\ExtractCallback.obj \
+ $O\FileFolderPluginOpen.obj \
+ $O\FilePlugins.obj \
+ $O\FM.obj \
+ $O\FormatUtils.obj \
+ $O\FSDrives.obj \
+ $O\FSFolder.obj \
+ $O\FSFolderCopy.obj \
+ $O\HelpUtils.obj \
+ $O\LangUtils.obj \
+ $O\MyLoadMenu.obj \
+ $O\NetFolder.obj \
+ $O\OpenCallback.obj \
+ $O\OptionsDialog.obj \
+ $O\Panel.obj \
+ $O\PanelCopy.obj \
+ $O\PanelCrc.obj \
+ $O\PanelDrag.obj \
+ $O\PanelFolderChange.obj \
+ $O\PanelItemOpen.obj \
+ $O\PanelItems.obj \
+ $O\PanelKey.obj \
+ $O\PanelListNotify.obj \
+ $O\PanelMenu.obj \
+ $O\PanelOperations.obj \
+ $O\PanelSelect.obj \
+ $O\PanelSort.obj \
+ $O\PanelSplitFile.obj \
+ $O\PhysDriveFolder.obj \
+ $O\ProgramLocation.obj \
+ $O\PropertyName.obj \
+ $O\RegistryAssociations.obj \
+ $O\RegistryPlugins.obj \
+ $O\RegistryUtils.obj \
+ $O\RootFolder.obj \
+ $O\SplitUtils.obj \
+ $O\StringUtils.obj \
+ $O\SysIconUtils.obj \
+ $O\TextPairs.obj \
+ $O\UpdateCallback100.obj \
+ $O\ViewSettings.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CRC.obj \
+ $O\IntToString.obj \
+ $O\Lang.obj \
+ $O\ListFileUtils.obj \
+ $O\NewHandler.obj \
+ $O\Random.obj \
+ $O\StdInStream.obj \
+ $O\StdOutStream.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\TextConfig.obj \
+ $O\UTFConvert.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\CommonDialog.obj \
+ $O\DLL.obj \
+ $O\Error.obj \
+ $O\FileDevice.obj \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\FileName.obj \
+ $O\FileSystem.obj \
+ $O\Memory.obj \
+ $O\MemoryLock.obj \
+ $O\Menu.obj \
+ $O\Net.obj \
+ $O\PropVariant.obj \
+ $O\PropVariantConversions.obj \
+ $O\Registry.obj \
+ $O\ResourceString.obj \
+ $O\Security.obj \
+ $O\Shell.obj \
+ $O\Synchronization.obj \
+ $O\Window.obj \
+
+WIN_CTRL_OBJS = \
+ $O\ComboBox.obj \
+ $O\Dialog.obj \
+ $O\ListView.obj \
+ $O\PropertyPage.obj \
+ $O\Window2.obj \
+
+7ZIP_COMMON_OBJS = \
+ $O\FilePathAutoRename.obj \
+ $O\FileStreams.obj \
+ $O\StreamObjects.obj \
+
+UI_COMMON_OBJS = \
+ $O\ArchiveName.obj \
+ $O\CompressCall.obj \
+ $O\PropIDUtils.obj \
+
+C_OBJS = \
+ $O\Sort.obj \
+
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(FM_OBJS)\
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(WIN_CTRL_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $O\AboutDialog.obj \
+ $O\BenchmarkDialog.obj \
+ $O\ComboDialog.obj \
+ $O\CopyDialog.obj \
+ $O\EditPage.obj \
+ $O\LangPage.obj \
+ $O\ListViewDialog.obj \
+ $O\MessagesDialog.obj \
+ $O\OverwriteDialog.obj \
+ $O\PasswordDialog.obj \
+ $O\PluginsPage.obj \
+ $O\ProgressDialog.obj \
+ $O\SettingsPage.obj \
+ $O\SplitDialog.obj \
+ $O\SystemPage.obj \
+ $O\resource.res \
+ $(C_OBJS) \
+
+!include "../../Build.mak"
+
+$(FM_OBJS): $(*B).cpp
+ $(COMPL)
+$(COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../Windows/$(*B).cpp
+ $(COMPL)
+$(WIN_CTRL_OBJS): ../../Windows/Control/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../Common/$(*B).cpp
+ $(COMPL)
+$(UI_COMMON_OBJS): ../UI/Common/$(*B).cpp
+ $(COMPL)
+
+$O\AboutDialog.obj: Resource/AboutDialog/AboutDialog.cpp
+ $(COMPL)
+$O\BenchmarkDialog.obj: Resource/BenchmarkDialog/BenchmarkDialog.cpp
+ $(COMPL)
+$O\ComboDialog.obj: Resource/ComboDialog/ComboDialog.cpp
+ $(COMPL)
+$O\CopyDialog.obj: Resource/CopyDialog/CopyDialog.cpp
+ $(COMPL)
+$O\EditPage.obj: Resource/EditPage/EditPage.cpp
+ $(COMPL)
+$O\LangPage.obj: Resource/LangPage/LangPage.cpp
+ $(COMPL)
+$O\ListViewDialog.obj: Resource/ListViewDialog/ListViewDialog.cpp
+ $(COMPL)
+$O\MessagesDialog.obj: Resource/MessagesDialog/MessagesDialog.cpp
+ $(COMPL)
+$O\OverwriteDialog.obj: Resource/OverwriteDialog/OverwriteDialog.cpp
+ $(COMPL)
+$O\PasswordDialog.obj: Resource/PasswordDialog/PasswordDialog.cpp
+ $(COMPL)
+$O\PluginsPage.obj: Resource/PluginsPage/PluginsPage.cpp
+ $(COMPL)
+$O\ProgressDialog.obj: Resource/ProgressDialog2/ProgressDialog.cpp
+ $(COMPL)
+$O\SettingsPage.obj: Resource/SettingsPage/SettingsPage.cpp
+ $(COMPL)
+$O\SplitDialog.obj: Resource/SplitDialog/SplitDialog.cpp
+ $(COMPL)
+$O\SystemPage.obj: Resource/SystemPage/SystemPage.cpp
+ $(COMPL)
+$(C_OBJS): ../../../C/$(*B).c
+ $(COMPL_O2)
+
+
diff --git a/CPP/7zip/FileManager/resource.h b/CPP/7zip/FileManager/resource.h
new file mode 100755
index 00000000..bc809306
--- /dev/null
+++ b/CPP/7zip/FileManager/resource.h
@@ -0,0 +1,154 @@
+#define IDI_FAM 101
+#define IDI_FM 101
+#define IDR_MENUBAR1 103
+#define IDM_MENU 103
+#define IDR_ACCELERATOR1 209
+#define IDM_FILE_OPEN 210
+#define IDM_FILE_OPEN_INSIDE 211
+#define IDM_FILE_OPEN_OUTSIDE 212
+#define IDM_FILE_VIEW 220
+#define IDM_FILE_EDIT 221
+#define IDM_RENAME 230
+#define IDM_COPY_TO 231
+#define IDM_MOVE_TO 232
+#define IDM_DELETE 233
+#define IDM_FILE_SPLIT 238
+#define IDM_FILE_COMBINE 239
+#define IDM_FILE_PROPERTIES 240
+#define IDM_FILE_COMMENT 241
+#define IDM_FILE_CRC 242
+#define IDM_CREATE_FOLDER 250
+#define IDM_CREATE_FILE 251
+#define IDM_EDIT_CUT 320
+#define IDM_EDIT_COPY 321
+#define IDM_EDIT_PASTE 322
+#define IDM_SELECT_ALL 330
+#define IDM_DESELECT_ALL 331
+#define IDM_INVERT_SELECTION 332
+#define IDM_SELECT 333
+#define IDM_DESELECT 334
+#define IDM_SELECT_BY_TYPE 335
+#define IDM_DESELECT_BY_TYPE 336
+#define IDM_VIEW_LARGE_ICONS 410
+#define IDM_VIEW_SMALL_ICONS 411
+#define IDM_VIEW_LIST 412
+#define IDM_VIEW_DETAILS 413
+#define IDM_VIEW_ARANGE_BY_NAME 420
+#define IDM_VIEW_ARANGE_BY_TYPE 421
+#define IDM_VIEW_ARANGE_BY_DATE 422
+#define IDM_VIEW_ARANGE_BY_SIZE 423
+#define IDM_VIEW_ARANGE_NO_SORT 424
+#define IDM_OPEN_ROOT_FOLDER 430
+#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_TWO_PANELS 450
+#define IDM_VIEW_TOOLBARS 451
+#define IDM_VIEW_STANDARD_TOOLBAR 460
+#define IDM_VIEW_ARCHIVE_TOOLBAR 461
+#define IDM_VIEW_TOOLBARS_LARGE_BUTTONS 462
+#define IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 463
+#define IDM_OPTIONS 510
+#define IDM_BENCHMARK 511
+#define IDM_HELP_CONTENTS 610
+#define IDM_ABOUT 620
+#define IDS_BOOKMARK 720
+#define IDB_ADD 2002
+#define IDB_EXTRACT 2003
+#define IDB_TEST 2004
+#define IDB_COPY 2010
+#define IDB_MOVE 2011
+#define IDB_DELETE 2012
+#define IDB_INFO 2013
+#define IDB_ADD2 2082
+#define IDB_EXTRACT2 2083
+#define IDB_TEST2 2084
+#define IDB_COPY2 2090
+#define IDB_MOVE2 2091
+#define IDB_DELETE2 2092
+#define IDB_INFO2 2093
+#define IDS_APP_TITLE 2200
+#define IDS_COPY 2201
+#define IDS_MOVE 2202
+#define IDS_COPY_TO 2203
+#define IDS_MOVE_TO 2204
+#define IDS_COPYING 2205
+#define IDS_MOVING 2206
+#define IDS_CANNOT_COPY 2207
+#define IDS_OPERATION_IS_NOT_SUPPORTED 2208
+
+#define IDS_CONFIRM_FILE_DELETE 2210
+#define IDS_CONFIRM_FOLDER_DELETE 2211
+#define IDS_CONFIRM_ITEMS_DELETE 2212
+#define IDS_WANT_TO_DELETE_FILE 2213
+#define IDS_WANT_TO_DELETE_FOLDER 2214
+#define IDS_WANT_TO_DELETE_ITEMS 2215
+#define IDS_DELETING 2216
+#define IDS_ERROR_DELETING 2217
+
+#define IDS_RENAMING 2220
+#define IDS_ERROR_RENAMING 2221
+#define IDS_CONFIRM_FILE_COPY 2222
+#define IDS_WANT_TO_COPY_FILES 2223
+
+
+#define IDS_CREATE_FOLDER 2230
+#define IDS_CREATE_FOLDER_NAME 2231
+#define IDS_CREATE_FOLDER_DEFAULT_NAME 2232
+#define IDS_CREATE_FOLDER_ERROR 2233
+#define IDS_CREATE_FILE 2240
+#define IDS_CREATE_FILE_NAME 2241
+#define IDS_CREATE_FOLDER_DEFAULT_FILE_NAME 2242
+#define IDS_CREATE_FILE_DEFAULT_NAME 2242
+#define IDS_CREATE_FILE_ERROR 2243
+#define IDS_SELECT 2250
+#define IDS_DESELECT 2251
+#define IDS_SELECT_MASK 2252
+#define IDS_FOLDERS_HISTORY 2260
+#define IDS_N_SELECTED_ITEMS 2270
+#define IDS_FILES_COLON 2274
+#define IDS_FOLDERS_COLON 2275
+#define IDS_SIZE_COLON 2276
+
+#define IDS_TOO_MANY_ITEMS 2279
+#define IDS_WANT_UPDATE_MODIFIED_FILE 2280
+#define IDS_CANNOT_UPDATE_FILE 2281
+#define IDS_CANNOT_START_EDITOR 2282
+#define IDS_OPENNING 2283
+#define IDS_COMPUTER 2300
+#define IDS_NETWORK 2301
+#define IDS_ADD 2400
+#define IDS_EXTRACT 2401
+#define IDS_TEST 2402
+#define IDS_BUTTON_COPY 2420
+#define IDS_BUTTON_MOVE 2421
+#define IDS_BUTTON_DELETE 2422
+#define IDS_BUTTON_INFO 2423
+#define IDS_PROPERTY_TOTAL_SIZE 3100
+#define IDS_PROPERTY_FREE_SPACE 3101
+#define IDS_PROPERTY_CLUSTER_SIZE 3102
+#define IDS_PROPERTY_VOLUME_NAME 3103
+#define IDS_PROPERTY_LOCAL_NAME 3200
+#define IDS_PROPERTY_PROVIDER 3201
+#define IDS_OPTIONS 4000
+#define IDS_COMMENT 4001
+#define IDS_COMMENT2 4002
+#define IDS_SYSTEM 4010
+
+#define IDS_SPLITTING 4020
+#define IDS_SPLIT_CONFIRM_TITLE 4021
+#define IDS_SPLIT_CONFIRM_MESSAGE 4022
+#define IDS_SPLIT_VOL_MUST_BE_SMALLER 4023
+
+#define IDS_COMBINE 4030
+#define IDS_COMBINE_TO 4031
+#define IDS_COMBINING 4032
+#define IDS_COMBINE_SELECT_ONE_FILE 4033
+
+#define IDS_CHECKSUM_CALCULATING 4040
+#define IDS_CHECKSUM_INFORMATION 4041
+#define IDS_CHECKSUM_CRC_DATA 4042
+#define IDS_CHECKSUM_CRC_DATA_NAMES 4043
+
+#define IDS_SCANNING 4050
diff --git a/CPP/7zip/FileManager/resource.rc b/CPP/7zip/FileManager/resource.rc
new file mode 100755
index 00000000..ed56cd48
--- /dev/null
+++ b/CPP/7zip/FileManager/resource.rc
@@ -0,0 +1,232 @@
+#include "../MyVersionInfo.rc"
+#include "../GuiCommon.rc"
+#include "resource.h"
+
+MY_VERSION_INFO_APP("7-Zip File Manager", "7zFM")
+
+
+IDR_ACCELERATOR1 ACCELERATORS
+BEGIN
+ "N", IDM_CREATE_FILE, VIRTKEY, CONTROL, NOINVERT
+ VK_F1, IDM_HELP_CONTENTS, VIRTKEY, NOINVERT
+ VK_F12, IDM_FOLDERS_HISTORY, VIRTKEY, ALT, NOINVERT
+ VK_F7, IDM_CREATE_FOLDER, VIRTKEY, NOINVERT
+END
+
+
+IDM_MENU MENU
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "&Open\tEnter", IDM_FILE_OPEN
+ MENUITEM "Open &Inside\tCtrl+PgDn", IDM_FILE_OPEN_INSIDE
+ MENUITEM "Open O&utside\tShift+Enter", IDM_FILE_OPEN_OUTSIDE
+ MENUITEM "&Edit\tF4", IDM_FILE_EDIT
+ MENUITEM SEPARATOR
+ MENUITEM "Rena&me\tF2", IDM_RENAME
+ MENUITEM "&Copy To...\tF5", IDM_COPY_TO
+ MENUITEM "&Move To...\tF6", IDM_MOVE_TO
+ MENUITEM "&Delete\tDel", IDM_DELETE
+ MENUITEM SEPARATOR
+ MENUITEM "&Split file...", IDM_FILE_SPLIT
+ MENUITEM "Com&bine files...", IDM_FILE_COMBINE
+ MENUITEM SEPARATOR
+ MENUITEM "P&roperties\tAlt+Enter", IDM_FILE_PROPERTIES
+ MENUITEM "Comme&nt\tCtrl+Z", IDM_FILE_COMMENT
+ MENUITEM "Calculate checksum", IDM_FILE_CRC
+ MENUITEM SEPARATOR
+ MENUITEM "Create Folder\tF7", IDM_CREATE_FOLDER
+ MENUITEM "Create File\tCtrl+N", IDM_CREATE_FILE
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit\tAlt+F4", IDCLOSE
+ 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 "Select &All\tShift+[Grey +]", IDM_SELECT_ALL
+ MENUITEM "Deselect All\tShift+[Grey -]", IDM_DESELECT_ALL
+ MENUITEM "&Invert Selection\tGrey *", IDM_INVERT_SELECTION
+ MENUITEM "Select...\tGrey +", IDM_SELECT
+ MENUITEM "Deselect...\tGrey -", IDM_DESELECT
+ MENUITEM "Select by Type\tAlt+[Grey+]", IDM_SELECT_BY_TYPE
+ MENUITEM "Deselect by Type\tAlt+[Grey -]", IDM_DESELECT_BY_TYPE
+ END
+ POPUP "&View"
+ BEGIN
+ MENUITEM "Lar&ge Icons\tCtrl+1", IDM_VIEW_LARGE_ICONS
+ MENUITEM "S&mall Icons\tCtrl+2", IDM_VIEW_SMALL_ICONS
+ MENUITEM "&List\tCtrl+3", IDM_VIEW_LIST
+ MENUITEM "&Details\tCtrl+4", IDM_VIEW_DETAILS, CHECKED
+ MENUITEM SEPARATOR
+ MENUITEM "Name\tCtrl+F3", IDM_VIEW_ARANGE_BY_NAME
+ MENUITEM "Type\tCtrl+F4", IDM_VIEW_ARANGE_BY_TYPE
+ MENUITEM "Date\tCtrl+F5", IDM_VIEW_ARANGE_BY_DATE
+ MENUITEM "Size\tCtrl+F6", IDM_VIEW_ARANGE_BY_SIZE
+ MENUITEM "Unsorted\tCtrl+F7", IDM_VIEW_ARANGE_NO_SORT
+ MENUITEM SEPARATOR
+ MENUITEM "Flat View", IDM_VIEW_FLAT_VIEW
+ MENUITEM "&2 Panels\tF9", IDM_VIEW_TWO_PANELS
+ POPUP "Toolbars"
+ BEGIN
+ MENUITEM "Archive Toolbar", IDM_VIEW_ARCHIVE_TOOLBAR
+ MENUITEM "Standard Toolbar", IDM_VIEW_STANDARD_TOOLBAR
+ MENUITEM SEPARATOR
+ MENUITEM "Large Buttons", IDM_VIEW_TOOLBARS_LARGE_BUTTONS
+ MENUITEM "Show Buttons Text", IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT
+ END
+ MENUITEM SEPARATOR
+ MENUITEM "Open Root Folder\t\\", IDM_OPEN_ROOT_FOLDER
+ MENUITEM "Up One Level\tBackspace", IDM_OPEN_PARENT_FOLDER
+ MENUITEM "Folders History...\tAlt+F12", IDM_FOLDERS_HISTORY
+ MENUITEM SEPARATOR
+ MENUITEM "&Refresh\tCtrl+R", IDM_VIEW_REFRESH
+ END
+ POPUP "F&avorites"
+ BEGIN
+ POPUP "&Add folder to Favorites as"
+ BEGIN
+ MENUITEM SEPARATOR
+ END
+ MENUITEM SEPARATOR
+ END
+ POPUP "&Tools"
+ BEGIN
+ MENUITEM "&Options...", IDM_OPTIONS
+ MENUITEM "&Benchmark", IDM_BENCHMARK
+ END
+ POPUP "&Help"
+ BEGIN
+ MENUITEM "&Contents...\tF1", IDM_HELP_CONTENTS
+ MENUITEM SEPARATOR
+ MENUITEM "&About 7-Zip...", IDM_ABOUT
+ END
+END
+
+
+IDI_FM ICON "FM.ico"
+
+1 24 MOVEABLE PURE "7zFM.exe.manifest"
+
+IDB_ADD BITMAP "Add.bmp"
+IDB_EXTRACT BITMAP "Extract.bmp"
+IDB_TEST BITMAP "Test.bmp"
+IDB_COPY BITMAP "Copy.bmp"
+IDB_MOVE BITMAP "Move.bmp"
+IDB_DELETE BITMAP "Delete.bmp"
+IDB_INFO BITMAP "Info.bmp"
+IDB_ADD2 BITMAP "Add2.bmp"
+IDB_EXTRACT2 BITMAP "Extract2.bmp"
+IDB_TEST2 BITMAP "Test2.bmp"
+IDB_COPY2 BITMAP "Copy2.bmp"
+IDB_MOVE2 BITMAP "Move2.bmp"
+IDB_DELETE2 BITMAP "Delete2.bmp"
+IDB_INFO2 BITMAP "Info2.bmp"
+
+
+STRINGTABLE
+BEGIN
+ IDS_APP_TITLE "7-Zip File Manager"
+ IDS_COPY "Copy"
+ IDS_MOVE "Move"
+ IDS_COPY_TO "Copy to:"
+ IDS_MOVE_TO "Move to:"
+ IDS_COPYING "Copying..."
+ IDS_MOVING "Moving..."
+ IDS_CANNOT_COPY "You cannot move or copy items for such folders."
+ IDS_SPLITTING "Splitting..."
+ IDS_SPLIT_CONFIRM_TITLE "Confirm Splitting"
+ IDS_SPLIT_CONFIRM_MESSAGE "Are you sure you want to split file into {0} volumes?"
+ IDS_SPLIT_VOL_MUST_BE_SMALLER "Volume size must be smaller than size of original file"
+
+ IDS_COMBINE "Combine Files"
+ IDS_COMBINE_TO "&Combine to:"
+ IDS_COMBINING "Combining..."
+ IDS_COMBINE_SELECT_ONE_FILE "Select only first file"
+
+ IDS_CHECKSUM_CALCULATING "Checksum calculating..."
+ IDS_CHECKSUM_INFORMATION "Checksum information"
+ IDS_CHECKSUM_CRC_DATA "CRC checksum for data:"
+ IDS_CHECKSUM_CRC_DATA_NAMES "CRC checksum for data and names:"
+
+ IDS_SCANNING "Scanning..."
+
+ IDS_OPERATION_IS_NOT_SUPPORTED "Operation is not supported."
+
+ IDS_CONFIRM_FILE_DELETE "Confirm File Delete"
+ IDS_CONFIRM_FOLDER_DELETE "Confirm Folder Delete"
+ IDS_CONFIRM_ITEMS_DELETE "Confirm Multiple File Delete"
+ IDS_WANT_TO_DELETE_FILE "Are you sure you want to delete '{0}'?"
+ IDS_WANT_TO_DELETE_FOLDER "Are you sure you want to delete the folder '{0}' and all its contents?"
+ 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_RENAMING "Renaming..."
+ IDS_ERROR_RENAMING "Error Renaming File or Folder"
+ IDS_CONFIRM_FILE_COPY "Confirm File Copy"
+ IDS_WANT_TO_COPY_FILES "Are you sure you want to copy files to archive"
+
+ IDS_CREATE_FOLDER "Create Folder"
+ IDS_CREATE_FOLDER_NAME "Folder name:"
+ IDS_CREATE_FOLDER_DEFAULT_NAME "New Folder"
+ IDS_CREATE_FOLDER_ERROR "Error Creating Folder"
+ IDS_CREATE_FILE "Create File"
+ IDS_CREATE_FILE_NAME "File Name:"
+ IDS_CREATE_FILE_DEFAULT_NAME "New File"
+ IDS_CREATE_FILE_ERROR "Error Creating File"
+ IDS_SELECT "Select"
+ IDS_DESELECT "Deselect"
+ IDS_SELECT_MASK "Mask:"
+ IDS_FOLDERS_HISTORY "Folders History"
+ IDS_N_SELECTED_ITEMS "{0} object(s) selected"
+ IDS_FILES_COLON "Files:"
+ IDS_FOLDERS_COLON "Folders:"
+ IDS_SIZE_COLON "Size:"
+
+ IDS_PROPERTY_TOTAL_SIZE "Total Size"
+ IDS_PROPERTY_FREE_SPACE "Free Space"
+ IDS_PROPERTY_CLUSTER_SIZE "Cluster Size"
+ IDS_PROPERTY_VOLUME_NAME "Label"
+ IDS_PROPERTY_LOCAL_NAME "Local Name"
+ IDS_PROPERTY_PROVIDER "Provider"
+ IDS_OPTIONS "Options"
+ IDS_COMMENT "Comment"
+ IDS_COMMENT2 "&Comment:"
+ IDS_SYSTEM "System"
+ IDS_TOO_MANY_ITEMS "Too many items"
+ IDS_WANT_UPDATE_MODIFIED_FILE "File '{0}' was modified.\nDo you want to update it in the archive?"
+ IDS_CANNOT_UPDATE_FILE "Can not update file\n'{0}'"
+ IDS_CANNOT_START_EDITOR "Cannot start editor."
+ IDS_OPENNING "Opening..."
+ IDS_ADD "Add"
+ IDS_EXTRACT "Extract"
+ IDS_TEST "Test"
+ IDS_BUTTON_COPY "Copy"
+ IDS_BUTTON_MOVE "Move"
+ IDS_BUTTON_DELETE "Delete"
+ IDS_BUTTON_INFO "Info"
+ IDS_BOOKMARK "Bookmark"
+ IDS_COMPUTER "Computer"
+ IDS_NETWORK "Network"
+END
+
+
+#include "Resource/ComboDialog/resource.rc"
+#include "Resource/CopyDialog/resource.rc"
+#include "Resource/ListViewDialog/resource.rc"
+#include "Resource/PropertyName/resource.rc"
+#include "Resource/MessagesDialog/resource.rc"
+#include "Resource/OverwriteDialog/resource.rc"
+#include "Resource/PasswordDialog/resource.rc"
+#include "Resource/SplitDialog/resource.rc"
+#include "Resource/ProgressDialog2/resource.rc"
+#include "Resource/BenchmarkDialog/resource.rc"
+#include "Resource/AboutDialog/resource.rc"
+#include "Resource/LangPage/resource.rc"
+#include "Resource/PluginsPage/resource.rc"
+#include "Resource/SystemPage/resource.rc"
+#include "Resource/EditPage/resource.rc"
+#include "Resource/SettingsPage/resource.rc"
+#include "../UI/Resource/Extract/resource.rc"
diff --git a/7zip/GuiCommon.rc b/CPP/7zip/GuiCommon.rc
index 66dc5ca6..66dc5ca6 100755
--- a/7zip/GuiCommon.rc
+++ b/CPP/7zip/GuiCommon.rc
diff --git a/7zip/Guid.txt b/CPP/7zip/Guid.txt
index 8fa5a291..8fa5a291 100755
--- a/7zip/Guid.txt
+++ b/CPP/7zip/Guid.txt
diff --git a/7zip/ICoder.h b/CPP/7zip/ICoder.h
index d84575dc..d84575dc 100755
--- a/7zip/ICoder.h
+++ b/CPP/7zip/ICoder.h
diff --git a/7zip/IPassword.h b/CPP/7zip/IPassword.h
index 8f2adcca..8f2adcca 100755
--- a/7zip/IPassword.h
+++ b/CPP/7zip/IPassword.h
diff --git a/7zip/IProgress.h b/CPP/7zip/IProgress.h
index aa3b64cc..aa3b64cc 100755
--- a/7zip/IProgress.h
+++ b/CPP/7zip/IProgress.h
diff --git a/7zip/IStream.h b/CPP/7zip/IStream.h
index bba21a31..bba21a31 100755
--- a/7zip/IStream.h
+++ b/CPP/7zip/IStream.h
diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h
new file mode 100755
index 00000000..7243563c
--- /dev/null
+++ b/CPP/7zip/MyVersion.h
@@ -0,0 +1,8 @@
+#define MY_VER_MAJOR 4
+#define MY_VER_MINOR 44
+#define MY_VER_BUILD 3
+#define MY_VERSION "4.44 beta"
+#define MY_7ZIP_VERSION "7-Zip 4.44 beta"
+#define MY_DATE "2007-01-20"
+#define MY_COPYRIGHT "Copyright (c) 1999-2007 Igor Pavlov"
+#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE
diff --git a/7zip/MyVersionInfo.rc b/CPP/7zip/MyVersionInfo.rc
index fd52d6aa..fd52d6aa 100755
--- a/7zip/MyVersionInfo.rc
+++ b/CPP/7zip/MyVersionInfo.rc
diff --git a/7zip/PropID.h b/CPP/7zip/PropID.h
index 79f82452..79f82452 100755
--- a/7zip/PropID.h
+++ b/CPP/7zip/PropID.h
diff --git a/7zip/SubBuild.mak b/CPP/7zip/SubBuild.mak
index f86ce436..f86ce436 100755
--- a/7zip/SubBuild.mak
+++ b/CPP/7zip/SubBuild.mak
diff --git a/CPP/7zip/UI/Agent/Agent.cpp b/CPP/7zip/UI/Agent/Agent.cpp
new file mode 100755
index 00000000..f983e2f9
--- /dev/null
+++ b/CPP/7zip/UI/Agent/Agent.cpp
@@ -0,0 +1,578 @@
+// Agent.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+#include "Common/ComTry.h"
+#include "Windows/Defs.h"
+#include "Windows/PropVariant.h"
+#include "Windows/FileFind.h"
+
+#include "../Common/DefaultName.h"
+#include "../Common/ArchiveExtractCallback.h"
+
+#include "Agent.h"
+
+#ifdef FORMAT_7Z
+#include "../../Archive/7z/7zHandler.h"
+#endif
+
+extern "C"
+{
+ #include "../../../../C/Sort.h"
+}
+
+
+using namespace NWindows;
+
+STDMETHODIMP CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder)
+{
+ *agentFolder = this;
+ return S_OK;
+}
+
+void CAgentFolder::LoadFolder(CProxyFolder *folder)
+{
+ int i;
+ CProxyItem item;
+ item.Folder = folder;
+ for (i = 0; i < folder->Folders.Size(); i++)
+ {
+ item.Index = i;
+ _items.Add(item);
+ LoadFolder(&folder->Folders[i]);
+ }
+ int start = folder->Folders.Size();
+ for (i = 0; i < folder->Files.Size(); i++)
+ {
+ item.Index = start + i;
+ _items.Add(item);
+ }
+}
+
+
+STDMETHODIMP CAgentFolder::LoadItems()
+{
+ _items.Clear();
+ if (_flatMode)
+ LoadFolder(_proxyFolderItem);
+ return S_OK;
+}
+
+STDMETHODIMP CAgentFolder::GetNumberOfItems(UINT32 *numItems)
+{
+ if (_flatMode)
+ *numItems = _items.Size();
+ else
+ *numItems = _proxyFolderItem->Folders.Size() +_proxyFolderItem->Files.Size();
+ return S_OK;
+}
+
+/*
+STDMETHODIMP CAgentFolder::GetNumberOfSubFolders(UINT32 *aNumSubFolders)
+{
+ *aNumSubFolders = _proxyFolderItem->Folders.Size();
+ return S_OK;
+}
+*/
+
+UString CAgentFolder::GetName(UInt32 index) const
+{
+ UInt32 realIndex;
+ const CProxyFolder *folder;
+ if (_flatMode)
+ {
+ const CProxyItem &item = _items[index];
+ folder = item.Folder;
+ realIndex = item.Index;
+ }
+ else
+ {
+ folder = _proxyFolderItem;
+ realIndex = index;
+ }
+
+ if (realIndex < (UINT32)folder->Folders.Size())
+ return folder->Folders[realIndex].Name;
+ return folder->Files[realIndex - folder->Folders.Size()].Name;
+}
+
+UString CAgentFolder::GetPrefix(UInt32 index) const
+{
+ if (!_flatMode)
+ return UString();
+ const CProxyItem &item = _items[index];
+ const CProxyFolder *folder = item.Folder;
+ UString path;
+ while(folder != _proxyFolderItem)
+ {
+ path = folder->Name + UString(L"\\") + path;
+ folder = folder->Parent;
+ }
+ return path;
+}
+
+UString CAgentFolder::GetFullPathPrefixPlusPrefix(UInt32 index) const
+{
+ return _proxyFolderItem->GetFullPathPrefix() + GetPrefix(index);
+}
+
+void CAgentFolder::GetPrefixIfAny(UInt32 index, NCOM::CPropVariant &propVariant) const
+{
+ if (!_flatMode)
+ return;
+ propVariant = GetPrefix(index);
+}
+
+
+STDMETHODIMP CAgentFolder::GetProperty(UINT32 itemIndex, PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant propVariant;
+ const CProxyFolder *folder;
+ UInt32 realIndex;
+ if (_flatMode)
+ {
+ const CProxyItem &item = _items[itemIndex];
+ folder = item.Folder;
+ realIndex = item.Index;
+ }
+ else
+ {
+ folder = _proxyFolderItem;
+ realIndex = itemIndex;
+ }
+
+ if (realIndex < (UINT32)folder->Folders.Size())
+ {
+ const CProxyFolder &item = folder->Folders[realIndex];
+ switch(propID)
+ {
+ case kpidIsFolder:
+ propVariant = true;
+ break;
+ case kpidName:
+ propVariant = item.Name;
+ break;
+ case kpidPrefix:
+ GetPrefixIfAny(itemIndex, propVariant);
+ break;
+ default:
+ if (item.IsLeaf)
+ return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
+ }
+ }
+ else
+ {
+ realIndex -= folder->Folders.Size();
+ const CProxyFile &item = folder->Files[realIndex];
+ switch(propID)
+ {
+ case kpidIsFolder:
+ propVariant = false;
+ break;
+ case kpidName:
+ propVariant = item.Name;
+ break;
+ case kpidPrefix:
+ GetPrefixIfAny(itemIndex, propVariant);
+ break;
+ default:
+ return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
+ }
+ }
+ propVariant.Detach(value);
+ return S_OK;
+}
+
+HRESULT CAgentFolder::BindToFolder(CProxyFolder *folder, IFolderFolder **resultFolder)
+{
+ CMyComPtr<IFolderFolder> parentFolder;
+ if (folder->Parent != _proxyFolderItem)
+ {
+ RINOK(BindToFolder(folder->Parent, &parentFolder));
+ }
+ else
+ parentFolder = this;
+ CAgentFolder *folderSpec = new CAgentFolder;
+ CMyComPtr<IFolderFolder> agentFolder = folderSpec;
+ folderSpec->Init(_proxyArchive, folder, parentFolder, _agentSpec);
+ *resultFolder = agentFolder.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CAgentFolder::BindToFolder(UINT32 index, IFolderFolder **resultFolder)
+{
+ COM_TRY_BEGIN
+
+ CProxyFolder *folder;
+ UInt32 realIndex;
+ if (_flatMode)
+ {
+ const CProxyItem &item = _items[index];
+ folder = item.Folder;
+ realIndex = item.Index;
+ }
+ else
+ {
+ folder = _proxyFolderItem;
+ realIndex = index;
+ }
+ if (realIndex >= (UINT32)folder->Folders.Size())
+ return E_INVALIDARG;
+ return BindToFolder(&folder->Folders[realIndex], resultFolder);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ COM_TRY_BEGIN
+ int index = _proxyFolderItem->FindDirSubItemIndex(name);
+ if (index < 0)
+ return E_INVALIDARG;
+ return BindToFolder(index, resultFolder);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
+{
+ COM_TRY_BEGIN
+ CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
+ *resultFolder = parentFolder.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::GetName(BSTR *name)
+{
+ CMyComBSTR temp = _proxyFolderItem->Name;
+ *name = temp.Detach();
+ return S_OK;
+}
+
+
+#ifdef NEW_FOLDER_INTERFACE
+
+struct CArchiveItemPropertyTemp
+{
+ UString Name;
+ PROPID ID;
+ VARTYPE Type;
+};
+
+STDMETHODIMP CAgentFolder::GetNumberOfProperties(UINT32 *numProperties)
+{
+ COM_TRY_BEGIN
+ RINOK(_agentSpec->GetArchive()->GetNumberOfProperties(numProperties));
+ if (_flatMode)
+ (*numProperties)++;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::GetPropertyInfo(UINT32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ COM_TRY_BEGIN
+ UINT32 numProperties;
+ _agentSpec->GetArchive()->GetNumberOfProperties(&numProperties);
+ if (index < numProperties)
+ {
+ RINOK(_agentSpec->GetArchive()->GetPropertyInfo(index, name, propID, varType));
+ if (*propID == kpidPath)
+ *propID = kpidName;
+ }
+ else
+ {
+ *name = NULL;
+ *propID = kpidPrefix;
+ *varType = VT_BSTR;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::GetTypeID(BSTR *name)
+{
+ COM_TRY_BEGIN
+ UString temp = UString(L"7-Zip.") + _agentSpec->ArchiveType;
+ CMyComBSTR bstrTemp = temp;
+ *name = bstrTemp.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::GetPath(BSTR *path)
+{
+ COM_TRY_BEGIN
+ UStringVector pathParts;
+ pathParts.Clear();
+ CMyComPtr<IFolderFolder> currentFolder = this;
+ for (;;)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ currentFolder->BindToParentFolder(&newFolder);
+ if (newFolder == NULL)
+ break;
+ CMyComBSTR aName;
+ currentFolder->GetName(&aName);
+ pathParts.Insert(0, (const wchar_t *)aName);
+ currentFolder = newFolder;
+ }
+
+ UString prefix;
+ for(int i = 0; i < pathParts.Size(); i++)
+ {
+ prefix += pathParts[i];
+ prefix += L'\\';
+ }
+
+ CMyComBSTR tempPath = prefix;
+ *path = tempPath.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgentFolder::SetFlatMode(Int32 flatMode)
+{
+ _flatMode = IntToBool(flatMode);
+ return S_OK;
+}
+
+#endif
+
+void CAgentFolder::GetRealIndices(const UINT32 *indices, UINT32 numItems, CUIntVector &realIndices) const
+{
+ if (!_flatMode)
+ {
+ _proxyFolderItem->GetRealIndices(indices, numItems, realIndices);
+ return;
+ }
+ realIndices.Clear();
+ for(UINT32 i = 0; i < numItems; i++)
+ {
+ const CProxyItem &item = _items[indices[i]];
+ const CProxyFolder *folder = item.Folder;
+ UInt32 realIndex = item.Index;
+ if (realIndex < (UINT32)folder->Folders.Size())
+ continue;
+ realIndices.Add(folder->Files[realIndex - folder->Folders.Size()].Index);
+ }
+ HeapSort(&realIndices.Front(), realIndices.Size());
+}
+
+STDMETHODIMP CAgentFolder::Extract(const UINT32 *indices,
+ UINT32 numItems,
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode,
+ const wchar_t *path,
+ INT32 testMode,
+ IFolderArchiveExtractCallback *extractCallback2)
+{
+ COM_TRY_BEGIN
+ CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
+ CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
+ UStringVector pathParts;
+ CProxyFolder *currentProxyFolder = _proxyFolderItem;
+ while (currentProxyFolder->Parent)
+ {
+ pathParts.Insert(0, currentProxyFolder->Name);
+ currentProxyFolder = currentProxyFolder->Parent;
+ }
+
+ /*
+ if (_flatMode)
+ pathMode = NExtract::NPathMode::kNoPathnames;
+ */
+
+ extractCallbackSpec->Init(_agentSpec->GetArchive(),
+ extractCallback2,
+ false,
+ path,
+ pathMode,
+ overwriteMode,
+ pathParts,
+ _agentSpec->DefaultName,
+ _agentSpec->DefaultTime,
+ _agentSpec->DefaultAttributes
+ // ,_agentSpec->_srcDirectoryPrefix
+ );
+ CUIntVector realIndices;
+ GetRealIndices(indices, numItems, realIndices);
+ return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
+ realIndices.Size(), testMode, extractCallback);
+ COM_TRY_END
+}
+
+/////////////////////////////////////////
+// CAgent
+
+CAgent::CAgent():
+ _proxyArchive(NULL)
+{
+}
+
+CAgent::~CAgent()
+{
+ if (_proxyArchive != NULL)
+ delete _proxyArchive;
+}
+
+STDMETHODIMP CAgent::Open(
+ const wchar_t *filePath,
+ BSTR *archiveType,
+ // CLSID *clsIDResult,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ _archiveFilePath = filePath;
+ NFile::NFind::CFileInfoW fileInfo;
+ if (!NFile::NFind::FindFile(_archiveFilePath, fileInfo))
+ return ::GetLastError();
+ if (fileInfo.IsDirectory())
+ return E_FAIL;
+ CArchiverInfo archiverInfo0, archiverInfo1;
+ HRESULT res = OpenArchive(_archiveFilePath, _archiveLink, openArchiveCallback);
+ // _archive = _archiveLink.GetArchive();
+ DefaultName = _archiveLink.GetDefaultItemName();
+ const CArchiverInfo &ai = _archiveLink.GetArchiverInfo();
+
+ RINOK(res);
+ DefaultTime = fileInfo.LastWriteTime;
+ DefaultAttributes = fileInfo.Attributes;
+ ArchiveType = ai.Name;
+ if (archiveType != 0)
+ {
+ CMyComBSTR name = ArchiveType;
+ *archiveType = name.Detach();
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::ReOpen(
+ // const wchar_t *filePath,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ if (_proxyArchive != NULL)
+ {
+ delete _proxyArchive;
+ _proxyArchive = NULL;
+ }
+ RINOK(ReOpenArchive(_archiveLink, _archiveFilePath));
+ return ReadItems();
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::Close()
+{
+ COM_TRY_BEGIN
+ RINOK(_archiveLink.Close());
+ if (_archiveLink.GetNumLevels() > 1)
+ {
+ // return S_OK;
+ }
+ // _archive->Close();
+ return S_OK;
+ COM_TRY_END
+}
+
+/*
+STDMETHODIMP CAgent::EnumProperties(IEnumSTATPROPSTG **EnumProperties)
+{
+ return _archive->EnumProperties(EnumProperties);
+}
+*/
+
+HRESULT CAgent::ReadItems()
+{
+ if (_proxyArchive != NULL)
+ return S_OK;
+ _proxyArchive = new CProxyArchive();
+ return _proxyArchive->Load(GetArchive(),
+ DefaultName,
+ // _defaultTime,
+ // _defaultAttributes,
+ NULL);
+}
+
+STDMETHODIMP CAgent::BindToRootFolder(IFolderFolder **resultFolder)
+{
+ COM_TRY_BEGIN
+ RINOK(ReadItems());
+ CAgentFolder *folderSpec = new CAgentFolder;
+ CMyComPtr<IFolderFolder> rootFolder = folderSpec;
+ folderSpec->Init(_proxyArchive, &_proxyArchive->RootFolder, NULL, this);
+ *resultFolder = rootFolder.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+
+STDMETHODIMP CAgent::Extract(
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode,
+ const wchar_t *path,
+ INT32 testMode,
+ IFolderArchiveExtractCallback *extractCallback2)
+{
+ COM_TRY_BEGIN
+ CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
+ CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
+ extractCallbackSpec->Init(GetArchive(),
+ extractCallback2,
+ false,
+ path,
+ pathMode,
+ overwriteMode,
+ UStringVector(),
+ DefaultName,
+ DefaultTime,
+ DefaultAttributes
+ // ,_srcDirectoryPrefix
+ );
+ return GetArchive()->Extract(0, (UInt32)(Int32)-1, testMode, extractCallback);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetNumberOfProperties(UINT32 *numProperties)
+{
+ COM_TRY_BEGIN
+ return GetArchive()->GetNumberOfProperties(numProperties);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetPropertyInfo(UINT32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ COM_TRY_BEGIN
+ RINOK(GetArchive()->GetPropertyInfo(index, name, propID, varType));
+ if (*propID == kpidPath)
+ *propID = kpidName;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ return GetArchive()->GetArchiveProperty(propID, value);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetNumberOfArchiveProperties(UINT32 *numProperties)
+{
+ COM_TRY_BEGIN
+ return GetArchive()->GetNumberOfArchiveProperties(numProperties);
+ COM_TRY_END
+}
+
+STDMETHODIMP CAgent::GetArchivePropertyInfo(UINT32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ COM_TRY_BEGIN
+ return GetArchive()->GetArchivePropertyInfo(index,
+ name, propID, varType);
+ COM_TRY_END
+}
+
diff --git a/7zip/UI/Agent/Agent.h b/CPP/7zip/UI/Agent/Agent.h
index 41f80266..41f80266 100755
--- a/7zip/UI/Agent/Agent.h
+++ b/CPP/7zip/UI/Agent/Agent.h
diff --git a/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp
index 25d65bb2..25d65bb2 100755
--- a/7zip/UI/Agent/AgentOut.cpp
+++ b/CPP/7zip/UI/Agent/AgentOut.cpp
diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp
new file mode 100755
index 00000000..42063e67
--- /dev/null
+++ b/CPP/7zip/UI/Agent/AgentProxy.cpp
@@ -0,0 +1,203 @@
+// AgentProxy.cpp
+
+#include "StdAfx.h"
+
+#include "AgentProxy.h"
+
+#include "Common/MyCom.h"
+#include "Windows/PropVariant.h"
+#include "Windows/Defs.h"
+#include "../Common/OpenArchive.h"
+
+extern "C"
+{
+ #include "../../../../C/Sort.h"
+}
+
+using namespace NWindows;
+
+int CProxyFolder::FindDirSubItemIndex(const UString &name, int &insertPos) const
+{
+ int left = 0, right = Folders.Size();
+ for (;;)
+ {
+ if (left == right)
+ {
+ insertPos = left;
+ return -1;
+ }
+ int mid = (left + right) / 2;
+ int compare = name.CompareNoCase(Folders[mid].Name);
+ if (compare == 0)
+ return mid;
+ if (compare < 0)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+}
+
+int CProxyFolder::FindDirSubItemIndex(const UString &name) const
+{
+ int insertPos;
+ return FindDirSubItemIndex(name, insertPos);
+}
+
+void CProxyFolder::AddFileSubItem(UINT32 index, const UString &name)
+{
+ Files.Add(CProxyFile());
+ Files.Back().Name = name;
+ Files.Back().Index = index;
+}
+
+CProxyFolder* CProxyFolder::AddDirSubItem(UINT32 index, bool leaf,
+ const UString &name)
+{
+ int insertPos;
+ int folderIndex = FindDirSubItemIndex(name, insertPos);
+ if (folderIndex >= 0)
+ {
+ CProxyFolder *item = &Folders[folderIndex];
+ if(leaf)
+ {
+ item->Index = index;
+ item->IsLeaf = true;
+ }
+ return item;
+ }
+ Folders.Insert(insertPos, CProxyFolder());
+ CProxyFolder *item = &Folders[insertPos];
+ item->Name = name;
+ item->Index = index;
+ item->Parent = this;
+ item->IsLeaf = leaf;
+ return item;
+}
+
+void CProxyFolder::Clear()
+{
+ Folders.Clear();
+ Files.Clear();
+}
+
+UString CProxyFolder::GetFullPathPrefix() const
+{
+ UString result;
+ const CProxyFolder *current = this;
+ while (current->Parent != NULL)
+ {
+ result = current->Name + UString(L'\\') + result;
+ current = current->Parent;
+ }
+ return result;
+}
+
+UString CProxyFolder::GetItemName(UINT32 index) const
+{
+ if (index < (UINT32)Folders.Size())
+ return Folders[index].Name;
+ return Files[index - Folders.Size()].Name;
+}
+
+void CProxyFolder::AddRealIndices(CUIntVector &realIndices) const
+{
+ if (IsLeaf)
+ realIndices.Add(Index);
+ int i;
+ for(i = 0; i < Folders.Size(); i++)
+ Folders[i].AddRealIndices(realIndices);
+ for(i = 0; i < Files.Size(); i++)
+ realIndices.Add(Files[i].Index);
+}
+
+void CProxyFolder::GetRealIndices(const UINT32 *indices,
+ UINT32 numItems, CUIntVector &realIndices) const
+{
+ realIndices.Clear();
+ for(UINT32 i = 0; i < numItems; i++)
+ {
+ int index = indices[i];
+ int numDirItems = Folders.Size();
+ if (index < numDirItems)
+ Folders[index].AddRealIndices(realIndices);
+ else
+ realIndices.Add(Files[index - numDirItems].Index);
+ }
+ HeapSort(&realIndices.Front(), realIndices.Size());
+}
+
+///////////////////////////////////////////////
+// CProxyArchive
+
+HRESULT CProxyArchive::Reload(IInArchive *archive, IProgress *progress)
+{
+ RootFolder.Clear();
+ return ReadObjects(archive, progress);
+}
+
+HRESULT CProxyArchive::Load(IInArchive *archive,
+ const UString &defaultName,
+ // const FILETIME &defaultTime,
+ // UINT32 defaultAttributes,
+ IProgress *progress)
+{
+ DefaultName = defaultName;
+ // DefaultTime = defaultTime;
+ // DefaultAttributes = defaultAttributes;
+ return Reload(archive, progress);
+}
+
+
+HRESULT CProxyArchive::ReadObjects(IInArchive *archiveHandler, IProgress *progress)
+{
+ UINT32 numItems;
+ RINOK(archiveHandler->GetNumberOfItems(&numItems));
+ if (progress != NULL)
+ {
+ UINT64 totalItems = numItems;
+ RINOK(progress->SetTotal(totalItems));
+ }
+ for(UINT32 i = 0; i < numItems; i++)
+ {
+ if (progress != NULL)
+ {
+ UINT64 currentItemIndex = i;
+ RINOK(progress->SetCompleted(&currentItemIndex));
+ }
+ NCOM::CPropVariant propVariantPath;
+ RINOK(archiveHandler->GetProperty(i, kpidPath, &propVariantPath));
+ CProxyFolder *currentItem = &RootFolder;
+ UString fileName;
+ if(propVariantPath.vt == VT_EMPTY)
+ fileName = DefaultName;
+ else
+ {
+ if(propVariantPath.vt != VT_BSTR)
+ return E_FAIL;
+ UString filePath = propVariantPath.bstrVal;
+
+ int len = filePath.Length();
+ for (int i = 0; i < len; i++)
+ {
+ wchar_t c = filePath[i];
+ if (c == '\\' || c == '/')
+ {
+ currentItem = currentItem->AddDirSubItem((UInt32)(Int32)-1, false, fileName);
+ fileName.Empty();
+ }
+ else
+ fileName += c;
+ }
+ }
+
+ NCOM::CPropVariant propVariantIsFolder;
+ bool isFolder;
+ RINOK(IsArchiveItemFolder(archiveHandler, i, isFolder));
+ if(isFolder)
+ currentItem->AddDirSubItem(i, true, fileName);
+ else
+ currentItem->AddFileSubItem(i, fileName);
+ }
+ return S_OK;
+}
+
diff --git a/7zip/UI/Agent/AgentProxy.h b/CPP/7zip/UI/Agent/AgentProxy.h
index 9402cfdd..9402cfdd 100755
--- a/7zip/UI/Agent/AgentProxy.h
+++ b/CPP/7zip/UI/Agent/AgentProxy.h
diff --git a/7zip/UI/Agent/ArchiveFolder.cpp b/CPP/7zip/UI/Agent/ArchiveFolder.cpp
index 0ce553dc..0ce553dc 100755
--- a/7zip/UI/Agent/ArchiveFolder.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolder.cpp
diff --git a/7zip/UI/Agent/ArchiveFolderOpen.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
index ce423941..ce423941 100755
--- a/7zip/UI/Agent/ArchiveFolderOpen.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
diff --git a/7zip/UI/Agent/ArchiveFolderOut.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
index 4d66d86d..4d66d86d 100755
--- a/7zip/UI/Agent/ArchiveFolderOut.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
diff --git a/7zip/UI/Agent/IFolderArchive.h b/CPP/7zip/UI/Agent/IFolderArchive.h
index 41d9eb22..41d9eb22 100755
--- a/7zip/UI/Agent/IFolderArchive.h
+++ b/CPP/7zip/UI/Agent/IFolderArchive.h
diff --git a/7zip/UI/Agent/UpdateCallbackAgent.cpp b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
index 0d57307c..0d57307c 100755
--- a/7zip/UI/Agent/UpdateCallbackAgent.cpp
+++ b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
diff --git a/7zip/UI/Agent/UpdateCallbackAgent.h b/CPP/7zip/UI/Agent/UpdateCallbackAgent.h
index 1cff501a..1cff501a 100755
--- a/7zip/UI/Agent/UpdateCallbackAgent.h
+++ b/CPP/7zip/UI/Agent/UpdateCallbackAgent.h
diff --git a/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp
index 46bdb727..46bdb727 100755
--- a/7zip/UI/Client7z/Client7z.cpp
+++ b/CPP/7zip/UI/Client7z/Client7z.cpp
diff --git a/7zip/UI/Client7z/Client7z.dsp b/CPP/7zip/UI/Client7z/Client7z.dsp
index b574bdb7..b574bdb7 100755
--- a/7zip/UI/Client7z/Client7z.dsp
+++ b/CPP/7zip/UI/Client7z/Client7z.dsp
diff --git a/7zip/UI/Client7z/Client7z.dsw b/CPP/7zip/UI/Client7z/Client7z.dsw
index 598a6d3f..598a6d3f 100755
--- a/7zip/UI/Client7z/Client7z.dsw
+++ b/CPP/7zip/UI/Client7z/Client7z.dsw
diff --git a/7zip/UI/Far/StdAfx.cpp b/CPP/7zip/UI/Client7z/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/7zip/UI/Far/StdAfx.cpp
+++ b/CPP/7zip/UI/Client7z/StdAfx.cpp
diff --git a/7zip/UI/Client7z/StdAfx.h b/CPP/7zip/UI/Client7z/StdAfx.h
index b23436e9..b23436e9 100755
--- a/7zip/UI/Client7z/StdAfx.h
+++ b/CPP/7zip/UI/Client7z/StdAfx.h
diff --git a/7zip/UI/Client7z/makefile b/CPP/7zip/UI/Client7z/makefile
index c4ae0aaf..c4ae0aaf 100755
--- a/7zip/UI/Client7z/makefile
+++ b/CPP/7zip/UI/Client7z/makefile
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
new file mode 100755
index 00000000..6f951a27
--- /dev/null
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
@@ -0,0 +1,985 @@
+// ArchiveCommandLine.cpp
+
+#include "StdAfx.h"
+
+#include <io.h>
+#include <stdio.h>
+
+#include "Common/ListFileUtils.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/FileName.h"
+#include "Windows/FileDir.h"
+#ifdef _WIN32
+#include "Windows/FileMapping.h"
+#include "Windows/Synchronization.h"
+#endif
+
+#include "ArchiveCommandLine.h"
+#include "UpdateAction.h"
+#include "Update.h"
+#include "ArchiverInfo.h"
+#include "SortUtils.h"
+#include "EnumDirItems.h"
+
+using namespace NCommandLineParser;
+using namespace NWindows;
+using namespace NFile;
+
+static const int kNumSwitches = 28;
+
+namespace NKey {
+enum Enum
+{
+ kHelp1 = 0,
+ kHelp2,
+ kHelp3,
+ kDisableHeaders,
+ kDisablePercents,
+ kArchiveType,
+ kYes,
+ kPassword,
+ kProperty,
+ kOutputDir,
+ kWorkingDir,
+ kInclude,
+ kExclude,
+ kArInclude,
+ kArExclude,
+ kNoArName,
+ kUpdate,
+ kVolume,
+ kRecursed,
+ kSfx,
+ kStdIn,
+ kStdOut,
+ kOverwrite,
+ kEmail,
+ kShowDialog,
+ kLargePages,
+ kCharSet,
+ kTechMode
+};
+
+}
+
+
+static const wchar_t kRecursedIDChar = 'R';
+static const wchar_t *kRecursedPostCharSet = L"0-";
+
+static const wchar_t *kDefaultArchiveType = L"7z";
+static const wchar_t *kSFXExtension =
+ #ifdef _WIN32
+ L"exe";
+ #else
+ L"";
+ #endif
+
+namespace NRecursedPostCharIndex {
+ enum EEnum
+ {
+ kWildCardRecursionOnly = 0,
+ kNoRecursion = 1
+ };
+}
+
+static const char kImmediateNameID = '!';
+static const char kMapNameID = '#';
+static const char kFileListID = '@';
+
+static const char kSomeCludePostStringMinSize = 2; // at least <@|!><N>ame must be
+static const char kSomeCludeAfterRecursedPostStringMinSize = 2; // at least <@|!><N>ame must be
+
+static const wchar_t *kOverwritePostCharSet = L"asut";
+
+NExtract::NOverwriteMode::EEnum k_OverwriteModes[] =
+{
+ NExtract::NOverwriteMode::kWithoutPrompt,
+ NExtract::NOverwriteMode::kSkipExisting,
+ NExtract::NOverwriteMode::kAutoRename,
+ NExtract::NOverwriteMode::kAutoRenameExisting
+};
+
+static const CSwitchForm kSwitchForms[kNumSwitches] =
+ {
+ { L"?", NSwitchType::kSimple, false },
+ { L"H", NSwitchType::kSimple, false },
+ { L"-HELP", NSwitchType::kSimple, false },
+ { L"BA", NSwitchType::kSimple, false },
+ { L"BD", NSwitchType::kSimple, false },
+ { L"T", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"Y", NSwitchType::kSimple, false },
+ { L"P", NSwitchType::kUnLimitedPostString, false, 0 },
+ { L"M", NSwitchType::kUnLimitedPostString, true, 1 },
+ { L"O", NSwitchType::kUnLimitedPostString, false, 1 },
+ { L"W", NSwitchType::kUnLimitedPostString, false, 0 },
+ { L"I", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
+ { L"X", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
+ { L"AI", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
+ { L"AX", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
+ { L"AN", NSwitchType::kSimple, false },
+ { L"U", NSwitchType::kUnLimitedPostString, true, 1},
+ { L"V", NSwitchType::kUnLimitedPostString, true, 1},
+ { L"R", NSwitchType::kPostChar, false, 0, 0, kRecursedPostCharSet },
+ { L"SFX", NSwitchType::kUnLimitedPostString, false, 0 },
+ { L"SI", NSwitchType::kUnLimitedPostString, false, 0 },
+ { L"SO", NSwitchType::kSimple, false, 0 },
+ { L"AO", NSwitchType::kPostChar, false, 1, 1, kOverwritePostCharSet},
+ { L"SEML", NSwitchType::kUnLimitedPostString, false, 0},
+ { L"AD", NSwitchType::kSimple, false },
+ { L"SLP", NSwitchType::kUnLimitedPostString, false, 0},
+ { L"SCS", NSwitchType::kUnLimitedPostString, false, 0},
+ { L"SLT", NSwitchType::kSimple, false }
+ };
+
+static const int kNumCommandForms = 7;
+
+static const CCommandForm g_CommandForms[kNumCommandForms] =
+{
+ { L"A", false },
+ { L"U", false },
+ { L"D", false },
+ { L"T", false },
+ { L"E", false },
+ { L"X", false },
+ { L"L", false }
+};
+
+static const int kMaxCmdLineSize = 1000;
+static const wchar_t *kUniversalWildcard = L"*";
+static const int kMinNonSwitchWords = 1;
+static const int kCommandIndex = 0;
+
+// ---------------------------
+// exception messages
+
+static const char *kUserErrorMessage = "Incorrect command line";
+static const char *kIncorrectListFile = "Incorrect wildcard in listfile";
+static const char *kIncorrectWildCardInListFile = "Incorrect wildcard in listfile";
+static const char *kIncorrectWildCardInCommandLine = "Incorrect wildcard in command line";
+static const char *kTerminalOutError = "I won't write compressed data to a terminal";
+static const char *kSameTerminalError = "I won't write data and program's messages to same terminal";
+
+static void ThrowException(const char *errorMessage)
+{
+ throw CArchiveCommandLineException(errorMessage);
+};
+
+static void ThrowUserErrorException()
+{
+ ThrowException(kUserErrorMessage);
+};
+
+// ---------------------------
+
+bool CArchiveCommand::IsFromExtractGroup() const
+{
+ switch(CommandType)
+ {
+ case NCommandType::kTest:
+ case NCommandType::kExtract:
+ case NCommandType::kFullExtract:
+ return true;
+ default:
+ return false;
+ }
+}
+
+NExtract::NPathMode::EEnum CArchiveCommand::GetPathMode() const
+{
+ switch(CommandType)
+ {
+ case NCommandType::kTest:
+ case NCommandType::kFullExtract:
+ return NExtract::NPathMode::kFullPathnames;
+ default:
+ return NExtract::NPathMode::kNoPathnames;
+ }
+}
+
+bool CArchiveCommand::IsFromUpdateGroup() const
+{
+ return (CommandType == NCommandType::kAdd ||
+ CommandType == NCommandType::kUpdate ||
+ CommandType == NCommandType::kDelete);
+}
+
+static NRecursedType::EEnum GetRecursedTypeFromIndex(int index)
+{
+ switch (index)
+ {
+ case NRecursedPostCharIndex::kWildCardRecursionOnly:
+ return NRecursedType::kWildCardOnlyRecursed;
+ case NRecursedPostCharIndex::kNoRecursion:
+ return NRecursedType::kNonRecursed;
+ default:
+ return NRecursedType::kRecursed;
+ }
+}
+
+static bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &command)
+{
+ UString commandStringUpper = commandString;
+ commandStringUpper.MakeUpper();
+ UString postString;
+ int commandIndex = ParseCommand(kNumCommandForms, g_CommandForms, commandStringUpper,
+ postString) ;
+ if (commandIndex < 0)
+ return false;
+ command.CommandType = (NCommandType::EEnum)commandIndex;
+ return true;
+}
+
+// ------------------------------------------------------------------
+// filenames functions
+
+static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
+ const UString &name, bool include, NRecursedType::EEnum type)
+{
+ bool isWildCard = DoesNameContainWildCard(name);
+ bool recursed = false;
+
+ switch (type)
+ {
+ case NRecursedType::kWildCardOnlyRecursed:
+ recursed = isWildCard;
+ break;
+ case NRecursedType::kRecursed:
+ recursed = true;
+ break;
+ case NRecursedType::kNonRecursed:
+ recursed = false;
+ break;
+ }
+ wildcardCensor.AddItem(include, name, recursed);
+ return true;
+}
+
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+
+static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
+ LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
+{
+ UStringVector names;
+ if (!ReadNamesFromListFile(GetSystemString(fileName, GetCurrentCodePage()), names, codePage))
+ throw kIncorrectListFile;
+ for (int i = 0; i < names.Size(); i++)
+ if (!AddNameToCensor(wildcardCensor, names[i], include, type))
+ throw kIncorrectWildCardInListFile;
+}
+
+static void AddCommandLineWildCardToCensr(NWildcard::CCensor &wildcardCensor,
+ const UString &name, bool include, NRecursedType::EEnum recursedType)
+{
+ if (!AddNameToCensor(wildcardCensor, name, include, recursedType))
+ throw kIncorrectWildCardInCommandLine;
+}
+
+static void AddToCensorFromNonSwitchesStrings(
+ int startIndex,
+ NWildcard::CCensor &wildcardCensor,
+ const UStringVector &nonSwitchStrings, NRecursedType::EEnum type,
+ bool thereAreSwitchIncludes, UINT codePage)
+{
+ if(nonSwitchStrings.Size() == startIndex && (!thereAreSwitchIncludes))
+ AddCommandLineWildCardToCensr(wildcardCensor, kUniversalWildcard, true, type);
+ for(int i = startIndex; i < nonSwitchStrings.Size(); i++)
+ {
+ const UString &s = nonSwitchStrings[i];
+ if (s[0] == kFileListID)
+ AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type, codePage);
+ else
+ AddCommandLineWildCardToCensr(wildcardCensor, s, true, type);
+ }
+}
+
+#ifdef _WIN32
+static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
+ const UString &switchParam, bool include,
+ NRecursedType::EEnum commonRecursedType)
+{
+ int splitPos = switchParam.Find(L':');
+ if (splitPos < 0)
+ ThrowUserErrorException();
+ UString mappingName = switchParam.Left(splitPos);
+
+ UString switchParam2 = switchParam.Mid(splitPos + 1);
+ splitPos = switchParam2.Find(L':');
+ if (splitPos < 0)
+ ThrowUserErrorException();
+
+ UString mappingSize = switchParam2.Left(splitPos);
+ UString eventName = switchParam2.Mid(splitPos + 1);
+
+ UInt64 dataSize64 = ConvertStringToUInt64(mappingSize, NULL);
+ UInt32 dataSize = (UInt32)dataSize64;
+ {
+ CFileMapping fileMapping;
+ if (!fileMapping.Open(FILE_MAP_READ, false, GetSystemString(mappingName)))
+ ThrowException("Can not open mapping");
+ LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_READ, 0, dataSize);
+ if (data == NULL)
+ ThrowException("MapViewOfFile error");
+ try
+ {
+ const wchar_t *curData = (const wchar_t *)data;
+ if (*curData != 0)
+ ThrowException("Incorrect mapping data");
+ UInt32 numChars = dataSize / sizeof(wchar_t);
+ UString name;
+ for (UInt32 i = 1; i < numChars; i++)
+ {
+ wchar_t c = curData[i];
+ if (c == L'\0')
+ {
+ AddCommandLineWildCardToCensr(wildcardCensor,
+ name, include, commonRecursedType);
+ name.Empty();
+ }
+ else
+ name += c;
+ }
+ if (!name.IsEmpty())
+ ThrowException("data error");
+ }
+ catch(...)
+ {
+ UnmapViewOfFile(data);
+ throw;
+ }
+ UnmapViewOfFile(data);
+ }
+
+ {
+ NSynchronization::CEvent event;
+ event.Open(EVENT_MODIFY_STATE, false, GetSystemString(eventName));
+ event.Set();
+ }
+}
+#endif
+
+static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
+ const UStringVector &strings, bool include,
+ NRecursedType::EEnum commonRecursedType, UINT codePage)
+{
+ for(int i = 0; i < strings.Size(); i++)
+ {
+ const UString &name = strings[i];
+ NRecursedType::EEnum recursedType;
+ int pos = 0;
+ if (name.Length() < kSomeCludePostStringMinSize)
+ ThrowUserErrorException();
+ if (::MyCharUpper(name[pos]) == kRecursedIDChar)
+ {
+ pos++;
+ int index = UString(kRecursedPostCharSet).Find(name[pos]);
+ recursedType = GetRecursedTypeFromIndex(index);
+ if (index >= 0)
+ pos++;
+ }
+ else
+ recursedType = commonRecursedType;
+ if (name.Length() < pos + kSomeCludeAfterRecursedPostStringMinSize)
+ ThrowUserErrorException();
+ UString tail = name.Mid(pos + 1);
+ if (name[pos] == kImmediateNameID)
+ AddCommandLineWildCardToCensr(wildcardCensor, tail, include, recursedType);
+ else if (name[pos] == kFileListID)
+ AddToCensorFromListFile(wildcardCensor, tail, include, recursedType, codePage);
+ #ifdef _WIN32
+ else if (name[pos] == kMapNameID)
+ ParseMapWithPaths(wildcardCensor, tail, include, recursedType);
+ #endif
+ else
+ ThrowUserErrorException();
+ }
+}
+
+#ifdef _WIN32
+
+// This code converts all short file names to long file names.
+
+static void ConvertToLongName(const UString &prefix, UString &name)
+{
+ if (name.IsEmpty() || DoesNameContainWildCard(name))
+ return;
+ NFind::CFileInfoW fileInfo;
+ if (NFind::FindFile(prefix + name, fileInfo))
+ name = fileInfo.Name;
+}
+
+static void ConvertToLongNames(const UString &prefix, CObjectVector<NWildcard::CItem> &items)
+{
+ for (int i = 0; i < items.Size(); i++)
+ {
+ NWildcard::CItem &item = items[i];
+ if (item.Recursive || item.PathParts.Size() != 1)
+ continue;
+ ConvertToLongName(prefix, item.PathParts.Front());
+ }
+}
+
+static void ConvertToLongNames(const UString &prefix, NWildcard::CCensorNode &node)
+{
+ ConvertToLongNames(prefix, node.IncludeItems);
+ ConvertToLongNames(prefix, node.ExcludeItems);
+ int i;
+ for (i = 0; i < node.SubNodes.Size(); i++)
+ ConvertToLongName(prefix, node.SubNodes[i].Name);
+ // mix folders with same name
+ for (i = 0; i < node.SubNodes.Size(); i++)
+ {
+ NWildcard::CCensorNode &nextNode1 = node.SubNodes[i];
+ for (int j = i + 1; j < node.SubNodes.Size();)
+ {
+ const NWildcard::CCensorNode &nextNode2 = node.SubNodes[j];
+ if (nextNode1.Name.CompareNoCase(nextNode2.Name) == 0)
+ {
+ nextNode1.IncludeItems += nextNode2.IncludeItems;
+ nextNode1.ExcludeItems += nextNode2.ExcludeItems;
+ node.SubNodes.Delete(j);
+ }
+ else
+ j++;
+ }
+ }
+ for (i = 0; i < node.SubNodes.Size(); i++)
+ {
+ NWildcard::CCensorNode &nextNode = node.SubNodes[i];
+ ConvertToLongNames(prefix + nextNode.Name + wchar_t(NFile::NName::kDirDelimiter), nextNode);
+ }
+}
+
+static void ConvertToLongNames(NWildcard::CCensor &censor)
+{
+ for (int i = 0; i < censor.Pairs.Size(); i++)
+ {
+ NWildcard::CPair &pair = censor.Pairs[i];
+ ConvertToLongNames(pair.Prefix, pair.Head);
+ }
+}
+
+#endif
+
+static NUpdateArchive::NPairAction::EEnum GetUpdatePairActionType(int i)
+{
+ switch(i)
+ {
+ case NUpdateArchive::NPairAction::kIgnore: return NUpdateArchive::NPairAction::kIgnore;
+ case NUpdateArchive::NPairAction::kCopy: return NUpdateArchive::NPairAction::kCopy;
+ case NUpdateArchive::NPairAction::kCompress: return NUpdateArchive::NPairAction::kCompress;
+ case NUpdateArchive::NPairAction::kCompressAsAnti: return NUpdateArchive::NPairAction::kCompressAsAnti;
+ }
+ throw 98111603;
+}
+
+const UString kUpdatePairStateIDSet = L"PQRXYZW";
+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 = '!';
+
+
+static bool ParseUpdateCommandString2(const UString &command,
+ NUpdateArchive::CActionSet &actionSet, UString &postString)
+{
+ for(int i = 0; i < command.Length();)
+ {
+ wchar_t c = MyCharUpper(command[i]);
+ int statePos = kUpdatePairStateIDSet.Find(c);
+ if (statePos < 0)
+ {
+ postString = command.Mid(i);
+ return true;
+ }
+ i++;
+ if (i >= command.Length())
+ return false;
+ int actionPos = kUpdatePairActionIDSet.Find(::MyCharUpper(command[i]));
+ if (actionPos < 0)
+ return false;
+ actionSet.StateActions[statePos] = GetUpdatePairActionType(actionPos);
+ if (kUpdatePairStateNotSupportedActions[statePos] == actionPos)
+ return false;
+ i++;
+ }
+ postString.Empty();
+ return true;
+}
+
+static void ParseUpdateCommandString(CUpdateOptions &options,
+ const UStringVector &updatePostStrings,
+ const NUpdateArchive::CActionSet &defaultActionSet)
+{
+ for(int i = 0; i < updatePostStrings.Size(); i++)
+ {
+ const UString &updateString = updatePostStrings[i];
+ if(updateString.CompareNoCase(kUpdateIgnoreItselfPostStringID) == 0)
+ {
+ if(options.UpdateArchiveItself)
+ {
+ options.UpdateArchiveItself = false;
+ options.Commands.Delete(0);
+ }
+ }
+ else
+ {
+ NUpdateArchive::CActionSet actionSet = defaultActionSet;
+
+ UString postString;
+ if (!ParseUpdateCommandString2(updateString, actionSet, postString))
+ ThrowUserErrorException();
+ if(postString.IsEmpty())
+ {
+ if(options.UpdateArchiveItself)
+ options.Commands[0].ActionSet = actionSet;
+ }
+ else
+ {
+ if(MyCharUpper(postString[0]) != kUpdateNewArchivePostCharID)
+ ThrowUserErrorException();
+ CUpdateArchiveCommand uc;
+ UString archivePath = postString.Mid(1);
+ if (archivePath.IsEmpty())
+ ThrowUserErrorException();
+ uc.ArchivePath.BaseExtension = options.ArchivePath.BaseExtension;
+ uc.ArchivePath.VolExtension = options.ArchivePath.VolExtension;
+ uc.ArchivePath.ParseFromPath(archivePath);
+ uc.ActionSet = actionSet;
+ options.Commands.Add(uc);
+ }
+ }
+ }
+}
+
+static const char kByteSymbol = 'B';
+static const char kKiloSymbol = 'K';
+static const char kMegaSymbol = 'M';
+static const char kGigaSymbol = 'G';
+
+static bool ParseComplexSize(const UString &src, UInt64 &result)
+{
+ UString s = src;
+ s.MakeUpper();
+
+ const wchar_t *start = s;
+ const wchar_t *end;
+ UInt64 number = ConvertStringToUInt64(start, &end);
+ int numDigits = (int)(end - start);
+ if (numDigits == 0 || s.Length() > numDigits + 1)
+ return false;
+ if (s.Length() == numDigits)
+ {
+ result = number;
+ return true;
+ }
+ int numBits;
+ switch (s[numDigits])
+ {
+ case kByteSymbol:
+ result = number;
+ return true;
+ case kKiloSymbol:
+ numBits = 10;
+ break;
+ case kMegaSymbol:
+ numBits = 20;
+ break;
+ case kGigaSymbol:
+ numBits = 30;
+ break;
+ default:
+ return false;
+ }
+ if (number >= ((UInt64)1 << (64 - numBits)))
+ return false;
+ result = number << numBits;
+ return true;
+}
+
+static void SetAddCommandOptions(
+ NCommandType::EEnum commandType,
+ const CParser &parser,
+ CUpdateOptions &options)
+{
+ NUpdateArchive::CActionSet defaultActionSet;
+ switch(commandType)
+ {
+ case NCommandType::kAdd:
+ defaultActionSet = NUpdateArchive::kAddActionSet;
+ break;
+ case NCommandType::kDelete:
+ defaultActionSet = NUpdateArchive::kDeleteActionSet;
+ break;
+ default:
+ defaultActionSet = NUpdateArchive::kUpdateActionSet;
+ }
+
+ options.UpdateArchiveItself = true;
+
+ options.Commands.Clear();
+ CUpdateArchiveCommand updateMainCommand;
+ updateMainCommand.ActionSet = defaultActionSet;
+ options.Commands.Add(updateMainCommand);
+ if(parser[NKey::kUpdate].ThereIs)
+ ParseUpdateCommandString(options, parser[NKey::kUpdate].PostStrings,
+ defaultActionSet);
+ if(parser[NKey::kWorkingDir].ThereIs)
+ {
+ const UString &postString = parser[NKey::kWorkingDir].PostStrings[0];
+ if (postString.IsEmpty())
+ NDirectory::MyGetTempPath(options.WorkingDir);
+ else
+ options.WorkingDir = postString;
+ }
+ options.SfxMode = parser[NKey::kSfx].ThereIs;
+ if (options.SfxMode)
+ options.SfxModule = parser[NKey::kSfx].PostStrings[0];
+
+ if (parser[NKey::kVolume].ThereIs)
+ {
+ const UStringVector &sv = parser[NKey::kVolume].PostStrings;
+ for (int i = 0; i < sv.Size(); i++)
+ {
+ UInt64 size;
+ if (!ParseComplexSize(sv[i], size))
+ ThrowException("Incorrect volume size");
+ options.VolumesSizes.Add(size);
+ }
+ }
+}
+
+static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &properties)
+{
+ if (parser[NKey::kProperty].ThereIs)
+ {
+ // options.MethodMode.Properties.Clear();
+ for(int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
+ {
+ CProperty property;
+ const UString &postString = parser[NKey::kProperty].PostStrings[i];
+ int index = postString.Find(L'=');
+ if (index < 0)
+ property.Name = postString;
+ else
+ {
+ property.Name = postString.Left(index);
+ property.Value = postString.Mid(index + 1);
+ }
+ properties.Add(property);
+ }
+ }
+}
+
+
+static void SetArchiveType(const UString &archiveType,
+#ifndef EXCLUDE_COM
+ UString &filePath, CLSID &classID,
+#else
+ UString &formatName,
+#endif
+ UString &archiveExtension)
+{
+ CObjectVector<CArchiverInfo> archiverInfoVector;
+ ReadArchiverInfoList(archiverInfoVector);
+ if (archiverInfoVector.Size() == 0)
+ ThrowException("There are no installed archive handlers");
+ if (archiveType.IsEmpty())
+ ThrowException("Incorrect archive type was assigned");
+ for (int i = 0; i < archiverInfoVector.Size(); i++)
+ {
+ const CArchiverInfo &archiverInfo = archiverInfoVector[i];
+ if (archiverInfo.Name.CompareNoCase(archiveType) == 0)
+ {
+ #ifndef EXCLUDE_COM
+ classID = archiverInfo.ClassID;
+ filePath = archiverInfo.FilePath;
+ #else
+ formatName = archiverInfo.Name;
+
+ #endif
+
+ archiveExtension = archiverInfo.GetMainExtension();
+ return;
+ }
+ }
+ ThrowException("Incorrect archive type was assigned");
+}
+
+
+CArchiveCommandLineParser::CArchiveCommandLineParser(): parser(kNumSwitches) {}
+
+void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
+ CArchiveCommandLineOptions &options)
+{
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
+ }
+ catch(...)
+ {
+ ThrowUserErrorException();
+ }
+
+ options.IsInTerminal = (_isatty(_fileno(stdin)) != 0);
+ options.IsStdOutTerminal = (_isatty(_fileno(stdout)) != 0);
+ options.IsStdErrTerminal = (_isatty(_fileno(stderr)) != 0);
+ options.StdOutMode = parser[NKey::kStdOut].ThereIs;
+ options.EnableHeaders = !parser[NKey::kDisableHeaders].ThereIs;
+ options.HelpMode = parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs || parser[NKey::kHelp3].ThereIs;
+
+ #ifdef _WIN32
+ options.LargePages = false;
+ if (parser[NKey::kLargePages].ThereIs)
+ {
+ const UString &postString = parser[NKey::kLargePages].PostStrings.Front();
+ if (postString.IsEmpty())
+ options.LargePages = true;
+ }
+ #endif
+}
+
+struct CCodePagePair
+{
+ const wchar_t *Name;
+ UINT CodePage;
+};
+
+static CCodePagePair g_CodePagePairs[] =
+{
+ { L"UTF-8", CP_UTF8 },
+ { L"WIN", CP_ACP },
+ { L"DOS", CP_OEMCP }
+};
+
+static const int kNumCodePages = sizeof(g_CodePagePairs) / sizeof(g_CodePagePairs[0]);
+
+void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
+{
+ const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
+ int numNonSwitchStrings = nonSwitchStrings.Size();
+ if(numNonSwitchStrings < kMinNonSwitchWords)
+ ThrowUserErrorException();
+
+ if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], options.Command))
+ ThrowUserErrorException();
+
+ options.TechMode = parser[NKey::kTechMode].ThereIs;
+
+ NRecursedType::EEnum recursedType;
+ if (parser[NKey::kRecursed].ThereIs)
+ recursedType = GetRecursedTypeFromIndex(parser[NKey::kRecursed].PostCharIndex);
+ else
+ recursedType = NRecursedType::kNonRecursed;
+
+ UINT codePage = CP_UTF8;
+ if (parser[NKey::kCharSet].ThereIs)
+ {
+ UString name = parser[NKey::kCharSet].PostStrings.Front();
+ name.MakeUpper();
+ int i;
+ for (i = 0; i < kNumCodePages; i++)
+ {
+ const CCodePagePair &pair = g_CodePagePairs[i];
+ if (name.Compare(pair.Name) == 0)
+ {
+ codePage = pair.CodePage;
+ break;
+ }
+ }
+ if (i >= kNumCodePages)
+ ThrowUserErrorException();
+ }
+
+ bool thereAreSwitchIncludes = false;
+ if (parser[NKey::kInclude].ThereIs)
+ {
+ thereAreSwitchIncludes = true;
+ AddSwitchWildCardsToCensor(options.WildcardCensor,
+ parser[NKey::kInclude].PostStrings, true, recursedType, codePage);
+ }
+ if (parser[NKey::kExclude].ThereIs)
+ AddSwitchWildCardsToCensor(options.WildcardCensor,
+ parser[NKey::kExclude].PostStrings, false, recursedType, codePage);
+
+ int curCommandIndex = kCommandIndex + 1;
+ bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs;
+ if (thereIsArchiveName)
+ {
+ if(curCommandIndex >= numNonSwitchStrings)
+ ThrowUserErrorException();
+ options.ArchiveName = nonSwitchStrings[curCommandIndex++];
+ }
+
+ AddToCensorFromNonSwitchesStrings(
+ curCommandIndex, options.WildcardCensor,
+ nonSwitchStrings, recursedType, thereAreSwitchIncludes, codePage);
+
+ options.YesToAll = parser[NKey::kYes].ThereIs;
+
+ bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
+
+ options.PasswordEnabled = parser[NKey::kPassword].ThereIs;
+
+ if(options.PasswordEnabled)
+ options.Password = parser[NKey::kPassword].PostStrings[0];
+
+ options.StdInMode = parser[NKey::kStdIn].ThereIs;
+ options.ShowDialog = parser[NKey::kShowDialog].ThereIs;
+
+ if(isExtractGroupCommand || options.Command.CommandType == NCommandType::kList)
+ {
+ if (options.StdInMode)
+ ThrowException("Reading archives from stdin is not implemented");
+ if (!options.WildcardCensor.AllAreRelative())
+ ThrowException("Cannot use absolute pathnames for this command");
+
+ NWildcard::CCensor archiveWildcardCensor;
+
+ if (parser[NKey::kArInclude].ThereIs)
+ {
+ AddSwitchWildCardsToCensor(archiveWildcardCensor,
+ parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage);
+ }
+ if (parser[NKey::kArExclude].ThereIs)
+ AddSwitchWildCardsToCensor(archiveWildcardCensor,
+ parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage);
+
+ if (thereIsArchiveName)
+ AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);
+
+ #ifdef _WIN32
+ ConvertToLongNames(archiveWildcardCensor);
+ #endif
+
+ 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);
+ }
+
+ if (archivePaths.Size() == 0)
+ throw "there is no such archive";
+
+ UStringVector archivePathsFull;
+
+ for (i = 0; i < archivePaths.Size(); i++)
+ {
+ UString fullPath;
+ NFile::NDirectory::MyGetFullPathName(archivePaths[i], fullPath);
+ archivePathsFull.Add(fullPath);
+ }
+ CIntVector indices;
+ SortStringsToIndices(archivePathsFull, indices);
+ options.ArchivePathsSorted.Reserve(indices.Size());
+ options.ArchivePathsFullSorted.Reserve(indices.Size());
+ for (i = 0; i < indices.Size(); i++)
+ {
+ options.ArchivePathsSorted.Add(archivePaths[indices[i]]);
+ options.ArchivePathsFullSorted.Add(archivePathsFull[indices[i]]);
+ }
+
+ if (isExtractGroupCommand)
+ {
+ SetMethodOptions(parser, options.ExtractProperties);
+ if (options.StdOutMode && options.IsStdOutTerminal && options.IsStdErrTerminal)
+ throw kSameTerminalError;
+ 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 =
+ k_OverwriteModes[parser[NKey::kOverwrite].PostCharIndex];
+ else if (options.YesToAll)
+ options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
+ }
+ }
+ else if(options.Command.IsFromUpdateGroup())
+ {
+ CUpdateOptions &updateOptions = options.UpdateOptions;
+
+ UString archiveType;
+ if(parser[NKey::kArchiveType].ThereIs)
+ archiveType = parser[NKey::kArchiveType].PostStrings[0];
+ else
+ archiveType = kDefaultArchiveType;
+
+ UString typeExtension;
+ if (!archiveType.IsEmpty())
+ {
+ #ifndef EXCLUDE_COM
+ SetArchiveType(archiveType, updateOptions.MethodMode.FilePath,
+ updateOptions.MethodMode.ClassID, typeExtension);
+ #else
+ SetArchiveType(archiveType, updateOptions.MethodMode.Name, typeExtension);
+ #endif
+ }
+ UString extension = typeExtension;
+ if(parser[NKey::kSfx].ThereIs)
+ extension = kSFXExtension;
+ updateOptions.ArchivePath.BaseExtension = extension;
+ updateOptions.ArchivePath.VolExtension = typeExtension;
+ updateOptions.ArchivePath.ParseFromPath(options.ArchiveName);
+ SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
+
+ SetMethodOptions(parser, updateOptions.MethodMode.Properties);
+
+ options.EnablePercents = !parser[NKey::kDisablePercents].ThereIs;
+
+ if (options.EnablePercents)
+ {
+ if ((options.StdOutMode && !options.IsStdErrTerminal) ||
+ (!options.StdOutMode && !options.IsStdOutTerminal))
+ options.EnablePercents = false;
+ }
+
+ updateOptions.EMailMode = parser[NKey::kEmail].ThereIs;
+ if (updateOptions.EMailMode)
+ {
+ updateOptions.EMailAddress = parser[NKey::kEmail].PostStrings.Front();
+ if (updateOptions.EMailAddress.Length() > 0)
+ if (updateOptions.EMailAddress[0] == L'.')
+ {
+ updateOptions.EMailRemoveAfter = true;
+ updateOptions.EMailAddress.Delete(0);
+ }
+ }
+
+ updateOptions.StdOutMode = options.StdOutMode;
+ updateOptions.StdInMode = options.StdInMode;
+
+ if (updateOptions.StdOutMode && updateOptions.EMailMode)
+ throw "stdout mode and email mode cannot be combined";
+ if (updateOptions.StdOutMode && options.IsStdOutTerminal)
+ throw kTerminalOutError;
+ if(updateOptions.StdInMode)
+ updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();
+
+ #ifdef _WIN32
+ ConvertToLongNames(options.WildcardCensor);
+ #endif
+ }
+ else
+ ThrowUserErrorException();
+ options.WildcardCensor.ExtendExclude();
+}
diff --git a/7zip/UI/Common/ArchiveCommandLine.h b/CPP/7zip/UI/Common/ArchiveCommandLine.h
index daa66fb6..daa66fb6 100755
--- a/7zip/UI/Common/ArchiveCommandLine.h
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.h
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
new file mode 100755
index 00000000..05520fed
--- /dev/null
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
@@ -0,0 +1,448 @@
+// ArchiveExtractCallback.cpp
+
+#include "StdAfx.h"
+
+#include "ArchiveExtractCallback.h"
+
+#include "Common/Wildcard.h"
+#include "Common/StringConvert.h"
+#include "Common/ComTry.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"
+
+#include "../../Common/FilePathAutoRename.h"
+
+#include "../Common/ExtractingFilePath.h"
+#include "OpenArchive.h"
+
+using namespace NWindows;
+
+static const wchar_t *kCantAutoRename = L"ERROR: Can not create file with auto name";
+static const wchar_t *kCantRenameFile = L"ERROR: Can not rename existing file ";
+static const wchar_t *kCantDeleteOutputFile = L"ERROR: Can not delete output file ";
+
+
+void CArchiveExtractCallback::Init(
+ IInArchive *archiveHandler,
+ IFolderArchiveExtractCallback *extractCallback2,
+ bool stdOutMode,
+ const UString &directoryPath,
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode,
+ const UStringVector &removePathParts,
+ const UString &itemDefaultName,
+ const FILETIME &utcLastWriteTimeDefault,
+ UInt32 attributesDefault)
+{
+ _stdOutMode = stdOutMode;
+ _numErrors = 0;
+ _extractCallback2 = extractCallback2;
+ _itemDefaultName = itemDefaultName;
+ _utcLastWriteTimeDefault = utcLastWriteTimeDefault;
+ _attributesDefault = attributesDefault;
+ _removePathParts = removePathParts;
+ _pathMode = pathMode;
+ _overwriteMode = overwriteMode;
+ _archiveHandler = archiveHandler;
+ _directoryPath = directoryPath;
+ NFile::NName::NormalizeDirPathPrefix(_directoryPath);
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetTotal(UInt64 size)
+{
+ COM_TRY_BEGIN
+ return _extractCallback2->SetTotal(size);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 *completeValue)
+{
+ COM_TRY_BEGIN
+ return _extractCallback2->SetCompleted(completeValue);
+ COM_TRY_END
+}
+
+void CArchiveExtractCallback::CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath)
+{
+ fullPath = _directoryPath;
+ for(int i = 0; i < dirPathParts.Size(); i++)
+ {
+ if (i > 0)
+ fullPath += wchar_t(NFile::NName::kDirDelimiter);
+ fullPath += dirPathParts[i];
+ NFile::NDirectory::MyCreateDirectory(fullPath);
+ }
+}
+
+static UString MakePathNameFromParts(const UStringVector &parts)
+{
+ UString result;
+ for(int i = 0; i < parts.Size(); i++)
+ {
+ if(i != 0)
+ result += wchar_t(NFile::NName::kDirDelimiter);
+ result += parts[i];
+ }
+ return result;
+}
+
+
+HRESULT CArchiveExtractCallback::GetTime(int index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined)
+{
+ filetimeIsDefined = false;
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, propID, &prop));
+ if (prop.vt == VT_FILETIME)
+ {
+ filetime = prop.filetime;
+ filetimeIsDefined = true;
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)
+{
+ COM_TRY_BEGIN
+ *outStream = 0;
+ _outFileStream.Release();
+
+ _encrypted = false;
+ _isSplit = false;
+
+ UString fullPath;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));
+
+ if(prop.vt == VT_EMPTY)
+ fullPath = _itemDefaultName;
+ else
+ {
+ if(prop.vt != VT_BSTR)
+ return E_FAIL;
+ fullPath = prop.bstrVal;
+ }
+ }
+
+ // UString fullPathCorrect = GetCorrectPath(fullPath);
+ _filePath = fullPath;
+
+ {
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidPosition, &prop));
+ if (prop.vt != VT_EMPTY)
+ {
+ if (prop.vt != VT_UI8)
+ return E_FAIL;
+ _position = prop.uhVal.QuadPart;
+ _isSplit = true;
+ }
+ }
+
+ {
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidEncrypted, &prop));
+ if (prop.vt == VT_BOOL)
+ _encrypted = VARIANT_BOOLToBool(prop.boolVal);
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ }
+
+ if(askExtractMode == NArchive::NExtract::NAskMode::kExtract)
+ {
+ if (_stdOutMode)
+ {
+ CMyComPtr<ISequentialOutStream> outStreamLoc = new CStdOutFileStream;
+ *outStream = outStreamLoc.Detach();
+ return S_OK;
+ }
+
+ {
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidAttributes, &prop));
+ if (prop.vt == VT_EMPTY)
+ {
+ _processedFileInfo.Attributes = _attributesDefault;
+ _processedFileInfo.AttributesAreDefined = false;
+ }
+ else
+ {
+ if (prop.vt != VT_UI4)
+ throw "incorrect item";
+ _processedFileInfo.Attributes = prop.ulVal;
+ _processedFileInfo.AttributesAreDefined = true;
+ }
+ }
+
+ RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.IsDirectory));
+
+ RINOK(GetTime(index, kpidCreationTime, _processedFileInfo.CreationTime,
+ _processedFileInfo.IsCreationTimeDefined));
+ RINOK(GetTime(index, kpidLastWriteTime, _processedFileInfo.LastWriteTime,
+ _processedFileInfo.IsLastWriteTimeDefined));
+ RINOK(GetTime(index, kpidLastAccessTime, _processedFileInfo.LastAccessTime,
+ _processedFileInfo.IsLastAccessTimeDefined));
+
+ bool newFileSizeDefined;
+ UInt64 newFileSize;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
+ newFileSizeDefined = (prop.vt != VT_EMPTY);
+ if (newFileSizeDefined)
+ newFileSize = ConvertPropVariantToUInt64(prop);
+ }
+
+ bool isAnti = false;
+ {
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidIsAnti, &prop));
+ if (prop.vt == VT_BOOL)
+ isAnti = VARIANT_BOOLToBool(prop.boolVal);
+ }
+
+ UStringVector pathParts;
+ SplitPathToParts(fullPath, pathParts);
+
+ if(pathParts.IsEmpty())
+ return E_FAIL;
+ UString processedPath;
+ switch(_pathMode)
+ {
+ case NExtract::NPathMode::kFullPathnames:
+ {
+ processedPath = fullPath;
+ break;
+ }
+ case NExtract::NPathMode::kCurrentPathnames:
+ {
+ // for incorrect paths: "/dir1/dir2/file"
+ int numRemovePathParts = _removePathParts.Size();
+ if(pathParts.Size() <= numRemovePathParts)
+ return E_FAIL;
+ for(int i = 0; i < numRemovePathParts; i++)
+ if(_removePathParts[i].CompareNoCase(pathParts[i]) != 0)
+ return E_FAIL;
+ pathParts.Delete(0, numRemovePathParts);
+ processedPath = MakePathNameFromParts(pathParts);
+ break;
+ }
+ case NExtract::NPathMode::kNoPathnames:
+ {
+ processedPath = pathParts.Back();
+ pathParts.Delete(0, pathParts.Size() - 1); // Test it!!
+ break;
+ }
+ }
+ processedPath = GetCorrectPath(processedPath);
+ if(!_processedFileInfo.IsDirectory)
+ pathParts.DeleteBack();
+
+ MakeCorrectPath(pathParts);
+
+ if (!isAnti)
+ {
+ if (!pathParts.IsEmpty())
+ {
+ 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);
+ }
+ }
+
+
+ UString fullProcessedPath = _directoryPath + processedPath;
+
+ if(_processedFileInfo.IsDirectory)
+ {
+ _diskFilePath = fullProcessedPath;
+ if (isAnti)
+ NFile::NDirectory::MyRemoveDirectory(_diskFilePath);
+ return S_OK;
+ }
+
+ if (!_isSplit)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if(NFile::NFind::FindFile(fullProcessedPath, fileInfo))
+ {
+ switch(_overwriteMode)
+ {
+ case NExtract::NOverwriteMode::kSkipExisting:
+ return S_OK;
+ case NExtract::NOverwriteMode::kAskBefore:
+ {
+ Int32 overwiteResult;
+ RINOK(_extractCallback2->AskOverwrite(
+ fullProcessedPath, &fileInfo.LastWriteTime, &fileInfo.Size, fullPath,
+ _processedFileInfo.IsLastWriteTimeDefined ? &_processedFileInfo.LastWriteTime : NULL,
+ newFileSizeDefined ? &newFileSize : NULL,
+ &overwiteResult))
+
+ switch(overwiteResult)
+ {
+ case NOverwriteAnswer::kCancel:
+ return E_ABORT;
+ case NOverwriteAnswer::kNo:
+ return S_OK;
+ case NOverwriteAnswer::kNoToAll:
+ _overwriteMode = NExtract::NOverwriteMode::kSkipExisting;
+ return S_OK;
+ case NOverwriteAnswer::kYesToAll:
+ _overwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
+ break;
+ case NOverwriteAnswer::kYes:
+ break;
+ case NOverwriteAnswer::kAutoRename:
+ _overwriteMode = NExtract::NOverwriteMode::kAutoRename;
+ break;
+ default:
+ throw 20413;
+ }
+ }
+ }
+ if (_overwriteMode == NExtract::NOverwriteMode::kAutoRename)
+ {
+ if (!AutoRenamePath(fullProcessedPath))
+ {
+ UString message = UString(kCantAutoRename) + fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return E_FAIL;
+ }
+ }
+ else if (_overwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting)
+ {
+ UString existPath = fullProcessedPath;
+ if (!AutoRenamePath(existPath))
+ {
+ UString message = kCantAutoRename + fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return E_FAIL;
+ }
+ if(!NFile::NDirectory::MyMoveFile(fullProcessedPath, existPath))
+ {
+ UString message = UString(kCantRenameFile) + fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return E_FAIL;
+ }
+ }
+ else
+ if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
+ {
+ UString message = UString(kCantDeleteOutputFile) +
+ fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return E_FAIL;
+ }
+ }
+ }
+ if (!isAnti)
+ {
+ _outFileStreamSpec = new COutFileStream;
+ CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
+ if (!_outFileStreamSpec->File.Open(fullProcessedPath,
+ _isSplit ? OPEN_ALWAYS: CREATE_ALWAYS))
+ {
+ // if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit)
+ {
+ UString message = L"can not open output file " + fullProcessedPath;
+ RINOK(_extractCallback2->MessageError(message));
+ return S_OK;
+ }
+ }
+ if (_isSplit)
+ {
+ RINOK(_outFileStreamSpec->Seek(_position, STREAM_SEEK_SET, NULL));
+ }
+ _outFileStream = outStreamLoc;
+ *outStream = outStreamLoc.Detach();
+ }
+ _diskFilePath = fullProcessedPath;
+ }
+ else
+ {
+ *outStream = NULL;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
+{
+ COM_TRY_BEGIN
+ _extractMode = false;
+ switch (askExtractMode)
+ {
+ case NArchive::NExtract::NAskMode::kExtract:
+ _extractMode = true;
+ };
+ return _extractCallback2->PrepareOperation(_filePath, askExtractMode, _isSplit ? &_position: 0);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
+{
+ COM_TRY_BEGIN
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kOK:
+ case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
+ case NArchive::NExtract::NOperationResult::kCRCError:
+ case NArchive::NExtract::NOperationResult::kDataError:
+ break;
+ default:
+ _outFileStream.Release();
+ return E_FAIL;
+ }
+ if(_outFileStream != NULL)
+ _outFileStreamSpec->File.SetTime(
+ (WriteCreated && _processedFileInfo.IsCreationTimeDefined) ? &_processedFileInfo.CreationTime : NULL,
+ (WriteAccessed && _processedFileInfo.IsLastAccessTimeDefined) ? &_processedFileInfo.LastAccessTime : NULL,
+ (WriteModified && _processedFileInfo.IsLastWriteTimeDefined) ? &_processedFileInfo.LastWriteTime : &_utcLastWriteTimeDefault);
+ _outFileStream.Release();
+ if (_extractMode && _processedFileInfo.AttributesAreDefined)
+ NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attributes);
+ RINOK(_extractCallback2->SetOperationResult(operationResult, _encrypted));
+ return S_OK;
+ COM_TRY_END
+}
+
+/*
+STDMETHODIMP CArchiveExtractCallback::GetInStream(
+ const wchar_t *name, ISequentialInStream **inStream)
+{
+ COM_TRY_BEGIN
+ CInFileStream *inFile = new CInFileStream;
+ CMyComPtr<ISequentialInStream> inStreamTemp = inFile;
+ if (!inFile->Open(_srcDirectoryPrefix + name))
+ return ::GetLastError();
+ *inStream = inStreamTemp.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+*/
+
+STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
+{
+ COM_TRY_BEGIN
+ if (!_cryptoGetTextPassword)
+ {
+ RINOK(_extractCallback2.QueryInterface(IID_ICryptoGetTextPassword,
+ &_cryptoGetTextPassword));
+ }
+ return _cryptoGetTextPassword->CryptoGetTextPassword(password);
+ COM_TRY_END
+}
+
diff --git a/7zip/UI/Common/ArchiveExtractCallback.h b/CPP/7zip/UI/Common/ArchiveExtractCallback.h
index 4fd63a53..4fd63a53 100755
--- a/7zip/UI/Common/ArchiveExtractCallback.h
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.h
diff --git a/7zip/UI/Common/ArchiveName.cpp b/CPP/7zip/UI/Common/ArchiveName.cpp
index 2d50ede1..2d50ede1 100755
--- a/7zip/UI/Common/ArchiveName.cpp
+++ b/CPP/7zip/UI/Common/ArchiveName.cpp
diff --git a/7zip/UI/Common/ArchiveName.h b/CPP/7zip/UI/Common/ArchiveName.h
index 6b001a5a..6b001a5a 100755
--- a/7zip/UI/Common/ArchiveName.h
+++ b/CPP/7zip/UI/Common/ArchiveName.h
diff --git a/7zip/UI/Common/ArchiveOpenCallback.cpp b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
index 1d2944d8..1d2944d8 100755
--- a/7zip/UI/Common/ArchiveOpenCallback.cpp
+++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.h b/CPP/7zip/UI/Common/ArchiveOpenCallback.h
new file mode 100755
index 00000000..454873ad
--- /dev/null
+++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.h
@@ -0,0 +1,89 @@
+// ArchiveOpenCallback.h
+
+#ifndef __ARCHIVE_OPEN_CALLBACK_H
+#define __ARCHIVE_OPEN_CALLBACK_H
+
+#include "Common/String.h"
+#include "Common/MyCom.h"
+#include "Windows/FileFind.h"
+
+#ifndef _NO_CRYPTO
+#include "../../IPassword.h"
+#endif
+#include "../../Archive/IArchive.h"
+
+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
+};
+
+class COpenCallbackImp:
+ public IArchiveOpenCallback,
+ public IArchiveOpenVolumeCallback,
+ public IArchiveOpenSetSubArchiveName,
+ #ifndef _NO_CRYPTO
+ public ICryptoGetTextPassword,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ #ifndef _NO_CRYPTO
+ MY_UNKNOWN_IMP3(
+ IArchiveOpenVolumeCallback,
+ ICryptoGetTextPassword,
+ IArchiveOpenSetSubArchiveName
+ )
+ #else
+ MY_UNKNOWN_IMP2(
+ 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);
+
+ #ifndef _NO_CRYPTO
+ // ICryptoGetTextPassword
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+ #endif
+
+ STDMETHOD(SetSubArchiveName(const wchar_t *name))
+ {
+ _subArchiveMode = true;
+ _subArchiveName = name;
+ return S_OK;
+ }
+
+private:
+ UString _folderPrefix;
+ NWindows::NFile::NFind::CFileInfoW _fileInfo;
+ bool _subArchiveMode;
+ UString _subArchiveName;
+public:
+ UStringVector FileNames;
+ IOpenCallbackUI *Callback;
+ void Init(const UString &folderPrefix, const UString &fileName)
+ {
+ _folderPrefix = folderPrefix;
+ if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo))
+ throw 1;
+ FileNames.Clear();
+ _subArchiveMode = false;
+ }
+ int FindName(const UString &name);
+};
+
+#endif
diff --git a/CPP/7zip/UI/Common/ArchiverInfo.cpp b/CPP/7zip/UI/Common/ArchiverInfo.cpp
new file mode 100755
index 00000000..7833ed3c
--- /dev/null
+++ b/CPP/7zip/UI/Common/ArchiverInfo.cpp
@@ -0,0 +1,372 @@
+// ArchiverInfo.cpp
+
+#include "StdAfx.h"
+
+#include "ArchiverInfo.h"
+
+#ifndef EXCLUDE_COM
+
+#include "Common/StringConvert.h"
+#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
+#include "Windows/DLL.h"
+#ifdef _WIN32
+#include "Windows/Registry.h"
+#endif
+#include "Windows/PropVariant.h"
+#include "../../Archive/IArchive.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+#endif
+
+extern HINSTANCE g_hInstance;
+
+#ifndef EXCLUDE_COM
+
+static void SplitString(const UString &srcString, UStringVector &destStrings)
+{
+ destStrings.Clear();
+ UString string;
+ int len = srcString.Length();
+ if (len == 0)
+ return;
+ for (int i = 0; i < len; i++)
+ {
+ wchar_t c = srcString[i];
+ if (c == L' ')
+ {
+ if (!string.IsEmpty())
+ {
+ destStrings.Add(string);
+ string.Empty();
+ }
+ }
+ else
+ string += c;
+ }
+ if (!string.IsEmpty())
+ destStrings.Add(string);
+}
+
+typedef UInt32 (WINAPI * GetHandlerPropertyFunc)(
+ PROPID propID, PROPVARIANT *value);
+
+static UString GetModuleFolderPrefix()
+{
+ UString path;
+ NDLL::MyGetModuleFileName(g_hInstance, path);
+ int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ return path.Left(pos + 1);
+}
+
+static wchar_t *kFormatFolderName = L"Formats";
+
+#ifdef _WIN32
+static LPCTSTR kRegistryPath = TEXT("Software\\7-zip");
+static LPCWSTR kProgramPathValue = L"Path";
+static bool ReadPathFromRegistry(HKEY baseKey, UString &path)
+{
+ NRegistry::CKey key;
+ if(key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
+ if (key.QueryValue(kProgramPathValue, path) == ERROR_SUCCESS)
+ {
+ NName::NormalizeDirPathPrefix(path);
+ return true;
+ }
+ return false;
+}
+#endif
+
+static UString GetBaseFolderPrefixFromRegistry()
+{
+ UString moduleFolderPrefix = GetModuleFolderPrefix();
+ NFind::CFileInfoW fileInfo;
+ if (NFind::FindFile(moduleFolderPrefix + kFormatFolderName, fileInfo))
+ if (fileInfo.IsDirectory())
+ return moduleFolderPrefix;
+ UString path;
+ #ifdef _WIN32
+ if(ReadPathFromRegistry(HKEY_CURRENT_USER, path))
+ return path;
+ if(ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
+ return path;
+ #endif
+ return moduleFolderPrefix;
+}
+
+typedef UInt32 (WINAPI *CreateObjectPointer)(
+ const GUID *clsID,
+ const GUID *interfaceID,
+ void **outObject);
+
+#endif
+
+#ifndef _SFX
+static inline void SetBuffer(CByteBuffer &bb, const Byte *data, int size)
+{
+ bb.SetCapacity(size);
+ memmove((Byte *)bb, data, size);
+}
+#endif
+
+void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
+{
+ archivers.Clear();
+
+ #ifdef EXCLUDE_COM
+
+ #ifdef FORMAT_7Z
+ {
+ CArchiverInfo item;
+ item.UpdateEnabled = true;
+ item.Name = L"7z";
+ item.Extensions.Add(CArchiverExtInfo(L"7z"));
+ #ifndef _SFX
+ const unsigned char kSig[] = {'7' , 'z', 0xBC, 0xAF, 0x27, 0x1C};
+ SetBuffer(item.StartSignature, kSig, 6);
+ #endif
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_BZIP2
+ {
+ CArchiverInfo item;
+ item.UpdateEnabled = true;
+ item.KeepName = true;
+ item.Name = L"BZip2";
+ item.Extensions.Add(CArchiverExtInfo(L"bz2"));
+ item.Extensions.Add(CArchiverExtInfo(L"tbz2", L".tar"));
+ #ifndef _SFX
+ const unsigned char sig[] = {'B' , 'Z', 'h' };
+ SetBuffer(item.StartSignature, sig, 3);
+ #endif
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_CAB
+ {
+ CArchiverInfo item;
+ item.Name = L"Cab";
+ item.Extensions.Add(CArchiverExtInfo(L"cab"));
+ #ifndef _SFX
+ const unsigned char sig[] = { 0x4D, 0x53, 0x43, 0x46 };
+ SetBuffer(item.StartSignature, sig, 4);
+ #endif
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_GZIP
+ {
+ CArchiverInfo item;
+ item.UpdateEnabled = true;
+ item.Name = L"GZip";
+ item.Extensions.Add(CArchiverExtInfo(L"gz"));
+ item.Extensions.Add(CArchiverExtInfo(L"tgz", L".tar"));
+ #ifndef _SFX
+ const unsigned char sig[] = { 0x1F, 0x8B };
+ SetBuffer(item.StartSignature, sig, 2);
+ #endif
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_SPLIT
+ {
+ CArchiverInfo item;
+ item.UpdateEnabled = false;
+ item.KeepName = true;
+ item.Name = L"Split";
+ item.Extensions.Add(CArchiverExtInfo(L"001"));
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_TAR
+ {
+ CArchiverInfo item;
+ item.UpdateEnabled = true;
+ item.Name = L"Tar";
+ item.Extensions.Add(CArchiverExtInfo(L"tar"));
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_ZIP
+ {
+ CArchiverInfo item;
+ item.UpdateEnabled = true;
+ item.Name = L"Zip";
+ item.Extensions.Add(CArchiverExtInfo(L"zip"));
+ #ifndef _SFX
+ const unsigned char sig[] = { 0x50, 0x4B, 0x03, 0x04 };
+ SetBuffer(item.StartSignature, sig, 4);
+ #endif
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_CPIO
+ {
+ CArchiverInfo item;
+ item.Name = L"Cpio";
+ item.Extensions.Add(CArchiverExtInfo(L"cpio"));
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_RPM
+ {
+ CArchiverInfo item;
+ item.Name = L"Rpm";
+ item.Extensions.Add(CArchiverExtInfo(L"rpm", L".cpio.gz"));
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_ARJ
+ {
+ CArchiverInfo item;
+ item.Name = L"Arj";
+ item.Extensions.Add(CArchiverExtInfo(L"arj"));
+ #ifndef _SFX
+ const unsigned char sig[] = { 0x60, 0xEA };
+ SetBuffer(item.StartSignature, sig, 2);
+ #endif
+ archivers.Add(item);
+ }
+ #endif
+
+ #ifdef FORMAT_Z
+ {
+ CArchiverInfo item;
+ item.Name = L"Z";
+ item.Extensions.Add(CArchiverExtInfo(L"Z"));
+ #ifndef _SFX
+ const unsigned char sig[] = { 0x1F, 0x9D };
+ SetBuffer(item.StartSignature, sig, 2);
+ #endif
+ archivers.Add(item);
+ }
+ #endif
+
+ #else
+
+ UString folderPath = GetBaseFolderPrefixFromRegistry() +
+ (UString)kFormatFolderName + (UString)WSTRING_PATH_SEPARATOR;
+ NFind::CEnumeratorW enumerator(folderPath + L"*");
+ NFind::CFileInfoW fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ if (fileInfo.IsDirectory())
+ continue;
+ UString filePath = folderPath + fileInfo.Name;
+ {
+ NDLL::CLibrary library;
+ if (!library.LoadEx(filePath, LOAD_LIBRARY_AS_DATAFILE))
+ continue;
+ }
+
+ NDLL::CLibrary library;
+ if (!library.Load(filePath))
+ continue;
+ GetHandlerPropertyFunc getHandlerProperty = (GetHandlerPropertyFunc)
+ library.GetProcAddress("GetHandlerProperty");
+ if (getHandlerProperty == NULL)
+ continue;
+
+ CArchiverInfo item;
+ item.FilePath = filePath;
+
+ NWindows::NCOM::CPropVariant prop;
+ if (getHandlerProperty(NArchive::kName, &prop) != S_OK)
+ continue;
+ if (prop.vt != VT_BSTR)
+ continue;
+ item.Name = prop.bstrVal;
+ prop.Clear();
+
+ if (getHandlerProperty(NArchive::kClassID, &prop) != S_OK)
+ continue;
+ if (prop.vt != VT_BSTR)
+ continue;
+ item.ClassID = *(const GUID *)prop.bstrVal;
+ prop.Clear();
+
+ if (getHandlerProperty(NArchive::kExtension, &prop) != S_OK)
+ continue;
+ if (prop.vt != VT_BSTR)
+ continue;
+
+ UString ext = prop.bstrVal;
+ UString addExt;
+
+ prop.Clear();
+
+ if (getHandlerProperty(NArchive::kAddExtension, &prop) != S_OK)
+ continue;
+ if (prop.vt == VT_BSTR)
+ {
+ addExt = prop.bstrVal;
+ }
+ else if (prop.vt != VT_EMPTY)
+ continue;
+ prop.Clear();
+
+ UStringVector exts, addExts;
+ SplitString(ext, exts);
+ SplitString(addExt, addExts);
+
+ prop.Clear();
+ for (int i = 0; i < exts.Size(); i++)
+ {
+ CArchiverExtInfo extInfo;
+ extInfo.Ext = exts[i];
+ if (addExts.Size() > 0)
+ extInfo.AddExt = addExts[i];
+ if (extInfo.AddExt == L"*")
+ extInfo.AddExt.Empty();
+ item.Extensions.Add(extInfo);
+ }
+
+ if (getHandlerProperty(NArchive::kUpdate, &prop) == S_OK)
+ if (prop.vt == VT_BOOL)
+ item.UpdateEnabled = VARIANT_BOOLToBool(prop.boolVal);
+ prop.Clear();
+
+ if (item.UpdateEnabled)
+ {
+ if (getHandlerProperty(NArchive::kKeepName, &prop) == S_OK)
+ if (prop.vt == VT_BOOL)
+ item.KeepName = VARIANT_BOOLToBool(prop.boolVal);
+ prop.Clear();
+ }
+
+ if (getHandlerProperty(NArchive::kStartSignature, &prop) == S_OK)
+ {
+ if (prop.vt == VT_BSTR)
+ {
+ UINT len = ::SysStringByteLen(prop.bstrVal);
+ item.StartSignature.SetCapacity(len);
+ memmove(item.StartSignature, prop.bstrVal, len);
+ }
+ }
+ prop.Clear();
+
+ if (getHandlerProperty(NArchive::kAssociate, &prop) == S_OK)
+ if (prop.vt == VT_BOOL)
+ item.Associate = VARIANT_BOOLToBool(prop.boolVal);
+ prop.Clear();
+
+
+ archivers.Add(item);
+ }
+
+ #endif
+}
+
+
diff --git a/7zip/UI/Common/ArchiverInfo.h b/CPP/7zip/UI/Common/ArchiverInfo.h
index 3b829518..3b829518 100755
--- a/7zip/UI/Common/ArchiverInfo.h
+++ b/CPP/7zip/UI/Common/ArchiverInfo.h
diff --git a/7zip/UI/Common/CompressCall.cpp b/CPP/7zip/UI/Common/CompressCall.cpp
index 86bdd297..86bdd297 100755
--- a/7zip/UI/Common/CompressCall.cpp
+++ b/CPP/7zip/UI/Common/CompressCall.cpp
diff --git a/7zip/UI/Common/CompressCall.h b/CPP/7zip/UI/Common/CompressCall.h
index 95be95c3..95be95c3 100755
--- a/7zip/UI/Common/CompressCall.h
+++ b/CPP/7zip/UI/Common/CompressCall.h
diff --git a/CPP/7zip/UI/Common/DefaultName.cpp b/CPP/7zip/UI/Common/DefaultName.cpp
new file mode 100755
index 00000000..8ee7c048
--- /dev/null
+++ b/CPP/7zip/UI/Common/DefaultName.cpp
@@ -0,0 +1,26 @@
+// DefaultName.cpp
+
+#include "StdAfx.h"
+
+#include "DefaultName.h"
+
+static const wchar_t *kEmptyFileAlias = L"[Content]";
+
+UString GetDefaultName2(const UString &fileName,
+ const UString &extension, const UString &addSubExtension)
+{
+ int extLength = extension.Length();
+ int fileNameLength = fileName.Length();
+ if (fileNameLength > extLength + 1)
+ {
+ int dotPos = fileNameLength - (extLength + 1);
+ if (fileName[dotPos] == '.')
+ if (extension.CompareNoCase(fileName.Mid(dotPos + 1)) == 0)
+ return fileName.Left(dotPos) + addSubExtension;
+ }
+ int dotPos = fileName.ReverseFind(L'.');
+ if (dotPos > 0)
+ return fileName.Left(dotPos) + addSubExtension;
+ return kEmptyFileAlias;
+}
+
diff --git a/7zip/UI/Common/DefaultName.h b/CPP/7zip/UI/Common/DefaultName.h
index ff6330fa..ff6330fa 100755
--- a/7zip/UI/Common/DefaultName.h
+++ b/CPP/7zip/UI/Common/DefaultName.h
diff --git a/7zip/UI/Common/DirItem.h b/CPP/7zip/UI/Common/DirItem.h
index 9537071c..9537071c 100755
--- a/7zip/UI/Common/DirItem.h
+++ b/CPP/7zip/UI/Common/DirItem.h
diff --git a/7zip/UI/Common/EnumDirItems.cpp b/CPP/7zip/UI/Common/EnumDirItems.cpp
index 454092ec..454092ec 100755
--- a/7zip/UI/Common/EnumDirItems.cpp
+++ b/CPP/7zip/UI/Common/EnumDirItems.cpp
diff --git a/7zip/UI/Common/EnumDirItems.h b/CPP/7zip/UI/Common/EnumDirItems.h
index 8d5495a8..8d5495a8 100755
--- a/7zip/UI/Common/EnumDirItems.h
+++ b/CPP/7zip/UI/Common/EnumDirItems.h
diff --git a/7zip/UI/Common/ExitCode.h b/CPP/7zip/UI/Common/ExitCode.h
index 0aac3695..0aac3695 100755
--- a/7zip/UI/Common/ExitCode.h
+++ b/CPP/7zip/UI/Common/ExitCode.h
diff --git a/CPP/7zip/UI/Common/Extract.cpp b/CPP/7zip/UI/Common/Extract.cpp
new file mode 100755
index 00000000..34fb383b
--- /dev/null
+++ b/CPP/7zip/UI/Common/Extract.cpp
@@ -0,0 +1,152 @@
+// Extract.cpp
+
+#include "StdAfx.h"
+
+#include "Extract.h"
+
+#include "Windows/Defs.h"
+#include "Windows/FileDir.h"
+
+#include "OpenArchive.h"
+#include "SetProperties.h"
+
+#ifndef EXCLUDE_COM
+#include "Windows/DLL.h"
+#endif
+
+using namespace NWindows;
+
+HRESULT DecompressArchive(
+ IInArchive *archive,
+ const UString &defaultName,
+ const NWildcard::CCensorNode &wildcardCensor,
+ const CExtractOptions &options,
+ IExtractCallbackUI *callback,
+ UString &errorMessage)
+{
+ CRecordVector<UInt32> realIndices;
+ UInt32 numItems;
+ RINOK(archive->GetNumberOfItems(&numItems));
+
+ for(UInt32 i = 0; i < numItems; i++)
+ {
+ UString filePath;
+ RINOK(GetArchiveItemPath(archive, i, options.DefaultItemName, filePath));
+ bool isFolder;
+ RINOK(IsArchiveItemFolder(archive, i, isFolder));
+ if (!wildcardCensor.CheckPath(filePath, !isFolder))
+ continue;
+ realIndices.Add(i);
+ }
+ if (realIndices.Size() == 0)
+ {
+ callback->ThereAreNoFiles();
+ return S_OK;
+ }
+
+ CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
+ CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
+
+ UStringVector removePathParts;
+
+ UString outDir = options.OutputDir;
+ outDir.Replace(L"*", defaultName);
+ if(!outDir.IsEmpty())
+ if(!NFile::NDirectory::CreateComplexDirectory(outDir))
+ {
+ HRESULT res = ::GetLastError();
+ if (res == S_OK)
+ res = E_FAIL;
+ errorMessage = ((UString)L"Can not create output directory ") + outDir;
+ return res;
+ }
+
+ extractCallbackSpec->Init(
+ archive,
+ callback,
+ options.StdOutMode,
+ outDir,
+ options.PathMode,
+ options.OverwriteMode,
+ removePathParts,
+ options.DefaultItemName,
+ options.ArchiveFileInfo.LastWriteTime,
+ options.ArchiveFileInfo.Attributes);
+
+ #ifdef COMPRESS_MT
+ RINOK(SetProperties(archive, options.Properties));
+ #endif
+
+ HRESULT result = archive->Extract(&realIndices.Front(),
+ realIndices.Size(), options.TestMode? 1: 0,
+ extractCallback);
+
+ return callback->ExtractResult(result);
+}
+
+HRESULT DecompressArchives(
+ UStringVector &archivePaths, UStringVector &archivePathsFull,
+ const NWildcard::CCensorNode &wildcardCensor,
+ const CExtractOptions &optionsSpec,
+ IOpenCallbackUI *openCallback,
+ IExtractCallbackUI *extractCallback,
+ UString &errorMessage)
+{
+ CExtractOptions options = optionsSpec;
+ for (int i = 0; i < archivePaths.Size(); i++)
+ {
+ const UString &archivePath = archivePaths[i];
+ NFile::NFind::CFileInfoW archiveFileInfo;
+ if (!NFile::NFind::FindFile(archivePath, archiveFileInfo))
+ throw "there is no such archive";
+
+ if (archiveFileInfo.IsDirectory())
+ throw "there is no such archive";
+
+ options.ArchiveFileInfo = archiveFileInfo;
+
+ #ifndef _NO_CRYPTO
+ openCallback->ClearPasswordWasAskedFlag();
+ #endif
+
+ RINOK(extractCallback->BeforeOpen(archivePath));
+ CArchiveLink archiveLink;
+ HRESULT result = MyOpenArchive(archivePath, archiveLink, openCallback);
+
+ bool crypted = false;
+ #ifndef _NO_CRYPTO
+ crypted = openCallback->WasPasswordAsked();
+ #endif
+
+ RINOK(extractCallback->OpenResult(archivePath, result, crypted));
+ if (result != S_OK)
+ continue;
+
+ for (int v = 0; v < archiveLink.VolumePaths.Size(); v++)
+ {
+ int index = archivePathsFull.FindInSorted(archiveLink.VolumePaths[v]);
+ if (index >= 0 && index > i)
+ {
+ archivePaths.Delete(index);
+ archivePathsFull.Delete(index);
+ }
+ }
+
+ #ifndef _NO_CRYPTO
+ UString password;
+ RINOK(openCallback->GetPasswordIfAny(password));
+ if (!password.IsEmpty())
+ {
+ RINOK(extractCallback->SetPassword(password));
+ }
+ #endif
+
+ options.DefaultItemName = archiveLink.GetDefaultItemName();
+ RINOK(DecompressArchive(
+ archiveLink.GetArchive(), archiveLink.GetDefaultItemName(),
+ wildcardCensor, options, extractCallback, errorMessage));
+ if (!errorMessage.IsEmpty())
+ return E_FAIL;
+ }
+ return S_OK;
+}
diff --git a/7zip/UI/Common/Extract.h b/CPP/7zip/UI/Common/Extract.h
index c7b47c84..c7b47c84 100755
--- a/7zip/UI/Common/Extract.h
+++ b/CPP/7zip/UI/Common/Extract.h
diff --git a/7zip/UI/Common/ExtractMode.h b/CPP/7zip/UI/Common/ExtractMode.h
index 96b5a8cd..96b5a8cd 100755
--- a/7zip/UI/Common/ExtractMode.h
+++ b/CPP/7zip/UI/Common/ExtractMode.h
diff --git a/7zip/UI/Common/ExtractingFilePath.cpp b/CPP/7zip/UI/Common/ExtractingFilePath.cpp
index a0b17282..a0b17282 100755
--- a/7zip/UI/Common/ExtractingFilePath.cpp
+++ b/CPP/7zip/UI/Common/ExtractingFilePath.cpp
diff --git a/7zip/UI/Common/ExtractingFilePath.h b/CPP/7zip/UI/Common/ExtractingFilePath.h
index 0ae9e9b8..0ae9e9b8 100755
--- a/7zip/UI/Common/ExtractingFilePath.h
+++ b/CPP/7zip/UI/Common/ExtractingFilePath.h
diff --git a/7zip/UI/Common/HandlerLoader.h b/CPP/7zip/UI/Common/HandlerLoader.h
index 2a878019..2a878019 100755
--- a/7zip/UI/Common/HandlerLoader.h
+++ b/CPP/7zip/UI/Common/HandlerLoader.h
diff --git a/CPP/7zip/UI/Common/IFileExtractCallback.h b/CPP/7zip/UI/Common/IFileExtractCallback.h
new file mode 100755
index 00000000..c70d7021
--- /dev/null
+++ b/CPP/7zip/UI/Common/IFileExtractCallback.h
@@ -0,0 +1,46 @@
+// IFileExtractCallback.h
+
+#ifndef __IFILEEXTRACTCALLBACK_H
+#define __IFILEEXTRACTCALLBACK_H
+
+#include "Common/String.h"
+
+namespace NOverwriteAnswer
+{
+ enum EEnum
+ {
+ kYes,
+ kYesToAll,
+ kNo,
+ kNoToAll,
+ kAutoRename,
+ kCancel,
+ };
+}
+
+// {23170F69-40C1-278A-0000-000100070000}
+DEFINE_GUID(IID_IFolderArchiveExtractCallback,
+0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00);
+MIDL_INTERFACE("23170F69-40C1-278A-0000-000100070000")
+IFolderArchiveExtractCallback: public IProgress
+{
+public:
+ STDMETHOD(AskOverwrite)(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer) PURE;
+ STDMETHOD(PrepareOperation)(const wchar_t *name, Int32 askExtractMode, const UInt64 *position) PURE;
+ STDMETHOD(MessageError)(const wchar_t *message) PURE;
+ STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted) PURE;
+};
+
+struct IExtractCallbackUI: IFolderArchiveExtractCallback
+{
+ virtual HRESULT BeforeOpen(const wchar_t *name) = 0;
+ virtual HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted) = 0;
+ virtual HRESULT ThereAreNoFiles() = 0;
+ virtual HRESULT ExtractResult(HRESULT result) = 0;
+ virtual HRESULT SetPassword(const UString &password) = 0;
+};
+
+#endif
diff --git a/CPP/7zip/UI/Common/OpenArchive.cpp b/CPP/7zip/UI/Common/OpenArchive.cpp
new file mode 100755
index 00000000..ce1a6de3
--- /dev/null
+++ b/CPP/7zip/UI/Common/OpenArchive.cpp
@@ -0,0 +1,531 @@
+// OpenArchive.cpp
+
+#include "StdAfx.h"
+
+#include "OpenArchive.h"
+
+#include "Common/Wildcard.h"
+
+#include "Windows/FileName.h"
+#include "Windows/FileDir.h"
+#include "Windows/Defs.h"
+#include "Windows/PropVariant.h"
+
+#include "../../Common/FileStreams.h"
+#include "../../Common/StreamUtils.h"
+
+#include "Common/StringConvert.h"
+
+#ifdef FORMAT_7Z
+#include "../../Archive/7z/7zHandler.h"
+#endif
+
+#ifdef FORMAT_BZIP2
+#include "../../Archive/BZip2/BZip2Handler.h"
+#endif
+
+#ifdef FORMAT_CAB
+#include "../../Archive/Cab/CabHandler.h"
+#endif
+
+#ifdef FORMAT_GZIP
+#include "../../Archive/GZip/GZipHandler.h"
+#endif
+
+#ifdef FORMAT_SPLIT
+#include "../../Archive/Split/SplitHandler.h"
+#endif
+
+#ifdef FORMAT_TAR
+#include "../../Archive/Tar/TarHandler.h"
+#endif
+
+#ifdef FORMAT_ZIP
+#include "../../Archive/Zip/ZipHandler.h"
+#endif
+
+#ifdef FORMAT_Z
+#include "../../Archive/Z/ZHandler.h"
+#endif
+
+#ifndef EXCLUDE_COM
+#include "HandlerLoader.h"
+#endif
+
+#include "DefaultName.h"
+
+using namespace NWindows;
+
+HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, UString &result)
+{
+ NCOM::CPropVariant prop;
+ RINOK(archive->GetProperty(index, kpidPath, &prop));
+ if(prop.vt == VT_BSTR)
+ result = prop.bstrVal;
+ else if (prop.vt == VT_EMPTY)
+ result.Empty();
+ else
+ return E_FAIL;
+ return S_OK;
+}
+
+HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, const UString &defaultName, UString &result)
+{
+ RINOK(GetArchiveItemPath(archive, index, result));
+ if (result.IsEmpty())
+ result = defaultName;
+ return S_OK;
+}
+
+HRESULT GetArchiveItemFileTime(IInArchive *archive, UInt32 index,
+ const FILETIME &defaultFileTime, FILETIME &fileTime)
+{
+ NCOM::CPropVariant prop;
+ RINOK(archive->GetProperty(index, kpidLastWriteTime, &prop));
+ if (prop.vt == VT_FILETIME)
+ fileTime = prop.filetime;
+ else if (prop.vt == VT_EMPTY)
+ fileTime = defaultFileTime;
+ else
+ return E_FAIL;
+ return S_OK;
+}
+
+static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result)
+{
+ NCOM::CPropVariant prop;
+ RINOK(archive->GetProperty(index, propID, &prop));
+ if(prop.vt == VT_BOOL)
+ result = VARIANT_BOOLToBool(prop.boolVal);
+ else if (prop.vt == VT_EMPTY)
+ result = false;
+ else
+ return E_FAIL;
+ return S_OK;
+}
+
+HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result)
+{
+ return IsArchiveItemProp(archive, index, kpidIsFolder, result);
+}
+
+HRESULT IsArchiveItemAnti(IInArchive *archive, UInt32 index, bool &result)
+{
+ return IsArchiveItemProp(archive, index, kpidIsAnti, result);
+}
+
+// Static-SFX (for Linux) can be big.
+const UInt64 kMaxCheckStartPosition = 1 << 22;
+
+HRESULT ReOpenArchive(IInArchive *archive, const UString &fileName)
+{
+ CInFileStream *inStreamSpec = new CInFileStream;
+ CMyComPtr<IInStream> inStream(inStreamSpec);
+ inStreamSpec->Open(fileName);
+ return archive->Open(inStream, &kMaxCheckStartPosition, NULL);
+}
+
+#ifndef _SFX
+static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size)
+{
+ for (size_t i = 0; i < size; i++)
+ if (p1[i] != p2[i])
+ return false;
+ return true;
+}
+#endif
+
+HRESULT OpenArchive(
+ IInStream *inStream,
+ const UString &fileName,
+ #ifndef EXCLUDE_COM
+ HMODULE *module,
+ #endif
+ IInArchive **archiveResult,
+ CArchiverInfo &archiverInfoResult,
+ UString &defaultItemName,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ *archiveResult = NULL;
+ CObjectVector<CArchiverInfo> archiverInfoList;
+ ReadArchiverInfoList(archiverInfoList);
+ UString extension;
+ {
+ int dotPos = fileName.ReverseFind(L'.');
+ if (dotPos >= 0)
+ extension = fileName.Mid(dotPos + 1);
+ }
+ CIntVector orderIndices;
+ int i;
+ bool finded = false;
+ for(i = 0; i < archiverInfoList.Size(); i++)
+ {
+ if (archiverInfoList[i].FindExtension(extension) >= 0)
+ {
+ orderIndices.Insert(0, i);
+ finded = true;
+ }
+ else
+ orderIndices.Add(i);
+ }
+
+ #ifndef _SFX
+ if (!finded)
+ {
+ CByteBuffer byteBuffer;
+ const UInt32 kBufferSize = (200 << 10);
+ byteBuffer.SetCapacity(kBufferSize);
+ Byte *buffer = byteBuffer;
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ UInt32 processedSize;
+ RINOK(ReadStream(inStream, buffer, kBufferSize, &processedSize));
+ int numFinded = 0;
+ for (int pos = (int)processedSize; pos >= 0 ; pos--)
+ {
+ for(int i = numFinded; i < orderIndices.Size(); i++)
+ {
+ int index = orderIndices[i];
+ const CArchiverInfo &ai = archiverInfoList[index];
+ const CByteBuffer &sig = ai.StartSignature;
+ if (sig.GetCapacity() == 0)
+ continue;
+ if (pos + sig.GetCapacity() > processedSize)
+ continue;
+ if (TestSignature(buffer + pos, sig, sig.GetCapacity()))
+ {
+ orderIndices.Delete(i);
+ orderIndices.Insert(0, index);
+ numFinded++;
+ }
+ }
+ }
+ }
+ #endif
+
+ HRESULT badResult = S_OK;
+ for(i = 0; i < orderIndices.Size(); i++)
+ {
+ inStream->Seek(0, STREAM_SEEK_SET, NULL);
+ const CArchiverInfo &archiverInfo = archiverInfoList[orderIndices[i]];
+ #ifndef EXCLUDE_COM
+ CHandlerLoader loader;
+ #endif
+ CMyComPtr<IInArchive> archive;
+
+ #ifdef FORMAT_7Z
+ if (archiverInfo.Name.CompareNoCase(L"7z") == 0)
+ archive = new NArchive::N7z::CHandler;
+ #endif
+
+ #ifdef FORMAT_BZIP2
+ if (archiverInfo.Name.CompareNoCase(L"BZip2") == 0)
+ archive = new NArchive::NBZip2::CHandler;
+ #endif
+
+ #ifdef FORMAT_CAB
+ if (archiverInfo.Name.CompareNoCase(L"Cab") == 0)
+ archive = new NArchive::NCab::CHandler;
+ #endif
+
+ #ifdef FORMAT_GZIP
+ if (archiverInfo.Name.CompareNoCase(L"GZip") == 0)
+ archive = new NArchive::NGZip::CHandler;
+ #endif
+
+ #ifdef FORMAT_SPLIT
+ if (archiverInfo.Name.CompareNoCase(L"Split") == 0)
+ archive = new NArchive::NSplit::CHandler;
+ #endif
+
+ #ifdef FORMAT_TAR
+ if (archiverInfo.Name.CompareNoCase(L"Tar") == 0)
+ archive = new NArchive::NTar::CHandler;
+ #endif
+
+ #ifdef FORMAT_ZIP
+ if (archiverInfo.Name.CompareNoCase(L"Zip") == 0)
+ archive = new NArchive::NZip::CHandler;
+ #endif
+
+ #ifdef FORMAT_Z
+ if (archiverInfo.Name.CompareNoCase(L"Z") == 0)
+ archive = new NArchive::NZ::CHandler;
+ #endif
+
+
+ #ifndef EXCLUDE_COM
+ if (!archive)
+ {
+ HRESULT result = loader.CreateHandler(archiverInfo.FilePath,
+ archiverInfo.ClassID, (void **)&archive, false);
+ if (result != S_OK)
+ continue;
+ }
+ #endif
+
+ if (!archive)
+ return E_FAIL;
+
+ HRESULT result = archive->Open(inStream, &kMaxCheckStartPosition, openArchiveCallback);
+ if(result == S_FALSE)
+ continue;
+ if(result != S_OK)
+ {
+ badResult = result;
+ if(result == E_ABORT)
+ break;
+ continue;
+ }
+ *archiveResult = archive.Detach();
+ #ifndef EXCLUDE_COM
+ *module = loader.Detach();
+ #endif
+ archiverInfoResult = archiverInfo;
+ int subExtIndex = archiverInfo.FindExtension(extension);
+ if (subExtIndex < 0)
+ subExtIndex = 0;
+ defaultItemName = GetDefaultName2(fileName,
+ archiverInfo.Extensions[subExtIndex].Ext,
+ archiverInfo.Extensions[subExtIndex].AddExt);
+
+ return S_OK;
+ }
+ if (badResult != S_OK)
+ return badResult;
+ return S_FALSE;
+}
+
+HRESULT OpenArchive(const UString &filePath,
+ #ifndef EXCLUDE_COM
+ HMODULE *module,
+ #endif
+ IInArchive **archiveResult,
+ CArchiverInfo &archiverInfo,
+ UString &defaultItemName,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ CInFileStream *inStreamSpec = new CInFileStream;
+ CMyComPtr<IInStream> inStream(inStreamSpec);
+ if (!inStreamSpec->Open(filePath))
+ return GetLastError();
+ return OpenArchive(inStream, ExtractFileNameFromPath(filePath),
+ #ifndef EXCLUDE_COM
+ module,
+ #endif
+ archiveResult, archiverInfo,
+ defaultItemName, openArchiveCallback);
+}
+
+static void MakeDefaultName(UString &name)
+{
+ int dotPos = name.ReverseFind(L'.');
+ if (dotPos < 0)
+ return;
+ UString ext = name.Mid(dotPos + 1);
+ if (ext.IsEmpty())
+ return;
+ for (int pos = 0; pos < ext.Length(); pos++)
+ if (ext[pos] < L'0' || ext[pos] > L'9')
+ return;
+ name = name.Left(dotPos);
+}
+
+HRESULT OpenArchive(const UString &fileName,
+ #ifndef EXCLUDE_COM
+ HMODULE *module0,
+ HMODULE *module1,
+ #endif
+ IInArchive **archive0,
+ IInArchive **archive1,
+ CArchiverInfo &archiverInfo0,
+ CArchiverInfo &archiverInfo1,
+ UString &defaultItemName0,
+ UString &defaultItemName1,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ HRESULT result = OpenArchive(fileName,
+ #ifndef EXCLUDE_COM
+ module0,
+ #endif
+ archive0, archiverInfo0, defaultItemName0, openArchiveCallback);
+ RINOK(result);
+ CMyComPtr<IInArchiveGetStream> getStream;
+ result = (*archive0)->QueryInterface(IID_IInArchiveGetStream, (void **)&getStream);
+ if (result != S_OK || getStream == 0)
+ return S_OK;
+
+ CMyComPtr<ISequentialInStream> subSeqStream;
+ result = getStream->GetStream(0, &subSeqStream);
+ if (result != S_OK)
+ return S_OK;
+
+ CMyComPtr<IInStream> subStream;
+ if (subSeqStream.QueryInterface(IID_IInStream, &subStream) != S_OK)
+ return S_OK;
+ if (!subStream)
+ return S_OK;
+
+ UInt32 numItems;
+ RINOK((*archive0)->GetNumberOfItems(&numItems));
+ if (numItems < 1)
+ return S_OK;
+
+ UString subPath;
+ RINOK(GetArchiveItemPath(*archive0, 0, subPath))
+ if (subPath.IsEmpty())
+ {
+ MakeDefaultName(defaultItemName0);
+ subPath = defaultItemName0;
+ if (archiverInfo0.Name.CompareNoCase(L"7z") == 0)
+ {
+ if (subPath.Right(3).CompareNoCase(L".7z") != 0)
+ subPath += L".7z";
+ }
+ }
+ else
+ subPath = ExtractFileNameFromPath(subPath);
+
+ CMyComPtr<IArchiveOpenSetSubArchiveName> setSubArchiveName;
+ openArchiveCallback->QueryInterface(IID_IArchiveOpenSetSubArchiveName, (void **)&setSubArchiveName);
+ if (setSubArchiveName)
+ setSubArchiveName->SetSubArchiveName(subPath);
+
+ result = OpenArchive(subStream, subPath,
+ #ifndef EXCLUDE_COM
+ module1,
+ #endif
+ archive1, archiverInfo1, defaultItemName1, openArchiveCallback);
+ return S_OK;
+}
+
+HRESULT MyOpenArchive(const UString &archiveName,
+ #ifndef EXCLUDE_COM
+ HMODULE *module,
+ #endif
+ IInArchive **archive,
+ UString &defaultItemName,
+ IOpenCallbackUI *openCallbackUI)
+{
+ COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
+ CMyComPtr<IArchiveOpenCallback> openCallback = openCallbackSpec;
+ openCallbackSpec->Callback = openCallbackUI;
+
+ UString fullName;
+ int fileNamePartStartIndex;
+ NFile::NDirectory::MyGetFullPathName(archiveName, fullName, fileNamePartStartIndex);
+ openCallbackSpec->Init(
+ fullName.Left(fileNamePartStartIndex),
+ fullName.Mid(fileNamePartStartIndex));
+
+ CArchiverInfo archiverInfo;
+ return OpenArchive(archiveName,
+ #ifndef EXCLUDE_COM
+ module,
+ #endif
+ archive,
+ archiverInfo,
+ defaultItemName,
+ openCallback);
+}
+
+HRESULT MyOpenArchive(const UString &archiveName,
+ #ifndef EXCLUDE_COM
+ HMODULE *module0,
+ HMODULE *module1,
+ #endif
+ IInArchive **archive0,
+ IInArchive **archive1,
+ UString &defaultItemName0,
+ UString &defaultItemName1,
+ UStringVector &volumePaths,
+ IOpenCallbackUI *openCallbackUI)
+{
+ COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
+ CMyComPtr<IArchiveOpenCallback> openCallback = openCallbackSpec;
+ openCallbackSpec->Callback = openCallbackUI;
+
+ UString fullName;
+ int fileNamePartStartIndex;
+ NFile::NDirectory::MyGetFullPathName(archiveName, fullName, fileNamePartStartIndex);
+ UString prefix = fullName.Left(fileNamePartStartIndex);
+ UString name = fullName.Mid(fileNamePartStartIndex);
+ openCallbackSpec->Init(prefix, name);
+
+ CArchiverInfo archiverInfo0, archiverInfo1;
+ HRESULT result = OpenArchive(archiveName,
+ #ifndef EXCLUDE_COM
+ module0,
+ module1,
+ #endif
+ archive0,
+ archive1,
+ archiverInfo0,
+ archiverInfo1,
+ defaultItemName0,
+ defaultItemName1,
+ openCallback);
+ RINOK(result);
+ volumePaths.Add(prefix + name);
+ for (int i = 0; i < openCallbackSpec->FileNames.Size(); i++)
+ volumePaths.Add(prefix + openCallbackSpec->FileNames[i]);
+ return S_OK;
+}
+
+HRESULT CArchiveLink::Close()
+{
+ if (Archive1 != 0)
+ RINOK(Archive1->Close());
+ if (Archive0 != 0)
+ RINOK(Archive0->Close());
+ return S_OK;
+}
+
+void CArchiveLink::Release()
+{
+ if (Archive1 != 0)
+ Archive1.Release();
+ if (Archive0 != 0)
+ Archive0.Release();
+ #ifndef EXCLUDE_COM
+ Library1.Free();
+ Library0.Free();
+ #endif
+}
+
+HRESULT OpenArchive(const UString &archiveName,
+ CArchiveLink &archiveLink,
+ IArchiveOpenCallback *openCallback)
+{
+ return OpenArchive(archiveName,
+ #ifndef EXCLUDE_COM
+ &archiveLink.Library0, &archiveLink.Library1,
+ #endif
+ &archiveLink.Archive0, &archiveLink.Archive1,
+ archiveLink.ArchiverInfo0, archiveLink.ArchiverInfo1,
+ archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
+ openCallback);
+}
+
+HRESULT MyOpenArchive(const UString &archiveName,
+ CArchiveLink &archiveLink,
+ IOpenCallbackUI *openCallbackUI)
+{
+ return MyOpenArchive(archiveName,
+ #ifndef EXCLUDE_COM
+ &archiveLink.Library0, &archiveLink.Library1,
+ #endif
+ &archiveLink.Archive0, &archiveLink.Archive1,
+ archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
+ archiveLink.VolumePaths,
+ openCallbackUI);
+}
+
+HRESULT ReOpenArchive(CArchiveLink &archiveLink,
+ const UString &fileName)
+{
+ if (archiveLink.GetNumLevels() > 1)
+ return E_NOTIMPL;
+ if (archiveLink.GetNumLevels() == 0)
+ return MyOpenArchive(fileName, archiveLink, 0);
+ return ReOpenArchive(archiveLink.GetArchive(), fileName);
+}
diff --git a/7zip/UI/Common/OpenArchive.h b/CPP/7zip/UI/Common/OpenArchive.h
index f96b1ebf..f96b1ebf 100755
--- a/7zip/UI/Common/OpenArchive.h
+++ b/CPP/7zip/UI/Common/OpenArchive.h
diff --git a/7zip/UI/Common/PropIDUtils.cpp b/CPP/7zip/UI/Common/PropIDUtils.cpp
index 8869e565..8869e565 100755
--- a/7zip/UI/Common/PropIDUtils.cpp
+++ b/CPP/7zip/UI/Common/PropIDUtils.cpp
diff --git a/7zip/UI/Common/PropIDUtils.h b/CPP/7zip/UI/Common/PropIDUtils.h
index aa540885..aa540885 100755
--- a/7zip/UI/Common/PropIDUtils.h
+++ b/CPP/7zip/UI/Common/PropIDUtils.h
diff --git a/7zip/UI/Common/Property.h b/CPP/7zip/UI/Common/Property.h
index 57e7b452..57e7b452 100755
--- a/7zip/UI/Common/Property.h
+++ b/CPP/7zip/UI/Common/Property.h
diff --git a/7zip/UI/Common/SetProperties.cpp b/CPP/7zip/UI/Common/SetProperties.cpp
index 6c92a847..6c92a847 100755
--- a/7zip/UI/Common/SetProperties.cpp
+++ b/CPP/7zip/UI/Common/SetProperties.cpp
diff --git a/7zip/UI/Common/SetProperties.h b/CPP/7zip/UI/Common/SetProperties.h
index 892f1a21..892f1a21 100755
--- a/7zip/UI/Common/SetProperties.h
+++ b/CPP/7zip/UI/Common/SetProperties.h
diff --git a/CPP/7zip/UI/Common/SortUtils.cpp b/CPP/7zip/UI/Common/SortUtils.cpp
new file mode 100755
index 00000000..c0111581
--- /dev/null
+++ b/CPP/7zip/UI/Common/SortUtils.cpp
@@ -0,0 +1,78 @@
+// SortUtils.cpp
+
+#include "StdAfx.h"
+
+#include "SortUtils.h"
+#include "Common/Types.h"
+
+/*
+template <class T>
+void TSortRefDown(T *p, UInt32 k, UInt32 size, int (*compare)(const T*, const T*, void *), void *param)
+{
+ T temp = p[k];
+ for (;;)
+ {
+ UInt32 s = (k << 1);
+ if (s > size)
+ break;
+ if (s < size && compare(p + s + 1, p + s, param) > 0)
+ s++;
+ if (compare(&temp, p + s, param) >= 0)
+ break;
+ p[k] = p[s];
+ k = s;
+ }
+ p[k] = temp;
+}
+
+template <class T>
+void TSort(T* p, UInt32 size, int (*compare)(const T*, const T*, void *), void *param)
+{
+ if (size <= 1)
+ return;
+ p--;
+ {
+ UInt32 i = size / 2;
+ do
+ TSortRefDown(p, i, size, compare, param);
+ while(--i != 0);
+ }
+ do
+ {
+ T temp = p[size];
+ p[size--] = p[1];
+ p[1] = temp;
+ TSortRefDown(p, 1, size, compare, param);
+ }
+ while (size > 1);
+}
+*/
+
+static int CompareStrings(const int *p1, const int *p2, void *param)
+{
+ const UStringVector &strings = *(const UStringVector *)param;
+ const UString &s1 = strings[*p1];
+ const UString &s2 = strings[*p2];
+ return s1.CompareNoCase(s2);
+}
+
+void SortStringsToIndices(const UStringVector &strings, CIntVector &indices)
+{
+ indices.Clear();
+ int numItems = strings.Size();
+ indices.Reserve(numItems);
+ for(int i = 0; i < numItems; i++)
+ indices.Add(i);
+ indices.Sort(CompareStrings, (void *)&strings);
+ // TSort(&indices.Front(), indices.Size(), CompareStrings, (void *)&strings);
+}
+
+void SortStrings(const UStringVector &src, UStringVector &dest)
+{
+ CIntVector indices;
+ SortStringsToIndices(src, indices);
+ dest.Clear();
+ dest.Reserve(indices.Size());
+ for (int i = 0; i < indices.Size(); i++)
+ dest.Add(src[indices[i]]);
+}
diff --git a/7zip/UI/Common/SortUtils.h b/CPP/7zip/UI/Common/SortUtils.h
index 5b9af264..5b9af264 100755
--- a/7zip/UI/Common/SortUtils.h
+++ b/CPP/7zip/UI/Common/SortUtils.h
diff --git a/7zip/UI/Common/StdAfx.h b/CPP/7zip/UI/Common/StdAfx.h
index 100f4344..100f4344 100755
--- a/7zip/UI/Common/StdAfx.h
+++ b/CPP/7zip/UI/Common/StdAfx.h
diff --git a/7zip/UI/Common/TempFiles.cpp b/CPP/7zip/UI/Common/TempFiles.cpp
index 3e604aea..3e604aea 100755
--- a/7zip/UI/Common/TempFiles.cpp
+++ b/CPP/7zip/UI/Common/TempFiles.cpp
diff --git a/7zip/UI/Common/TempFiles.h b/CPP/7zip/UI/Common/TempFiles.h
index 173713a0..173713a0 100755
--- a/7zip/UI/Common/TempFiles.h
+++ b/CPP/7zip/UI/Common/TempFiles.h
diff --git a/7zip/UI/Common/Update.cpp b/CPP/7zip/UI/Common/Update.cpp
index cd7975d0..cd7975d0 100755
--- a/7zip/UI/Common/Update.cpp
+++ b/CPP/7zip/UI/Common/Update.cpp
diff --git a/7zip/UI/Common/Update.h b/CPP/7zip/UI/Common/Update.h
index 465acc24..465acc24 100755
--- a/7zip/UI/Common/Update.h
+++ b/CPP/7zip/UI/Common/Update.h
diff --git a/7zip/UI/Common/UpdateAction.cpp b/CPP/7zip/UI/Common/UpdateAction.cpp
index 5e3b5a10..5e3b5a10 100755
--- a/7zip/UI/Common/UpdateAction.cpp
+++ b/CPP/7zip/UI/Common/UpdateAction.cpp
diff --git a/7zip/UI/Common/UpdateAction.h b/CPP/7zip/UI/Common/UpdateAction.h
index aa050975..aa050975 100755
--- a/7zip/UI/Common/UpdateAction.h
+++ b/CPP/7zip/UI/Common/UpdateAction.h
diff --git a/7zip/UI/Common/UpdateCallback.cpp b/CPP/7zip/UI/Common/UpdateCallback.cpp
index db3bf805..db3bf805 100755
--- a/7zip/UI/Common/UpdateCallback.cpp
+++ b/CPP/7zip/UI/Common/UpdateCallback.cpp
diff --git a/7zip/UI/Common/UpdateCallback.h b/CPP/7zip/UI/Common/UpdateCallback.h
index 8b14a9dc..8b14a9dc 100755
--- a/7zip/UI/Common/UpdateCallback.h
+++ b/CPP/7zip/UI/Common/UpdateCallback.h
diff --git a/7zip/UI/Common/UpdatePair.cpp b/CPP/7zip/UI/Common/UpdatePair.cpp
index dd51646f..dd51646f 100755
--- a/7zip/UI/Common/UpdatePair.cpp
+++ b/CPP/7zip/UI/Common/UpdatePair.cpp
diff --git a/7zip/UI/Common/UpdatePair.h b/CPP/7zip/UI/Common/UpdatePair.h
index f50a23f8..f50a23f8 100755
--- a/7zip/UI/Common/UpdatePair.h
+++ b/CPP/7zip/UI/Common/UpdatePair.h
diff --git a/7zip/UI/Common/UpdateProduce.cpp b/CPP/7zip/UI/Common/UpdateProduce.cpp
index 992bbeec..992bbeec 100755
--- a/7zip/UI/Common/UpdateProduce.cpp
+++ b/CPP/7zip/UI/Common/UpdateProduce.cpp
diff --git a/7zip/UI/Common/UpdateProduce.h b/CPP/7zip/UI/Common/UpdateProduce.h
index 8f58dab9..8f58dab9 100755
--- a/7zip/UI/Common/UpdateProduce.h
+++ b/CPP/7zip/UI/Common/UpdateProduce.h
diff --git a/7zip/UI/Common/WorkDir.cpp b/CPP/7zip/UI/Common/WorkDir.cpp
index 8db6f4f1..8db6f4f1 100755
--- a/7zip/UI/Common/WorkDir.cpp
+++ b/CPP/7zip/UI/Common/WorkDir.cpp
diff --git a/7zip/UI/Common/WorkDir.h b/CPP/7zip/UI/Common/WorkDir.h
index 0643d67a..0643d67a 100755
--- a/7zip/UI/Common/WorkDir.h
+++ b/CPP/7zip/UI/Common/WorkDir.h
diff --git a/7zip/UI/Common/ZipRegistry.cpp b/CPP/7zip/UI/Common/ZipRegistry.cpp
index e449d6b4..e449d6b4 100755
--- a/7zip/UI/Common/ZipRegistry.cpp
+++ b/CPP/7zip/UI/Common/ZipRegistry.cpp
diff --git a/7zip/UI/Common/ZipRegistry.h b/CPP/7zip/UI/Common/ZipRegistry.h
index 30e7ee44..30e7ee44 100755
--- a/7zip/UI/Common/ZipRegistry.h
+++ b/CPP/7zip/UI/Common/ZipRegistry.h
diff --git a/7zip/UI/Console/Console.dsp b/CPP/7zip/UI/Console/Console.dsp
index e457008c..e457008c 100755
--- a/7zip/UI/Console/Console.dsp
+++ b/CPP/7zip/UI/Console/Console.dsp
diff --git a/7zip/UI/Console/Console.dsw b/CPP/7zip/UI/Console/Console.dsw
index 0d93da2f..0d93da2f 100755
--- a/7zip/UI/Console/Console.dsw
+++ b/CPP/7zip/UI/Console/Console.dsw
diff --git a/7zip/UI/Console/ConsoleClose.cpp b/CPP/7zip/UI/Console/ConsoleClose.cpp
index a514c12a..a514c12a 100755
--- a/7zip/UI/Console/ConsoleClose.cpp
+++ b/CPP/7zip/UI/Console/ConsoleClose.cpp
diff --git a/7zip/UI/Console/ConsoleClose.h b/CPP/7zip/UI/Console/ConsoleClose.h
index 3c5fd55d..3c5fd55d 100755
--- a/7zip/UI/Console/ConsoleClose.h
+++ b/CPP/7zip/UI/Console/ConsoleClose.h
diff --git a/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
new file mode 100755
index 00000000..9bd605ec
--- /dev/null
+++ b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
@@ -0,0 +1,235 @@
+// ExtractCallbackConsole.h
+
+#include "StdAfx.h"
+
+#include "ExtractCallbackConsole.h"
+#include "UserInputUtils.h"
+#include "ConsoleClose.h"
+
+#include "Common/Wildcard.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/Time.h"
+#include "Windows/Defs.h"
+#include "Windows/PropVariant.h"
+#include "Windows/Error.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../Common/FilePathAutoRename.h"
+
+#include "../Common/ExtractingFilePath.h"
+
+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 *kCantAutoRename = "can not create file with auto name\n";
+static const char *kCantRenameFile = "can not rename existing file\n";
+static const char *kCantDeleteOutputFile = "can not delete output file ";
+static const char *kError = "ERROR: ";
+static const char *kMemoryExceptionMessage = "Can't allocate required memory!";
+
+static const char *kProcessing = "Processing archive: ";
+static const char *kEverythingIsOk = "Everything is Ok";
+static const char *kNoFiles = "No files to process";
+
+static const char *kUnsupportedMethod = "Unsupported Method";
+static const char *kCrcFailed = "CRC Failed";
+static const char *kCrcFailedEncrypted = "CRC Failed in encrypted file. Wrong password?";
+static const char *kDataError = "Data Error";
+static const char *kDataErrorEncrypted = "Data Error in encrypted file. Wrong password?";
+static const char *kUnknownError = "Unknown Error";
+
+STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
+ const wchar_t *existName, const FILETIME *, const UInt64 *,
+ const wchar_t *newName, const FILETIME *, const UInt64 *,
+ Int32 *answer)
+{
+ (*OutStream) << "file " << existName <<
+ "\nalready exists. Overwrite with " << endl;
+ (*OutStream) << newName;
+
+ NUserAnswerMode::EEnum overwriteAnswer = ScanUserYesNoAllQuit(OutStream);
+
+ 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;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 askExtractMode, const UInt64 *position)
+{
+ 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;
+ };
+ (*OutStream) << name;
+ if (position != 0)
+ (*OutStream) << " <" << *position << ">";
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
+{
+ (*OutStream) << message << endl;
+ NumFileErrorsInCurrentArchive++;
+ NumFileErrors++;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 operationResult, bool encrypted)
+{
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kOK:
+ break;
+ default:
+ {
+ NumFileErrorsInCurrentArchive++;
+ NumFileErrors++;
+ (*OutStream) << " ";
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
+ (*OutStream) << kUnsupportedMethod;
+ break;
+ case NArchive::NExtract::NOperationResult::kCRCError:
+ (*OutStream) << (encrypted ? kCrcFailedEncrypted: kCrcFailed);
+ break;
+ case NArchive::NExtract::NOperationResult::kDataError:
+ (*OutStream) << (encrypted ? kDataErrorEncrypted : kDataError);
+ break;
+ default:
+ (*OutStream) << kUnknownError;
+ }
+ }
+ }
+ (*OutStream) << endl;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
+{
+ if (!PasswordIsDefined)
+ {
+ Password = GetPassword(OutStream);
+ PasswordIsDefined = true;
+ }
+ CMyComBSTR tempName(Password);
+ *password = tempName.Detach();
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name)
+{
+ NumArchives++;
+ NumFileErrorsInCurrentArchive = 0;
+ (*OutStream) << endl << kProcessing << name << endl;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::OpenResult(const wchar_t * /* name */, HRESULT result, bool encrypted)
+{
+ (*OutStream) << endl;
+ if (result != S_OK)
+ {
+ (*OutStream) << "Error: ";
+ if (encrypted)
+ (*OutStream) << "Can not open encrypted archive. Wrong password?";
+ else
+ (*OutStream) << "Can not open file as archive";
+ (*OutStream) << endl;
+ NumArchiveErrors++;
+ }
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::ThereAreNoFiles()
+{
+ (*OutStream) << endl << kNoFiles << endl;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
+{
+ if (result == S_OK)
+ {
+ (*OutStream) << endl;
+ if (NumFileErrorsInCurrentArchive == 0)
+ (*OutStream) << kEverythingIsOk << endl;
+ else
+ {
+ NumArchiveErrors++;
+ (*OutStream) << "Sub items Errors: " << NumFileErrorsInCurrentArchive << endl;
+ }
+ }
+ if (result == S_OK)
+ return result;
+ NumArchiveErrors++;
+ if (result == E_ABORT || result == ERROR_DISK_FULL)
+ return result;
+ (*OutStream) << endl << kError;
+ if (result == E_OUTOFMEMORY)
+ (*OutStream) << kMemoryExceptionMessage;
+ else
+ {
+ UString message;
+ NError::MyFormatMessage(result, message);
+ (*OutStream) << message;
+ }
+ (*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
new file mode 100755
index 00000000..5b45106a
--- /dev/null
+++ b/CPP/7zip/UI/Console/ExtractCallbackConsole.h
@@ -0,0 +1,65 @@
+// ExtractCallbackConsole.h
+
+#ifndef __EXTRACTCALLBACKCONSOLE_H
+#define __EXTRACTCALLBACKCONSOLE_H
+
+#include "Common/String.h"
+#include "Common/StdOutStream.h"
+#include "../../Common/FileStreams.h"
+#include "../../IPassword.h"
+#include "../../Archive/IArchive.h"
+#include "../Common/ArchiveExtractCallback.h"
+
+class CExtractCallbackConsole:
+ public IExtractCallbackUI,
+ public ICryptoGetTextPassword,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP2(IFolderArchiveExtractCallback, ICryptoGetTextPassword)
+
+ STDMETHOD(SetTotal)(UInt64 total);
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue);
+
+ // IFolderArchiveExtractCallback
+ STDMETHOD(AskOverwrite)(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer);
+ STDMETHOD (PrepareOperation)(const wchar_t *name, Int32 askExtractMode, const UInt64 *position);
+
+ 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);
+
+ HRESULT SetPassword(const UString &password);
+
+public:
+ bool PasswordIsDefined;
+ UString Password;
+
+ UInt64 NumArchives;
+ UInt64 NumArchiveErrors;
+ UInt64 NumFileErrors;
+ UInt64 NumFileErrorsInCurrentArchive;
+
+ CStdOutStream *OutStream;
+
+ void Init()
+ {
+ NumArchives = 0;
+ NumArchiveErrors = 0;
+ NumFileErrors = 0;
+ NumFileErrorsInCurrentArchive = 0;
+ }
+
+};
+
+#endif
diff --git a/7zip/UI/Console/List.cpp b/CPP/7zip/UI/Console/List.cpp
index 6001e114..6001e114 100755
--- a/7zip/UI/Console/List.cpp
+++ b/CPP/7zip/UI/Console/List.cpp
diff --git a/7zip/UI/Console/List.h b/CPP/7zip/UI/Console/List.h
index 201a4128..201a4128 100755
--- a/7zip/UI/Console/List.h
+++ b/CPP/7zip/UI/Console/List.h
diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp
new file mode 100755
index 00000000..387b8c2a
--- /dev/null
+++ b/CPP/7zip/UI/Console/Main.cpp
@@ -0,0 +1,382 @@
+// Main.cpp
+
+#include "StdAfx.h"
+
+#include <io.h>
+
+#include "Common/MyInitGuid.h"
+#include "Common/CommandLineParser.h"
+#include "Common/StdOutStream.h"
+#include "Common/Wildcard.h"
+#include "Common/ListFileUtils.h"
+#include "Common/StringConvert.h"
+#include "Common/StdInStream.h"
+#include "Common/StringToInt.h"
+#include "Common/Exception.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+#include "Windows/Defs.h"
+#include "Windows/Error.h"
+// #include "Windows/System.h"
+#ifdef _WIN32
+#include "Windows/MemoryLock.h"
+#endif
+
+#include "../../IPassword.h"
+#include "../../ICoder.h"
+#include "../Common/ArchiverInfo.h"
+#include "../Common/UpdateAction.h"
+#include "../Common/Update.h"
+#include "../Common/Extract.h"
+#include "../Common/ArchiveCommandLine.h"
+#include "../Common/ExitCode.h"
+
+#include "List.h"
+#include "OpenCallbackConsole.h"
+#include "ExtractCallbackConsole.h"
+#include "UpdateCallbackConsole.h"
+
+#include "../../MyVersion.h"
+
+#ifndef EXCLUDE_COM
+#include "Windows/DLL.h"
+#endif
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NCommandLineParser;
+
+HINSTANCE g_hInstance = 0;
+extern CStdOutStream *g_StdStream;
+
+static const char *kCopyrightString = "\n7-Zip"
+#ifdef EXCLUDE_COM
+" (A)"
+#endif
+
+#ifdef UNICODE
+" [NT]"
+#endif
+
+" " MY_VERSION_COPYRIGHT_DATE "\n";
+
+static const char *kHelpString =
+ "\nUsage: 7z"
+#ifdef _NO_CRYPTO
+ "r"
+#elif EXCLUDE_COM
+ "a"
+#endif
+ " <command> [<switches>...] <archive_name> [<file_names>...]\n"
+ " [<@listfiles...>]\n"
+ "\n"
+ "<Commands>\n"
+ " a: Add files to archive\n"
+ " d: Delete files from archive\n"
+ " e: Extract files from archive (without using directory names)\n"
+ " l: List contents of archive\n"
+// " l[a|t][f]: List contents of archive\n"
+// " a - with Additional fields\n"
+// " t - with all fields\n"
+// " f - with Full pathnames\n"
+ " t: Test integrity of archive\n"
+ " u: Update files to archive\n"
+ " x: eXtract files with full paths\n"
+ "<Switches>\n"
+ " -ai[r[-|0]]{@listfile|!wildcard}: Include archives\n"
+ " -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives\n"
+ " -bd: Disable percentage indicator\n"
+ " -i[r[-|0]]{@listfile|!wildcard}: Include filenames\n"
+ " -m{Parameters}: set compression Method\n"
+ " -o{Directory}: set Output directory\n"
+ " -p{Password}: set Password\n"
+ " -r[-|0]: Recurse subdirectories\n"
+ " -scs{UTF-8 | WIN | DOS}: set charset for list files\n"
+ " -sfx[{name}]: Create SFX archive\n"
+ " -si[{name}]: read data from stdin\n"
+ " -slt: show technical information for l (List) command\n"
+ " -so: write data to stdout\n"
+ " -t{Type}: Set type of archive\n"
+ " -v{Size}[b|k|m|g]: Create volumes\n"
+ " -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options\n"
+ " -w[{path}]: assign Work directory. Empty path means a temporary directory\n"
+ " -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames\n"
+ " -y: assume Yes on all queries\n";
+
+// ---------------------------
+// exception messages
+
+static const char *kProcessArchiveMessage = " archive: ";
+static const char *kEverythingIsOk = "Everything is Ok";
+static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode::kUserError
+
+static const wchar_t *kDefaultSfxModule = L"7zCon.sfx";
+
+static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExitCode::EEnum code)
+{
+ s << message << endl;
+ throw code;
+}
+
+static void PrintHelpAndExit(CStdOutStream &s) // yyy
+{
+ s << kHelpString;
+ ShowMessageAndThrowException(s, kUserErrorMessage, NExitCode::kUserError);
+}
+
+#ifndef _WIN32
+static void GetArguments(int numArguments, const char *arguments[], UStringVector &parts)
+{
+ parts.Clear();
+ for(int i = 0; i < numArguments; i++)
+ {
+ UString s = MultiByteToUnicodeString(arguments[i]);
+ parts.Add(s);
+ }
+}
+#endif
+
+static void ShowCopyrightAndHelp(CStdOutStream &s, bool needHelp)
+{
+ s << kCopyrightString;
+ /*
+ UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
+ s << "System configuration: " << (UInt64)numCPUs << " CPU";
+ if (numCPUs > 1)
+ s << "s";
+ s << "\n";
+ */
+ if (needHelp)
+ s << kHelpString;
+}
+
+int Main2(
+ #ifndef _WIN32
+ int numArguments, const char *arguments[]
+ #endif
+)
+{
+ #ifdef _WIN32
+ SetFileApisToOEM();
+ #endif
+
+ UStringVector commandStrings;
+ #ifdef _WIN32
+ NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
+ #else
+ GetArguments(numArguments, arguments, commandStrings);
+ #endif
+
+ if(commandStrings.Size() == 1)
+ {
+ ShowCopyrightAndHelp(g_StdOut, true);
+ return 0;
+ }
+ commandStrings.Delete(0);
+
+ CArchiveCommandLineOptions options;
+
+ CArchiveCommandLineParser parser;
+
+ parser.Parse1(commandStrings, options);
+
+ if(options.HelpMode)
+ {
+ ShowCopyrightAndHelp(g_StdOut, true);
+ return 0;
+ }
+
+ #ifdef _WIN32
+ if (options.LargePages)
+ NSecurity::EnableLockMemoryPrivilege();
+ #endif
+
+ CStdOutStream &stdStream = options.StdOutMode ? g_StdErr : g_StdOut;
+ g_StdStream = &stdStream;
+
+ if (options.EnableHeaders)
+ ShowCopyrightAndHelp(stdStream, false);
+
+ parser.Parse2(options);
+
+ bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
+ if(isExtractGroupCommand ||
+ options.Command.CommandType == NCommandType::kList)
+ {
+ if(isExtractGroupCommand)
+ {
+ CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
+ CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
+
+ ecs->OutStream = &stdStream;
+ ecs->PasswordIsDefined = options.PasswordEnabled;
+ ecs->Password = options.Password;
+ ecs->Init();
+
+ COpenCallbackConsole openCallback;
+ openCallback.OutStream = &stdStream;
+ openCallback.PasswordIsDefined = options.PasswordEnabled;
+ openCallback.Password = options.Password;
+
+ CExtractOptions eo;
+ eo.StdOutMode = options.StdOutMode;
+ eo.PathMode = options.Command.GetPathMode();
+ eo.TestMode = options.Command.IsTestMode();
+ eo.OverwriteMode = options.OverwriteMode;
+ eo.OutputDir = options.OutputDir;
+ eo.YesToAll = options.YesToAll;
+ #ifdef COMPRESS_MT
+ eo.Properties = options.ExtractProperties;
+ #endif
+ UString errorMessage;
+ HRESULT result = DecompressArchives(
+ options.ArchivePathsSorted,
+ options.ArchivePathsFullSorted,
+ options.WildcardCensor.Pairs.Front().Head,
+ eo, &openCallback, ecs, errorMessage);
+ if (!errorMessage.IsEmpty())
+ {
+ stdStream << endl << "Error: " << errorMessage;
+ if (result == S_OK)
+ result = E_FAIL;
+ }
+
+ if (ecs->NumArchives > 1)
+ {
+ stdStream << endl << endl << "Total:" << endl;
+ stdStream << "Archives: " << ecs->NumArchives << endl;
+ }
+ if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
+ {
+ if (ecs->NumArchives > 1)
+ {
+ if (ecs->NumArchiveErrors != 0)
+ stdStream << "Archive Errors: " << ecs->NumArchiveErrors << endl;
+ if (ecs->NumFileErrors != 0)
+ stdStream << "Sub items Errors: " << ecs->NumFileErrors << endl;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ return NExitCode::kFatalError;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ }
+ else
+ {
+ HRESULT result = ListArchives(
+ options.ArchivePathsSorted,
+ options.ArchivePathsFullSorted,
+ options.WildcardCensor.Pairs.Front().Head,
+ options.EnableHeaders,
+ options.TechMode,
+ options.PasswordEnabled,
+ options.Password);
+ if (result != S_OK)
+ throw CSystemException(result);
+ }
+ }
+ else if(options.Command.IsFromUpdateGroup())
+ {
+ UString workingDir;
+
+ CUpdateOptions &uo = options.UpdateOptions;
+ if (uo.SfxMode && uo.SfxModule.IsEmpty())
+ uo.SfxModule = kDefaultSfxModule;
+
+ bool passwordIsDefined =
+ options.PasswordEnabled && !options.Password.IsEmpty();
+
+ COpenCallbackConsole openCallback;
+ openCallback.OutStream = &stdStream;
+ openCallback.PasswordIsDefined = passwordIsDefined;
+ openCallback.Password = options.Password;
+
+ CUpdateCallbackConsole callback;
+ callback.EnablePercents = options.EnablePercents;
+ callback.PasswordIsDefined = passwordIsDefined;
+ callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
+ callback.Password = options.Password;
+ callback.StdOutMode = uo.StdOutMode;
+ callback.Init(&stdStream);
+
+ CUpdateErrorInfo errorInfo;
+
+ HRESULT result = UpdateArchive(options.WildcardCensor, uo,
+ errorInfo, &openCallback, &callback);
+
+ int exitCode = NExitCode::kSuccess;
+ if (callback.CantFindFiles.Size() > 0)
+ {
+ stdStream << endl;
+ stdStream << "WARNINGS for files:" << endl << endl;
+ int numErrors = callback.CantFindFiles.Size();
+ for (int i = 0; i < numErrors; i++)
+ {
+ stdStream << callback.CantFindFiles[i] << " : ";
+ stdStream << NError::MyFormatMessageW(callback.CantFindCodes[i]) << endl;
+ }
+ stdStream << "----------------" << endl;
+ stdStream << "WARNING: Cannot find " << numErrors << " file";
+ if (numErrors > 1)
+ stdStream << "s";
+ stdStream << endl;
+ exitCode = NExitCode::kWarning;
+ }
+
+ if (result != S_OK)
+ {
+ UString message;
+ if (!errorInfo.Message.IsEmpty())
+ {
+ message += errorInfo.Message;
+ message += L"\n";
+ }
+ if (!errorInfo.FileName.IsEmpty())
+ {
+ message += errorInfo.FileName;
+ message += L"\n";
+ }
+ if (!errorInfo.FileName2.IsEmpty())
+ {
+ message += errorInfo.FileName2;
+ message += L"\n";
+ }
+ if (errorInfo.SystemError != 0)
+ {
+ message += NError::MyFormatMessageW(errorInfo.SystemError);
+ message += L"\n";
+ }
+ if (!message.IsEmpty())
+ stdStream << L"\nError:\n" << message;
+ throw CSystemException(result);
+ }
+ int numErrors = callback.FailedFiles.Size();
+ if (numErrors == 0)
+ {
+ if (callback.CantFindFiles.Size() == 0)
+ stdStream << kEverythingIsOk << endl;
+ }
+ else
+ {
+ stdStream << endl;
+ stdStream << "WARNINGS for files:" << endl << endl;
+ for (int i = 0; i < numErrors; i++)
+ {
+ stdStream << callback.FailedFiles[i] << " : ";
+ stdStream << NError::MyFormatMessageW(callback.FailedCodes[i]) << endl;
+ }
+ stdStream << "----------------" << endl;
+ stdStream << "WARNING: Cannot open " << numErrors << " file";
+ if (numErrors > 1)
+ stdStream << "s";
+ stdStream << endl;
+ exitCode = NExitCode::kWarning;
+ }
+ return exitCode;
+ }
+ else
+ PrintHelpAndExit(stdStream);
+ return 0;
+}
diff --git a/CPP/7zip/UI/Console/MainAr.cpp b/CPP/7zip/UI/Console/MainAr.cpp
new file mode 100755
index 00000000..4bdf813a
--- /dev/null
+++ b/CPP/7zip/UI/Console/MainAr.cpp
@@ -0,0 +1,169 @@
+// MainAr.cpp
+
+#include "StdAfx.h"
+
+// #include <locale.h>
+
+#include "Windows/Error.h"
+
+#include "Common/StdOutStream.h"
+#include "Common/NewHandler.h"
+#include "Common/Exception.h"
+#include "Common/StringConvert.h"
+#ifdef _WIN32
+#include "Common/Alloc.h"
+#endif
+
+#include "../Common/ExitCode.h"
+#include "../Common/ArchiveCommandLine.h"
+#include "ConsoleClose.h"
+
+#ifdef CRC_GENERATE_TABLE
+extern "C"
+{
+ #include "../../../../C/7zCrc.h"
+}
+#endif
+
+using namespace NWindows;
+
+CStdOutStream *g_StdStream = 0;
+
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
+
+extern int Main2(
+ #ifndef _WIN32
+ int numArguments, const char *arguments[]
+ #endif
+);
+
+static const char *kExceptionErrorMessage = "\n\nError:\n";
+static const char *kUserBreak = "\nBreak signaled\n";
+
+static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required memory!\n";
+static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n";
+static const char *kInternalExceptionMessage = "\n\nInternal Error #";
+
+static inline bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+
+int
+#ifdef _MSC_VER
+__cdecl
+#endif
+main
+(
+#ifndef _WIN32
+int numArguments, const char *arguments[]
+#endif
+)
+{
+ #ifdef CRC_GENERATE_TABLE
+ CrcGenerateTable();
+ #endif
+ g_StdStream = &g_StdOut;
+ #ifdef _UNICODE
+ if (!IsItWindowsNT())
+ {
+ (*g_StdStream) << "This program requires Windows NT/2000/XP/2003";
+ return NExitCode::kFatalError;
+ }
+ #else
+ g_IsNT = IsItWindowsNT();
+ #endif
+
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+
+ // setlocale(LC_COLLATE, ".OCP");
+ NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
+ int res = 0;
+ try
+ {
+ res = Main2(
+#ifndef _WIN32
+ numArguments, arguments
+#endif
+ );
+ }
+ catch(const CNewException &)
+ {
+ (*g_StdStream) << kMemoryExceptionMessage;
+ return (NExitCode::kMemoryError);
+ }
+ catch(const NConsoleClose::CCtrlBreakException &)
+ {
+ (*g_StdStream) << endl << kUserBreak;
+ return (NExitCode::kUserBreak);
+ }
+ catch(const CArchiveCommandLineException &e)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << e << endl;
+ return (NExitCode::kUserError);
+ }
+ catch(const CSystemException &systemError)
+ {
+ if (systemError.ErrorCode == E_OUTOFMEMORY)
+ {
+ (*g_StdStream) << kMemoryExceptionMessage;
+ return (NExitCode::kMemoryError);
+ }
+ if (systemError.ErrorCode == E_ABORT)
+ {
+ (*g_StdStream) << endl << kUserBreak;
+ return (NExitCode::kUserBreak);
+ }
+ UString message;
+ NError::MyFormatMessage(systemError.ErrorCode, message);
+ (*g_StdStream) << endl << endl << "System error:" << endl <<
+ message << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(NExitCode::EEnum &exitCode)
+ {
+ (*g_StdStream) << kInternalExceptionMessage << exitCode << endl;
+ return (exitCode);
+ }
+ /*
+ catch(const NExitCode::CMultipleErrors &multipleErrors)
+ {
+ (*g_StdStream) << endl << multipleErrors.NumErrors << " errors" << endl;
+ return (NExitCode::kFatalError);
+ }
+ */
+ catch(const UString &s)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << s << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(const AString &s)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << s << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(const char *s)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << s << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(int t)
+ {
+ (*g_StdStream) << kInternalExceptionMessage << t << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(...)
+ {
+ (*g_StdStream) << kUnknownExceptionMessage;
+ return (NExitCode::kFatalError);
+ }
+ return res;
+}
diff --git a/CPP/7zip/UI/Console/OpenCallbackConsole.cpp b/CPP/7zip/UI/Console/OpenCallbackConsole.cpp
new file mode 100755
index 00000000..06ff165f
--- /dev/null
+++ b/CPP/7zip/UI/Console/OpenCallbackConsole.cpp
@@ -0,0 +1,58 @@
+// OpenCallbackConsole.cpp
+
+#include "StdAfx.h"
+
+#include "OpenCallbackConsole.h"
+
+#include "ConsoleClose.h"
+#include "UserInputUtils.h"
+
+HRESULT COpenCallbackConsole::CheckBreak()
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT COpenCallbackConsole::SetTotal(const UInt64 *, const UInt64 *)
+{
+ return CheckBreak();
+}
+
+HRESULT COpenCallbackConsole::SetCompleted(const UInt64 *, const UInt64 *)
+{
+ return CheckBreak();
+}
+
+HRESULT COpenCallbackConsole::CryptoGetTextPassword(BSTR *password)
+{
+ PasswordWasAsked = true;
+ RINOK(CheckBreak());
+ if (!PasswordIsDefined)
+ {
+ Password = GetPassword(OutStream);
+ PasswordIsDefined = true;
+ }
+ CMyComBSTR temp(Password);
+ *password = temp.Detach();
+ return S_OK;
+}
+
+HRESULT COpenCallbackConsole::GetPasswordIfAny(UString &password)
+{
+ if (PasswordIsDefined)
+ password = Password;
+ return S_OK;
+}
+
+bool COpenCallbackConsole::WasPasswordAsked()
+{
+ return PasswordWasAsked;
+}
+
+void COpenCallbackConsole::ClearPasswordWasAskedFlag()
+{
+ PasswordWasAsked = false;
+}
+
+
diff --git a/CPP/7zip/UI/Console/OpenCallbackConsole.h b/CPP/7zip/UI/Console/OpenCallbackConsole.h
new file mode 100755
index 00000000..db0e9bd8
--- /dev/null
+++ b/CPP/7zip/UI/Console/OpenCallbackConsole.h
@@ -0,0 +1,27 @@
+// OpenCallbackConsole.h
+
+#ifndef __OPENCALLBACKCONSOLE_H
+#define __OPENCALLBACKCONSOLE_H
+
+#include "Common/StdOutStream.h"
+#include "../Common/ArchiveOpenCallback.h"
+
+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();
+
+ CStdOutStream *OutStream;
+ bool PasswordIsDefined;
+ UString Password;
+ bool PasswordWasAsked;
+ COpenCallbackConsole(): PasswordIsDefined(false), PasswordWasAsked(false) {}
+};
+
+#endif
diff --git a/CPP/7zip/UI/Console/PercentPrinter.cpp b/CPP/7zip/UI/Console/PercentPrinter.cpp
new file mode 100755
index 00000000..ec87b5d4
--- /dev/null
+++ b/CPP/7zip/UI/Console/PercentPrinter.cpp
@@ -0,0 +1,90 @@
+// PercentPrinter.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/String.h"
+
+#include "PercentPrinter.h"
+
+const int kPaddingSize = 2;
+const int kPercentsSize = 4;
+const int kMaxExtraSize = kPaddingSize + 32 + kPercentsSize;
+
+static void ClearPrev(char *p, int num)
+{
+ int i;
+ for (i = 0; i < num; i++) *p++ = '\b';
+ for (i = 0; i < num; i++) *p++ = ' ';
+ for (i = 0; i < num; i++) *p++ = '\b';
+ *p = '\0';
+}
+
+void CPercentPrinter::ClosePrint()
+{
+ if (m_NumExtraChars == 0)
+ return;
+ char s[kMaxExtraSize * 3 + 1];
+ ClearPrev(s, m_NumExtraChars);
+ (*OutStream) << s;
+ m_NumExtraChars = 0;
+}
+
+void CPercentPrinter::PrintString(const char *s)
+{
+ ClosePrint();
+ (*OutStream) << s;
+}
+
+void CPercentPrinter::PrintString(const wchar_t *s)
+{
+ ClosePrint();
+ (*OutStream) << s;
+}
+
+void CPercentPrinter::PrintNewLine()
+{
+ ClosePrint();
+ (*OutStream) << "\n";
+}
+
+void CPercentPrinter::RePrintRatio()
+{
+ char s[32];
+ ConvertUInt64ToString(((m_Total == 0) ? 0 : (m_CurValue * 100 / m_Total)), s);
+ int size = (int)strlen(s);
+ s[size++] = '%';
+ s[size] = '\0';
+
+ int extraSize = kPaddingSize + MyMax(size, kPercentsSize);
+ if (extraSize < m_NumExtraChars)
+ extraSize = m_NumExtraChars;
+
+ char fullString[kMaxExtraSize * 3];
+ char *p = fullString;
+ int i;
+ if (m_NumExtraChars == 0)
+ {
+ for (i = 0; i < extraSize; i++)
+ *p++ = ' ';
+ m_NumExtraChars = extraSize;
+ }
+
+ for (i = 0; i < m_NumExtraChars; i++)
+ *p++ = '\b';
+ m_NumExtraChars = extraSize;
+ for (; size < m_NumExtraChars; size++)
+ *p++ = ' ';
+ strcpy(p, s);
+ (*OutStream) << fullString;
+ OutStream->Flush();
+ m_PrevValue = m_CurValue;
+}
+
+void CPercentPrinter::PrintRatio()
+{
+ 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
new file mode 100755
index 00000000..e8b40916
--- /dev/null
+++ b/CPP/7zip/UI/Console/PercentPrinter.h
@@ -0,0 +1,31 @@
+// PercentPrinter.h
+
+#ifndef __PERCENTPRINTER_H
+#define __PERCENTPRINTER_H
+
+#include "Common/Types.h"
+#include "Common/StdOutStream.h"
+
+class CPercentPrinter
+{
+ UInt64 m_MinStepSize;
+ UInt64 m_PrevValue;
+ UInt64 m_CurValue;
+ UInt64 m_Total;
+ int m_NumExtraChars;
+public:
+ CStdOutStream *OutStream;
+
+ 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; }
+ void PrintString(const char *s);
+ void PrintString(const wchar_t *s);
+ void PrintNewLine();
+ void ClosePrint();
+ void RePrintRatio();
+ void PrintRatio();
+};
+
+#endif
diff --git a/CPP/7zip/UI/Console/StdAfx.cpp b/CPP/7zip/UI/Console/StdAfx.cpp
new file mode 100755
index 00000000..d0feea85
--- /dev/null
+++ b/CPP/7zip/UI/Console/StdAfx.cpp
@@ -0,0 +1,3 @@
+// StdAfx.cpp
+
+#include "StdAfx.h"
diff --git a/7zip/UI/Console/StdAfx.h b/CPP/7zip/UI/Console/StdAfx.h
index 8531cc9c..8531cc9c 100755
--- a/7zip/UI/Console/StdAfx.h
+++ b/CPP/7zip/UI/Console/StdAfx.h
diff --git a/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
new file mode 100755
index 00000000..5cbc11c0
--- /dev/null
+++ b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
@@ -0,0 +1,196 @@
+// UpdateCallbackConsole.cpp
+
+#include "StdAfx.h"
+
+#include "UpdateCallbackConsole.h"
+
+#include "Windows/Error.h"
+#ifdef COMPRESS_MT
+#include "Windows/Synchronization.h"
+#endif
+
+#include "ConsoleClose.h"
+#include "UserInputUtils.h"
+
+using namespace NWindows;
+
+#ifdef COMPRESS_MT
+static NSynchronization::CCriticalSection g_CriticalSection;
+#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+#else
+#define MT_LOCK
+#endif
+
+static const wchar_t *kEmptyFileAlias = L"[Content]";
+
+static const char *kCreatingArchiveMessage = "Creating archive ";
+static const char *kUpdatingArchiveMessage = "Updating archive ";
+static const char *kScanningMessage = "Scanning";
+static const char *kNoFilesScannedMessage = "No files scanned";
+static const char *kTotalFilesAddedMessage = "Total files added to archive: ";
+
+
+HRESULT CUpdateCallbackConsole::OpenResult(const wchar_t *name, HRESULT result)
+{
+ (*OutStream) << endl;
+ if (result != S_OK)
+ (*OutStream) << "Error: " << name << " is not supported archive" << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::StartScanning()
+{
+ (*OutStream) << kScanningMessage;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::CanNotFindError(const wchar_t *name, DWORD systemError)
+{
+ CantFindFiles.Add(name);
+ CantFindCodes.Add(systemError);
+ // m_PercentPrinter.ClosePrint();
+ if (!m_WarningsMode)
+ {
+ (*OutStream) << endl << endl;
+ m_PercentPrinter.PrintNewLine();
+ m_WarningsMode = true;
+ }
+ m_PercentPrinter.PrintString(name);
+ m_PercentPrinter.PrintString(": WARNING: ");
+ m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
+ m_PercentPrinter.PrintNewLine();
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::FinishScanning()
+{
+ (*OutStream) << endl << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::StartArchive(const wchar_t *name, bool updating)
+{
+ if(updating)
+ (*OutStream) << kUpdatingArchiveMessage;
+ else
+ (*OutStream) << kCreatingArchiveMessage;
+ if (name != 0)
+ (*OutStream) << name;
+ else
+ (*OutStream) << "StdOut";
+ (*OutStream) << endl << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::FinishArchive()
+{
+ (*OutStream) << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::CheckBreak()
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::Finilize()
+{
+ MT_LOCK
+ if (m_NeedBeClosed)
+ {
+ if (EnablePercents)
+ {
+ m_PercentPrinter.ClosePrint();
+ }
+ if (!StdOutMode && m_NeedNewLine)
+ {
+ m_PercentPrinter.PrintNewLine();
+ m_NeedNewLine = false;
+ }
+ m_NeedBeClosed = false;
+ }
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetTotal(UInt64 size)
+{
+ MT_LOCK
+ if (EnablePercents)
+ m_PercentPrinter.SetTotal(size);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetCompleted(const UInt64 *completeValue)
+{
+ MT_LOCK
+ if (completeValue != NULL)
+ {
+ if (EnablePercents)
+ {
+ m_PercentPrinter.SetRatio(*completeValue);
+ m_PercentPrinter.PrintRatio();
+ m_NeedBeClosed = true;
+ }
+ }
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool isAnti)
+{
+ MT_LOCK
+ if (StdOutMode)
+ return S_OK;
+ if(isAnti)
+ m_PercentPrinter.PrintString("Anti item ");
+ else
+ m_PercentPrinter.PrintString("Compressing ");
+ if (name[0] == 0)
+ name = kEmptyFileAlias;
+ m_PercentPrinter.PrintString(name);
+ if (EnablePercents)
+ m_PercentPrinter.RePrintRatio();
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::OpenFileError(const wchar_t *name, DWORD systemError)
+{
+ MT_LOCK
+ FailedCodes.Add(systemError);
+ FailedFiles.Add(name);
+ // if (systemError == ERROR_SHARING_VIOLATION)
+ {
+ m_PercentPrinter.ClosePrint();
+ m_PercentPrinter.PrintNewLine();
+ m_PercentPrinter.PrintString("WARNING: ");
+ m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
+ return S_FALSE;
+ }
+ // return systemError;
+}
+
+HRESULT CUpdateCallbackConsole::SetOperationResult(Int32 )
+{
+ m_NeedBeClosed = true;
+ m_NeedNewLine = true;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ if (!PasswordIsDefined)
+ {
+ if (AskPassword)
+ {
+ Password = GetPassword(OutStream);
+ PasswordIsDefined = true;
+ }
+ }
+ *passwordIsDefined = BoolToInt(PasswordIsDefined);
+ CMyComBSTR tempName(Password);
+ *password = tempName.Detach();
+ return S_OK;
+}
diff --git a/CPP/7zip/UI/Console/UpdateCallbackConsole.h b/CPP/7zip/UI/Console/UpdateCallbackConsole.h
new file mode 100755
index 00000000..2fcb891b
--- /dev/null
+++ b/CPP/7zip/UI/Console/UpdateCallbackConsole.h
@@ -0,0 +1,75 @@
+// UpdateCallbackConsole.h
+
+#ifndef __UPDATECALLBACKCONSOLE_H
+#define __UPDATECALLBACKCONSOLE_H
+
+#include "Common/String.h"
+#include "Common/StdOutStream.h"
+#include "PercentPrinter.h"
+#include "../Common/Update.h"
+
+class CUpdateCallbackConsole: public IUpdateCallbackUI2
+{
+ CPercentPrinter m_PercentPrinter;
+ bool m_NeedBeClosed;
+ bool m_NeedNewLine;
+
+ bool m_WarningsMode;
+
+ CStdOutStream *OutStream;
+public:
+ bool EnablePercents;
+ bool StdOutMode;
+
+ bool PasswordIsDefined;
+ UString Password;
+ bool AskPassword;
+
+
+ CUpdateCallbackConsole():
+ m_PercentPrinter(1 << 16),
+ PasswordIsDefined(false),
+ AskPassword(false),
+ StdOutMode(false),
+ EnablePercents(true),
+ m_WarningsMode(false)
+ {}
+
+ ~CUpdateCallbackConsole() { Finilize(); }
+ void Init(CStdOutStream *outStream)
+ {
+ m_NeedBeClosed = false;
+ m_NeedNewLine = false;
+ FailedFiles.Clear();
+ FailedCodes.Clear();
+ OutStream = outStream;
+ m_PercentPrinter.OutStream = outStream;
+ }
+
+ HRESULT OpenResult(const wchar_t *name, HRESULT result);
+
+ HRESULT StartScanning();
+ HRESULT CanNotFindError(const wchar_t *name, DWORD systemError);
+ HRESULT FinishScanning();
+
+ HRESULT StartArchive(const wchar_t *name, bool updating);
+ HRESULT FinishArchive();
+
+ HRESULT CheckBreak();
+ HRESULT Finilize();
+ HRESULT SetTotal(UInt64 size);
+ HRESULT SetCompleted(const UInt64 *completeValue);
+
+ HRESULT GetStream(const wchar_t *name, bool isAnti);
+ HRESULT OpenFileError(const wchar_t *name, DWORD systemError);
+ HRESULT SetOperationResult(Int32 operationResult);
+ HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password);
+
+ UStringVector FailedFiles;
+ CRecordVector<HRESULT> FailedCodes;
+
+ UStringVector CantFindFiles;
+ CRecordVector<HRESULT> CantFindCodes;
+};
+
+#endif
diff --git a/7zip/UI/Console/UserInputUtils.cpp b/CPP/7zip/UI/Console/UserInputUtils.cpp
index 164af99c..164af99c 100755
--- a/7zip/UI/Console/UserInputUtils.cpp
+++ b/CPP/7zip/UI/Console/UserInputUtils.cpp
diff --git a/7zip/UI/Console/UserInputUtils.h b/CPP/7zip/UI/Console/UserInputUtils.h
index 75c85ee6..75c85ee6 100755
--- a/7zip/UI/Console/UserInputUtils.h
+++ b/CPP/7zip/UI/Console/UserInputUtils.h
diff --git a/7zip/UI/Console/afxres.h b/CPP/7zip/UI/Console/afxres.h
index c2fadd4a..c2fadd4a 100755
--- a/7zip/UI/Console/afxres.h
+++ b/CPP/7zip/UI/Console/afxres.h
diff --git a/CPP/7zip/UI/Console/makefile b/CPP/7zip/UI/Console/makefile
new file mode 100755
index 00000000..54e83ea1
--- /dev/null
+++ b/CPP/7zip/UI/Console/makefile
@@ -0,0 +1,93 @@
+PROG = 7z.exe
+LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib
+CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT -DWIN_LONG_PATH
+
+CONSOLE_OBJS = \
+ $O\ConsoleClose.obj \
+ $O\ExtractCallbackConsole.obj \
+ $O\List.obj \
+ $O\Main.obj \
+ $O\MainAr.obj \
+ $O\OpenCallbackConsole.obj \
+ $O\PercentPrinter.obj \
+ $O\UpdateCallbackConsole.obj \
+ $O\UserInputUtils.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CommandLineParser.obj \
+ $O\IntToString.obj \
+ $O\ListFileUtils.obj \
+ $O\NewHandler.obj \
+ $O\StdInStream.obj \
+ $O\StdOutStream.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\UTFConvert.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\DLL.obj \
+ $O\Error.obj \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\FileName.obj \
+ $O\MemoryLock.obj \
+ $O\PropVariant.obj \
+ $O\PropVariantConversions.obj \
+ $O\Registry.obj \
+
+7ZIP_COMMON_OBJS = \
+ $O\FilePathAutoRename.obj \
+ $O\FileStreams.obj \
+ $O\StreamUtils.obj \
+
+UI_COMMON_OBJS = \
+ $O\ArchiveCommandLine.obj \
+ $O\ArchiveExtractCallback.obj \
+ $O\ArchiveOpenCallback.obj \
+ $O\ArchiverInfo.obj \
+ $O\DefaultName.obj \
+ $O\EnumDirItems.obj \
+ $O\Extract.obj \
+ $O\ExtractingFilePath.obj \
+ $O\OpenArchive.obj \
+ $O\PropIDUtils.obj \
+ $O\SetProperties.obj \
+ $O\SortUtils.obj \
+ $O\TempFiles.obj \
+ $O\Update.obj \
+ $O\UpdateAction.obj \
+ $O\UpdateCallback.obj \
+ $O\UpdatePair.obj \
+ $O\UpdateProduce.obj \
+ $O\WorkDir.obj \
+
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(CONSOLE_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $O\CopyCoder.obj \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(CONSOLE_OBJS): $(*B).cpp
+ $(COMPL)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(UI_COMMON_OBJS): ../Common/$(*B).cpp
+ $(COMPL)
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
diff --git a/7zip/UI/Console/resource.rc b/CPP/7zip/UI/Console/resource.rc
index 6e09bb96..6e09bb96 100755
--- a/7zip/UI/Console/resource.rc
+++ b/CPP/7zip/UI/Console/resource.rc
diff --git a/7zip/UI/Explorer/7-zip.dll.manifest b/CPP/7zip/UI/Explorer/7-zip.dll.manifest
index cba1c5df..cba1c5df 100755
--- a/7zip/UI/Explorer/7-zip.dll.manifest
+++ b/CPP/7zip/UI/Explorer/7-zip.dll.manifest
diff --git a/7zip/UI/Explorer/ContextMenu.cpp b/CPP/7zip/UI/Explorer/ContextMenu.cpp
index fd40add5..fd40add5 100755
--- a/7zip/UI/Explorer/ContextMenu.cpp
+++ b/CPP/7zip/UI/Explorer/ContextMenu.cpp
diff --git a/7zip/UI/Explorer/ContextMenu.h b/CPP/7zip/UI/Explorer/ContextMenu.h
index 60970a22..60970a22 100755
--- a/7zip/UI/Explorer/ContextMenu.h
+++ b/CPP/7zip/UI/Explorer/ContextMenu.h
diff --git a/7zip/UI/Explorer/ContextMenuFlags.h b/CPP/7zip/UI/Explorer/ContextMenuFlags.h
index d138baf9..d138baf9 100755
--- a/7zip/UI/Explorer/ContextMenuFlags.h
+++ b/CPP/7zip/UI/Explorer/ContextMenuFlags.h
diff --git a/7zip/UI/Explorer/DllExports.cpp b/CPP/7zip/UI/Explorer/DllExports.cpp
index fb7daf04..fb7daf04 100755
--- a/7zip/UI/Explorer/DllExports.cpp
+++ b/CPP/7zip/UI/Explorer/DllExports.cpp
diff --git a/7zip/UI/Explorer/Explorer.def b/CPP/7zip/UI/Explorer/Explorer.def
index 752fbb7a..752fbb7a 100755
--- a/7zip/UI/Explorer/Explorer.def
+++ b/CPP/7zip/UI/Explorer/Explorer.def
diff --git a/CPP/7zip/UI/Explorer/Explorer.dsp b/CPP/7zip/UI/Explorer/Explorer.dsp
new file mode 100755
index 00000000..c395c6d2
--- /dev/null
+++ b/CPP/7zip/UI/Explorer/Explorer.dsp
@@ -0,0 +1,818 @@
+# Microsoft Developer Studio Project File - Name="Explorer" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=Explorer - Win32 DebugU
+!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 "Explorer.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 "Explorer.mak" CFG="Explorer - Win32 DebugU"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Explorer - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "Explorer - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "Explorer - Win32 ReleaseU" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "Explorer - Win32 DebugU" (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)" == "Explorer - 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 "EXPLORER_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /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 comctl32.lib htmlhelp.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "Explorer - 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 "EXPLORER_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /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 comctl32.lib htmlhelp.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "Explorer - Win32 ReleaseU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseU"
+# PROP BASE Intermediate_Dir "ReleaseU"
+# PROP BASE Ignore_Export_Lib 1
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseU"
+# PROP Intermediate_Dir "ReleaseU"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "_MBCS" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /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 comctl32.lib htmlhelp.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /opt:NOWIN98
+# SUBTRACT BASE LINK32 /pdb:none
+# 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 comctl32.lib htmlhelp.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zipn.dll" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "Explorer - Win32 DebugU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugU"
+# PROP BASE Intermediate_Dir "DebugU"
+# PROP BASE Ignore_Export_Lib 1
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugU"
+# PROP Intermediate_Dir "DebugU"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /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 comctl32.lib htmlhelp.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /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 comctl32.lib htmlhelp.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7-Zip.dll" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "Explorer - Win32 Release"
+# Name "Explorer - Win32 Debug"
+# Name "Explorer - Win32 ReleaseU"
+# Name "Explorer - Win32 DebugU"
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\DllExports.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Explorer.def
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# 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 "UI Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Common\ArchiveExtractCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveExtractCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveName.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveOpenCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveOpenCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiverInfo.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiverInfo.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\CompressCall.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\CompressCall.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\DefaultName.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\DefaultName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\EnumDirItems.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\EnumDirItems.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ExtractingFilePath.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ExtractingFilePath.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\HandlerLoader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\OpenArchive.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\OpenArchive.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\PropIDUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\PropIDUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\SortUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\SortUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateAction.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateAction.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdatePair.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdatePair.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateProduce.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateProduce.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\WorkDir.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\WorkDir.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ZipRegistry.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ZipRegistry.h
+# End Source File
+# End Group
+# Begin Group "Engine"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\ContextMenu.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ContextMenu.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\MyMessages.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\MyMessages.h
+# End Source File
+# End Group
+# Begin Group "Dialogs"
+
+# PROP Default_Filter ""
+# Begin Group "Options"
+
+# PROP Default_Filter ""
+# Begin Group "SystemPage"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\SystemPage\SystemPage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SystemPage\SystemPage.h
+# End Source File
+# End Group
+# Begin Group "FoldersPage"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\FoldersPage\FoldersPage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FoldersPage\FoldersPage.h
+# End Source File
+# End Group
+# End Group
+# End Group
+# Begin Group "Agent"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Agent\Agent.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\Agent.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\AgentOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\AgentProxy.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\AgentProxy.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\ArchiveFolder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\ArchiveFolderOpen.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\ArchiveFolderOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\IFileExtractCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\IFolderArchive.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\UpdateCallbackAgent.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Agent\UpdateCallbackAgent.h
+# End Source File
+# End Group
+# Begin Group "FileManager"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\FileManager\FormatUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\FormatUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\HelpUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\HelpUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\IFolder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\LangUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\LangUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\ProgramLocation.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\ProgramLocation.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\RegistryUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\RegistryUtils.h
+# End Source File
+# End Group
+# Begin Group "SDK"
+
+# PROP Default_Filter ""
+# Begin Group "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.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\Lang.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Lang.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyCom.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\Random.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Random.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.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
+# Begin Source File
+
+SOURCE=..\..\..\Common\TextConfig.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\TextConfig.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Types.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\UTFConvert.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\UTFConvert.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.h
+# End Source File
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# Begin Group "Control"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\Dialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\Dialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\PropertyPage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\PropertyPage.h
+# End Source File
+# End Group
+# 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\Error.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Error.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\FileMapping.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileName.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Memory.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Memory.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Menu.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Menu.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\PropVariantConversions.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\PropVariantConversions.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Registry.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Registry.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\ResourceString.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\ResourceString.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Shell.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Shell.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Synchronization.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Window.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Window.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "7-zip common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.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 "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\Sort.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=".\7-zip.dll.manifest"
+# End Source File
+# Begin Source File
+
+SOURCE=.\ContextMenuFlags.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\OptionsDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\OptionsDialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\RegistryContextMenu.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\RegistryContextMenu.h
+# End Source File
+# End Target
+# End Project
diff --git a/7zip/UI/Explorer/Explorer.dsw b/CPP/7zip/UI/Explorer/Explorer.dsw
index beb8df7b..beb8df7b 100755
--- a/7zip/UI/Explorer/Explorer.dsw
+++ b/CPP/7zip/UI/Explorer/Explorer.dsw
diff --git a/7zip/UI/Explorer/FoldersPage/FoldersPage.cpp b/CPP/7zip/UI/Explorer/FoldersPage/FoldersPage.cpp
index 776813d8..776813d8 100755
--- a/7zip/UI/Explorer/FoldersPage/FoldersPage.cpp
+++ b/CPP/7zip/UI/Explorer/FoldersPage/FoldersPage.cpp
diff --git a/7zip/UI/Explorer/FoldersPage/FoldersPage.h b/CPP/7zip/UI/Explorer/FoldersPage/FoldersPage.h
index 97950fc6..97950fc6 100755
--- a/7zip/UI/Explorer/FoldersPage/FoldersPage.h
+++ b/CPP/7zip/UI/Explorer/FoldersPage/FoldersPage.h
diff --git a/7zip/UI/Explorer/FoldersPage/resource.h b/CPP/7zip/UI/Explorer/FoldersPage/resource.h
index 3052409b..3052409b 100755
--- a/7zip/UI/Explorer/FoldersPage/resource.h
+++ b/CPP/7zip/UI/Explorer/FoldersPage/resource.h
diff --git a/7zip/UI/Explorer/FoldersPage/resource.rc b/CPP/7zip/UI/Explorer/FoldersPage/resource.rc
index 96b2c9d3..96b2c9d3 100755
--- a/7zip/UI/Explorer/FoldersPage/resource.rc
+++ b/CPP/7zip/UI/Explorer/FoldersPage/resource.rc
diff --git a/7zip/UI/Explorer/MyMessages.cpp b/CPP/7zip/UI/Explorer/MyMessages.cpp
index 61d2429d..61d2429d 100755
--- a/7zip/UI/Explorer/MyMessages.cpp
+++ b/CPP/7zip/UI/Explorer/MyMessages.cpp
diff --git a/7zip/UI/Explorer/MyMessages.h b/CPP/7zip/UI/Explorer/MyMessages.h
index 1a96f569..1a96f569 100755
--- a/7zip/UI/Explorer/MyMessages.h
+++ b/CPP/7zip/UI/Explorer/MyMessages.h
diff --git a/7zip/UI/Explorer/OptionsDialog.cpp b/CPP/7zip/UI/Explorer/OptionsDialog.cpp
index b7831afd..b7831afd 100755
--- a/7zip/UI/Explorer/OptionsDialog.cpp
+++ b/CPP/7zip/UI/Explorer/OptionsDialog.cpp
diff --git a/7zip/UI/Explorer/OptionsDialog.h b/CPP/7zip/UI/Explorer/OptionsDialog.h
index 7e85d357..7e85d357 100755
--- a/7zip/UI/Explorer/OptionsDialog.h
+++ b/CPP/7zip/UI/Explorer/OptionsDialog.h
diff --git a/7zip/UI/Explorer/RegistryContextMenu.cpp b/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp
index 73a8420e..73a8420e 100755
--- a/7zip/UI/Explorer/RegistryContextMenu.cpp
+++ b/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp
diff --git a/7zip/UI/Explorer/RegistryContextMenu.h b/CPP/7zip/UI/Explorer/RegistryContextMenu.h
index 52b053da..52b053da 100755
--- a/7zip/UI/Explorer/RegistryContextMenu.h
+++ b/CPP/7zip/UI/Explorer/RegistryContextMenu.h
diff --git a/7zip/UI/Explorer/StdAfx.cpp b/CPP/7zip/UI/Explorer/StdAfx.cpp
index 2550270c..2550270c 100755
--- a/7zip/UI/Explorer/StdAfx.cpp
+++ b/CPP/7zip/UI/Explorer/StdAfx.cpp
diff --git a/7zip/UI/Explorer/StdAfx.h b/CPP/7zip/UI/Explorer/StdAfx.h
index b9c0ee3a..b9c0ee3a 100755
--- a/7zip/UI/Explorer/StdAfx.h
+++ b/CPP/7zip/UI/Explorer/StdAfx.h
diff --git a/7zip/UI/Explorer/SystemPage/SystemPage.cpp b/CPP/7zip/UI/Explorer/SystemPage/SystemPage.cpp
index cc2f974d..cc2f974d 100755
--- a/7zip/UI/Explorer/SystemPage/SystemPage.cpp
+++ b/CPP/7zip/UI/Explorer/SystemPage/SystemPage.cpp
diff --git a/7zip/UI/Explorer/SystemPage/SystemPage.h b/CPP/7zip/UI/Explorer/SystemPage/SystemPage.h
index a7de7c79..a7de7c79 100755
--- a/7zip/UI/Explorer/SystemPage/SystemPage.h
+++ b/CPP/7zip/UI/Explorer/SystemPage/SystemPage.h
diff --git a/7zip/UI/Explorer/SystemPage/resource.h b/CPP/7zip/UI/Explorer/SystemPage/resource.h
index b125849c..b125849c 100755
--- a/7zip/UI/Explorer/SystemPage/resource.h
+++ b/CPP/7zip/UI/Explorer/SystemPage/resource.h
diff --git a/7zip/UI/Explorer/SystemPage/resource.rc b/CPP/7zip/UI/Explorer/SystemPage/resource.rc
index fdfed433..fdfed433 100755
--- a/7zip/UI/Explorer/SystemPage/resource.rc
+++ b/CPP/7zip/UI/Explorer/SystemPage/resource.rc
diff --git a/CPP/7zip/UI/Explorer/makefile b/CPP/7zip/UI/Explorer/makefile
new file mode 100755
index 00000000..0fcc57e4
--- /dev/null
+++ b/CPP/7zip/UI/Explorer/makefile
@@ -0,0 +1,137 @@
+PROG = 7-zip.dll
+DEF_FILE = Explorer.def
+LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib htmlhelp.lib shell32.lib comctl32.lib ole32.lib comdlg32.lib
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DLANG \
+ -DNEW_FOLDER_INTERFACE \
+ -DWIN_LONG_PATH
+
+EXPLORER_OBJS = \
+ $O\DllExports.obj \
+ $O\ContextMenu.obj \
+ $O\MyMessages.obj \
+ $O\OptionsDialog.obj \
+ $O\RegistryContextMenu.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\IntToString.obj \
+ $O\Lang.obj \
+ $O\ListFileUtils.obj \
+ $O\NewHandler.obj \
+ $O\Random.obj \
+ $O\StdInStream.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\TextConfig.obj \
+ $O\UTFConvert.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\DLL.obj \
+ $O\Error.obj \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\FileName.obj \
+ $O\Menu.obj \
+ $O\PropVariant.obj \
+ $O\PropVariantConversions.obj \
+ $O\Registry.obj \
+ $O\ResourceString.obj \
+ $O\Shell.obj \
+ $O\Synchronization.obj \
+ $O\Window.obj \
+
+WIN_CTRL_OBJS = \
+ $O\Dialog.obj \
+ $O\PropertyPage.obj \
+
+7ZIP_COMMON_OBJS = \
+ $O\FilePathAutoRename.obj \
+ $O\FileStreams.obj \
+ $O\StreamUtils.obj \
+
+UI_COMMON_OBJS = \
+ $O\ArchiveExtractCallback.obj \
+ $O\ArchiveName.obj \
+ $O\ArchiveOpenCallback.obj \
+ $O\ArchiverInfo.obj \
+ $O\CompressCall.obj \
+ $O\DefaultName.obj \
+ $O\EnumDirItems.obj \
+ $O\ExtractingFilePath.obj \
+ $O\OpenArchive.obj \
+ $O\PropIDUtils.obj \
+ $O\SortUtils.obj \
+ $O\UpdateAction.obj \
+ $O\UpdateCallback.obj \
+ $O\UpdatePair.obj \
+ $O\UpdateProduce.obj \
+ $O\WorkDir.obj \
+ $O\ZipRegistry.obj \
+
+AGENT_OBJS = \
+ $O\Agent.obj \
+ $O\AgentOut.obj \
+ $O\AgentProxy.obj \
+ $O\ArchiveFolder.obj \
+ $O\ArchiveFolderOpen.obj \
+ $O\ArchiveFolderOut.obj \
+ $O\UpdateCallbackAgent.obj \
+
+
+FM_COMMON_OBJS = \
+ $O\FormatUtils.obj \
+ $O\HelpUtils.obj \
+ $O\LangUtils.obj \
+ $O\ProgramLocation.obj \
+ $O\RegistryUtils.obj \
+
+C_OBJS = \
+ $O\Sort.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(EXPLORER_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(WIN_CTRL_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $(AGENT_OBJS) \
+ $(FM_COMMON_OBJS)\
+ $(C_OBJS) \
+ $O\SystemPage.obj \
+ $O\FoldersPage.obj \
+ $O\CopyCoder.obj \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(EXPLORER_OBJS): $(*B).cpp
+ $(COMPL)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(UI_COMMON_OBJS): ../Common/$(*B).cpp
+ $(COMPL)
+$(AGENT_OBJS): ../Agent/$(*B).cpp
+ $(COMPL)
+$(FM_COMMON_OBJS): ../../FileManager/$(*B).cpp
+ $(COMPL)
+$O\SystemPage.obj: SystemPage/$(*B).cpp
+ $(COMPL)
+$O\FoldersPage.obj: FoldersPage/$(*B).cpp
+ $(COMPL)
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
diff --git a/7zip/UI/Explorer/resource.h b/CPP/7zip/UI/Explorer/resource.h
index aec1e7cd..aec1e7cd 100755
--- a/7zip/UI/Explorer/resource.h
+++ b/CPP/7zip/UI/Explorer/resource.h
diff --git a/7zip/UI/Explorer/resource.rc b/CPP/7zip/UI/Explorer/resource.rc
index bf7601d9..bf7601d9 100755
--- a/7zip/UI/Explorer/resource.rc
+++ b/CPP/7zip/UI/Explorer/resource.rc
diff --git a/7zip/UI/Far/CLSIDConst.cpp b/CPP/7zip/UI/Far/CLSIDConst.cpp
index a6cea92e..a6cea92e 100755
--- a/7zip/UI/Far/CLSIDConst.cpp
+++ b/CPP/7zip/UI/Far/CLSIDConst.cpp
diff --git a/7zip/UI/Far/ExtractEngine.cpp b/CPP/7zip/UI/Far/ExtractEngine.cpp
index e85df5e1..e85df5e1 100755
--- a/7zip/UI/Far/ExtractEngine.cpp
+++ b/CPP/7zip/UI/Far/ExtractEngine.cpp
diff --git a/7zip/UI/Far/ExtractEngine.h b/CPP/7zip/UI/Far/ExtractEngine.h
index 57c04f76..57c04f76 100755
--- a/7zip/UI/Far/ExtractEngine.h
+++ b/CPP/7zip/UI/Far/ExtractEngine.h
diff --git a/7zip/UI/Far/Far.def b/CPP/7zip/UI/Far/Far.def
index d96501e2..d96501e2 100755
--- a/7zip/UI/Far/Far.def
+++ b/CPP/7zip/UI/Far/Far.def
diff --git a/7zip/UI/Far/Far.dsp b/CPP/7zip/UI/Far/Far.dsp
index 47c44c69..47c44c69 100755
--- a/7zip/UI/Far/Far.dsp
+++ b/CPP/7zip/UI/Far/Far.dsp
diff --git a/7zip/UI/Far/Far.dsw b/CPP/7zip/UI/Far/Far.dsw
index f4ef0801..f4ef0801 100755
--- a/7zip/UI/Far/Far.dsw
+++ b/CPP/7zip/UI/Far/Far.dsw
diff --git a/7zip/UI/Far/FarPlugin.h b/CPP/7zip/UI/Far/FarPlugin.h
index f61bbcb4..f61bbcb4 100755
--- a/7zip/UI/Far/FarPlugin.h
+++ b/CPP/7zip/UI/Far/FarPlugin.h
diff --git a/7zip/UI/Far/FarUtils.cpp b/CPP/7zip/UI/Far/FarUtils.cpp
index abbb6817..abbb6817 100755
--- a/7zip/UI/Far/FarUtils.cpp
+++ b/CPP/7zip/UI/Far/FarUtils.cpp
diff --git a/7zip/UI/Far/FarUtils.h b/CPP/7zip/UI/Far/FarUtils.h
index 4fba193d..4fba193d 100755
--- a/7zip/UI/Far/FarUtils.h
+++ b/CPP/7zip/UI/Far/FarUtils.h
diff --git a/7zip/UI/Far/Main.cpp b/CPP/7zip/UI/Far/Main.cpp
index a7994b6d..a7994b6d 100755
--- a/7zip/UI/Far/Main.cpp
+++ b/CPP/7zip/UI/Far/Main.cpp
diff --git a/7zip/UI/Far/Messages.h b/CPP/7zip/UI/Far/Messages.h
index 8b6e2a49..8b6e2a49 100755
--- a/7zip/UI/Far/Messages.h
+++ b/CPP/7zip/UI/Far/Messages.h
diff --git a/7zip/UI/Far/OverwriteDialog.cpp b/CPP/7zip/UI/Far/OverwriteDialog.cpp
index 028fff4e..028fff4e 100755
--- a/7zip/UI/Far/OverwriteDialog.cpp
+++ b/CPP/7zip/UI/Far/OverwriteDialog.cpp
diff --git a/7zip/UI/Far/OverwriteDialog.h b/CPP/7zip/UI/Far/OverwriteDialog.h
index ff1a480e..ff1a480e 100755
--- a/7zip/UI/Far/OverwriteDialog.h
+++ b/CPP/7zip/UI/Far/OverwriteDialog.h
diff --git a/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp
index 0d4b150e..0d4b150e 100755
--- a/7zip/UI/Far/Plugin.cpp
+++ b/CPP/7zip/UI/Far/Plugin.cpp
diff --git a/7zip/UI/Far/Plugin.h b/CPP/7zip/UI/Far/Plugin.h
index 0b617cfb..0b617cfb 100755
--- a/7zip/UI/Far/Plugin.h
+++ b/CPP/7zip/UI/Far/Plugin.h
diff --git a/7zip/UI/Far/PluginCommon.cpp b/CPP/7zip/UI/Far/PluginCommon.cpp
index 3e8e3cee..3e8e3cee 100755
--- a/7zip/UI/Far/PluginCommon.cpp
+++ b/CPP/7zip/UI/Far/PluginCommon.cpp
diff --git a/7zip/UI/Far/PluginDelete.cpp b/CPP/7zip/UI/Far/PluginDelete.cpp
index 6a969c15..6a969c15 100755
--- a/7zip/UI/Far/PluginDelete.cpp
+++ b/CPP/7zip/UI/Far/PluginDelete.cpp
diff --git a/7zip/UI/Far/PluginRead.cpp b/CPP/7zip/UI/Far/PluginRead.cpp
index 503ff639..503ff639 100755
--- a/7zip/UI/Far/PluginRead.cpp
+++ b/CPP/7zip/UI/Far/PluginRead.cpp
diff --git a/7zip/UI/Far/PluginWrite.cpp b/CPP/7zip/UI/Far/PluginWrite.cpp
index d6730985..d6730985 100755
--- a/7zip/UI/Far/PluginWrite.cpp
+++ b/CPP/7zip/UI/Far/PluginWrite.cpp
diff --git a/7zip/UI/Far/ProgressBox.cpp b/CPP/7zip/UI/Far/ProgressBox.cpp
index 64e0e09d..64e0e09d 100755
--- a/7zip/UI/Far/ProgressBox.cpp
+++ b/CPP/7zip/UI/Far/ProgressBox.cpp
diff --git a/7zip/UI/Far/ProgressBox.h b/CPP/7zip/UI/Far/ProgressBox.h
index 8721b456..8721b456 100755
--- a/7zip/UI/Far/ProgressBox.h
+++ b/CPP/7zip/UI/Far/ProgressBox.h
diff --git a/CPP/7zip/UI/Far/StdAfx.cpp b/CPP/7zip/UI/Far/StdAfx.cpp
new file mode 100755
index 00000000..d0feea85
--- /dev/null
+++ b/CPP/7zip/UI/Far/StdAfx.cpp
@@ -0,0 +1,3 @@
+// StdAfx.cpp
+
+#include "StdAfx.h"
diff --git a/7zip/UI/Far/StdAfx.h b/CPP/7zip/UI/Far/StdAfx.h
index 0a7c347b..0a7c347b 100755
--- a/7zip/UI/Far/StdAfx.h
+++ b/CPP/7zip/UI/Far/StdAfx.h
diff --git a/7zip/UI/Far/UpdateCallback100.cpp b/CPP/7zip/UI/Far/UpdateCallback100.cpp
index f1a2946e..f1a2946e 100755
--- a/7zip/UI/Far/UpdateCallback100.cpp
+++ b/CPP/7zip/UI/Far/UpdateCallback100.cpp
diff --git a/7zip/UI/Far/UpdateCallback100.h b/CPP/7zip/UI/Far/UpdateCallback100.h
index d66137cc..d66137cc 100755
--- a/7zip/UI/Far/UpdateCallback100.h
+++ b/CPP/7zip/UI/Far/UpdateCallback100.h
diff --git a/CPP/7zip/UI/Far/makefile b/CPP/7zip/UI/Far/makefile
new file mode 100755
index 00000000..4dbd1988
--- /dev/null
+++ b/CPP/7zip/UI/Far/makefile
@@ -0,0 +1,102 @@
+PROG = 7-ZipFar.dll
+DEF_FILE = Far.def
+LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib ole32.lib
+CFLAGS = $(CFLAGS) -I ../../../ -DWIN_LONG_PATH
+
+FAR_OBJS = \
+ $O\CLSIDConst.obj \
+ $O\ExtractEngine.obj \
+ $O\FarUtils.obj \
+ $O\Main.obj \
+ $O\OverwriteDialog.obj \
+ $O\Plugin.obj \
+ $O\PluginCommon.obj \
+ $O\PluginDelete.obj \
+ $O\PluginRead.obj \
+ $O\PluginWrite.obj \
+ $O\ProgressBox.obj \
+ $O\UpdateCallback100.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\IntToString.obj \
+ $O\NewHandler.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\DLL.obj \
+ $O\Error.obj \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\FileName.obj \
+ $O\PropVariant.obj \
+ $O\PropVariantConversions.obj \
+ $O\Registry.obj \
+ $O\Synchronization.obj \
+
+7ZIP_COMMON_OBJS = \
+ $O\FilePathAutoRename.obj \
+ $O\FileStreams.obj \
+ $O\StreamUtils.obj \
+
+UI_COMMON_OBJS = \
+ $O\ArchiveExtractCallback.obj \
+ $O\ArchiveOpenCallback.obj \
+ $O\ArchiverInfo.obj \
+ $O\DefaultName.obj \
+ $O\EnumDirItems.obj \
+ $O\ExtractingFilePath.obj \
+ $O\OpenArchive.obj \
+ $O\PropIDUtils.obj \
+ $O\SortUtils.obj \
+ $O\UpdateAction.obj \
+ $O\UpdateCallback.obj \
+ $O\UpdatePair.obj \
+ $O\UpdateProduce.obj \
+ $O\WorkDir.obj \
+ $O\ZipRegistry.obj \
+
+AGENT_OBJS = \
+ $O\Agent.obj \
+ $O\AgentOut.obj \
+ $O\AgentProxy.obj \
+ $O\UpdateCallbackAgent.obj \
+
+C_OBJS = \
+ $O\Sort.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(FAR_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $(AGENT_OBJS) \
+ $(C_OBJS) \
+ $O\CopyCoder.obj \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(FAR_OBJS): $(*B).cpp
+ $(COMPL)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(UI_COMMON_OBJS): ../Common/$(*B).cpp
+ $(COMPL)
+$(AGENT_OBJS): ../Agent/$(*B).cpp
+ $(COMPL)
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
diff --git a/7zip/UI/Far/resource.rc b/CPP/7zip/UI/Far/resource.rc
index a5c2e2f3..a5c2e2f3 100755
--- a/7zip/UI/Far/resource.rc
+++ b/CPP/7zip/UI/Far/resource.rc
diff --git a/7zip/UI/GUI/7zG.exe.manifest b/CPP/7zip/UI/GUI/7zG.exe.manifest
index c6ef90e8..c6ef90e8 100755
--- a/7zip/UI/GUI/7zG.exe.manifest
+++ b/CPP/7zip/UI/GUI/7zG.exe.manifest
diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp
new file mode 100755
index 00000000..f49bb078
--- /dev/null
+++ b/CPP/7zip/UI/GUI/CompressDialog.cpp
@@ -0,0 +1,1373 @@
+// CompressDialog.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+#include "Common/Defs.h"
+#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
+#include "Windows/CommonDialog.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+#include "Windows/ResourceString.h"
+#include "Windows/System.h"
+
+#include "../../FileManager/HelpUtils.h"
+#include "../../FileManager/SplitUtils.h"
+#include "../../FileManager/FormatUtils.h"
+
+#include "../Explorer/MyMessages.h"
+
+#include "../Common/ZipRegistry.h"
+
+#include "CompressDialog.h"
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+#ifdef LANG
+#include "../../FileManager/LangUtils.h"
+#endif
+
+#include "../Resource/CompressDialog/resource.h"
+
+#define MY_SIZE_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_COMPRESS_ARCHIVE, 0x02000D01 },
+ { IDC_STATIC_COMPRESS_FORMAT, 0x02000D03 },
+ { IDC_STATIC_COMPRESS_LEVEL, 0x02000D0B },
+ { IDC_STATIC_COMPRESS_METHOD, 0x02000D04 },
+ { IDC_STATIC_COMPRESS_DICTIONARY, 0x02000D0C },
+ { IDC_STATIC_COMPRESS_ORDER, 0x02000D0D },
+ { IDC_STATIC_COMPRESS_MEMORY, 0x02000D0E },
+ { IDC_STATIC_COMPRESS_MEMORY_DE, 0x02000D0F },
+ { IDC_COMPRESS_SOLID, 0x02000D05 },
+ { IDC_COMPRESS_MULTI_THREAD, 0x02000D09 },
+ { IDC_STATIC_COMPRESS_VOLUME, 0x02000D40 },
+ { IDC_STATIC_COMPRESS_PARAMETERS, 0x02000D06 },
+
+ { IDC_STATIC_COMPRESS_UPDATE_MODE, 0x02000D02 },
+ { IDC_STATIC_COMPRESS_OPTIONS, 0x02000D07 },
+ { IDC_COMPRESS_SFX, 0x02000D08 },
+
+ { IDC_COMPRESS_ENCRYPTION, 0x02000D10 },
+ { IDC_STATIC_COMPRESS_PASSWORD1, 0x02000B01 },
+ { IDC_STATIC_COMPRESS_PASSWORD2, 0x02000B03 },
+ { IDC_COMPRESS_CHECK_SHOW_PASSWORD, 0x02000B02 },
+ { IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, 0x02000D11 },
+ { IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, 0x02000D0A },
+
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 },
+ { IDHELP, 0x02000720 }
+};
+#endif
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NName;
+using namespace NDirectory;
+
+static const int kHistorySize = 8;
+
+static LPCWSTR kExeExt = L".exe";
+static LPCWSTR k7zFormat = L"7z";
+
+struct CLevelInfo
+{
+ UInt32 ResourceID;
+ UInt32 LangID;
+};
+
+enum ELevel
+{
+ kStore = 0,
+ kFastest = 1,
+ kFast = 3,
+ kNormal = 5,
+ kMaximum = 7,
+ kUltra = 9
+};
+
+static const CLevelInfo g_Levels[] =
+{
+ { IDS_METHOD_STORE, 0x02000D81 },
+ { IDS_METHOD_FASTEST, 0x02000D85 },
+ { 0, 0 },
+ { IDS_METHOD_FAST, 0x02000D84 },
+ { 0, 0 },
+ { IDS_METHOD_NORMAL, 0x02000D82 },
+ { 0, 0 },
+ { IDS_METHOD_MAXIMUM, 0x02000D83 },
+ { 0, 0 },
+ { IDS_METHOD_ULTRA, 0x02000D86 }
+};
+
+enum EMethodID
+{
+ kCopy,
+ kLZMA,
+ kPPMd,
+ kBZip2,
+ kDeflate,
+ kDeflate64
+};
+
+static const LPCWSTR kMethodsNames[] =
+{
+ L"Copy",
+ L"LZMA",
+ L"PPMd",
+ L"BZip2",
+ L"Deflate",
+ L"Deflate64"
+};
+
+static const EMethodID g_7zMethods[] =
+{
+ kLZMA,
+ kPPMd,
+ kBZip2
+};
+
+static const EMethodID g_7zSfxMethods[] =
+{
+ kCopy,
+ kLZMA,
+ kPPMd
+};
+
+static EMethodID g_ZipMethods[] =
+{
+ kDeflate,
+ kDeflate64,
+ kBZip2
+};
+
+static EMethodID g_GZipMethods[] =
+{
+ kDeflate
+};
+
+static EMethodID g_BZip2Methods[] =
+{
+ kBZip2
+};
+
+struct CFormatInfo
+{
+ LPCWSTR Name;
+ UInt32 LevelsMask;
+ const EMethodID *MathodIDs;
+ int NumMethods;
+ bool Filter;
+ bool Solid;
+ bool MultiThread;
+ bool SFX;
+ bool Encrypt;
+ bool EncryptFileNames;
+};
+
+static const CFormatInfo g_Formats[] =
+{
+ {
+ 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),
+ 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),
+ g_ZipMethods, MY_SIZE_OF_ARRAY(g_ZipMethods) ,
+ false, false, true, false, true, false
+ },
+ {
+ L"GZip",
+ (1 << 5) | (1 << 7) | (1 << 9),
+ g_GZipMethods, MY_SIZE_OF_ARRAY(g_GZipMethods),
+ false, false, false, false, false, false
+ },
+ {
+ L"BZip2",
+ (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
+ g_BZip2Methods,
+ MY_SIZE_OF_ARRAY(g_BZip2Methods),
+ false, false, true, false, false
+ },
+ {
+ L"Tar",
+ (1 << 0),
+ 0, 0,
+ false, false, false, false, false, false
+ }
+};
+
+static bool IsMethodSupportedBySfx(int methodID)
+{
+ for (int i = 0; i < MY_SIZE_OF_ARRAY(g_7zSfxMethods); i++)
+ if (methodID == g_7zSfxMethods[i])
+ return true;
+ return false;
+};
+
+#ifndef _WIN64
+typedef BOOL (WINAPI *GlobalMemoryStatusExP)(LPMEMORYSTATUSEX lpBuffer);
+#endif
+
+static UInt64 GetPhysicalRamSize()
+{
+ MEMORYSTATUSEX stat;
+ stat.dwLength = sizeof(stat);
+ // return (128 << 20);
+ #ifdef _WIN64
+ if (!::GlobalMemoryStatusEx(&stat))
+ return 0;
+ return stat.ullTotalPhys;
+ #else
+ GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
+ ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
+ "GlobalMemoryStatusEx");
+ if (globalMemoryStatusEx != 0)
+ if (globalMemoryStatusEx(&stat))
+ return stat.ullTotalPhys;
+ {
+ MEMORYSTATUS stat;
+ stat.dwLength = sizeof(stat);
+ GlobalMemoryStatus(&stat);
+ return stat.dwTotalPhys;
+ }
+ #endif
+}
+
+static UInt64 GetMaxRamSizeForProgram()
+{
+ UInt64 physSize = GetPhysicalRamSize();
+ const UInt64 kMinSysSize = (1 << 24);
+ if (physSize <= kMinSysSize)
+ physSize = 0;
+ else
+ physSize -= kMinSysSize;
+ const UInt64 kMinUseSize = (1 << 25);
+ if (physSize < kMinUseSize)
+ physSize = kMinUseSize;
+ return physSize;
+}
+
+bool CCompressDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000D00);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, MY_SIZE_OF_ARRAY(kIDLangPairs) );
+ #endif
+ _password1Control.Attach(GetItem(IDC_COMPRESS_EDIT_PASSWORD1));
+ _password2Control.Attach(GetItem(IDC_COMPRESS_EDIT_PASSWORD2));
+ _password1Control.SetText(Info.Password);
+ _password2Control.SetText(Info.Password);
+ _encryptionMethod.Attach(GetItem(IDC_COMPRESS_COMBO_ENCRYPTION_METHOD));
+
+ m_ArchivePath.Attach(GetItem(IDC_COMPRESS_COMBO_ARCHIVE));
+ m_Format.Attach(GetItem(IDC_COMPRESS_COMBO_FORMAT));
+ m_Level.Attach(GetItem(IDC_COMPRESS_COMBO_LEVEL));
+ m_Method.Attach(GetItem(IDC_COMPRESS_COMBO_METHOD));
+ m_Dictionary.Attach(GetItem(IDC_COMPRESS_COMBO_DICTIONARY));
+ m_Order.Attach(GetItem(IDC_COMPRESS_COMBO_ORDER));
+
+ m_UpdateMode.Attach(GetItem(IDC_COMPRESS_COMBO_UPDATE_MODE));
+ m_Volume.Attach(GetItem(IDC_COMPRESS_COMBO_VOLUME));
+ m_Params.Attach(GetItem(IDC_COMPRESS_EDIT_PARAMETERS));
+
+ AddVolumeItems(m_Volume);
+
+ ReadCompressionInfo(m_RegistryInfo);
+ CheckButton(IDC_COMPRESS_CHECK_SHOW_PASSWORD, m_RegistryInfo.ShowPassword);
+ CheckButton(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, m_RegistryInfo.EncryptHeaders);
+
+ UpdatePasswordControl();
+
+ Info.ArchiverInfoIndex = 0;
+ int i;
+ for(i = 0; i < m_ArchiverInfoList.Size(); i++)
+ {
+ const CArchiverInfo &ai = m_ArchiverInfoList[i];
+ m_Format.AddString(ai.Name);
+ if (ai.Name.CompareNoCase(m_RegistryInfo.ArchiveType) == 0)
+ Info.ArchiverInfoIndex = i;
+ }
+ m_Format.SetCurSel(Info.ArchiverInfoIndex);
+
+ SetArchiveName(Info.ArchiveName);
+ SetLevel();
+ SetParams();
+
+ for(i = 0; i < m_RegistryInfo.HistoryArchives.Size() && i < kHistorySize; i++)
+ m_ArchivePath.AddString(m_RegistryInfo.HistoryArchives[i]);
+
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_ADD, 0x02000DA1));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_UPDATE, 0x02000DA2));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_FRESH, 0x02000DA3));
+ m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE, 0x02000DA4));
+
+ m_UpdateMode.SetCurSel(0);
+
+ Info.Solid = m_RegistryInfo.Solid;
+ Info.MultiThread = m_RegistryInfo.MultiThread;
+
+ CheckButton(IDC_COMPRESS_SOLID, Info.Solid);
+ CheckButton(IDC_COMPRESS_MULTI_THREAD, Info.MultiThread);
+ CheckButton(IDC_COMPRESS_SFX, Info.SFXMode);
+
+ CheckControlsEnable();
+
+ OnButtonSFX();
+
+ SetEncryptionMethod();
+ return CModalDialog::OnInit();
+}
+
+namespace NCompressDialog
+{
+ bool CInfo::GetFullPathName(UString &result) const
+ {
+ NDirectory::MySetCurrentDirectory(CurrentDirPrefix);
+ return MyGetFullPathName(ArchiveName, result);
+ }
+}
+
+void CCompressDialog::UpdatePasswordControl()
+{
+ bool showPassword = IsShowPasswordChecked();
+ TCHAR c = showPassword ? 0: TEXT('*');
+ _password1Control.SetPasswordChar(c);
+ _password2Control.SetPasswordChar(c);
+ UString password;
+ _password1Control.GetText(password);
+ _password1Control.SetText(password);
+ _password2Control.GetText(password);
+ _password2Control.SetText(password);
+
+ int cmdShow = showPassword ? SW_HIDE : SW_SHOW;
+ ShowItem(IDC_STATIC_COMPRESS_PASSWORD2, cmdShow);
+ _password2Control.Show(cmdShow);
+}
+
+bool CCompressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_COMPRESS_BUTTON_SET_ARCHIVE:
+ {
+ OnButtonSetArchive();
+ return true;
+ }
+ case IDC_COMPRESS_SFX:
+ {
+ OnButtonSFX();
+ return true;
+ }
+ case IDC_COMPRESS_CHECK_SHOW_PASSWORD:
+ {
+ UpdatePasswordControl();
+ return true;
+ }
+ case IDC_COMPRESS_MULTI_THREAD:
+ {
+ SetMemoryUsage();
+ return true;
+ }
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+static bool IsMultiProcessor()
+{
+ return NSystem::GetNumberOfProcessors() > 1;
+}
+
+void CCompressDialog::CheckSFXControlsEnable()
+{
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ bool enable = fi.SFX;
+ if (enable)
+ {
+ int methodID = GetMethodID();
+ enable = (methodID == -1 || IsMethodSupportedBySfx(methodID));
+ }
+ if (!enable)
+ CheckButton(IDC_COMPRESS_SFX, false);
+ EnableItem(IDC_COMPRESS_SFX, enable);
+}
+
+void CCompressDialog::CheckVolumeEnable()
+{
+ bool isSFX = IsSFX();
+ m_Volume.Enable(!isSFX);
+ if (isSFX)
+ m_Volume.SetText(TEXT(""));
+}
+
+void CCompressDialog::CheckControlsEnable()
+{
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ Info.SolidIsAllowed = fi.Solid;
+ bool multiThreadEnable = fi.MultiThread & IsMultiProcessor();
+ Info.MultiThreadIsAllowed = multiThreadEnable;
+ Info.EncryptHeadersIsAllowed = fi.EncryptFileNames;
+
+ EnableItem(IDC_COMPRESS_SOLID, fi.Solid);
+ EnableItem(IDC_COMPRESS_MULTI_THREAD, multiThreadEnable);
+ CheckSFXControlsEnable();
+ CheckVolumeEnable();
+
+ EnableItem(IDC_COMPRESS_ENCRYPTION, fi.Encrypt);
+
+ EnableItem(IDC_STATIC_COMPRESS_PASSWORD1, fi.Encrypt);
+ EnableItem(IDC_STATIC_COMPRESS_PASSWORD2, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_EDIT_PASSWORD1, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_EDIT_PASSWORD2, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_CHECK_SHOW_PASSWORD, fi.Encrypt);
+
+ EnableItem(IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, fi.Encrypt);
+ EnableItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames);
+}
+
+bool CCompressDialog::IsSFX()
+{
+ CWindow sfxButton = GetItem(IDC_COMPRESS_SFX);
+ return sfxButton.IsEnabled() && IsButtonCheckedBool(IDC_COMPRESS_SFX);
+}
+
+void CCompressDialog::OnButtonSFX()
+{
+ SetMethod();
+
+ UString fileName;
+ m_ArchivePath.GetText(fileName);
+ int dotPos = fileName.ReverseFind(L'.');
+ int slashPos = fileName.ReverseFind(L'\\');
+ if (dotPos < 0 || dotPos <= slashPos)
+ dotPos = -1;
+ bool isSFX = IsSFX();
+ if (isSFX)
+ {
+ if (dotPos >= 0)
+ fileName = fileName.Left(dotPos);
+ fileName += kExeExt;
+ m_ArchivePath.SetText(fileName);
+ }
+ else
+ {
+ if (dotPos >= 0)
+ {
+ UString ext = fileName.Mid(dotPos);
+ if (ext.CompareNoCase(kExeExt) == 0)
+ {
+ fileName = fileName.Left(dotPos);
+ m_ArchivePath.SetText(fileName);
+ }
+ }
+ SetArchiveName2(false); // it's for OnInit
+ }
+
+ CheckVolumeEnable();
+}
+
+void CCompressDialog::OnButtonSetArchive()
+{
+ UString fileName;
+ m_ArchivePath.GetText(fileName);
+ fileName.Trim();
+ Info.ArchiveName = fileName;
+ UString fullFileName;
+ if (!Info.GetFullPathName(fullFileName))
+ {
+ fullFileName = Info.ArchiveName;
+ return;
+ }
+ UString title = LangString(IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE, 0x02000D90);
+ UString s = LangString(IDS_OPEN_TYPE_ALL_FILES, 0x02000DB1);
+ s += L" (*.*)";
+ UString resPath;
+ if (!MyGetOpenFileName(HWND(*this), title, fullFileName, s, resPath))
+ return;
+ m_ArchivePath.SetText(resPath);
+}
+
+// in ExtractDialog.cpp
+extern void AddUniqueString(UStringVector &strings, const UString &srcString);
+
+static bool IsAsciiString(const UString &s)
+{
+ for (int i = 0; i < s.Length(); i++)
+ {
+ wchar_t c = s[i];
+ if (c < 0x20 || c > 0x7F)
+ return false;
+ }
+ return true;
+}
+
+void CCompressDialog::OnOK()
+{
+ _password1Control.GetText(Info.Password);
+ if (IsZipFormat())
+ {
+ if (!IsAsciiString(Info.Password))
+ {
+ MyMessageBoxResource(*this, IDS_PASSWORD_USE_ASCII, 0x02000B11);
+ return;
+ }
+ UString method = GetEncryptionMethodSpec();
+ method.MakeUpper();
+ if (method.Find(L"AES") == 0)
+ {
+ if (Info.Password.Length() > 99)
+ {
+ MyMessageBoxResource(*this, IDS_PASSWORD_IS_TOO_LONG, 0x02000B12);
+ return;
+ }
+ }
+ }
+ if (!IsShowPasswordChecked())
+ {
+ UString password2;
+ _password2Control.GetText(password2);
+ if (password2 != Info.Password)
+ {
+ MyMessageBoxResource(*this, IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH, 0x02000B10);
+ return;
+ }
+ }
+
+ SaveOptionsInMem();
+ UString s;
+ m_ArchivePath.GetText(s);
+ s.Trim();
+ m_RegistryInfo.HistoryArchives.Clear();
+ AddUniqueString(m_RegistryInfo.HistoryArchives, s);
+ Info.ArchiveName = s;
+ Info.UpdateMode = NCompressDialog::NUpdateMode::EEnum(m_UpdateMode.GetCurSel());
+
+ Info.Level = GetLevelSpec();
+ Info.Dictionary = GetDictionarySpec();
+ Info.Order = GetOrderSpec();
+ Info.OrderMode = GetOrderMode();
+ Info.Method = GetMethodSpec();
+ Info.EncryptionMethod = GetEncryptionMethodSpec();
+
+ Info.ArchiverInfoIndex = m_Format.GetCurSel();
+
+ Info.SFXMode = IsSFX();
+ m_RegistryInfo.Solid = Info.Solid = IsButtonCheckedBool(IDC_COMPRESS_SOLID);
+ m_RegistryInfo.MultiThread = Info.MultiThread = IsMultiThread();
+ m_RegistryInfo.EncryptHeaders = Info.EncryptHeaders = IsButtonCheckedBool(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES);
+
+ m_Params.GetText(Info.Options);
+ UString volumeString;
+ m_Volume.GetText(volumeString);
+ volumeString.Trim();
+ Info.VolumeSizes.Clear();
+ if (!volumeString.IsEmpty())
+ {
+ if (!ParseVolumeSizes(volumeString, Info.VolumeSizes))
+ {
+ MyMessageBoxResource(*this, IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41);
+ return;
+ }
+ if (!Info.VolumeSizes.IsEmpty())
+ {
+ const UInt64 volumeSize = Info.VolumeSizes.Back();
+ if (volumeSize < (100 << 10))
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString(volumeSize, s);
+ if (::MessageBoxW(*this, MyFormatNew(IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, 0x02000D42, s),
+ L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES)
+ return;
+ }
+ }
+ }
+
+ for(int i = 0; i < m_ArchivePath.GetCount(); i++)
+ {
+ UString sTemp;
+ m_ArchivePath.GetLBText(i, sTemp);
+ sTemp.Trim();
+ AddUniqueString(m_RegistryInfo.HistoryArchives, sTemp);
+ }
+ if (m_RegistryInfo.HistoryArchives.Size() > kHistorySize)
+ m_RegistryInfo.HistoryArchives.DeleteBack();
+
+ ////////////////////
+ // Method
+
+ m_RegistryInfo.Level = Info.Level;
+ m_RegistryInfo.ArchiveType = m_ArchiverInfoList[Info.ArchiverInfoIndex].Name;
+
+ m_RegistryInfo.ShowPassword = IsShowPasswordChecked();
+
+ SaveCompressionInfo(m_RegistryInfo);
+
+ CModalDialog::OnOK();
+}
+
+static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/add.htm";
+
+void CCompressDialog::OnHelp()
+{
+ ShowHelpWindow(NULL, kHelpTopic);
+}
+
+bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
+{
+ if (code == CBN_SELCHANGE)
+ {
+ switch(itemID)
+ {
+ case IDC_COMPRESS_COMBO_FORMAT:
+ {
+ OnChangeFormat();
+ return true;
+ }
+ case IDC_COMPRESS_COMBO_LEVEL:
+ {
+ const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ int index = FindRegistryFormatAlways(ai.Name);
+ NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ fo.ResetForLevelChange();
+ SetMethod();
+ CheckSFXNameChange();
+ return true;
+ }
+ case IDC_COMPRESS_COMBO_METHOD:
+ {
+ SetDictionary();
+ SetOrder();
+ CheckSFXNameChange();
+ return true;
+ }
+ case IDC_COMPRESS_COMBO_DICTIONARY:
+ case IDC_COMPRESS_COMBO_ORDER:
+ {
+ SetMemoryUsage();
+ return true;
+ }
+ }
+ }
+ return CModalDialog::OnCommand(code, itemID, lParam);
+}
+
+void CCompressDialog::CheckSFXNameChange()
+{
+ bool isSFX = IsSFX();
+ CheckSFXControlsEnable();
+ if (isSFX != IsSFX())
+ SetArchiveName2(isSFX);
+}
+
+void CCompressDialog::SetArchiveName2(bool prevWasSFX)
+{
+ UString fileName;
+ m_ArchivePath.GetText(fileName);
+ const CArchiverInfo &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat];
+ if (prevArchiverInfo.KeepName || Info.KeepName)
+ {
+ UString prevExtension = prevArchiverInfo.GetMainExtension();
+ if (prevWasSFX)
+ prevExtension = kExeExt;
+ else
+ prevExtension = UString('.') + prevExtension;
+ const int prevExtensionLen = prevExtension.Length();
+ if (fileName.Length() >= prevExtensionLen)
+ if (fileName.Right(prevExtensionLen).CompareNoCase(prevExtension) == 0)
+ fileName = fileName.Left(fileName.Length() - prevExtensionLen);
+ }
+ SetArchiveName(fileName);
+}
+
+void CCompressDialog::OnChangeFormat()
+{
+ bool isSFX = IsSFX();
+ SaveOptionsInMem();
+ SetLevel();
+ SetParams();
+ CheckControlsEnable();
+ SetArchiveName2(isSFX);
+ SetEncryptionMethod();
+}
+
+// if type.KeepName then use OriginalFileName
+// else if !KeepName remove extension
+// add new extension
+
+void CCompressDialog::SetArchiveName(const UString &name)
+{
+ UString fileName = name;
+ Info.ArchiverInfoIndex = m_Format.GetCurSel();
+ const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
+ m_PrevFormat = Info.ArchiverInfoIndex;
+ if (ai.KeepName)
+ {
+ fileName = OriginalFileName;
+ }
+ else
+ {
+ if (!Info.KeepName)
+ {
+ int dotPos = fileName.ReverseFind('.');
+ int slashPos = MyMax(fileName.ReverseFind('\\'), fileName.ReverseFind('/'));
+ if (dotPos >= 0 && dotPos > slashPos + 1)
+ fileName = fileName.Left(dotPos);
+ }
+ }
+
+ if (IsSFX())
+ fileName += kExeExt;
+ else
+ {
+ fileName += L'.';
+ fileName += ai.GetMainExtension();
+ }
+ m_ArchivePath.SetText(fileName);
+}
+
+int CCompressDialog::FindRegistryFormat(const UString &name)
+{
+ for (int i = 0; i < m_RegistryInfo.FormatOptionsVector.Size(); i++)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[i];
+ if (GetUnicodeString(fo.FormatID) == name)
+ return i;
+ }
+ return -1;
+}
+
+int CCompressDialog::FindRegistryFormatAlways(const UString &name)
+{
+ int index = FindRegistryFormat(name);
+ if (index < 0)
+ {
+ NCompression::CFormatOptions fo;
+ fo.FormatID = GetSystemString(name);
+ index = m_RegistryInfo.FormatOptionsVector.Add(fo);
+ }
+ return index;
+}
+
+int CCompressDialog::GetStaticFormatIndex()
+{
+ int formatIndex = m_Format.GetCurSel();
+ const CArchiverInfo &ai = m_ArchiverInfoList[formatIndex];
+ for (int i = 0; i < MY_SIZE_OF_ARRAY(g_Formats); i++)
+ if (ai.Name.CompareNoCase(g_Formats[i].Name) == 0)
+ return i;
+ return 0; // -1;
+}
+
+void CCompressDialog::SetNearestSelectComboBox(
+ NControl::CComboBox &comboBox, UInt32 value)
+{
+ for (int i = comboBox.GetCount() - 1; i >= 0; i--)
+ if ((UInt32)comboBox.GetItemData(i) <= value)
+ {
+ comboBox.SetCurSel(i);
+ return;
+ }
+ if (comboBox.GetCount() > 0)
+ comboBox.SetCurSel(0);
+}
+
+void CCompressDialog::SetLevel()
+{
+ m_Level.ResetContent();
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ int index = FindRegistryFormat(ai.Name);
+ UInt32 level = kNormal;
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Level <= kUltra)
+ level = fo.Level;
+ else
+ level = kUltra;
+ }
+ int i;
+ for (i = 0; i <= kUltra; i++)
+ {
+ if ((fi.LevelsMask & (1 << i)) != 0)
+ {
+ const CLevelInfo &levelInfo = g_Levels[i];
+ int index = (int)m_Level.AddString(LangString(levelInfo.ResourceID, levelInfo.LangID));
+ m_Level.SetItemData(index, i);
+ }
+ }
+ SetNearestSelectComboBox(m_Level, level);
+ SetMethod();
+}
+
+int CCompressDialog::GetLevel()
+{
+ if (m_Level.GetCount() <= 0)
+ return -1;
+ return (int)m_Level.GetItemData(m_Level.GetCurSel());
+}
+
+int CCompressDialog::GetLevelSpec()
+{
+ if (m_Level.GetCount() <= 1)
+ return -1;
+ return GetLevel();
+}
+
+int CCompressDialog::GetLevel2()
+{
+ int level = GetLevel();
+ if (level < 0)
+ level = 5;
+ return level;
+}
+
+bool CCompressDialog::IsMultiThread()
+{
+ /*
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ bool multiThreadEnable = fi.MultiThread & IsMultiProcessor();
+ if (!multiThreadEnable)
+ return false;
+ */
+ return IsButtonCheckedBool(IDC_COMPRESS_MULTI_THREAD);
+}
+
+void CCompressDialog::SetMethod()
+{
+ m_Method.ResetContent();
+ if (GetLevel() <= 0)
+ {
+ SetDictionary();
+ SetOrder();
+ return;
+ }
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ int index = FindRegistryFormat(ai.Name);
+ UString defaultMethod;
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ defaultMethod = fo.Method;
+ }
+ bool isSfx = IsSFX();
+ for(int m = 0; m < fi.NumMethods; m++)
+ {
+ EMethodID methodID = fi.MathodIDs[m];
+ if (isSfx)
+ if (!IsMethodSupportedBySfx(methodID))
+ continue;
+ const LPCWSTR method = kMethodsNames[methodID];
+ int itemIndex = (int)m_Method.AddString(GetSystemString(method));
+ if (defaultMethod.CompareNoCase(method) == 0 || m == 0)
+ m_Method.SetCurSel(itemIndex);
+ }
+ SetDictionary();
+ SetOrder();
+}
+
+bool CCompressDialog::IsZipFormat()
+{
+ const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ return (ai.Name.CompareNoCase(L"zip") == 0);
+}
+
+void CCompressDialog::SetEncryptionMethod()
+{
+ _encryptionMethod.ResetContent();
+ const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ if (ai.Name.CompareNoCase(L"7z") == 0)
+ {
+ _encryptionMethod.AddString(TEXT("AES-256"));
+ _encryptionMethod.SetCurSel(0);
+ }
+ else if (ai.Name.CompareNoCase(L"zip") == 0)
+ {
+ int index = FindRegistryFormat(ai.Name);
+ UString encryptionMethod;
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ encryptionMethod = fo.EncryptionMethod;
+ }
+ _encryptionMethod.AddString(TEXT("ZipCrypto"));
+ _encryptionMethod.AddString(TEXT("AES-256"));
+ _encryptionMethod.SetCurSel(encryptionMethod.Find(L"AES") == 0 ? 1 : 0);
+ }
+}
+
+int CCompressDialog::GetMethodID()
+{
+ UString methodName;
+ m_Method.GetText(methodName);
+ for (int i = 0; i < MY_SIZE_OF_ARRAY(kMethodsNames); i++)
+ if (methodName.CompareNoCase(kMethodsNames[i]) == 0)
+ return i;
+ return -1;
+}
+
+UString CCompressDialog::GetMethodSpec()
+{
+ if (m_Method.GetCount() <= 1)
+ return UString();
+ UString result;
+ m_Method.GetText(result);
+ return result;
+}
+
+UString CCompressDialog::GetEncryptionMethodSpec()
+{
+ if (m_Method.GetCount() <= 1)
+ return UString();
+ if (_encryptionMethod.GetCurSel() <= 0)
+ return UString();
+ UString result;
+ _encryptionMethod.GetText(result);
+ result.Replace(L"-", L"");
+ return result;
+}
+
+int CCompressDialog::AddDictionarySize(UInt32 size, bool kilo, bool maga)
+{
+ UInt32 sizePrint = size;
+ if (kilo)
+ sizePrint >>= 10;
+ else if (maga)
+ sizePrint >>= 20;
+ TCHAR s[40];
+ ConvertUInt64ToString(sizePrint, s);
+ if (kilo)
+ lstrcat(s, TEXT(" K"));
+ else if (maga)
+ lstrcat(s, TEXT(" M"));
+ else
+ lstrcat(s, TEXT(" "));
+ lstrcat(s, TEXT("B"));
+ int index = (int)m_Dictionary.AddString(s);
+ m_Dictionary.SetItemData(index, size);
+ return index;
+}
+
+int CCompressDialog::AddDictionarySize(UInt32 size)
+{
+ if (size > 0)
+ {
+ if ((size & 0xFFFFF) == 0)
+ return AddDictionarySize(size, false, true);
+ if ((size & 0x3FF) == 0)
+ return AddDictionarySize(size, true, false);
+ }
+ return AddDictionarySize(size, false, false);
+}
+
+void CCompressDialog::SetDictionary()
+{
+ m_Dictionary.ResetContent();
+ const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ int index = FindRegistryFormat(ai.Name);
+ UInt32 defaultDictionary = UInt32(-1);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
+ defaultDictionary = fo.Dictionary;
+ }
+ int methodID = GetMethodID();
+ int level = GetLevel2();
+ if (methodID < 0)
+ {
+ SetMemoryUsage();
+ return;
+ }
+ const UInt64 maxRamSize = GetMaxRamSizeForProgram();
+ switch (methodID)
+ {
+ case kLZMA:
+ {
+ static const UInt32 kMinDicSize = (1 << 16);
+ if (defaultDictionary == UInt32(-1))
+ {
+ if (level >= 9)
+ defaultDictionary = (1 << 26);
+ else if (level >= 7)
+ defaultDictionary = (1 << 24);
+ else if (level >= 5)
+ defaultDictionary = (1 << 22);
+ else if (level >= 3)
+ defaultDictionary = (1 << 20);
+ else
+ defaultDictionary = (kMinDicSize);
+ }
+ int i;
+ AddDictionarySize(kMinDicSize);
+ m_Dictionary.SetCurSel(0);
+ for (i = 20; i <= 30; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ if (i == 20 && j > 0)
+ continue;
+ UInt32 dictionary = (1 << i) + (j << (i - 1));
+ if (dictionary >
+ #ifdef _WIN64
+ (1 << 30)
+ #else
+ (1 << 27)
+ #endif
+ )
+ continue;
+ AddDictionarySize(dictionary);
+ UInt64 decomprSize;
+ UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
+ if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize)
+ m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
+ }
+
+ // SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
+ break;
+ }
+ case kPPMd:
+ {
+ if (defaultDictionary == UInt32(-1))
+ {
+ if (level >= 9)
+ defaultDictionary = (192 << 20);
+ else if (level >= 7)
+ defaultDictionary = (64 << 20);
+ else if (level >= 5)
+ defaultDictionary = (16 << 20);
+ else
+ defaultDictionary = (4 << 20);
+ }
+ int i;
+ for (i = 20; i < 31; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ if (i == 20 && j > 0)
+ continue;
+ UInt32 dictionary = (1 << i) + (j << (i - 1));
+ if (dictionary >= (1 << 31))
+ continue;
+ AddDictionarySize(dictionary);
+ UInt64 decomprSize;
+ UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
+ if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
+ m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
+ }
+ SetNearestSelectComboBox(m_Dictionary, defaultDictionary);
+ break;
+ }
+ case kDeflate:
+ {
+ AddDictionarySize(32 << 10);
+ m_Dictionary.SetCurSel(0);
+ break;
+ }
+ case kDeflate64:
+ {
+ AddDictionarySize(64 << 10);
+ m_Dictionary.SetCurSel(0);
+ break;
+ }
+ case kBZip2:
+ {
+ UInt32 defaultDictionary;
+ if (level >= 5)
+ defaultDictionary = (900 << 10);
+ else if (level >= 3)
+ defaultDictionary = (500 << 10);
+ else
+ defaultDictionary = (100 << 10);
+ for (int i = 1; i <= 9; i++)
+ {
+ UInt32 dictionary = (i * 100) << 10;
+ AddDictionarySize(dictionary);
+ if (dictionary <= defaultDictionary || m_Dictionary.GetCount() == 0)
+ m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
+ }
+ break;
+ }
+ }
+ SetMemoryUsage();
+}
+
+UInt32 CCompressDialog::GetDictionary()
+{
+ if (m_Dictionary.GetCount() <= 0)
+ return (UInt32)-1;
+ return (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
+}
+
+UInt32 CCompressDialog::GetDictionarySpec()
+{
+ if (m_Dictionary.GetCount() <= 1)
+ return (UInt32)-1;
+ return GetDictionary();
+}
+
+int CCompressDialog::AddOrder(UInt32 size)
+{
+ TCHAR s[40];
+ ConvertUInt64ToString(size, s);
+ int index = (int)m_Order.AddString(s);
+ m_Order.SetItemData(index, size);
+ return index;
+}
+
+void CCompressDialog::SetOrder()
+{
+ m_Order.ResetContent();
+ const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ int index = FindRegistryFormat(ai.Name);
+ UInt32 defaultOrder = UInt32(-1);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
+ defaultOrder = fo.Order;
+ }
+ int methodID = GetMethodID();
+ int level = GetLevel2();
+ if (methodID < 0)
+ {
+ SetMemoryUsage();
+ return;
+ }
+ switch (methodID)
+ {
+ case kLZMA:
+ {
+ if (defaultOrder == UInt32(-1))
+ defaultOrder = (level >= 7) ? 64 : 32;
+ for (int i = 3; i <= 8; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ UInt32 order = (1 << i) + (j << (i - 1));
+ if (order <= 256)
+ AddOrder(order);
+ }
+ AddOrder(273);
+ SetNearestSelectComboBox(m_Order, defaultOrder);
+ break;
+ }
+ case kPPMd:
+ {
+ if (defaultOrder == UInt32(-1))
+ {
+ if (level >= 9)
+ defaultOrder = 32;
+ else if (level >= 7)
+ defaultOrder = 16;
+ else if (level >= 5)
+ defaultOrder = 6;
+ else
+ defaultOrder = 4;
+ }
+ int i;
+ AddOrder(2);
+ AddOrder(3);
+ for (i = 2; i < 8; i++)
+ for (int j = 0; j < 4; j++)
+ {
+ UInt32 order = (1 << i) + (j << (i - 2));
+ if (order < 32)
+ AddOrder(order);
+ }
+ AddOrder(32);
+ SetNearestSelectComboBox(m_Order, defaultOrder);
+ break;
+ }
+ case kDeflate:
+ case kDeflate64:
+ {
+ if (defaultOrder == UInt32(-1))
+ {
+ if (level >= 9)
+ defaultOrder = 128;
+ else if (level >= 7)
+ defaultOrder = 64;
+ else
+ defaultOrder = 32;
+ }
+ int i;
+ for (i = 3; i <= 8; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ UInt32 order = (1 << i) + (j << (i - 1));
+ if (order <= 256)
+ AddOrder(order);
+ }
+ AddOrder(methodID == kDeflate64 ? 257 : 258);
+ SetNearestSelectComboBox(m_Order, defaultOrder);
+ break;
+ }
+ case kBZip2:
+ {
+ break;
+ }
+ }
+ SetMemoryUsage();
+}
+
+bool CCompressDialog::GetOrderMode()
+{
+ switch (GetMethodID())
+ {
+ case kPPMd:
+ return true;
+ }
+ return false;
+}
+
+UInt32 CCompressDialog::GetOrder()
+{
+ if (m_Order.GetCount() <= 0)
+ return (UInt32)-1;
+ return (UInt32)m_Order.GetItemData(m_Order.GetCurSel());
+}
+
+UInt32 CCompressDialog::GetOrderSpec()
+{
+ if (m_Order.GetCount() <= 1)
+ return (UInt32)-1;
+ return GetOrder();
+}
+
+UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory)
+{
+ decompressMemory = UInt64(Int64(-1));
+ int level = GetLevel2();
+ if (level == 0)
+ {
+ decompressMemory = (1 << 20);
+ return decompressMemory;
+ }
+ UInt64 size = 0;
+
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ if (fi.Filter && level >= 9)
+ size += (12 << 20) * 2 + (5 << 20);
+ switch (GetMethodID())
+ {
+ case kLZMA:
+ {
+ UInt32 hs = dictionary - 1;
+ hs |= (hs >> 1);
+ hs |= (hs >> 2);
+ hs |= (hs >> 4);
+ hs |= (hs >> 8);
+ hs >>= 1;
+ hs |= 0xFFFF;
+ if (hs > (1 << 24))
+ hs >>= 1;
+ hs++;
+ size += hs * 4;
+ size += (UInt64)dictionary * 11 / 2;
+ if (level >= 5)
+ size += dictionary * 4;
+ size += (2 << 20);
+ if (isMultiThread && level >= 5)
+ size += (2 << 20) + (4 << 20);
+
+ decompressMemory = dictionary + (2 << 20);
+ return size;
+ }
+ case kPPMd:
+ {
+ decompressMemory = dictionary + (2 << 20);
+ return size + decompressMemory;
+ }
+ case kDeflate:
+ case kDeflate64:
+ {
+ UInt32 order = GetOrder();
+ if (order == UInt32(-1))
+ order = 32;
+ if (level >= 7)
+ size += (1 << 20);
+ size += 3 << 20;
+ decompressMemory = (2 << 20);
+ return size;
+ }
+ case kBZip2:
+ {
+ decompressMemory = (7 << 20);
+ UInt64 memForOneThread = (10 << 20);
+ if (isMultiThread)
+ memForOneThread *= NSystem::GetNumberOfProcessors();
+ return size + (10 << 20);
+ }
+ }
+ return UInt64(Int64(-1));
+}
+
+UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
+{
+ return GetMemoryUsage(GetDictionary(), IsMultiThread(), decompressMemory);
+}
+
+void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
+{
+ if (value == (UInt64)Int64(-1))
+ {
+ SetItemText(res, TEXT("?"));
+ return;
+ }
+ value = (value + (1 << 20) - 1) >> 20;
+ TCHAR s[40];
+ ConvertUInt64ToString(value, s);
+ lstrcat(s, TEXT(" MB"));
+ SetItemText(res, s);
+}
+
+void CCompressDialog::SetMemoryUsage()
+{
+ UInt64 decompressMem;
+ UInt64 memUsage = GetMemoryUsage(decompressMem);
+ PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_VALUE, memUsage);
+ PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, decompressMem);
+}
+
+void CCompressDialog::SetParams()
+{
+ const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ m_Params.SetText(TEXT(""));
+ int index = FindRegistryFormat(ai.Name);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ m_Params.SetText(fo.Options);
+ }
+}
+
+void CCompressDialog::SaveOptionsInMem()
+{
+ const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
+ int index = FindRegistryFormatAlways(ai.Name);
+ m_Params.GetText(Info.Options);
+ Info.Options.Trim();
+ NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ fo.Options = Info.Options;
+ fo.Level = GetLevelSpec();
+ fo.Dictionary = GetDictionarySpec();
+ fo.Order = GetOrderSpec();
+ fo.Method = GetMethodSpec();
+ fo.EncryptionMethod = GetEncryptionMethodSpec();
+}
diff --git a/CPP/7zip/UI/GUI/CompressDialog.h b/CPP/7zip/UI/GUI/CompressDialog.h
new file mode 100755
index 00000000..87cf5d79
--- /dev/null
+++ b/CPP/7zip/UI/GUI/CompressDialog.h
@@ -0,0 +1,171 @@
+// CompressDialog.h
+
+#ifndef __COMPRESSDIALOG_H
+#define __COMPRESSDIALOG_H
+
+#include "../Common/ZipRegistry.h"
+#include "../Common/ArchiverInfo.h"
+#include "../Resource/CompressDialog/resource.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/Edit.h"
+#include "Windows/Control/ComboBox.h"
+
+namespace NCompressDialog
+{
+ namespace NUpdateMode
+ {
+ enum EEnum
+ {
+ kAdd,
+ kUpdate,
+ kFresh,
+ kSynchronize,
+ };
+ }
+ struct CInfo
+ {
+ NUpdateMode::EEnum UpdateMode;
+ bool SolidIsAllowed;
+ bool Solid;
+
+ bool MultiThreadIsAllowed;
+ bool MultiThread;
+
+ CRecordVector<UInt64> VolumeSizes;
+
+ UInt32 Level;
+ UString Method;
+ UInt32 Dictionary;
+ bool OrderMode;
+ UInt32 Order;
+ UString Options;
+
+ UString EncryptionMethod;
+
+ bool SFXMode;
+
+ UString ArchiveName; // in: Relative for ; out: abs
+ UString CurrentDirPrefix;
+ bool KeepName;
+
+ bool GetFullPathName(UString &result) const;
+
+ int ArchiverInfoIndex;
+
+ UString Password;
+ bool EncryptHeadersIsAllowed;
+ bool EncryptHeaders;
+
+ void Init()
+ {
+ Level = Dictionary = Order = UInt32(-1);
+ OrderMode = false;
+ Method.Empty();
+ Options.Empty();
+ EncryptionMethod.Empty();
+ }
+ CInfo()
+ {
+ Init();
+ }
+ };
+}
+
+class CCompressDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox m_ArchivePath;
+ NWindows::NControl::CComboBox m_Format;
+ NWindows::NControl::CComboBox m_Level;
+ NWindows::NControl::CComboBox m_Method;
+ NWindows::NControl::CComboBox m_Dictionary;
+ NWindows::NControl::CComboBox m_Order;
+ NWindows::NControl::CComboBox m_UpdateMode;
+ NWindows::NControl::CComboBox m_Volume;
+ NWindows::NControl::CDialogChildControl m_Params;
+
+ NWindows::NControl::CEdit _password1Control;
+ NWindows::NControl::CEdit _password2Control;
+ NWindows::NControl::CComboBox _encryptionMethod;
+
+ NCompression::CInfo m_RegistryInfo;
+
+ int m_PrevFormat;
+ void SetArchiveName(const UString &name);
+ int FindRegistryFormat(const UString &name);
+ int FindRegistryFormatAlways(const UString &name);
+
+ void OnChangeFormat();
+ void CheckSFXNameChange();
+ void SetArchiveName2(bool prevWasSFX);
+
+ int GetStaticFormatIndex();
+
+ void SetNearestSelectComboBox(NWindows::NControl::CComboBox &comboBox, UInt32 value);
+
+ void SetLevel();
+ int GetLevel();
+ int GetLevelSpec();
+ int GetLevel2();
+ bool IsMultiThread();
+
+ void SetMethod();
+ int GetMethodID();
+ UString GetMethodSpec();
+ UString GetEncryptionMethodSpec();
+
+ bool IsZipFormat();
+
+ void SetEncryptionMethod();
+
+ int AddDictionarySize(UInt32 size, bool kilo, bool maga);
+ int AddDictionarySize(UInt32 size);
+
+ void SetDictionary();
+ UInt32 GetDictionary();
+ UInt32 GetDictionarySpec();
+
+ int AddOrder(UInt32 size);
+ void SetOrder();
+ bool GetOrderMode();
+ UInt32 GetOrder();
+ UInt32 GetOrderSpec();
+
+ UInt64 GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory);
+ UInt64 GetMemoryUsage(UInt64 &decompressMemory);
+ void PrintMemUsage(UINT res, UInt64 value);
+ void SetMemoryUsage();
+ void SetParams();
+ void SaveOptionsInMem();
+
+ void UpdatePasswordControl();
+ bool IsShowPasswordChecked() const
+ { return IsButtonChecked(IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED; }
+public:
+ CObjectVector<CArchiverInfo> m_ArchiverInfoList;
+
+ NCompressDialog::CInfo Info;
+ UString OriginalFileName; // for bzip2, gzip2
+
+ INT_PTR Create(HWND wndParent = 0)
+ { return CModalDialog::Create(IDD_DIALOG_COMPRESS, wndParent); }
+
+protected:
+
+ void CheckSFXControlsEnable();
+ void CheckVolumeEnable();
+ void CheckControlsEnable();
+
+ void OnButtonSetArchive();
+ bool IsSFX();
+ void OnButtonSFX();
+
+ virtual bool OnInit();
+ virtual bool OnCommand(int code, int itemID, LPARAM lParam);
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ virtual void OnOK();
+ virtual void OnHelp();
+
+};
+
+#endif
diff --git a/7zip/UI/GUI/ExtractDialog.cpp b/CPP/7zip/UI/GUI/ExtractDialog.cpp
index 55c871ad..55c871ad 100755
--- a/7zip/UI/GUI/ExtractDialog.cpp
+++ b/CPP/7zip/UI/GUI/ExtractDialog.cpp
diff --git a/CPP/7zip/UI/GUI/ExtractDialog.h b/CPP/7zip/UI/GUI/ExtractDialog.h
new file mode 100755
index 00000000..0020c693
--- /dev/null
+++ b/CPP/7zip/UI/GUI/ExtractDialog.h
@@ -0,0 +1,77 @@
+// ExtractDialog.h
+
+#ifndef __EXTRACTDIALOG_H
+#define __EXTRACTDIALOG_H
+
+#include "resource.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/Edit.h"
+#include "Windows/Control/ComboBox.h"
+
+#ifndef NO_REGISTRY
+#include "../Common/ZipRegistry.h"
+#endif
+#include "../Common/ExtractMode.h"
+
+namespace NExtractionDialog
+{
+ /*
+ namespace NFilesMode
+ {
+ enum EEnum
+ {
+ kSelected,
+ kAll,
+ kSpecified
+ };
+ }
+ */
+}
+
+class CExtractDialog: public NWindows::NControl::CModalDialog
+{
+ #ifdef NO_REGISTRY
+ NWindows::NControl::CDialogChildControl _path;
+ #else
+ NWindows::NControl::CComboBox _path;
+ #endif
+
+ #ifndef _SFX
+ NWindows::NControl::CEdit _passwordControl;
+ #endif
+
+ #ifndef _SFX
+ void GetPathMode();
+ void SetPathMode();
+ void GetOverwriteMode();
+ void SetOverwriteMode();
+ // int GetFilesMode() const;
+ void UpdatePasswordControl();
+ #endif
+
+ void OnButtonSetPath();
+
+ virtual bool OnInit();
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ virtual void OnOK();
+ #ifndef NO_REGISTRY
+ virtual void OnHelp();
+ #endif
+public:
+ // bool _enableSelectedFilesButton;
+ // bool _enableFilesButton;
+ // NExtractionDialog::NFilesMode::EEnum FilesMode;
+
+ UString DirectoryPath;
+ #ifndef _SFX
+ UString Password;
+ #endif
+ NExtract::NPathMode::EEnum PathMode;
+ NExtract::NOverwriteMode::EEnum OverwriteMode;
+
+ INT_PTR Create(HWND aWndParent = 0)
+ { return CModalDialog::Create(IDD_DIALOG_EXTRACT, aWndParent); }
+};
+
+#endif
diff --git a/7zip/UI/GUI/ExtractGUI.cpp b/CPP/7zip/UI/GUI/ExtractGUI.cpp
index 395df5a9..395df5a9 100755
--- a/7zip/UI/GUI/ExtractGUI.cpp
+++ b/CPP/7zip/UI/GUI/ExtractGUI.cpp
diff --git a/7zip/UI/GUI/ExtractGUI.h b/CPP/7zip/UI/GUI/ExtractGUI.h
index 5a0b157d..5a0b157d 100755
--- a/7zip/UI/GUI/ExtractGUI.h
+++ b/CPP/7zip/UI/GUI/ExtractGUI.h
diff --git a/7zip/UI/GUI/FM.ico b/CPP/7zip/UI/GUI/FM.ico
index 3a0a34da..3a0a34da 100755
--- a/7zip/UI/GUI/FM.ico
+++ b/CPP/7zip/UI/GUI/FM.ico
Binary files differ
diff --git a/7zip/UI/GUI/GUI.cpp b/CPP/7zip/UI/GUI/GUI.cpp
index fe956dbd..fe956dbd 100755
--- a/7zip/UI/GUI/GUI.cpp
+++ b/CPP/7zip/UI/GUI/GUI.cpp
diff --git a/CPP/7zip/UI/GUI/GUI.dsp b/CPP/7zip/UI/GUI/GUI.dsp
new file mode 100755
index 00000000..dadb9648
--- /dev/null
+++ b/CPP/7zip/UI/GUI/GUI.dsp
@@ -0,0 +1,904 @@
+# Microsoft Developer Studio Project File - Name="GUI" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=GUI - Win32 DebugU
+!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 "GUI.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 "GUI.mak" CFG="GUI - Win32 DebugU"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "GUI - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "GUI - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE "GUI - Win32 ReleaseU" (based on "Win32 (x86) Application")
+!MESSAGE "GUI - Win32 DebugU" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "GUI - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /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 /subsystem:windows /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 comctl32.lib htmlhelp.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-Zip\7zg.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "GUI - 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 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /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 /subsystem:windows /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 comctl32.lib htmlhelp.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-Zip\7zg.exe" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "GUI - Win32 ReleaseU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseU"
+# PROP BASE Intermediate_Dir "ReleaseU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseU"
+# PROP Intermediate_Dir "ReleaseU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /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 /subsystem:windows /machine:I386 /out:"C:\UTIL\7zg.exe"
+# 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 comctl32.lib htmlhelp.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-Zip\7zgn.exe" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "GUI - Win32 DebugU"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugU"
+# PROP BASE Intermediate_Dir "DebugU"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugU"
+# PROP Intermediate_Dir "DebugU"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /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 /subsystem:windows /debug /machine:I386 /out:"C:\UTIL\7zg.exe" /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 comctl32.lib htmlhelp.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-Zip\7zgn.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "GUI - Win32 Release"
+# Name "GUI - Win32 Debug"
+# Name "GUI - Win32 ReleaseU"
+# Name "GUI - Win32 DebugU"
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\7zG.exe.manifest
+# End Source File
+# Begin Source File
+
+SOURCE=.\FM.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# 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 "SDK"
+
+# PROP Default_Filter ""
+# Begin Group "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CommandLineParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CommandLineParser.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\Lang.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Lang.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\ListFileUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\ListFileUtils.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\StdInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StdInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\String.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
+# Begin Source File
+
+SOURCE=..\..\..\Common\TextConfig.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\TextConfig.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\UTFConvert.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\UTFConvert.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Vector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Wildcard.h
+# End Source File
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# Begin Group "Control"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\ComboBox.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\ComboBox.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\Dialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\Dialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\Edit.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\ProgressBar.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=..\..\..\Windows\CommonDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\CommonDialog.h
+# End Source File
+# 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\Error.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Error.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.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\MemoryLock.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\MemoryLock.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\PropVariantConversions.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\PropVariantConversions.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Registry.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Registry.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\ResourceString.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\ResourceString.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Shell.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Shell.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\Window.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Window.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "UI Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Common\ArchiveCommandLine.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveCommandLine.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveExtractCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveExtractCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveOpenCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiveOpenCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiverInfo.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ArchiverInfo.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\DefaultName.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\DefaultName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\DirItem.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\EnumDirItems.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\EnumDirItems.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ExitCode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\Extract.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\Extract.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ExtractingFilePath.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ExtractingFilePath.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ExtractMode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\HandlerLoader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\IFileExtractCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\OpenArchive.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\OpenArchive.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\Property.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\PropIDUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\PropIDUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\SetProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\SetProperties.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\SortUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\SortUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\TempFiles.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\TempFiles.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\Update.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\Update.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateAction.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateAction.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdatePair.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdatePair.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateProduce.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\UpdateProduce.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\WorkDir.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\WorkDir.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ZipRegistry.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ZipRegistry.h
+# End Source File
+# End Group
+# Begin Group "Explorer"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Explorer\MyMessages.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Explorer\MyMessages.h
+# End Source File
+# End Group
+# Begin Group "Dialogs"
+
+# PROP Default_Filter ""
+# Begin Group "Progress"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\FileManager\Resource\ProgressDialog2\ProgressDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\Resource\ProgressDialog2\ProgressDialog.h
+# End Source File
+# End Group
+# Begin Group "Messages"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\FileManager\Resource\MessagesDialog\MessagesDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\Resource\MessagesDialog\MessagesDialog.h
+# End Source File
+# End Group
+# Begin Group "Overwtite"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\FileManager\Resource\OverwriteDialog\OverwriteDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\Resource\OverwriteDialog\OverwriteDialog.h
+# End Source File
+# End Group
+# Begin Group "Password"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\FileManager\Resource\PasswordDialog\PasswordDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\Resource\PasswordDialog\PasswordDialog.h
+# End Source File
+# End Group
+# Begin Group "Compress Dialog"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\CompressDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\CompressDialog.h
+# End Source File
+# End Group
+# Begin Group "Extract Dialog"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\ExtractDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ExtractDialog.h
+# End Source File
+# End Group
+# End Group
+# Begin Group "FM Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\FileManager\ExtractCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\ExtractCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\FolderInterface.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\FormatUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\FormatUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\HelpUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\HelpUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\LangUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\LangUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\OpenCallback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\OpenCallback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\ProgramLocation.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\ProgramLocation.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\RegistryUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\RegistryUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\SplitUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\SplitUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\StringUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\StringUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\UpdateCallback100.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\FileManager\UpdateCallback100.h
+# End Source File
+# End Group
+# Begin Group "Engine"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\ExtractGUI.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ExtractGUI.h
+# End Source File
+# Begin Source File
+
+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
+
+SOURCE=.\UpdateCallbackGUI.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\UpdateGUI.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\UpdateGUI.h
+# End Source File
+# End Group
+# Begin Group "7-zip Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.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 "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
+# End Target
+# End Project
diff --git a/7zip/UI/GUI/GUI.dsw b/CPP/7zip/UI/GUI/GUI.dsw
index 85d33484..85d33484 100755
--- a/7zip/UI/GUI/GUI.dsw
+++ b/CPP/7zip/UI/GUI/GUI.dsw
diff --git a/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp b/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp
new file mode 100755
index 00000000..bc6cf393
--- /dev/null
+++ b/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp
@@ -0,0 +1,65 @@
+// OpenCallbackGUI.cpp
+
+#include "StdAfx.h"
+
+#include "OpenCallbackGUI.h"
+
+#include "Common/StdOutStream.h"
+#include "Common/StdInStream.h"
+#include "Common/StringConvert.h"
+
+#ifndef _NO_CRYPTO
+#include "../../FileManager/Resource/PasswordDialog/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
new file mode 100755
index 00000000..6b531d3c
--- /dev/null
+++ b/CPP/7zip/UI/GUI/OpenCallbackGUI.h
@@ -0,0 +1,35 @@
+// 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/StdAfx.cpp b/CPP/7zip/UI/GUI/StdAfx.cpp
new file mode 100755
index 00000000..d0feea85
--- /dev/null
+++ b/CPP/7zip/UI/GUI/StdAfx.cpp
@@ -0,0 +1,3 @@
+// StdAfx.cpp
+
+#include "StdAfx.h"
diff --git a/7zip/UI/GUI/StdAfx.h b/CPP/7zip/UI/GUI/StdAfx.h
index 46ea51cf..46ea51cf 100755
--- a/7zip/UI/GUI/StdAfx.h
+++ b/CPP/7zip/UI/GUI/StdAfx.h
diff --git a/7zip/UI/GUI/UpdateCallbackGUI.cpp b/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp
index eff29953..eff29953 100755
--- a/7zip/UI/GUI/UpdateCallbackGUI.cpp
+++ b/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp
diff --git a/7zip/UI/GUI/UpdateCallbackGUI.h b/CPP/7zip/UI/GUI/UpdateCallbackGUI.h
index 16f0220c..16f0220c 100755
--- a/7zip/UI/GUI/UpdateCallbackGUI.h
+++ b/CPP/7zip/UI/GUI/UpdateCallbackGUI.h
diff --git a/7zip/UI/GUI/UpdateGUI.cpp b/CPP/7zip/UI/GUI/UpdateGUI.cpp
index e39e7faf..e39e7faf 100755
--- a/7zip/UI/GUI/UpdateGUI.cpp
+++ b/CPP/7zip/UI/GUI/UpdateGUI.cpp
diff --git a/7zip/UI/GUI/UpdateGUI.h b/CPP/7zip/UI/GUI/UpdateGUI.h
index c5061aca..c5061aca 100755
--- a/7zip/UI/GUI/UpdateGUI.h
+++ b/CPP/7zip/UI/GUI/UpdateGUI.h
diff --git a/CPP/7zip/UI/GUI/makefile b/CPP/7zip/UI/GUI/makefile
new file mode 100755
index 00000000..bc6af149
--- /dev/null
+++ b/CPP/7zip/UI/GUI/makefile
@@ -0,0 +1,135 @@
+PROG = 7zG.exe
+LIBS = $(LIBS) user32.lib advapi32.lib oleaut32.lib shell32.lib comctl32.lib htmlhelp.lib ole32.lib comdlg32.lib
+CFLAGS = $(CFLAGS) -I ../../../ -DLANG -DCOMPRESS_MT -DWIN_LONG_PATH
+
+GUI_OBJS = \
+ $O\CompressDialog.obj \
+ $O\ExtractDialog.obj \
+ $O\ExtractGUI.obj \
+ $O\GUI.obj \
+ $O\OpenCallbackGUI.obj \
+ $O\UpdateCallbackGUI.obj \
+ $O\UpdateGUI.obj \
+
+COMMON_OBJS = \
+ $O\Alloc.obj \
+ $O\CommandLineParser.obj \
+ $O\IntToString.obj \
+ $O\Lang.obj \
+ $O\ListFileUtils.obj \
+ $O\NewHandler.obj \
+ $O\StdInStream.obj \
+ $O\String.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\TextConfig.obj \
+ $O\UTFConvert.obj \
+ $O\Vector.obj \
+ $O\Wildcard.obj \
+
+WIN_OBJS = \
+ $O\CommonDialog.obj \
+ $O\DLL.obj \
+ $O\Error.obj \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\FileName.obj \
+ $O\MemoryLock.obj \
+ $O\PropVariant.obj \
+ $O\PropVariantConversions.obj \
+ $O\Registry.obj \
+ $O\ResourceString.obj \
+ $O\Shell.obj \
+ $O\Synchronization.obj \
+ $O\Window.obj \
+
+WIN_CTRL_OBJS = \
+ $O\ComboBox.obj \
+ $O\Dialog.obj \
+ $O\ListView.obj \
+
+7ZIP_COMMON_OBJS = \
+ $O\FilePathAutoRename.obj \
+ $O\FileStreams.obj \
+ $O\StreamUtils.obj \
+
+UI_COMMON_OBJS = \
+ $O\ArchiveCommandLine.obj \
+ $O\ArchiveExtractCallback.obj \
+ $O\ArchiveOpenCallback.obj \
+ $O\ArchiverInfo.obj \
+ $O\DefaultName.obj \
+ $O\EnumDirItems.obj \
+ $O\Extract.obj \
+ $O\ExtractingFilePath.obj \
+ $O\OpenArchive.obj \
+ $O\PropIDUtils.obj \
+ $O\SetProperties.obj \
+ $O\SortUtils.obj \
+ $O\TempFiles.obj \
+ $O\Update.obj \
+ $O\UpdateAction.obj \
+ $O\UpdateCallback.obj \
+ $O\UpdatePair.obj \
+ $O\UpdateProduce.obj \
+ $O\WorkDir.obj \
+ $O\ZipRegistry.obj \
+
+FM_OBJS = \
+ $O\ExtractCallback.obj \
+ $O\FormatUtils.obj \
+ $O\HelpUtils.obj \
+ $O\LangUtils.obj \
+ $O\OpenCallback.obj \
+ $O\ProgramLocation.obj \
+ $O\RegistryUtils.obj \
+ $O\SplitUtils.obj \
+ $O\StringUtils.obj \
+ $O\UpdateCallback100.obj \
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(GUI_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(WIN_CTRL_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $(FM_OBJS)\
+ $O\MyMessages.obj \
+ $O\MessagesDialog.obj \
+ $O\OverwriteDialog.obj \
+ $O\PasswordDialog.obj \
+ $O\ProgressDialog.obj \
+ $O\CopyCoder.obj \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(GUI_OBJS): $(*B).cpp
+ $(COMPL)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(UI_COMMON_OBJS): ../Common/$(*B).cpp
+ $(COMPL)
+$(FM_OBJS): ../../FileManager/$(*B).cpp
+ $(COMPL)
+$O\MyMessages.obj: ../Explorer/MyMessages.cpp
+ $(COMPL)
+$O\MessagesDialog.obj: ../../FileManager/Resource/MessagesDialog/$(*B).cpp
+ $(COMPL)
+$O\OverwriteDialog.obj: ../../FileManager/Resource/OverwriteDialog./$(*B).cpp
+ $(COMPL)
+$O\PasswordDialog.obj: ../../FileManager/Resource/PasswordDialog/$(*B).cpp
+ $(COMPL)
+$O\ProgressDialog.obj: ../../FileManager/Resource/ProgressDialog2/$(*B).cpp
+ $(COMPL)
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
diff --git a/CPP/7zip/UI/GUI/resource.h b/CPP/7zip/UI/GUI/resource.h
new file mode 100755
index 00000000..d88af787
--- /dev/null
+++ b/CPP/7zip/UI/GUI/resource.h
@@ -0,0 +1,45 @@
+#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_OPEN_TYPE_ALL_FILES 80
+
+#define IDS_METHOD_STORE 81
+#define IDS_METHOD_NORMAL 82
+#define IDS_METHOD_MAXIMUM 83
+#define IDS_METHOD_FAST 84
+#define IDS_METHOD_FASTEST 85
+#define IDS_METHOD_ULTRA 86
+
+#define IDS_COMPRESS_UPDATE_MODE_ADD 90
+#define IDS_COMPRESS_UPDATE_MODE_UPDATE 91
+#define IDS_COMPRESS_UPDATE_MODE_FRESH 92
+#define IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE 93
+
+#define IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE 94
+#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95
+
+#define IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE 96
+#define IDS_CANT_UPDATE_ARCHIVE 97
+
+#define IDS_PROGRESS_COMPRESSING 98
+#define IDS_PROGRESS_TESTING 99
+#define IDS_ERROR 100
+#define IDS_MESSAGE_NO_ERRORS 101
+#define IDS_CONFIG_DIALOG_CAPTION 102
+
+#define IDS_PASSWORD_USE_ASCII 110
+#define IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH 111
+#define IDS_PASSWORD_IS_TOO_LONG 112
+
+#define IDD_DIALOG_EXTRACT 137
+#define IDB_DELETE 149
+#define IDC_LIST1 1067
+#define IDC_COLUMN_EDIT_WIDTH 1068
+
diff --git a/CPP/7zip/UI/GUI/resource.rc b/CPP/7zip/UI/GUI/resource.rc
new file mode 100755
index 00000000..19f7e61b
--- /dev/null
+++ b/CPP/7zip/UI/GUI/resource.rc
@@ -0,0 +1,57 @@
+#include "../../MyVersionInfo.rc"
+#include <winnt.h>
+#include "resource.h"
+
+MY_VERSION_INFO_APP("7-Zip GUI", "7zg")
+
+IDI_ICON1 ICON "FM.ico"
+
+1 24 MOVEABLE PURE "7zG.exe.manifest"
+
+STRINGTABLE
+BEGIN
+ IDS_CONTEXT_EXTRACT "Extract files..."
+ IDS_CONTEXT_EXTRACT_HELP "Extracts files from the selected archive."
+ IDS_CONTEXT_COMPRESS "Add to archive..."
+ IDS_CONTEXT_COMPRESS_HELP "Adds the selected items to archive."
+ IDS_CONTEXT_OPEN "Open"
+ IDS_CONTEXT_OPEN_HELP "Opens the selected archive."
+ IDS_CONTEXT_TEST "Test archive"
+ IDS_CONTEXT_TEST_HELP "Tests integrity of the selected archive."
+ IDS_CONTEXT_CAPTION_HELP "7-Zip commands"
+ IDS_CONTEXT_POPUP_CAPTION "7-Zip"
+ IDS_OPEN_TYPE_ALL_FILES "All Files"
+ IDS_METHOD_STORE "Store"
+ IDS_METHOD_NORMAL "Normal"
+ IDS_METHOD_MAXIMUM "Maximum"
+ IDS_METHOD_FAST "Fast"
+ IDS_METHOD_FASTEST "Fastest"
+ IDS_METHOD_ULTRA "Ultra"
+ IDS_COMPRESS_UPDATE_MODE_ADD "Add and replace files"
+ IDS_COMPRESS_UPDATE_MODE_UPDATE "Update and add files"
+ IDS_COMPRESS_UPDATE_MODE_FRESH "Freshen existing files"
+ IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE "Synchronize files"
+ IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE "Browse"
+ IDS_COMPRESS_INCORRECT_VOLUME_SIZE "Incorrect volume size"
+ IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE "Specified volume size: {0} bytes.\nAre you sure you want to split archive into such volumes?"
+
+ IDS_PASSWORD_USE_ASCII "Use only English letters, numbers and special characters (!, #, $, ...) for password."
+ IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH "Passwords do not match"
+ IDS_PASSWORD_IS_TOO_LONG "Password is too long"
+
+ IDS_CANT_UPDATE_ARCHIVE "Can not update archive '{0}'"
+ IDS_PROGRESS_COMPRESSING "Compressing"
+ IDS_PROGRESS_TESTING "Testing"
+ IDS_ERROR "Error"
+ IDS_MESSAGE_NO_ERRORS "There are no errors"
+ IDS_CONFIG_DIALOG_CAPTION "7-Zip Options"
+END
+
+#include "../../FileManager/Resource/PropertyName/resource.rc"
+#include "../../FileManager/Resource/OverwriteDialog/resource.rc"
+#include "../../FileManager/Resource/PasswordDialog/resource.rc"
+#include "../../FileManager/Resource/MessagesDialog/resource.rc"
+#include "../../FileManager/Resource/ProgressDialog2/resource.rc"
+#include "../Resource/Extract/resource.rc"
+#include "../Resource/ExtractDialog/resource.rc"
+#include "../Resource/CompressDialog/resource.rc"
diff --git a/7zip/UI/Resource/CompressDialog/resource.h b/CPP/7zip/UI/Resource/CompressDialog/resource.h
index 847bb3f9..847bb3f9 100755
--- a/7zip/UI/Resource/CompressDialog/resource.h
+++ b/CPP/7zip/UI/Resource/CompressDialog/resource.h
diff --git a/7zip/UI/Resource/CompressDialog/resource.rc b/CPP/7zip/UI/Resource/CompressDialog/resource.rc
index 9019a1af..9019a1af 100755
--- a/7zip/UI/Resource/CompressDialog/resource.rc
+++ b/CPP/7zip/UI/Resource/CompressDialog/resource.rc
diff --git a/CPP/7zip/UI/Resource/Extract/resource.h b/CPP/7zip/UI/Resource/Extract/resource.h
new file mode 100755
index 00000000..917c0a34
--- /dev/null
+++ b/CPP/7zip/UI/Resource/Extract/resource.h
@@ -0,0 +1,15 @@
+#define IDS_CANNOT_CREATE_FOLDER 200
+#define IDS_OPEN_IS_NOT_SUPORTED_ARCHIVE 201
+
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC 202
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR 203
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD 204
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED 205
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED 206
+
+#define IDS_EXTRACT_SET_FOLDER 207
+#define IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CANNOT_OPEN_FILE 208
+#define IDS_PROGRESS_EXTRACTING 209
+
+#define IDS_CANT_OPEN_ARCHIVE 103
+#define IDS_CANT_OPEN_ENCRYPTED_ARCHIVE 104
diff --git a/CPP/7zip/UI/Resource/Extract/resource.rc b/CPP/7zip/UI/Resource/Extract/resource.rc
new file mode 100755
index 00000000..d3fd1df9
--- /dev/null
+++ b/CPP/7zip/UI/Resource/Extract/resource.rc
@@ -0,0 +1,19 @@
+#include "resource.h"
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ 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."
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR "Data error in '{0}'. File is broken"
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED "CRC failed in encrypted file '{0}'. Wrong password?"
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED "Data error in encrypted file '{0}'. Wrong password?"
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD "Unsupported compression method for '{0}'."
+ IDS_EXTRACT_SET_FOLDER "Specify a location for extracted files."
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CANNOT_OPEN_FILE "Can not open output file '{0}'."
+ 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?"
+END
diff --git a/7zip/UI/Resource/ExtractDialog/resource.h b/CPP/7zip/UI/Resource/ExtractDialog/resource.h
index 338a2561..338a2561 100755
--- a/7zip/UI/Resource/ExtractDialog/resource.h
+++ b/CPP/7zip/UI/Resource/ExtractDialog/resource.h
diff --git a/CPP/7zip/UI/Resource/ExtractDialog/resource.rc b/CPP/7zip/UI/Resource/ExtractDialog/resource.rc
new file mode 100755
index 00000000..05cf5ea6
--- /dev/null
+++ b/CPP/7zip/UI/Resource/ExtractDialog/resource.rc
@@ -0,0 +1,80 @@
+#include "resource.h"
+#include "../../../GuiCommon.rc"
+
+#define xSize2 285
+#define ySize2 204
+
+#define xSize (xSize2 + marg + marg)
+#define ySize (ySize2 + marg + marg)
+
+#undef g1XSize
+#undef g1XSize2
+#undef g1XPos2
+#undef g2XPos
+#undef g2XPos2
+#undef g2XSize
+#undef g2XSize2
+
+#define bYPos (ySize - marg - bYSize)
+
+#define g1XSize 127
+#define g1XSize2 (g1XSize - 13)
+#define g1XPos2 (marg + 7)
+
+#define gSpace 14
+#define g2XPos (marg + g1XSize + gSpace)
+#define g2XPos2 (g2XPos + 7)
+#define g2XSize (xSize2 - g1XSize - gSpace)
+#define g2XSize2 (g2XSize - 14)
+
+#define bXPos1 (xSize - marg - bXSize)
+#define bXPos2 (bXPos1 - 10 - bXSize)
+#define bXPos3 (bXPos2 - 10 - bXSize)
+
+IDD_DIALOG_EXTRACT DIALOG DISCARDABLE 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
+CAPTION "Extract"
+MY_FONT
+BEGIN
+ LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, marg, marg, xSize2, 8
+
+ COMBOBOX IDC_EXTRACT_COMBO_PATH, marg, 21, xSize2 - bDotsSize - 13, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+
+ PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xSize - marg - bDotsSize, 20, bDotsSize, bYSize, WS_GROUP
+
+ GROUPBOX "Path mode",IDC_EXTRACT_PATH_MODE, marg, 44, g1XSize, 57
+ CONTROL "Full pathnames", IDC_EXTRACT_RADIO_FULL_PATHNAMES,"Button", BS_AUTORADIOBUTTON | WS_GROUP,
+ g1XPos2, 57, g1XSize2, 10
+ CONTROL "Current pathnames",IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, "Button", BS_AUTORADIOBUTTON,
+ g1XPos2, 71, g1XSize2, 10
+ CONTROL "No pathnames", IDC_EXTRACT_RADIO_NO_PATHNAMES, "Button", BS_AUTORADIOBUTTON,
+ g1XPos2, 85, g1XSize2, 10
+
+ GROUPBOX "Overwrite mode",IDC_EXTRACT_OVERWRITE_MODE, g2XPos, 44, g2XSize, 88, WS_GROUP
+ CONTROL "Ask before overwrite", IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, "Button", BS_AUTORADIOBUTTON | WS_GROUP,
+ g2XPos2, 57, g2XSize2, 10
+ CONTROL "Overwrite without prompt", IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, "Button", BS_AUTORADIOBUTTON,
+ g2XPos2, 71, g2XSize2, 10
+ CONTROL "Skip existing files", IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, "Button", BS_AUTORADIOBUTTON,
+ g2XPos2, 85, g2XSize2, 10
+ CONTROL "Auto rename", IDC_EXTRACT_RADIO_AUTO_RENAME, "Button", BS_AUTORADIOBUTTON,
+ g2XPos2, 99, g2XSize2, 10
+ CONTROL "Auto rename existing files", IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, "Button", BS_AUTORADIOBUTTON,
+ g2XPos2,113, g2XSize2, 10
+
+ GROUPBOX "Files",IDC_EXTRACT_FILES, marg, 140, 127, 48, NOT WS_VISIBLE | WS_DISABLED | WS_GROUP
+ CONTROL "&Selected files",IDC_EXTRACT_RADIO_SELECTED_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_GROUP,
+ g1XPos2, 153, g1XSize2, 10
+ CONTROL "&All files",IDC_EXTRACT_RADIO_ALL_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED,
+ g1XPos2, 166, g1XSize2, 10
+
+ GROUPBOX "Password",IDC_EXTRACT_PASSWORD, g2XPos, 142, g2XSize, 46
+ EDITTEXT IDC_EXTRACT_EDIT_PASSWORD,154,153,130,14, ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Show Password",IDC_EXTRACT_CHECK_SHOW_PASSWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ g2XPos2, 172, g2XSize2, 10
+
+ DEFPUSHBUTTON "OK", IDOK, bXPos3, bYPos, bXSize, bYSize, WS_GROUP
+ PUSHBUTTON "Cancel", IDCANCEL, bXPos2, bYPos, bXSize, bYSize
+ PUSHBUTTON "Help", IDHELP, bXPos1, bYPos, bXSize, bYSize
+END
+
+
diff --git a/7zip/UI/makefile b/CPP/7zip/UI/makefile
index 942beaa0..942beaa0 100755
--- a/7zip/UI/makefile
+++ b/CPP/7zip/UI/makefile
diff --git a/7zip/makefile b/CPP/7zip/makefile
index 1db4c9ad..1db4c9ad 100755
--- a/7zip/makefile
+++ b/CPP/7zip/makefile
diff --git a/Build.mak b/CPP/Build.mak
index 4f25c853..4f25c853 100755
--- a/Build.mak
+++ b/CPP/Build.mak
diff --git a/Common/AlignedBuffer.cpp b/CPP/Common/AlignedBuffer.cpp
index ec472ced..ec472ced 100755
--- a/Common/AlignedBuffer.cpp
+++ b/CPP/Common/AlignedBuffer.cpp
diff --git a/Common/AlignedBuffer.h b/CPP/Common/AlignedBuffer.h
index d040463e..d040463e 100755
--- a/Common/AlignedBuffer.h
+++ b/CPP/Common/AlignedBuffer.h
diff --git a/Common/Alloc.cpp b/CPP/Common/Alloc.cpp
index e4fc6a81..e4fc6a81 100755
--- a/Common/Alloc.cpp
+++ b/CPP/Common/Alloc.cpp
diff --git a/Common/Alloc.h b/CPP/Common/Alloc.h
index d444f631..d444f631 100755
--- a/Common/Alloc.h
+++ b/CPP/Common/Alloc.h
diff --git a/CPP/Common/AutoPtr.h b/CPP/Common/AutoPtr.h
new file mode 100755
index 00000000..c5808cb0
--- /dev/null
+++ b/CPP/Common/AutoPtr.h
@@ -0,0 +1,35 @@
+// Common/AutoPtr.h
+
+#ifndef __COMMON_AUTOPTR_H
+#define __COMMON_AUTOPTR_H
+
+template<class T> class CMyAutoPtr
+{
+ T *_p;
+public:
+ CMyAutoPtr(T *p = 0) : _p(p) {}
+ CMyAutoPtr(CMyAutoPtr<T>& p): _p(p.release()) {}
+ CMyAutoPtr<T>& operator=(CMyAutoPtr<T>& p)
+ {
+ reset(p.release());
+ return (*this);
+ }
+ ~CMyAutoPtr() { delete _p; }
+ T& operator*() const { return *_p; }
+ // T* operator->() const { return (&**this); }
+ T* get() const { return _p; }
+ T* release()
+ {
+ T *tmp = _p;
+ _p = 0;
+ return tmp;
+ }
+ void reset(T* p = 0)
+ {
+ if (p != _p)
+ delete _p;
+ _p = p;
+ }
+};
+
+#endif
diff --git a/CPP/Common/Buffer.h b/CPP/Common/Buffer.h
new file mode 100755
index 00000000..0b8ac804
--- /dev/null
+++ b/CPP/Common/Buffer.h
@@ -0,0 +1,77 @@
+// Common/Buffer.h
+
+#ifndef __COMMON_BUFFER_H
+#define __COMMON_BUFFER_H
+
+#include "Defs.h"
+
+template <class T> class CBuffer
+{
+protected:
+ size_t _capacity;
+ T *_items;
+ void Free()
+ {
+ delete []_items;
+ _items = 0;
+ _capacity = 0;
+ }
+public:
+ CBuffer(): _capacity(0), _items(0) {};
+ CBuffer(const CBuffer &buffer): _capacity(0), _items(0) { *this = buffer; }
+ CBuffer(size_t size): _items(0), _capacity(0) { SetCapacity(size); }
+ virtual ~CBuffer() { delete []_items; }
+ operator T *() { return _items; };
+ operator const T *() const { return _items; };
+ size_t GetCapacity() const { return _capacity; }
+ void SetCapacity(size_t newCapacity)
+ {
+ if (newCapacity == _capacity)
+ return;
+ T *newBuffer;
+ if (newCapacity > 0)
+ {
+ newBuffer = new T[newCapacity];
+ if(_capacity > 0)
+ memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T));
+ }
+ else
+ newBuffer = 0;
+ delete []_items;
+ _items = newBuffer;
+ _capacity = newCapacity;
+ }
+ CBuffer& operator=(const CBuffer &buffer)
+ {
+ Free();
+ if(buffer._capacity > 0)
+ {
+ SetCapacity(buffer._capacity);
+ memmove(_items, buffer._items, buffer._capacity * sizeof(T));
+ }
+ return *this;
+ }
+};
+
+template <class T>
+bool operator==(const CBuffer<T>& b1, const CBuffer<T>& b2)
+{
+ if (b1.GetCapacity() != b2.GetCapacity())
+ return false;
+ for (size_t i = 0; i < b1.GetCapacity(); i++)
+ if (b1[i] != b2[i])
+ return false;
+ return true;
+}
+
+template <class T>
+bool operator!=(const CBuffer<T>& b1, const CBuffer<T>& b2)
+{
+ return !(b1 == b2);
+}
+
+typedef CBuffer<char> CCharBuffer;
+typedef CBuffer<wchar_t> CWCharBuffer;
+typedef CBuffer<unsigned char> CByteBuffer;
+
+#endif
diff --git a/Common/CRC.cpp b/CPP/Common/CRC.cpp
index 35e1a187..35e1a187 100755
--- a/Common/CRC.cpp
+++ b/CPP/Common/CRC.cpp
diff --git a/CPP/Common/CRC.h b/CPP/Common/CRC.h
new file mode 100755
index 00000000..277ae673
--- /dev/null
+++ b/CPP/Common/CRC.h
@@ -0,0 +1,36 @@
+// Common/CRC.h
+
+#ifndef __COMMON_CRC_H
+#define __COMMON_CRC_H
+
+#include <stddef.h>
+#include "Types.h"
+
+class CCRC
+{
+ UInt32 _value;
+public:
+ static UInt32 Table[256];
+ static void InitTable();
+
+ CCRC(): _value(0xFFFFFFFF){};
+ void Init() { _value = 0xFFFFFFFF; }
+ void UpdateByte(Byte v);
+ void UpdateUInt16(UInt16 v);
+ void UpdateUInt32(UInt32 v);
+ void UpdateUInt64(UInt64 v);
+ void Update(const void *data, size_t size);
+ UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
+ static UInt32 CalculateDigest(const void *data, size_t size)
+ {
+ CCRC crc;
+ crc.Update(data, size);
+ return crc.GetDigest();
+ }
+ static bool VerifyDigest(UInt32 digest, const void *data, size_t size)
+ {
+ return (CalculateDigest(data, size) == digest);
+ }
+};
+
+#endif
diff --git a/Common/C_FileIO.cpp b/CPP/Common/C_FileIO.cpp
index 7d9e00d0..7d9e00d0 100755
--- a/Common/C_FileIO.cpp
+++ b/CPP/Common/C_FileIO.cpp
diff --git a/Common/C_FileIO.h b/CPP/Common/C_FileIO.h
index 2ad07167..2ad07167 100755
--- a/Common/C_FileIO.h
+++ b/CPP/Common/C_FileIO.h
diff --git a/Common/ComTry.h b/CPP/Common/ComTry.h
index 5153362f..5153362f 100755
--- a/Common/ComTry.h
+++ b/CPP/Common/ComTry.h
diff --git a/Common/CommandLineParser.cpp b/CPP/Common/CommandLineParser.cpp
index 67f72675..67f72675 100755
--- a/Common/CommandLineParser.cpp
+++ b/CPP/Common/CommandLineParser.cpp
diff --git a/Common/CommandLineParser.h b/CPP/Common/CommandLineParser.h
index f59d8e4c..f59d8e4c 100755
--- a/Common/CommandLineParser.h
+++ b/CPP/Common/CommandLineParser.h
diff --git a/Common/Defs.h b/CPP/Common/Defs.h
index dad3ae8f..dad3ae8f 100755
--- a/Common/Defs.h
+++ b/CPP/Common/Defs.h
diff --git a/Common/DynamicBuffer.h b/CPP/Common/DynamicBuffer.h
index 1709657d..1709657d 100755
--- a/Common/DynamicBuffer.h
+++ b/CPP/Common/DynamicBuffer.h
diff --git a/Common/Exception.h b/CPP/Common/Exception.h
index d7f86a90..d7f86a90 100755
--- a/Common/Exception.h
+++ b/CPP/Common/Exception.h
diff --git a/Common/IntToString.cpp b/CPP/Common/IntToString.cpp
index 7d81d966..7d81d966 100755
--- a/Common/IntToString.cpp
+++ b/CPP/Common/IntToString.cpp
diff --git a/Common/IntToString.h b/CPP/Common/IntToString.h
index cf86090f..cf86090f 100755
--- a/Common/IntToString.h
+++ b/CPP/Common/IntToString.h
diff --git a/CPP/Common/Lang.cpp b/CPP/Common/Lang.cpp
new file mode 100755
index 00000000..f1861d6e
--- /dev/null
+++ b/CPP/Common/Lang.cpp
@@ -0,0 +1,142 @@
+// Common/Lang.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Lang.h"
+#include "Common/TextConfig.h"
+
+#include "StdInStream.h"
+#include "UTFConvert.h"
+#include "Defs.h"
+
+/*
+static UInt32 HexStringToNumber(const char *string, int &finishPos)
+{
+ UInt32 number = 0;
+ for (finishPos = 0; finishPos < 8; finishPos++)
+ {
+ char c = string[finishPos];
+ int a;
+ if (c >= '0' && c <= '9')
+ a = c - '0';
+ else if (c >= 'A' && c <= 'F')
+ a = 10 + c - 'A';
+ else if (c >= 'a' && c <= 'f')
+ a = 10 + c - 'a';
+ else
+ return number;
+ number *= 0x10;
+ number += a;
+ }
+ return number;
+}
+*/
+static bool HexStringToNumber(const UString &string, UInt32 &aResultValue)
+{
+ aResultValue = 0;
+ if (string.IsEmpty())
+ return false;
+ for (int i = 0; i < string.Length(); i++)
+ {
+ wchar_t c = string[i];
+ int a;
+ if (c >= L'0' && c <= L'9')
+ a = c - L'0';
+ else if (c >= L'A' && c <= L'F')
+ a = 10 + c - L'A';
+ else if (c >= L'a' && c <= L'f')
+ a = 10 + c - L'a';
+ else
+ return false;
+ aResultValue *= 0x10;
+ aResultValue += a;
+ }
+ return true;
+}
+
+
+static bool WaitNextLine(const AString &string, int &pos)
+{
+ for (;pos < string.Length(); pos++)
+ if (string[pos] == 0x0A)
+ return true;
+ return false;
+}
+
+static int CompareLangItems(void *const *elem1, void *const *elem2, void *)
+{
+ const CLangPair &langPair1 = *(*((const CLangPair **)elem1));
+ const CLangPair &langPair2 = *(*((const CLangPair **)elem2));
+ return MyCompare(langPair1.Value, langPair2.Value);
+}
+
+bool CLang::Open(LPCTSTR fileName)
+{
+ _langPairs.Clear();
+ CStdInStream file;
+ if (!file.Open(fileName))
+ return false;
+ AString string;
+ file.ReadToString(string);
+ file.Close();
+ int pos = 0;
+ if (string.Length() >= 3)
+ {
+ if (Byte(string[0]) == 0xEF && Byte(string[1]) == 0xBB && Byte(string[2]) == 0xBF)
+ pos += 3;
+ }
+
+ /////////////////////
+ // read header
+
+ AString stringID = ";!@Lang@!UTF-8!";
+ if (string.Mid(pos, stringID.Length()) != stringID)
+ return false;
+ pos += stringID.Length();
+
+ if (!WaitNextLine(string, pos))
+ return false;
+
+ CObjectVector<CTextConfigPair> pairs;
+ if (!GetTextConfig(string.Mid(pos), pairs))
+ return false;
+
+ _langPairs.Reserve(_langPairs.Size());
+ for (int i = 0; i < pairs.Size(); i++)
+ {
+ CTextConfigPair textConfigPair = pairs[i];
+ CLangPair langPair;
+ if (!HexStringToNumber(textConfigPair.ID, langPair.Value))
+ return false;
+ langPair.String = textConfigPair.String;
+ _langPairs.Add(langPair);
+ }
+ _langPairs.Sort(CompareLangItems, NULL);
+ return true;
+}
+
+int CLang::FindItem(UInt32 value) const
+{
+ int left = 0, right = _langPairs.Size();
+ while (left != right)
+ {
+ UInt32 mid = (left + right) / 2;
+ UInt32 midValue = _langPairs[mid].Value;
+ if (value == midValue)
+ return mid;
+ if (value < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ return -1;
+}
+
+bool CLang::GetMessage(UInt32 value, UString &message) const
+{
+ int index = FindItem(value);
+ if (index < 0)
+ return false;
+ message = _langPairs[index].String;
+ return true;
+}
diff --git a/Common/Lang.h b/CPP/Common/Lang.h
index 2b4615d0..2b4615d0 100755
--- a/Common/Lang.h
+++ b/CPP/Common/Lang.h
diff --git a/Common/ListFileUtils.cpp b/CPP/Common/ListFileUtils.cpp
index ea4cde38..ea4cde38 100755
--- a/Common/ListFileUtils.cpp
+++ b/CPP/Common/ListFileUtils.cpp
diff --git a/Common/ListFileUtils.h b/CPP/Common/ListFileUtils.h
index 93bb4507..93bb4507 100755
--- a/Common/ListFileUtils.h
+++ b/CPP/Common/ListFileUtils.h
diff --git a/Common/MyCom.h b/CPP/Common/MyCom.h
index e9034930..e9034930 100755
--- a/Common/MyCom.h
+++ b/CPP/Common/MyCom.h
diff --git a/Common/MyGuidDef.h b/CPP/Common/MyGuidDef.h
index 2c954f81..2c954f81 100755
--- a/Common/MyGuidDef.h
+++ b/CPP/Common/MyGuidDef.h
diff --git a/Common/MyInitGuid.h b/CPP/Common/MyInitGuid.h
index 5bdfeed5..5bdfeed5 100755
--- a/Common/MyInitGuid.h
+++ b/CPP/Common/MyInitGuid.h
diff --git a/Common/MyUnknown.h b/CPP/Common/MyUnknown.h
index d28d8542..d28d8542 100755
--- a/Common/MyUnknown.h
+++ b/CPP/Common/MyUnknown.h
diff --git a/Common/MyWindows.cpp b/CPP/Common/MyWindows.cpp
index 4cf065cf..4cf065cf 100755
--- a/Common/MyWindows.cpp
+++ b/CPP/Common/MyWindows.cpp
diff --git a/CPP/Common/MyWindows.h b/CPP/Common/MyWindows.h
new file mode 100755
index 00000000..a93d750a
--- /dev/null
+++ b/CPP/Common/MyWindows.h
@@ -0,0 +1,203 @@
+// MyWindows.h
+
+#ifndef __MYWINDOWS_H
+#define __MYWINDOWS_H
+
+#ifdef _WIN32
+
+#include <windows.h>
+
+#define CHAR_PATH_SEPARATOR '\\'
+#define WCHAR_PATH_SEPARATOR L'\\'
+#define STRING_PATH_SEPARATOR "\\"
+#define WSTRING_PATH_SEPARATOR L"\\"
+
+#else
+
+#define CHAR_PATH_SEPARATOR '/'
+#define WCHAR_PATH_SEPARATOR L'/'
+#define STRING_PATH_SEPARATOR "/"
+#define WSTRING_PATH_SEPARATOR L"/"
+
+#include <stddef.h> // for wchar_t
+#include <string.h>
+
+#include "MyGuidDef.h"
+
+typedef char CHAR;
+typedef unsigned char UCHAR;
+
+#undef BYTE
+typedef unsigned char BYTE;
+
+typedef short SHORT;
+typedef unsigned short USHORT;
+
+#undef WORD
+typedef unsigned short WORD;
+typedef short VARIANT_BOOL;
+
+typedef int INT;
+typedef Int32 INT32;
+typedef unsigned int UINT;
+typedef UInt32 UINT32;
+typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit
+typedef UINT32 ULONG;
+
+#undef DWORD
+typedef UINT32 DWORD;
+
+typedef Int64 LONGLONG;
+typedef UInt64 ULONGLONG;
+
+typedef struct LARGE_INTEGER { LONGLONG QuadPart; }LARGE_INTEGER;
+typedef struct _ULARGE_INTEGER { ULONGLONG QuadPart;} ULARGE_INTEGER;
+
+typedef const CHAR *LPCSTR;
+typedef CHAR TCHAR;
+typedef const TCHAR *LPCTSTR;
+typedef wchar_t WCHAR;
+typedef WCHAR OLECHAR;
+typedef const WCHAR *LPCWSTR;
+typedef OLECHAR *BSTR;
+typedef const OLECHAR *LPCOLESTR;
+typedef OLECHAR *LPOLESTR;
+
+typedef struct _FILETIME
+{
+ DWORD dwLowDateTime;
+ DWORD dwHighDateTime;
+}FILETIME;
+
+#define HRESULT LONG
+#define FAILED(Status) ((HRESULT)(Status)<0)
+typedef ULONG PROPID;
+typedef LONG SCODE;
+
+#define S_OK ((HRESULT)0x00000000L)
+#define S_FALSE ((HRESULT)0x00000001L)
+#define E_NOTIMPL ((HRESULT)0x80004001L)
+#define E_NOINTERFACE ((HRESULT)0x80004002L)
+#define E_ABORT ((HRESULT)0x80004004L)
+#define E_FAIL ((HRESULT)0x80004005L)
+#define STG_E_INVALIDFUNCTION ((HRESULT)0x80030001L)
+#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
+#define E_INVALIDARG ((HRESULT)0x80070057L)
+
+#ifdef _MSC_VER
+#define STDMETHODCALLTYPE __stdcall
+#else
+#define STDMETHODCALLTYPE
+#endif
+
+#define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f
+#define STDMETHOD(f) STDMETHOD_(HRESULT, f)
+#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
+#define STDMETHODIMP STDMETHODIMP_(HRESULT)
+
+#define PURE = 0
+
+#define MIDL_INTERFACE(x) struct
+
+struct IUnknown
+{
+ STDMETHOD(QueryInterface) (REFIID iid, void **outObject) PURE;
+ STDMETHOD_(ULONG, AddRef)() PURE;
+ STDMETHOD_(ULONG, Release)() PURE;
+ #ifndef _WIN32
+ virtual ~IUnknown() {}
+ #endif
+};
+
+typedef IUnknown *LPUNKNOWN;
+
+#define VARIANT_TRUE ((VARIANT_BOOL)-1)
+#define VARIANT_FALSE ((VARIANT_BOOL)0)
+
+enum VARENUM
+{
+ VT_EMPTY = 0,
+ VT_NULL = 1,
+ VT_I2 = 2,
+ VT_I4 = 3,
+ VT_R4 = 4,
+ VT_R8 = 5,
+ VT_CY = 6,
+ VT_DATE = 7,
+ VT_BSTR = 8,
+ VT_DISPATCH = 9,
+ VT_ERROR = 10,
+ VT_BOOL = 11,
+ VT_VARIANT = 12,
+ VT_UNKNOWN = 13,
+ VT_DECIMAL = 14,
+ VT_I1 = 16,
+ VT_UI1 = 17,
+ VT_UI2 = 18,
+ VT_UI4 = 19,
+ VT_I8 = 20,
+ VT_UI8 = 21,
+ VT_INT = 22,
+ VT_UINT = 23,
+ VT_VOID = 24,
+ VT_HRESULT = 25,
+ VT_FILETIME = 64
+};
+
+typedef unsigned short VARTYPE;
+typedef WORD PROPVAR_PAD1;
+typedef WORD PROPVAR_PAD2;
+typedef WORD PROPVAR_PAD3;
+
+typedef struct tagPROPVARIANT
+{
+ VARTYPE vt;
+ PROPVAR_PAD1 wReserved1;
+ PROPVAR_PAD2 wReserved2;
+ PROPVAR_PAD3 wReserved3;
+ union
+ {
+ CHAR cVal;
+ UCHAR bVal;
+ SHORT iVal;
+ USHORT uiVal;
+ LONG lVal;
+ ULONG ulVal;
+ INT intVal;
+ UINT uintVal;
+ LARGE_INTEGER hVal;
+ ULARGE_INTEGER uhVal;
+ VARIANT_BOOL boolVal;
+ SCODE scode;
+ FILETIME filetime;
+ BSTR bstrVal;
+ };
+} PROPVARIANT;
+
+typedef PROPVARIANT tagVARIANT;
+typedef tagVARIANT VARIANT;
+typedef VARIANT VARIANTARG;
+
+MY_EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len);
+MY_EXTERN_C BSTR SysAllocString(const OLECHAR *sz);
+MY_EXTERN_C void SysFreeString(BSTR bstr);
+MY_EXTERN_C UINT SysStringByteLen(BSTR bstr);
+MY_EXTERN_C UINT SysStringLen(BSTR bstr);
+
+MY_EXTERN_C DWORD GetLastError();
+MY_EXTERN_C HRESULT VariantClear(VARIANTARG *prop);
+MY_EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src);
+MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2);
+
+#define CP_ACP 0
+#define CP_OEMCP 1
+
+typedef enum tagSTREAM_SEEK
+{
+ STREAM_SEEK_SET = 0,
+ STREAM_SEEK_CUR = 1,
+ STREAM_SEEK_END = 2
+} STREAM_SEEK;
+
+#endif
+#endif
diff --git a/Common/NewHandler.cpp b/CPP/Common/NewHandler.cpp
index 094eb642..094eb642 100755
--- a/Common/NewHandler.cpp
+++ b/CPP/Common/NewHandler.cpp
diff --git a/Common/NewHandler.h b/CPP/Common/NewHandler.h
index 0619fc69..0619fc69 100755
--- a/Common/NewHandler.h
+++ b/CPP/Common/NewHandler.h
diff --git a/Common/Random.cpp b/CPP/Common/Random.cpp
index f4a629c2..f4a629c2 100755
--- a/Common/Random.cpp
+++ b/CPP/Common/Random.cpp
diff --git a/Common/Random.h b/CPP/Common/Random.h
index ffef20d1..ffef20d1 100755
--- a/Common/Random.h
+++ b/CPP/Common/Random.h
diff --git a/Common/StdAfx.h b/CPP/Common/StdAfx.h
index 681ee935..681ee935 100755
--- a/Common/StdAfx.h
+++ b/CPP/Common/StdAfx.h
diff --git a/Common/StdInStream.cpp b/CPP/Common/StdInStream.cpp
index 923f366e..923f366e 100755
--- a/Common/StdInStream.cpp
+++ b/CPP/Common/StdInStream.cpp
diff --git a/Common/StdInStream.h b/CPP/Common/StdInStream.h
index c1a0a222..c1a0a222 100755
--- a/Common/StdInStream.h
+++ b/CPP/Common/StdInStream.h
diff --git a/Common/StdOutStream.cpp b/CPP/Common/StdOutStream.cpp
index 5f1ef0fc..5f1ef0fc 100755
--- a/Common/StdOutStream.cpp
+++ b/CPP/Common/StdOutStream.cpp
diff --git a/Common/StdOutStream.h b/CPP/Common/StdOutStream.h
index a3b11979..a3b11979 100755
--- a/Common/StdOutStream.h
+++ b/CPP/Common/StdOutStream.h
diff --git a/Common/String.cpp b/CPP/Common/String.cpp
index 34da1487..34da1487 100755
--- a/Common/String.cpp
+++ b/CPP/Common/String.cpp
diff --git a/CPP/Common/String.h b/CPP/Common/String.h
new file mode 100755
index 00000000..cbc6ee26
--- /dev/null
+++ b/CPP/Common/String.h
@@ -0,0 +1,631 @@
+// Common/String.h
+
+#ifndef __COMMON_STRING_H
+#define __COMMON_STRING_H
+
+#include <string.h>
+// #include <wchar.h>
+
+#include "Vector.h"
+
+#ifdef _WIN32
+#include "MyWindows.h"
+#endif
+
+static const char *kTrimDefaultCharSet = " \n\t";
+
+template <class T>
+inline int MyStringLen(const T *s)
+{
+ int i;
+ for (i = 0; s[i] != '\0'; i++);
+ return i;
+}
+
+template <class T>
+inline T * MyStringCopy(T *dest, const T *src)
+{
+ T *destStart = dest;
+ while((*dest++ = *src++) != 0);
+ return destStart;
+}
+
+inline wchar_t* MyStringGetNextCharPointer(wchar_t *p)
+ { return (p + 1); }
+inline const wchar_t* MyStringGetNextCharPointer(const wchar_t *p)
+ { return (p + 1); }
+inline wchar_t* MyStringGetPrevCharPointer(const wchar_t *, wchar_t *p)
+ { return (p - 1); }
+inline const wchar_t* MyStringGetPrevCharPointer(const wchar_t *, const wchar_t *p)
+ { return (p - 1); }
+
+#ifdef _WIN32
+
+inline char* MyStringGetNextCharPointer(char *p)
+ { return CharNextA(p); }
+inline const char* MyStringGetNextCharPointer(const char *p)
+ { return CharNextA(p); }
+
+inline char* MyStringGetPrevCharPointer(char *base, char *p)
+ { return CharPrevA(base, p); }
+inline const char* MyStringGetPrevCharPointer(const char *base, const char *p)
+ { return CharPrevA(base, p); }
+
+inline char MyCharUpper(char c)
+ { return (char)(unsigned int)(UINT_PTR)CharUpperA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); }
+#ifdef _UNICODE
+inline wchar_t MyCharUpper(wchar_t c)
+ { return (wchar_t)CharUpperW((LPWSTR)c); }
+#else
+wchar_t MyCharUpper(wchar_t c);
+#endif
+
+inline char MyCharLower(char c)
+ { return (char)(unsigned int)(UINT_PTR)CharLowerA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); }
+#ifdef _UNICODE
+inline wchar_t MyCharLower(wchar_t c)
+ { return (wchar_t)CharLowerW((LPWSTR)c); }
+#else
+wchar_t MyCharLower(wchar_t c);
+#endif
+
+inline char * MyStringUpper(char *s) { return CharUpperA(s); }
+#ifdef _UNICODE
+inline wchar_t * MyStringUpper(wchar_t *s) { return CharUpperW(s); }
+#else
+wchar_t * MyStringUpper(wchar_t *s);
+#endif
+
+inline char * MyStringLower(char *s) { return CharLowerA(s); }
+#ifdef _UNICODE
+inline wchar_t * MyStringLower(wchar_t *s) { return CharLowerW(s); }
+#else
+wchar_t * MyStringLower(wchar_t *s);
+#endif
+
+#else // Standard-C
+wchar_t MyCharUpper(wchar_t c);
+#endif
+
+//////////////////////////////////////
+// Compare
+
+/*
+#ifndef _WIN32_WCE
+int MyStringCollate(const char *s1, const char *s2);
+int MyStringCollateNoCase(const char *s1, const char *s2);
+#endif
+int MyStringCollate(const wchar_t *s1, const wchar_t *s2);
+int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2);
+*/
+
+int MyStringCompare(const char *s1, const char *s2);
+int MyStringCompare(const wchar_t *s1, const wchar_t *s2);
+
+#ifdef _WIN32
+int MyStringCompareNoCase(const char *s1, const char *s2);
+#endif
+
+int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2);
+
+template <class T>
+class CStringBase
+{
+ void TrimLeftWithCharSet(const CStringBase &charSet)
+ {
+ const T *p = _chars;
+ while (charSet.Find(*p) >= 0 && (*p != 0))
+ p = GetNextCharPointer(p);
+ Delete(0, (int)(p - _chars));
+ }
+ void TrimRightWithCharSet(const CStringBase &charSet)
+ {
+ const T *p = _chars;
+ const T *pLast = NULL;
+ while (*p != 0)
+ {
+ if (charSet.Find(*p) >= 0)
+ {
+ if (pLast == NULL)
+ pLast = p;
+ }
+ else
+ pLast = NULL;
+ p = GetNextCharPointer(p);
+ }
+ if(pLast != NULL)
+ {
+ int i = (int)(pLast - _chars);
+ Delete(i, _length - i);
+ }
+
+ }
+ void MoveItems(int destIndex, int srcIndex)
+ {
+ memmove(_chars + destIndex, _chars + srcIndex,
+ sizeof(T) * (_length - srcIndex + 1));
+ }
+
+ void InsertSpace(int &index, int size)
+ {
+ CorrectIndex(index);
+ GrowLength(size);
+ MoveItems(index + size, index);
+ }
+
+ static T *GetNextCharPointer(T *p)
+ { return MyStringGetNextCharPointer(p); }
+ static const T *GetNextCharPointer(const T *p)
+ { return MyStringGetNextCharPointer(p); }
+ static T *GetPrevCharPointer(T *base, T *p)
+ { return MyStringGetPrevCharPointer(base, p); }
+ static const T *GetPrevCharPointer(const T *base, const T *p)
+ { return MyStringGetPrevCharPointer(base, p); }
+protected:
+ T *_chars;
+ int _length;
+ int _capacity;
+
+ void SetCapacity(int newCapacity)
+ {
+ int realCapacity = newCapacity + 1;
+ if(realCapacity == _capacity)
+ return;
+ /*
+ const int kMaxStringSize = 0x20000000;
+ #ifndef _WIN32_WCE
+ if(newCapacity > kMaxStringSize || newCapacity < _length)
+ throw 1052337;
+ #endif
+ */
+ T *newBuffer = new T[realCapacity];
+ if(_capacity > 0)
+ {
+ for (int i = 0; i < (_length + 1); i++)
+ newBuffer[i] = _chars[i];
+ delete []_chars;
+ _chars = newBuffer;
+ }
+ else
+ {
+ _chars = newBuffer;
+ _chars[0] = 0;
+ }
+ _capacity = realCapacity;
+ }
+
+ void GrowLength(int n)
+ {
+ int freeSize = _capacity - _length - 1;
+ if (n <= freeSize)
+ return;
+ int delta;
+ if (_capacity > 64)
+ delta = _capacity / 2;
+ else if (_capacity > 8)
+ delta = 16;
+ else
+ delta = 4;
+ if (freeSize + delta < n)
+ delta = n - freeSize;
+ SetCapacity(_capacity + delta);
+ }
+
+ void CorrectIndex(int &index) const
+ {
+ if (index > _length)
+ index = _length;
+ }
+
+public:
+ CStringBase(): _chars(0), _length(0), _capacity(0)
+ { SetCapacity(16 - 1); }
+ CStringBase(T c): _chars(0), _length(0), _capacity(0)
+ {
+ SetCapacity(1);
+ _chars[0] = c;
+ _chars[1] = 0;
+ _length = 1;
+ }
+ CStringBase(const T *chars): _chars(0), _length(0), _capacity(0)
+ {
+ int length = MyStringLen(chars);
+ SetCapacity(length);
+ MyStringCopy(_chars, chars); // can be optimized by memove()
+ _length = length;
+ }
+ CStringBase(const CStringBase &s): _chars(0), _length(0), _capacity(0)
+ {
+ SetCapacity(s._length);
+ MyStringCopy(_chars, s._chars);
+ _length = s._length;
+ }
+ ~CStringBase() { delete []_chars; }
+
+ operator const T*() const { return _chars;}
+
+ // The minimum size of the character buffer in characters.
+ // This value does not include space for a null terminator.
+ T* GetBuffer(int minBufLength)
+ {
+ if(minBufLength >= _capacity)
+ SetCapacity(minBufLength + 1);
+ return _chars;
+ }
+ void ReleaseBuffer() { ReleaseBuffer(MyStringLen(_chars)); }
+ void ReleaseBuffer(int newLength)
+ {
+ /*
+ #ifndef _WIN32_WCE
+ if(newLength >= _capacity)
+ throw 282217;
+ #endif
+ */
+ _chars[newLength] = 0;
+ _length = newLength;
+ }
+
+ CStringBase& operator=(T c)
+ {
+ Empty();
+ SetCapacity(1);
+ _chars[0] = c;
+ _chars[1] = 0;
+ _length = 1;
+ return *this;
+ }
+ CStringBase& operator=(const T *chars)
+ {
+ Empty();
+ int length = MyStringLen(chars);
+ SetCapacity(length);
+ MyStringCopy(_chars, chars);
+ _length = length;
+ return *this;
+ }
+ CStringBase& operator=(const CStringBase& s)
+ {
+ if(&s == this)
+ return *this;
+ Empty();
+ SetCapacity(s._length);
+ MyStringCopy(_chars, s._chars);
+ _length = s._length;
+ return *this;
+ }
+
+ CStringBase& operator+=(T c)
+ {
+ GrowLength(1);
+ _chars[_length] = c;
+ _chars[++_length] = 0;
+ return *this;
+ }
+ CStringBase& operator+=(const T *s)
+ {
+ int len = MyStringLen(s);
+ GrowLength(len);
+ MyStringCopy(_chars + _length, s);
+ _length += len;
+ return *this;
+ }
+ CStringBase& operator+=(const CStringBase &s)
+ {
+ GrowLength(s._length);
+ MyStringCopy(_chars + _length, s._chars);
+ _length += s._length;
+ return *this;
+ }
+ void Empty()
+ {
+ _length = 0;
+ _chars[0] = 0;
+ }
+ int Length() const { return _length; }
+ bool IsEmpty() const { return (_length == 0); }
+
+ CStringBase Mid(int startIndex) const
+ { return Mid(startIndex, _length - startIndex); }
+ CStringBase Mid(int startIndex, int count ) const
+ {
+ if (startIndex + count > _length)
+ count = _length - startIndex;
+
+ if (startIndex == 0 && startIndex + count == _length)
+ return *this;
+
+ CStringBase<T> result;
+ result.SetCapacity(count);
+ // MyStringNCopy(result._chars, _chars + startIndex, count);
+ for (int i = 0; i < count; i++)
+ result._chars[i] = _chars[startIndex + i];
+ result._chars[count] = 0;
+ result._length = count;
+ return result;
+ }
+ CStringBase Left(int count) const
+ { return Mid(0, count); }
+ CStringBase Right(int count) const
+ {
+ if (count > _length)
+ count = _length;
+ return Mid(_length - count, count);
+ }
+
+ void MakeUpper()
+ { MyStringUpper(_chars); }
+ void MakeLower()
+ { MyStringLower(_chars); }
+
+ int Compare(const CStringBase& s) const
+ { return MyStringCompare(_chars, s._chars); }
+
+ int CompareNoCase(const CStringBase& s) const
+ { return MyStringCompareNoCase(_chars, s._chars); }
+ /*
+ int Collate(const CStringBase& s) const
+ { return MyStringCollate(_chars, s._chars); }
+ int CollateNoCase(const CStringBase& s) const
+ { return MyStringCollateNoCase(_chars, s._chars); }
+ */
+
+ int Find(T c) const { return Find(c, 0); }
+ int Find(T c, int startIndex) const
+ {
+ T *p = _chars + startIndex;
+ for (;;)
+ {
+ if (*p == c)
+ return (int)(p - _chars);
+ if (*p == 0)
+ return -1;
+ p = GetNextCharPointer(p);
+ }
+ }
+ int Find(const CStringBase &s) const { return Find(s, 0); }
+ int Find(const CStringBase &s, int startIndex) const
+ {
+ if (s.IsEmpty())
+ return startIndex;
+ for (; startIndex < _length; startIndex++)
+ {
+ int j;
+ for (j = 0; j < s._length && startIndex + j < _length; j++)
+ if (_chars[startIndex+j] != s._chars[j])
+ break;
+ if (j == s._length)
+ return startIndex;
+ }
+ return -1;
+ }
+ int ReverseFind(T c) const
+ {
+ if (_length == 0)
+ return -1;
+ T *p = _chars + _length - 1;
+ for (;;)
+ {
+ if (*p == c)
+ return (int)(p - _chars);
+ if (p == _chars)
+ return -1;
+ p = GetPrevCharPointer(_chars, p);
+ }
+ }
+ int FindOneOf(const CStringBase &s) const
+ {
+ for(int i = 0; i < _length; i++)
+ if (s.Find(_chars[i]) >= 0)
+ return i;
+ return -1;
+ }
+
+ void TrimLeft(T c)
+ {
+ const T *p = _chars;
+ while (c == *p)
+ p = GetNextCharPointer(p);
+ Delete(0, p - _chars);
+ }
+ private:
+ CStringBase GetTrimDefaultCharSet()
+ {
+ CStringBase<T> charSet;
+ for(int i = 0; i < (int)(sizeof(kTrimDefaultCharSet) /
+ sizeof(kTrimDefaultCharSet[0])); i++)
+ charSet += (T)kTrimDefaultCharSet[i];
+ return charSet;
+ }
+ public:
+
+ void TrimLeft()
+ {
+ TrimLeftWithCharSet(GetTrimDefaultCharSet());
+ }
+ void TrimRight()
+ {
+ TrimRightWithCharSet(GetTrimDefaultCharSet());
+ }
+ void TrimRight(T c)
+ {
+ const T *p = _chars;
+ const T *pLast = NULL;
+ while (*p != 0)
+ {
+ if (*p == c)
+ {
+ if (pLast == NULL)
+ pLast = p;
+ }
+ else
+ pLast = NULL;
+ p = GetNextCharPointer(p);
+ }
+ if(pLast != NULL)
+ {
+ int i = pLast - _chars;
+ Delete(i, _length - i);
+ }
+ }
+ void Trim()
+ {
+ TrimRight();
+ TrimLeft();
+ }
+
+ int Insert(int index, T c)
+ {
+ InsertSpace(index, 1);
+ _chars[index] = c;
+ _length++;
+ return _length;
+ }
+ int Insert(int index, const CStringBase &s)
+ {
+ CorrectIndex(index);
+ if (s.IsEmpty())
+ return _length;
+ int numInsertChars = s.Length();
+ InsertSpace(index, numInsertChars);
+ for(int i = 0; i < numInsertChars; i++)
+ _chars[index + i] = s[i];
+ _length += numInsertChars;
+ return _length;
+ }
+
+ // !!!!!!!!!!!!!!! test it if newChar = '\0'
+ int Replace(T oldChar, T newChar)
+ {
+ if (oldChar == newChar)
+ return 0;
+ int number = 0;
+ int pos = 0;
+ while (pos < Length())
+ {
+ pos = Find(oldChar, pos);
+ if (pos < 0)
+ break;
+ _chars[pos] = newChar;
+ pos++;
+ number++;
+ }
+ return number;
+ }
+ int Replace(const CStringBase &oldString, const CStringBase &newString)
+ {
+ if (oldString.IsEmpty())
+ return 0;
+ if (oldString == newString)
+ return 0;
+ int oldStringLength = oldString.Length();
+ int newStringLength = newString.Length();
+ int number = 0;
+ int pos = 0;
+ while (pos < _length)
+ {
+ pos = Find(oldString, pos);
+ if (pos < 0)
+ break;
+ Delete(pos, oldStringLength);
+ Insert(pos, newString);
+ pos += newStringLength;
+ number++;
+ }
+ return number;
+ }
+ int Delete(int index, int count = 1 )
+ {
+ if (index + count > _length)
+ count = _length - index;
+ if (count > 0)
+ {
+ MoveItems(index, index + count);
+ _length -= count;
+ }
+ return _length;
+ }
+};
+
+template <class T>
+CStringBase<T> operator+(const CStringBase<T>& s1, const CStringBase<T>& s2)
+{
+ CStringBase<T> result(s1);
+ result += s2;
+ return result;
+}
+
+template <class T>
+CStringBase<T> operator+(const CStringBase<T>& s, T c)
+{
+ CStringBase<T> result(s);
+ result += c;
+ return result;
+}
+
+template <class T>
+CStringBase<T> operator+(T c, const CStringBase<T>& s)
+{
+ CStringBase<T> result(c);
+ result += s;
+ return result;
+}
+
+template <class T>
+CStringBase<T> operator+(const CStringBase<T>& s, const T * chars)
+{
+ CStringBase<T> result(s);
+ result += chars;
+ return result;
+}
+
+template <class T>
+CStringBase<T> operator+(const T * chars, const CStringBase<T>& s)
+{
+ CStringBase<T> result(chars);
+ result += s;
+ return result;
+}
+
+template <class T>
+bool operator==(const CStringBase<T>& s1, const CStringBase<T>& s2)
+ { return (s1.Compare(s2) == 0); }
+
+template <class T>
+bool operator<(const CStringBase<T>& s1, const CStringBase<T>& s2)
+ { return (s1.Compare(s2) < 0); }
+
+template <class T>
+bool operator==(const T *s1, const CStringBase<T>& s2)
+ { return (s2.Compare(s1) == 0); }
+
+template <class T>
+bool operator==(const CStringBase<T>& s1, const T *s2)
+ { return (s1.Compare(s2) == 0); }
+
+template <class T>
+bool operator!=(const CStringBase<T>& s1, const CStringBase<T>& s2)
+ { return (s1.Compare(s2) != 0); }
+
+template <class T>
+bool operator!=(const T *s1, const CStringBase<T>& s2)
+ { return (s2.Compare(s1) != 0); }
+
+template <class T>
+bool operator!=(const CStringBase<T>& s1, const T *s2)
+ { return (s1.Compare(s2) != 0); }
+
+typedef CStringBase<char> AString;
+typedef CStringBase<wchar_t> UString;
+
+typedef CObjectVector<AString> AStringVector;
+typedef CObjectVector<UString> UStringVector;
+
+#ifdef _UNICODE
+ typedef UString CSysString;
+#else
+ typedef AString CSysString;
+#endif
+
+typedef CObjectVector<CSysString> CSysStringVector;
+
+#endif
diff --git a/CPP/Common/StringConvert.cpp b/CPP/Common/StringConvert.cpp
new file mode 100755
index 00000000..c0b19e16
--- /dev/null
+++ b/CPP/Common/StringConvert.cpp
@@ -0,0 +1,94 @@
+// Common/StringConvert.cpp
+
+#include "StdAfx.h"
+
+#include "StringConvert.h"
+
+#ifndef _WIN32
+#include <stdlib.h>
+#endif
+
+#ifdef _WIN32
+UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
+{
+ UString resultString;
+ if(!srcString.IsEmpty())
+ {
+ int numChars = MultiByteToWideChar(codePage, 0, srcString,
+ srcString.Length(), resultString.GetBuffer(srcString.Length()),
+ srcString.Length() + 1);
+ #ifndef _WIN32_WCE
+ if(numChars == 0)
+ throw 282228;
+ #endif
+ resultString.ReleaseBuffer(numChars);
+ }
+ return resultString;
+}
+
+AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
+{
+ AString resultString;
+ if(!srcString.IsEmpty())
+ {
+ int numRequiredBytes = srcString.Length() * 2;
+ char defaultChar = '_';
+ int numChars = WideCharToMultiByte(codePage, 0, srcString,
+ srcString.Length(), resultString.GetBuffer(numRequiredBytes),
+ numRequiredBytes + 1, &defaultChar, NULL);
+ #ifndef _WIN32_WCE
+ if(numChars == 0)
+ throw 282229;
+ #endif
+ resultString.ReleaseBuffer(numChars);
+ }
+ return resultString;
+}
+
+#ifndef _WIN32_WCE
+AString SystemStringToOemString(const CSysString &srcString)
+{
+ AString result;
+ CharToOem(srcString, result.GetBuffer(srcString.Length() * 2));
+ result.ReleaseBuffer();
+ return result;
+}
+#endif
+
+#else
+
+UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
+{
+ UString resultString;
+ for (int i = 0; i < srcString.Length(); i++)
+ resultString += wchar_t(srcString[i]);
+ /*
+ if(!srcString.IsEmpty())
+ {
+ int numChars = mbstowcs(resultString.GetBuffer(srcString.Length()), srcString, srcString.Length() + 1);
+ if (numChars < 0) throw "Your environment does not support UNICODE";
+ resultString.ReleaseBuffer(numChars);
+ }
+ */
+ return resultString;
+}
+
+AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
+{
+ AString resultString;
+ for (int i = 0; i < srcString.Length(); i++)
+ resultString += char(srcString[i]);
+ /*
+ if(!srcString.IsEmpty())
+ {
+ int numRequiredBytes = srcString.Length() * 6 + 1;
+ int numChars = wcstombs(resultString.GetBuffer(numRequiredBytes), srcString, numRequiredBytes);
+ if (numChars < 0) throw "Your environment does not support UNICODE";
+ resultString.ReleaseBuffer(numChars);
+ }
+ */
+ return resultString;
+}
+
+#endif
+
diff --git a/Common/StringConvert.h b/CPP/Common/StringConvert.h
index 84eaed9a..84eaed9a 100755
--- a/Common/StringConvert.h
+++ b/CPP/Common/StringConvert.h
diff --git a/Common/StringToInt.cpp b/CPP/Common/StringToInt.cpp
index ec6733e3..ec6733e3 100755
--- a/Common/StringToInt.cpp
+++ b/CPP/Common/StringToInt.cpp
diff --git a/Common/StringToInt.h b/CPP/Common/StringToInt.h
index bb971f62..bb971f62 100755
--- a/Common/StringToInt.h
+++ b/CPP/Common/StringToInt.h
diff --git a/Common/TextConfig.cpp b/CPP/Common/TextConfig.cpp
index 4fce320a..4fce320a 100755
--- a/Common/TextConfig.cpp
+++ b/CPP/Common/TextConfig.cpp
diff --git a/Common/TextConfig.h b/CPP/Common/TextConfig.h
index 1552df65..1552df65 100755
--- a/Common/TextConfig.h
+++ b/CPP/Common/TextConfig.h
diff --git a/Common/Types.h b/CPP/Common/Types.h
index 41d785e9..41d785e9 100755
--- a/Common/Types.h
+++ b/CPP/Common/Types.h
diff --git a/Common/UTFConvert.cpp b/CPP/Common/UTFConvert.cpp
index e15695bb..e15695bb 100755
--- a/Common/UTFConvert.cpp
+++ b/CPP/Common/UTFConvert.cpp
diff --git a/Common/UTFConvert.h b/CPP/Common/UTFConvert.h
index 47434111..47434111 100755
--- a/Common/UTFConvert.h
+++ b/CPP/Common/UTFConvert.h
diff --git a/Common/Vector.cpp b/CPP/Common/Vector.cpp
index b3dd70a5..b3dd70a5 100755
--- a/Common/Vector.cpp
+++ b/CPP/Common/Vector.cpp
diff --git a/CPP/Common/Vector.h b/CPP/Common/Vector.h
new file mode 100755
index 00000000..1bb67a1d
--- /dev/null
+++ b/CPP/Common/Vector.h
@@ -0,0 +1,237 @@
+// Common/Vector.h
+
+#ifndef __COMMON_VECTOR_H
+#define __COMMON_VECTOR_H
+
+#include "Defs.h"
+
+class CBaseRecordVector
+{
+ void MoveItems(int destIndex, int srcIndex);
+protected:
+ int _capacity;
+ int _size;
+ void *_items;
+ size_t _itemSize;
+
+ void ReserveOnePosition();
+ void InsertOneItem(int index);
+ void TestIndexAndCorrectNum(int index, int &num) const
+ { if (index + num > _size) num = _size - index; }
+public:
+ CBaseRecordVector(size_t itemSize):
+ _capacity(0), _size(0), _items(0), _itemSize(itemSize) {}
+ virtual ~CBaseRecordVector();
+ void Free();
+ int Size() const { return _size; }
+ bool IsEmpty() const { return (_size == 0); }
+ void Reserve(int newCapacity);
+ virtual void Delete(int index, int num = 1);
+ void Clear();
+ void DeleteFrom(int index);
+ void DeleteBack();
+};
+
+template <class T>
+class CRecordVector: public CBaseRecordVector
+{
+public:
+ CRecordVector():CBaseRecordVector(sizeof(T)){};
+ CRecordVector(const CRecordVector &v):
+ CBaseRecordVector(sizeof(T)) { *this = v;}
+ CRecordVector& operator=(const CRecordVector &v)
+ {
+ Clear();
+ return (*this += v);
+ }
+ CRecordVector& operator+=(const CRecordVector &v)
+ {
+ int size = v.Size();
+ Reserve(Size() + size);
+ for(int i = 0; i < size; i++)
+ Add(v[i]);
+ return *this;
+ }
+ int Add(T item)
+ {
+ ReserveOnePosition();
+ ((T *)_items)[_size] = item;
+ return _size++;
+ }
+ void Insert(int index, T item)
+ {
+ InsertOneItem(index);
+ ((T *)_items)[index] = item;
+ }
+ // T* GetPointer() const { return (T*)_items; }
+ // operator const T *() const { return _items; };
+ const T& operator[](int index) const { return ((T *)_items)[index]; }
+ T& operator[](int index) { return ((T *)_items)[index]; }
+ const T& Front() const { return operator[](0); }
+ T& Front() { return operator[](0); }
+ const T& Back() const { return operator[](_size - 1); }
+ T& Back() { return operator[](_size - 1); }
+
+ void Swap(int i, int j)
+ {
+ T temp = operator[](i);
+ operator[](i) = operator[](j);
+ operator[](j) = temp;
+ }
+
+ int FindInSorted(const T& item) const
+ {
+ int left = 0, right = Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ const T& midValue = (*this)[mid];
+ if (item == midValue)
+ return mid;
+ if (item < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ return -1;
+ }
+
+
+ static void SortRefDown(T* p, int k, int size, int (*compare)(const T*, const T*, void *), void *param)
+ {
+ T temp = p[k];
+ for (;;)
+ {
+ int s = (k << 1);
+ if (s > size)
+ break;
+ if (s < size && compare(p + s + 1, p + s, param) > 0)
+ s++;
+ if (compare(&temp, p + s, param) >= 0)
+ break;
+ p[k] = p[s];
+ k = s;
+ }
+ p[k] = temp;
+ }
+
+ void Sort(int (*compare)(const T*, const T*, void *), void *param)
+ {
+ int size = _size;
+ if (size <= 1)
+ return;
+ T* p = (&Front()) - 1;
+ {
+ int i = size / 2;
+ do
+ SortRefDown(p, i, size, compare, param);
+ while(--i != 0);
+ }
+ do
+ {
+ T temp = p[size];
+ p[size--] = p[1];
+ p[1] = temp;
+ SortRefDown(p, 1, size, compare, param);
+ }
+ while (size > 1);
+ }
+};
+
+typedef CRecordVector<int> CIntVector;
+typedef CRecordVector<unsigned int> CUIntVector;
+typedef CRecordVector<bool> CBoolVector;
+typedef CRecordVector<unsigned char> CByteVector;
+typedef CRecordVector<void *> CPointerVector;
+
+template <class T>
+class CObjectVector: public CPointerVector
+{
+public:
+ CObjectVector(){};
+ ~CObjectVector() { Clear(); }
+ CObjectVector(const CObjectVector &objectVector)
+ { *this = objectVector; }
+ CObjectVector& operator=(const CObjectVector &objectVector)
+ {
+ Clear();
+ return (*this += objectVector);
+ }
+ CObjectVector& operator+=(const CObjectVector &objectVector)
+ {
+ int size = objectVector.Size();
+ Reserve(Size() + size);
+ for(int i = 0; i < size; i++)
+ Add(objectVector[i]);
+ return *this;
+ }
+ const T& operator[](int index) const { return *((T *)CPointerVector::operator[](index)); }
+ T& operator[](int index) { return *((T *)CPointerVector::operator[](index)); }
+ T& Front() { return operator[](0); }
+ const T& Front() const { return operator[](0); }
+ T& Back() { return operator[](_size - 1); }
+ const T& Back() const { return operator[](_size - 1); }
+ int Add(const T& item)
+ { return CPointerVector::Add(new T(item)); }
+ void Insert(int index, const T& item)
+ { CPointerVector::Insert(index, new T(item)); }
+ virtual void Delete(int index, int num = 1)
+ {
+ TestIndexAndCorrectNum(index, num);
+ for(int i = 0; i < num; i++)
+ delete (T *)(((void **)_items)[index + i]);
+ CPointerVector::Delete(index, num);
+ }
+ int Find(const T& item) const
+ {
+ for(int i = 0; i < Size(); i++)
+ if (item == (*this)[i])
+ return i;
+ return -1;
+ }
+ int FindInSorted(const T& item) const
+ {
+ int left = 0, right = Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ const T& midValue = (*this)[mid];
+ if (item == midValue)
+ return mid;
+ if (item < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ return -1;
+ }
+ int AddToSorted(const T& item)
+ {
+ int left = 0, right = Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ const T& midValue = (*this)[mid];
+ if (item == midValue)
+ {
+ right = mid + 1;
+ break;
+ }
+ if (item < midValue)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ Insert(right, item);
+ return right;
+ }
+
+ void Sort(int (*compare)(void *const *, void *const *, void *), void *param)
+ { CPointerVector::Sort(compare, param); }
+
+ static int CompareObjectItems(void *const *a1, void *const *a2, void * /* param */)
+ { return MyCompare(*(*((const T **)a1)), *(*((const T **)a2))); }
+ void Sort() { CPointerVector::Sort(CompareObjectItems, 0); }
+};
+
+#endif
diff --git a/Common/Wildcard.cpp b/CPP/Common/Wildcard.cpp
index ddadc7b1..ddadc7b1 100755
--- a/Common/Wildcard.cpp
+++ b/CPP/Common/Wildcard.cpp
diff --git a/Common/Wildcard.h b/CPP/Common/Wildcard.h
index 82d2bbd2..82d2bbd2 100755
--- a/Common/Wildcard.h
+++ b/CPP/Common/Wildcard.h
diff --git a/Windows/COM.cpp b/CPP/Windows/COM.cpp
index 2f9fdcda..2f9fdcda 100755
--- a/Windows/COM.cpp
+++ b/CPP/Windows/COM.cpp
diff --git a/Windows/COM.h b/CPP/Windows/COM.h
index 80651406..80651406 100755
--- a/Windows/COM.h
+++ b/CPP/Windows/COM.h
diff --git a/Windows/CommonDialog.cpp b/CPP/Windows/CommonDialog.cpp
index d0234c54..d0234c54 100755
--- a/Windows/CommonDialog.cpp
+++ b/CPP/Windows/CommonDialog.cpp
diff --git a/Windows/CommonDialog.h b/CPP/Windows/CommonDialog.h
index d0149aba..d0149aba 100755
--- a/Windows/CommonDialog.h
+++ b/CPP/Windows/CommonDialog.h
diff --git a/Windows/Console.cpp b/CPP/Windows/Console.cpp
index 1dffc377..1dffc377 100755
--- a/Windows/Console.cpp
+++ b/CPP/Windows/Console.cpp
diff --git a/Windows/Console.h b/CPP/Windows/Console.h
index b4e6d35b..b4e6d35b 100755
--- a/Windows/Console.h
+++ b/CPP/Windows/Console.h
diff --git a/Windows/Control/ComboBox.cpp b/CPP/Windows/Control/ComboBox.cpp
index 5b1d2651..5b1d2651 100755
--- a/Windows/Control/ComboBox.cpp
+++ b/CPP/Windows/Control/ComboBox.cpp
diff --git a/Windows/Control/ComboBox.h b/CPP/Windows/Control/ComboBox.h
index 2fb2302e..2fb2302e 100755
--- a/Windows/Control/ComboBox.h
+++ b/CPP/Windows/Control/ComboBox.h
diff --git a/Windows/Control/Dialog.cpp b/CPP/Windows/Control/Dialog.cpp
index 64009b79..64009b79 100755
--- a/Windows/Control/Dialog.cpp
+++ b/CPP/Windows/Control/Dialog.cpp
diff --git a/Windows/Control/Dialog.h b/CPP/Windows/Control/Dialog.h
index f6182c4b..f6182c4b 100755
--- a/Windows/Control/Dialog.h
+++ b/CPP/Windows/Control/Dialog.h
diff --git a/Windows/Control/Edit.h b/CPP/Windows/Control/Edit.h
index d1af3644..d1af3644 100755
--- a/Windows/Control/Edit.h
+++ b/CPP/Windows/Control/Edit.h
diff --git a/Windows/Control/ImageList.cpp b/CPP/Windows/Control/ImageList.cpp
index 16a46fa4..16a46fa4 100755
--- a/Windows/Control/ImageList.cpp
+++ b/CPP/Windows/Control/ImageList.cpp
diff --git a/Windows/Control/ImageList.h b/CPP/Windows/Control/ImageList.h
index fc8ddfbd..fc8ddfbd 100755
--- a/Windows/Control/ImageList.h
+++ b/CPP/Windows/Control/ImageList.h
diff --git a/Windows/Control/ListView.cpp b/CPP/Windows/Control/ListView.cpp
index b532a7a4..b532a7a4 100755
--- a/Windows/Control/ListView.cpp
+++ b/CPP/Windows/Control/ListView.cpp
diff --git a/CPP/Windows/Control/ListView.h b/CPP/Windows/Control/ListView.h
new file mode 100755
index 00000000..60b8146e
--- /dev/null
+++ b/CPP/Windows/Control/ListView.h
@@ -0,0 +1,138 @@
+// Windows/Control/ListView.h
+
+#ifndef __WINDOWS_CONTROL_LISTVIEW_H
+#define __WINDOWS_CONTROL_LISTVIEW_H
+
+#include "Windows/Window.h"
+#include "Windows/Defs.h"
+
+#include <commctrl.h>
+
+namespace NWindows {
+namespace NControl {
+
+class CListView: public NWindows::CWindow
+{
+public:
+ bool CreateEx(DWORD exStyle, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance, LPVOID createParam);
+
+ bool SetUnicodeFormat(bool fUnicode)
+ { return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); }
+
+ bool DeleteAllItems()
+ { return BOOLToBool(ListView_DeleteAllItems(_window)); }
+ int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo)
+ { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
+ #ifndef _UNICODE
+ int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo)
+ { return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
+ #endif
+ bool DeleteColumn(int columnIndex)
+ { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
+
+ int InsertItem(const LVITEM* item)
+ { return ListView_InsertItem(_window, item); }
+ #ifndef _UNICODE
+ int InsertItem(const LV_ITEMW* item)
+ { return (int)SendMessage(LVM_INSERTITEMW, 0, (LPARAM)item); }
+ #endif
+
+ bool SetItem(const LVITEM* item)
+ { return BOOLToBool(ListView_SetItem(_window, item)); }
+ #ifndef _UNICODE
+ bool SetItem(const LV_ITEMW* item)
+ { return BOOLToBool((BOOL)SendMessage(LVM_SETITEMW, 0, (LPARAM)item)); }
+ #endif
+
+ bool DeleteItem(int itemIndex)
+ { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
+
+ UINT GetSelectedCount() const
+ { return ListView_GetSelectedCount(_window); }
+ int GetItemCount() const
+ { return ListView_GetItemCount(_window); }
+
+ INT GetSelectionMark() const
+ { return ListView_GetSelectionMark(_window); }
+
+ void SetItemCount(int numItems)
+ { ListView_SetItemCount(_window, numItems); }
+ void SetItemCountEx(int numItems, DWORD flags)
+ { ListView_SetItemCountEx(_window, numItems, flags); }
+
+ int GetNextItem(int startIndex, UINT flags) const
+ { return ListView_GetNextItem(_window, startIndex, flags); }
+ int GetNextSelectedItem(int startIndex) const
+ { return GetNextItem(startIndex, LVNI_SELECTED); }
+ int GetFocusedItem() const
+ { return GetNextItem(-1, LVNI_FOCUSED); }
+
+ bool GetItem(LVITEM* item) const
+ { return BOOLToBool(ListView_GetItem(_window, item)); }
+ bool GetItemParam(int itemIndex, LPARAM &param) const;
+ void GetItemText(int itemIndex, int aSubItemIndex, LPTSTR aText, int aTextSizeMax) const
+ { ListView_GetItemText(_window, itemIndex, aSubItemIndex, aText, aTextSizeMax); }
+ bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
+ { return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
+
+ void SetItemState(int index, UINT state, UINT mask)
+ { ListView_SetItemState(_window, index, state, mask); }
+ UINT GetItemState(int index, UINT mask) const
+ { return ListView_GetItemState(_window, index, mask); }
+
+ bool GetColumn(int columnIndex, LVCOLUMN* columnInfo) const
+ { return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
+
+ HIMAGELIST SetImageList(HIMAGELIST imageList, int imageListType)
+ { return ListView_SetImageList(_window, imageList, imageListType); }
+
+ // version 4.70: NT5 | (NT4 + ie3) | w98 | (w95 + ie3)
+ DWORD GetExtendedListViewStyle()
+ { return ListView_GetExtendedListViewStyle(_window); }
+ void SetExtendedListViewStyle(DWORD exStyle)
+ { ListView_SetExtendedListViewStyle(_window, exStyle); }
+ void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle)
+ { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
+
+ #ifndef _WIN32_WCE
+ void SetCheckState(UINT index, bool checkState)
+ { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); }
+ #endif
+ bool GetCheckState(UINT index)
+ { return BOOLToBool(ListView_GetCheckState(_window, index)); }
+
+
+ bool EnsureVisible(int index, bool partialOK)
+ { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
+
+ bool GetItemRect(int index, RECT *rect, int code)
+ { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); }
+
+ HWND GetEditControl()
+ { return ListView_GetEditControl(_window) ; }
+ HWND EditLabel(int itemIndex)
+ { return ListView_EditLabel(_window, itemIndex) ; }
+
+ bool RedrawItems(int firstIndex, int lastIndex)
+ { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
+ bool RedrawAllItems()
+ {
+ if (GetItemCount() > 0)
+ return RedrawItems(0, GetItemCount() - 1);
+ return true;
+ }
+ bool RedrawItem(int index)
+ { return RedrawItems(index, index); }
+
+ int HitTest(LPLVHITTESTINFO info)
+ { return ListView_HitTest(_window, info); }
+
+ COLORREF GetBkColor()
+ { return ListView_GetBkColor(_window); }
+};
+
+}}
+#endif \ No newline at end of file
diff --git a/Windows/Control/ProgressBar.h b/CPP/Windows/Control/ProgressBar.h
index 6ce837cc..6ce837cc 100755
--- a/Windows/Control/ProgressBar.h
+++ b/CPP/Windows/Control/ProgressBar.h
diff --git a/Windows/Control/PropertyPage.cpp b/CPP/Windows/Control/PropertyPage.cpp
index f8996be1..f8996be1 100755
--- a/Windows/Control/PropertyPage.cpp
+++ b/CPP/Windows/Control/PropertyPage.cpp
diff --git a/Windows/Control/PropertyPage.h b/CPP/Windows/Control/PropertyPage.h
index e041d289..e041d289 100755
--- a/Windows/Control/PropertyPage.h
+++ b/CPP/Windows/Control/PropertyPage.h
diff --git a/Windows/Control/ReBar.h b/CPP/Windows/Control/ReBar.h
index ec27f0ed..ec27f0ed 100755
--- a/Windows/Control/ReBar.h
+++ b/CPP/Windows/Control/ReBar.h
diff --git a/Windows/Control/Static.h b/CPP/Windows/Control/Static.h
index 5dded0ec..5dded0ec 100755
--- a/Windows/Control/Static.h
+++ b/CPP/Windows/Control/Static.h
diff --git a/Windows/Control/StatusBar.h b/CPP/Windows/Control/StatusBar.h
index e8018a56..e8018a56 100755
--- a/Windows/Control/StatusBar.h
+++ b/CPP/Windows/Control/StatusBar.h
diff --git a/Windows/Control/StdAfx.h b/CPP/Windows/Control/StdAfx.h
index 27a77b10..27a77b10 100755
--- a/Windows/Control/StdAfx.h
+++ b/CPP/Windows/Control/StdAfx.h
diff --git a/Windows/Control/ToolBar.h b/CPP/Windows/Control/ToolBar.h
index ff5cafd2..ff5cafd2 100755
--- a/Windows/Control/ToolBar.h
+++ b/CPP/Windows/Control/ToolBar.h
diff --git a/Windows/Control/Trackbar.h b/CPP/Windows/Control/Trackbar.h
index bbd7009a..bbd7009a 100755
--- a/Windows/Control/Trackbar.h
+++ b/CPP/Windows/Control/Trackbar.h
diff --git a/CPP/Windows/Control/Window2.cpp b/CPP/Windows/Control/Window2.cpp
new file mode 100755
index 00000000..66857523
--- /dev/null
+++ b/CPP/Windows/Control/Window2.cpp
@@ -0,0 +1,203 @@
+// Windows/Control/Window2.cpp
+
+#include "StdAfx.h"
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+#include "Windows/Control/Window2.h"
+
+// extern HINSTANCE g_hInstance;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+
+#ifndef _UNICODE
+ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
+#endif
+
+namespace NControl {
+
+static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ CWindow tempWindow(aHWND);
+ if (message == WM_NCCREATE)
+ tempWindow.SetUserDataLongPtr(
+ LONG_PTR(((LPCREATESTRUCT)lParam)->lpCreateParams));
+ CWindow2 *window = (CWindow2*)(tempWindow.GetUserDataLongPtr());
+ if (window != NULL && message == WM_NCCREATE)
+ window->Attach(aHWND);
+ if (window == 0)
+ {
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(aHWND, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(aHWND, message, wParam, lParam);
+ }
+ return window->OnMessage(message, wParam, lParam);
+}
+
+bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className,
+ LPCTSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance)
+{
+ WNDCLASS windowClass;
+ if(!::GetClassInfo(instance, className, &windowClass))
+ {
+ // windowClass.style = CS_HREDRAW | CS_VREDRAW;
+ windowClass.style = 0;
+
+ windowClass.lpfnWndProc = WindowProcedure;
+ windowClass.cbClsExtra = NULL;
+ windowClass.cbWndExtra = NULL;
+ windowClass.hInstance = instance;
+ windowClass.hIcon = NULL;
+ windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ windowClass.lpszMenuName = NULL;
+ windowClass.lpszClassName = className;
+ if (::RegisterClass(&windowClass) == 0)
+ return false;
+ }
+ return CWindow::CreateEx(exStyle, className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, this);
+}
+
+#ifndef _UNICODE
+
+bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className,
+ LPCWSTR windowName, DWORD style,
+ int x, int y, int width, int height,
+ HWND parentWindow, HMENU idOrHMenu,
+ HINSTANCE instance)
+{
+ bool needRegister;
+ if(g_IsNT)
+ {
+ WNDCLASSW windowClass;
+ needRegister = ::GetClassInfoW(instance, className, &windowClass) == 0;
+ }
+ else
+ {
+ WNDCLASSA windowClassA;
+ AString classNameA;
+ LPCSTR classNameP;
+ if (IS_INTRESOURCE(className))
+ classNameP = (LPCSTR)className;
+ else
+ {
+ classNameA = GetSystemString(className);
+ classNameP = classNameA;
+ }
+ needRegister = ::GetClassInfoA(instance, classNameP, &windowClassA) == 0;
+ }
+ if (needRegister)
+ {
+ WNDCLASSW windowClass;
+ // windowClass.style = CS_HREDRAW | CS_VREDRAW;
+ windowClass.style = 0;
+ windowClass.lpfnWndProc = WindowProcedure;
+ windowClass.cbClsExtra = NULL;
+ windowClass.cbWndExtra = NULL;
+ windowClass.hInstance = instance;
+ windowClass.hIcon = NULL;
+ windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ windowClass.lpszMenuName = NULL;
+ windowClass.lpszClassName = className;
+ if (MyRegisterClass(&windowClass) == 0)
+ return false;
+ }
+ return CWindow::CreateEx(exStyle, className, windowName,
+ style, x, y, width, height, parentWindow,
+ idOrHMenu, instance, this);
+
+}
+#endif
+
+LRESULT CWindow2::DefProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(_window, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(_window, message, wParam, lParam);
+}
+
+LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT result;
+ switch (message)
+ {
+ case WM_CREATE:
+ if (!OnCreate((CREATESTRUCT *)lParam))
+ return -1;
+ break;
+ case WM_COMMAND:
+ if (OnCommand(wParam, lParam, result))
+ return result;
+ break;
+ case WM_NOTIFY:
+ if (OnNotify((UINT)wParam, (LPNMHDR) lParam, result))
+ return result;
+ break;
+ case WM_DESTROY:
+ OnDestroy();
+ break;
+ case WM_CLOSE:
+ OnClose();
+ return 0;
+ case WM_SIZE:
+ if (OnSize(wParam, LOWORD(lParam), HIWORD(lParam)))
+ return 0;
+ }
+ return DefProc(message, wParam, lParam);
+}
+
+bool CWindow2::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result)
+{
+ return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam, result);
+}
+
+bool CWindow2::OnCommand(int /* code */, int /* itemID */, LPARAM /* lParam */, LRESULT & /* result */)
+{
+ return false;
+ // return DefProc(message, wParam, lParam);
+ /*
+ if (code == BN_CLICKED)
+ return OnButtonClicked(itemID, (HWND)lParam);
+ */
+}
+
+/*
+bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(aButtonID)
+ {
+ case IDOK:
+ OnOK();
+ break;
+ case IDCANCEL:
+ OnCancel();
+ break;
+ case IDHELP:
+ OnHelp();
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+*/
+
+}}
diff --git a/Windows/Control/Window2.h b/CPP/Windows/Control/Window2.h
index 2d0e574d..2d0e574d 100755
--- a/Windows/Control/Window2.h
+++ b/CPP/Windows/Control/Window2.h
diff --git a/Windows/DLL.cpp b/CPP/Windows/DLL.cpp
index 9e92dc26..9e92dc26 100755
--- a/Windows/DLL.cpp
+++ b/CPP/Windows/DLL.cpp
diff --git a/Windows/DLL.h b/CPP/Windows/DLL.h
index bad0dd6d..bad0dd6d 100755
--- a/Windows/DLL.h
+++ b/CPP/Windows/DLL.h
diff --git a/Windows/Defs.h b/CPP/Windows/Defs.h
index f8c6daaa..f8c6daaa 100755
--- a/Windows/Defs.h
+++ b/CPP/Windows/Defs.h
diff --git a/Windows/Error.cpp b/CPP/Windows/Error.cpp
index e559c4cc..e559c4cc 100755
--- a/Windows/Error.cpp
+++ b/CPP/Windows/Error.cpp
diff --git a/Windows/Error.h b/CPP/Windows/Error.h
index 4d9a9fa6..4d9a9fa6 100755
--- a/Windows/Error.h
+++ b/CPP/Windows/Error.h
diff --git a/Windows/FileDevice.cpp b/CPP/Windows/FileDevice.cpp
index 76f1aa7a..76f1aa7a 100755
--- a/Windows/FileDevice.cpp
+++ b/CPP/Windows/FileDevice.cpp
diff --git a/Windows/FileDevice.h b/CPP/Windows/FileDevice.h
index d4d71c39..d4d71c39 100755
--- a/Windows/FileDevice.h
+++ b/CPP/Windows/FileDevice.h
diff --git a/CPP/Windows/FileDir.cpp b/CPP/Windows/FileDir.cpp
new file mode 100755
index 00000000..c94c737d
--- /dev/null
+++ b/CPP/Windows/FileDir.cpp
@@ -0,0 +1,835 @@
+// Windows/FileDir.cpp
+
+#include "StdAfx.h"
+
+#include "FileDir.h"
+#include "FileName.h"
+#include "FileFind.h"
+#include "Defs.h"
+#ifndef _UNICODE
+#include "../Common/StringConvert.h"
+#endif
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+namespace NFile {
+
+#if defined(WIN_LONG_PATH) && defined(_UNICODE)
+#define WIN_LONG_PATH2
+#endif
+
+// SetCurrentDirectory doesn't support \\?\ prefix
+
+#ifdef WIN_LONG_PATH
+bool GetLongPathBase(LPCWSTR fileName, UString &res);
+bool GetLongPath(LPCWSTR fileName, UString &res);
+#endif
+
+namespace NDirectory {
+
+#ifndef _UNICODE
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static UString GetUnicodePath(const CSysString &sysPath)
+ { return MultiByteToUnicodeString(sysPath, GetCurrentCodePage()); }
+static CSysString GetSysPath(LPCWSTR sysPath)
+ { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
+#endif
+
+bool MyGetWindowsDirectory(CSysString &path)
+{
+ UINT needLength = ::GetWindowsDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+}
+
+bool MyGetSystemDirectory(CSysString &path)
+{
+ UINT needLength = ::GetSystemDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+}
+
+#ifndef _UNICODE
+bool MyGetWindowsDirectory(UString &path)
+{
+ if (g_IsNT)
+ {
+ UINT needLength = ::GetWindowsDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+ }
+ CSysString sysPath;
+ if (!MyGetWindowsDirectory(sysPath))
+ return false;
+ path = GetUnicodePath(sysPath);
+ return true;
+}
+
+bool MyGetSystemDirectory(UString &path)
+{
+ if (g_IsNT)
+ {
+ UINT needLength = ::GetSystemDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+ }
+ CSysString sysPath;
+ if (!MyGetSystemDirectory(sysPath))
+ return false;
+ path = GetUnicodePath(sysPath);
+ return true;
+}
+#endif
+
+bool SetDirTime(LPCWSTR fileName, const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime)
+{
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ return false;
+ }
+ #endif
+ HANDLE hDir = ::CreateFileW(fileName, GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ #ifdef WIN_LONG_PATH
+ if (hDir == INVALID_HANDLE_VALUE)
+ {
+ UString longPath;
+ if (GetLongPath(fileName, longPath))
+ hDir = ::CreateFileW(longPath, GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ }
+ #endif
+
+ bool res = false;
+ if (hDir != INVALID_HANDLE_VALUE)
+ {
+ res = BOOLToBool(::SetFileTime(hDir, creationTime, lastAccessTime, lastWriteTime));
+ ::CloseHandle(hDir);
+ }
+ return res;
+}
+
+bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes)
+{
+ if (::SetFileAttributes(fileName, fileAttributes))
+ return true;
+ #ifdef WIN_LONG_PATH2
+ UString longPath;
+ if (GetLongPath(fileName, longPath))
+ return BOOLToBool(::SetFileAttributesW(longPath, fileAttributes));
+ #endif
+ return false;
+}
+
+bool MyRemoveDirectory(LPCTSTR pathName)
+{
+ if (::RemoveDirectory(pathName))
+ return true;
+ #ifdef WIN_LONG_PATH2
+ UString longPath;
+ if (GetLongPath(pathName, longPath))
+ return BOOLToBool(::RemoveDirectoryW(longPath));
+ #endif
+ return false;
+}
+
+#ifdef WIN_LONG_PATH
+bool GetLongPaths(LPCWSTR s1, LPCWSTR s2, UString &d1, UString &d2)
+{
+ if (!GetLongPathBase(s1, d1) || !GetLongPathBase(s2, d2))
+ return false;
+ if (d1.IsEmpty() && d2.IsEmpty()) return false;
+ if (d1.IsEmpty()) d1 = s1;
+ if (d2.IsEmpty()) d2 = s2;
+ return true;
+}
+#endif
+
+bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName)
+{
+ if (::MoveFile(existFileName, newFileName))
+ return true;
+ #ifdef WIN_LONG_PATH2
+ UString d1, d2;
+ if (GetLongPaths(existFileName, newFileName, d1, d2))
+ return BOOLToBool(::MoveFileW(d1, d2));
+ #endif
+ return false;
+}
+
+#ifndef _UNICODE
+bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes)
+{
+ if (!g_IsNT)
+ return MySetFileAttributes(GetSysPath(fileName), fileAttributes);
+ if (::SetFileAttributesW(fileName, fileAttributes))
+ return true;
+ #ifdef WIN_LONG_PATH
+ UString longPath;
+ if (GetLongPath(fileName, longPath))
+ return BOOLToBool(::SetFileAttributesW(longPath, fileAttributes));
+ #endif
+ return false;
+}
+
+
+bool MyRemoveDirectory(LPCWSTR pathName)
+{
+ if (!g_IsNT)
+ return MyRemoveDirectory(GetSysPath(pathName));
+ if (::RemoveDirectoryW(pathName))
+ return true;
+ #ifdef WIN_LONG_PATH
+ UString longPath;
+ if (GetLongPath(pathName, longPath))
+ return BOOLToBool(::RemoveDirectoryW(longPath));
+ #endif
+ return false;
+}
+
+bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName)
+{
+ if (!g_IsNT)
+ return MyMoveFile(GetSysPath(existFileName), GetSysPath(newFileName));
+ if (::MoveFileW(existFileName, newFileName))
+ return true;
+ #ifdef WIN_LONG_PATH
+ UString d1, d2;
+ if (GetLongPaths(existFileName, newFileName, d1, d2))
+ return BOOLToBool(::MoveFileW(d1, d2));
+ #endif
+ return false;
+}
+#endif
+
+bool MyCreateDirectory(LPCTSTR pathName)
+{
+ if (::CreateDirectory(pathName, NULL))
+ return true;
+ #ifdef WIN_LONG_PATH2
+ UString longPath;
+ if (GetLongPath(pathName, longPath))
+ return BOOLToBool(::CreateDirectoryW(longPath, NULL));
+ #endif
+ return false;
+}
+
+#ifndef _UNICODE
+bool MyCreateDirectory(LPCWSTR pathName)
+{
+ if (!g_IsNT)
+ return MyCreateDirectory(GetSysPath(pathName));
+ if (::CreateDirectoryW(pathName, NULL))
+ return true;
+ #ifdef WIN_LONG_PATH
+ UString longPath;
+ if (GetLongPath(pathName, longPath))
+ return BOOLToBool(::CreateDirectoryW(longPath, NULL));
+ #endif
+ return false;
+}
+#endif
+
+/*
+bool CreateComplexDirectory(LPCTSTR pathName)
+{
+ NName::CParsedPath path;
+ path.ParsePath(pathName);
+ CSysString fullPath = path.Prefix;
+ DWORD errorCode = ERROR_SUCCESS;
+ for(int i = 0; i < path.PathParts.Size(); i++)
+ {
+ const CSysString &string = path.PathParts[i];
+ if(string.IsEmpty())
+ {
+ if(i != path.PathParts.Size() - 1)
+ return false;
+ return true;
+ }
+ fullPath += path.PathParts[i];
+ if (!MyCreateDirectory(fullPath))
+ {
+ DWORD errorCode = GetLastError();
+ if(errorCode != ERROR_ALREADY_EXISTS)
+ return false;
+ }
+ fullPath += NName::kDirDelimiter;
+ }
+ return true;
+}
+*/
+
+bool CreateComplexDirectory(LPCTSTR _aPathName)
+{
+ CSysString pathName = _aPathName;
+ int pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
+ if (pos > 0 && pos == pathName.Length() - 1)
+ {
+ if (pathName.Length() == 3 && pathName[1] == ':')
+ return true; // Disk folder;
+ pathName.Delete(pos);
+ }
+ CSysString pathName2 = pathName;
+ pos = pathName.Length();
+ for (;;)
+ {
+ if(MyCreateDirectory(pathName))
+ break;
+ if (::GetLastError() == ERROR_ALREADY_EXISTS)
+ {
+ NFind::CFileInfo fileInfo;
+ if (!NFind::FindFile(pathName, fileInfo)) // For network folders
+ return true;
+ if (!fileInfo.IsDirectory())
+ return false;
+ break;
+ }
+ pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
+ if (pos < 0 || pos == 0)
+ return false;
+ if (pathName[pos - 1] == ':')
+ return false;
+ pathName = pathName.Left(pos);
+ }
+ pathName = pathName2;
+ while(pos < pathName.Length())
+ {
+ pos = pathName.Find(TEXT(CHAR_PATH_SEPARATOR), pos + 1);
+ if (pos < 0)
+ pos = pathName.Length();
+ if (!MyCreateDirectory(pathName.Left(pos)))
+ return false;
+ }
+ return true;
+}
+
+#ifndef _UNICODE
+
+bool CreateComplexDirectory(LPCWSTR _aPathName)
+{
+ UString pathName = _aPathName;
+ int pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos > 0 && pos == pathName.Length() - 1)
+ {
+ if (pathName.Length() == 3 && pathName[1] == L':')
+ return true; // Disk folder;
+ pathName.Delete(pos);
+ }
+ UString pathName2 = pathName;
+ pos = pathName.Length();
+ for (;;)
+ {
+ if(MyCreateDirectory(pathName))
+ break;
+ if (::GetLastError() == ERROR_ALREADY_EXISTS)
+ {
+ NFind::CFileInfoW fileInfo;
+ if (!NFind::FindFile(pathName, fileInfo)) // For network folders
+ return true;
+ if (!fileInfo.IsDirectory())
+ return false;
+ break;
+ }
+ pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0 || pos == 0)
+ return false;
+ if (pathName[pos - 1] == L':')
+ return false;
+ pathName = pathName.Left(pos);
+ }
+ pathName = pathName2;
+ while(pos < pathName.Length())
+ {
+ pos = pathName.Find(WCHAR_PATH_SEPARATOR, pos + 1);
+ if (pos < 0)
+ pos = pathName.Length();
+ if (!MyCreateDirectory(pathName.Left(pos)))
+ return false;
+ }
+ return true;
+}
+
+#endif
+
+bool DeleteFileAlways(LPCTSTR name)
+{
+ if (!MySetFileAttributes(name, 0))
+ return false;
+ if (::DeleteFile(name))
+ return true;
+ #ifdef WIN_LONG_PATH2
+ UString longPath;
+ if (GetLongPath(name, longPath))
+ return BOOLToBool(::DeleteFileW(longPath));
+ #endif
+ return false;
+}
+
+#ifndef _UNICODE
+bool DeleteFileAlways(LPCWSTR name)
+{
+ if (!g_IsNT)
+ return DeleteFileAlways(GetSysPath(name));
+ if (!MySetFileAttributes(name, 0))
+ return false;
+ if (::DeleteFileW(name))
+ return true;
+ #ifdef WIN_LONG_PATH
+ UString longPath;
+ if (GetLongPath(name, longPath))
+ return BOOLToBool(::DeleteFileW(longPath));
+ #endif
+ return false;
+}
+#endif
+
+static bool RemoveDirectorySubItems2(const CSysString pathPrefix, const NFind::CFileInfo &fileInfo)
+{
+ if(fileInfo.IsDirectory())
+ return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
+ return DeleteFileAlways(pathPrefix + fileInfo.Name);
+}
+
+bool RemoveDirectoryWithSubItems(const CSysString &path)
+{
+ NFind::CFileInfo fileInfo;
+ CSysString pathPrefix = path + NName::kDirDelimiter;
+ {
+ NFind::CEnumerator enumerator(pathPrefix + TCHAR(NName::kAnyStringWildcard));
+ while(enumerator.Next(fileInfo))
+ if (!RemoveDirectorySubItems2(pathPrefix, fileInfo))
+ return false;
+ }
+ if (!MySetFileAttributes(path, 0))
+ return false;
+ return MyRemoveDirectory(path);
+}
+
+#ifndef _UNICODE
+static bool RemoveDirectorySubItems2(const UString pathPrefix, const NFind::CFileInfoW &fileInfo)
+{
+ if(fileInfo.IsDirectory())
+ return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
+ return DeleteFileAlways(pathPrefix + fileInfo.Name);
+}
+bool RemoveDirectoryWithSubItems(const UString &path)
+{
+ NFind::CFileInfoW fileInfo;
+ UString pathPrefix = path + UString(NName::kDirDelimiter);
+ {
+ NFind::CEnumeratorW enumerator(pathPrefix + UString(NName::kAnyStringWildcard));
+ while(enumerator.Next(fileInfo))
+ if (!RemoveDirectorySubItems2(pathPrefix, fileInfo))
+ return false;
+ }
+ if (!MySetFileAttributes(path, 0))
+ return false;
+ return MyRemoveDirectory(path);
+}
+#endif
+
+#ifndef _WIN32_WCE
+
+bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath)
+{
+ DWORD needLength = ::GetShortPathName(longPath, shortPath.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
+ shortPath.ReleaseBuffer();
+ return (needLength > 0 && needLength < MAX_PATH);
+}
+
+bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, int &fileNamePartStartIndex)
+{
+ resultPath.Empty();
+ LPTSTR fileNamePointer = 0;
+ LPTSTR buffer = resultPath.GetBuffer(MAX_PATH);
+ DWORD needLength = ::GetFullPathName(fileName, MAX_PATH + 1, buffer, &fileNamePointer);
+ resultPath.ReleaseBuffer();
+ if (needLength == 0)
+ return false;
+ if (needLength >= MAX_PATH)
+ {
+ #ifdef WIN_LONG_PATH2
+ needLength++;
+ buffer = resultPath.GetBuffer(needLength + 1);
+ DWORD needLength2 = ::GetFullPathNameW(fileName, needLength, buffer, &fileNamePointer);
+ resultPath.ReleaseBuffer();
+ if (needLength2 == 0 || needLength2 > needLength)
+ #endif
+ return false;
+ }
+ if (fileNamePointer == 0)
+ fileNamePartStartIndex = lstrlen(fileName);
+ else
+ fileNamePartStartIndex = (int)(fileNamePointer - buffer);
+ return true;
+}
+
+#ifndef _UNICODE
+bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex)
+{
+ resultPath.Empty();
+ if (g_IsNT)
+ {
+ LPWSTR fileNamePointer = 0;
+ LPWSTR buffer = resultPath.GetBuffer(MAX_PATH);
+ DWORD needLength = ::GetFullPathNameW(fileName, MAX_PATH + 1, buffer, &fileNamePointer);
+ resultPath.ReleaseBuffer();
+ if (needLength == 0)
+ return false;
+ if (needLength >= MAX_PATH)
+ {
+ #ifdef WIN_LONG_PATH
+ needLength++;
+ buffer = resultPath.GetBuffer(needLength + 1);
+ DWORD needLength2 = ::GetFullPathNameW(fileName, needLength, buffer, &fileNamePointer);
+ resultPath.ReleaseBuffer();
+ if (needLength2 == 0 || needLength2 > needLength)
+ #endif
+ return false;
+ }
+ if (fileNamePointer == 0)
+ fileNamePartStartIndex = MyStringLen(fileName);
+ else
+ fileNamePartStartIndex = (int)(fileNamePointer - buffer);
+ }
+ else
+ {
+ CSysString sysPath;
+ if (!MyGetFullPathName(GetSysPath(fileName), sysPath, fileNamePartStartIndex))
+ return false;
+ UString resultPath1 = GetUnicodePath(sysPath.Left(fileNamePartStartIndex));
+ UString resultPath2 = GetUnicodePath(sysPath.Mid(fileNamePartStartIndex));
+ fileNamePartStartIndex = resultPath1.Length();
+ resultPath = resultPath1 + resultPath2;
+ }
+ return true;
+}
+#endif
+
+
+bool MyGetFullPathName(LPCTSTR fileName, CSysString &path)
+{
+ int index;
+ return MyGetFullPathName(fileName, path, index);
+}
+
+#ifndef _UNICODE
+bool MyGetFullPathName(LPCWSTR fileName, UString &path)
+{
+ int index;
+ return MyGetFullPathName(fileName, path, index);
+}
+#endif
+
+bool GetOnlyName(LPCTSTR fileName, CSysString &resultName)
+{
+ int index;
+ if (!MyGetFullPathName(fileName, resultName, index))
+ return false;
+ resultName = resultName.Mid(index);
+ return true;
+}
+
+#ifndef _UNICODE
+bool GetOnlyName(LPCWSTR fileName, UString &resultName)
+{
+ int index;
+ if (!MyGetFullPathName(fileName, resultName, index))
+ return false;
+ resultName = resultName.Mid(index);
+ return true;
+}
+#endif
+
+bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName)
+{
+ int index;
+ if (!MyGetFullPathName(fileName, resultName, index))
+ return false;
+ resultName = resultName.Left(index);
+ return true;
+}
+
+#ifndef _UNICODE
+bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName)
+{
+ int index;
+ if (!MyGetFullPathName(fileName, resultName, index))
+ return false;
+ resultName = resultName.Left(index);
+ return true;
+}
+#endif
+
+bool MyGetCurrentDirectory(CSysString &path)
+{
+ DWORD needLength = ::GetCurrentDirectory(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+}
+
+#ifndef _UNICODE
+bool MySetCurrentDirectory(LPCWSTR path)
+{
+ if (g_IsNT)
+ return BOOLToBool(::SetCurrentDirectoryW(path));
+ return MySetCurrentDirectory(GetSysPath(path));
+}
+bool MyGetCurrentDirectory(UString &path)
+{
+ if (g_IsNT)
+ {
+ DWORD needLength = ::GetCurrentDirectoryW(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+ }
+ CSysString sysPath;
+ if (!MyGetCurrentDirectory(sysPath))
+ return false;
+ path = GetUnicodePath(sysPath);
+ return true;
+}
+#endif
+#endif
+
+bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
+ CSysString &resultPath, UINT32 &filePart)
+{
+ LPTSTR filePartPointer;
+ DWORD value = ::SearchPath(path, fileName, extension,
+ MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
+ filePart = (UINT32)(filePartPointer - (LPCTSTR)resultPath);
+ resultPath.ReleaseBuffer();
+ return (value > 0 && value <= MAX_PATH);
+}
+
+#ifndef _UNICODE
+bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
+ UString &resultPath, UINT32 &filePart)
+{
+ if (g_IsNT)
+ {
+ LPWSTR filePartPointer = 0;
+ DWORD value = ::SearchPathW(path, fileName, extension,
+ MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
+ filePart = (UINT32)(filePartPointer - (LPCWSTR)resultPath);
+ resultPath.ReleaseBuffer();
+ return (value > 0 && value <= MAX_PATH);
+ }
+
+ CSysString sysPath;
+ if (!MySearchPath(
+ path != 0 ? (LPCTSTR)GetSysPath(path): 0,
+ fileName != 0 ? (LPCTSTR)GetSysPath(fileName): 0,
+ extension != 0 ? (LPCTSTR)GetSysPath(extension): 0,
+ sysPath, filePart))
+ return false;
+ UString resultPath1 = GetUnicodePath(sysPath.Left(filePart));
+ UString resultPath2 = GetUnicodePath(sysPath.Mid(filePart));
+ filePart = resultPath1.Length();
+ resultPath = resultPath1 + resultPath2;
+ return true;
+}
+#endif
+
+bool MyGetTempPath(CSysString &path)
+{
+ DWORD needLength = ::GetTempPath(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+}
+
+#ifndef _UNICODE
+bool MyGetTempPath(UString &path)
+{
+ path.Empty();
+ if (g_IsNT)
+ {
+ DWORD needLength = ::GetTempPathW(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
+ path.ReleaseBuffer();
+ return (needLength > 0 && needLength <= MAX_PATH);
+ }
+ CSysString sysPath;
+ if (!MyGetTempPath(sysPath))
+ return false;
+ path = GetUnicodePath(sysPath);
+ return true;
+}
+#endif
+
+UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &path)
+{
+ UINT number = ::GetTempFileName(dirPath, prefix, 0, path.GetBuffer(MAX_PATH + 1));
+ path.ReleaseBuffer();
+ return number;
+}
+
+#ifndef _UNICODE
+UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &path)
+{
+ if (g_IsNT)
+ {
+ UINT number = ::GetTempFileNameW(dirPath, prefix, 0, path.GetBuffer(MAX_PATH));
+ path.ReleaseBuffer();
+ return number;
+ }
+ CSysString sysPath;
+ UINT number = MyGetTempFileName(
+ dirPath ? (LPCTSTR)GetSysPath(dirPath): 0,
+ prefix ? (LPCTSTR)GetSysPath(prefix): 0,
+ sysPath);
+ path = GetUnicodePath(sysPath);
+ return number;
+}
+#endif
+
+UINT CTempFile::Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath)
+{
+ Remove();
+ UINT number = MyGetTempFileName(dirPath, prefix, resultPath);
+ if(number != 0)
+ {
+ _fileName = resultPath;
+ _mustBeDeleted = true;
+ }
+ return number;
+}
+
+bool CTempFile::Create(LPCTSTR prefix, CSysString &resultPath)
+{
+ CSysString tempPath;
+ if (!MyGetTempPath(tempPath))
+ return false;
+ if (Create(tempPath, prefix, resultPath) != 0)
+ return true;
+ if (!MyGetWindowsDirectory(tempPath))
+ return false;
+ return (Create(tempPath, prefix, resultPath) != 0);
+}
+
+bool CTempFile::Remove()
+{
+ if (!_mustBeDeleted)
+ return true;
+ _mustBeDeleted = !DeleteFileAlways(_fileName);
+ return !_mustBeDeleted;
+}
+
+#ifndef _UNICODE
+
+UINT CTempFileW::Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath)
+{
+ Remove();
+ UINT number = MyGetTempFileName(dirPath, prefix, resultPath);
+ if(number != 0)
+ {
+ _fileName = resultPath;
+ _mustBeDeleted = true;
+ }
+ return number;
+}
+
+bool CTempFileW::Create(LPCWSTR prefix, UString &resultPath)
+{
+ UString tempPath;
+ if (!MyGetTempPath(tempPath))
+ return false;
+ if (Create(tempPath, prefix, resultPath) != 0)
+ return true;
+ if (!MyGetWindowsDirectory(tempPath))
+ return false;
+ return (Create(tempPath, prefix, resultPath) != 0);
+}
+
+bool CTempFileW::Remove()
+{
+ if (!_mustBeDeleted)
+ return true;
+ _mustBeDeleted = !DeleteFileAlways(_fileName);
+ return !_mustBeDeleted;
+}
+
+#endif
+
+bool CreateTempDirectory(LPCTSTR prefix, CSysString &dirName)
+{
+ /*
+ CSysString prefix = tempPath + prefixChars;
+ CRandom random;
+ random.Init();
+ */
+ for (;;)
+ {
+ CTempFile tempFile;
+ if (!tempFile.Create(prefix, dirName))
+ return false;
+ if (!::DeleteFile(dirName))
+ return false;
+ /*
+ UINT32 randomNumber = random.Generate();
+ TCHAR randomNumberString[32];
+ _stprintf(randomNumberString, _T("%04X"), randomNumber);
+ dirName = prefix + randomNumberString;
+ */
+ if(NFind::DoesFileExist(dirName))
+ continue;
+ if (MyCreateDirectory(dirName))
+ return true;
+ if (::GetLastError() != ERROR_ALREADY_EXISTS)
+ return false;
+ }
+}
+
+bool CTempDirectory::Create(LPCTSTR prefix)
+{
+ Remove();
+ return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
+}
+
+#ifndef _UNICODE
+
+bool CreateTempDirectory(LPCWSTR prefix, UString &dirName)
+{
+ /*
+ CSysString prefix = tempPath + prefixChars;
+ CRandom random;
+ random.Init();
+ */
+ for (;;)
+ {
+ CTempFileW tempFile;
+ if (!tempFile.Create(prefix, dirName))
+ return false;
+ if (!DeleteFileAlways(dirName))
+ return false;
+ /*
+ UINT32 randomNumber = random.Generate();
+ TCHAR randomNumberString[32];
+ _stprintf(randomNumberString, _T("%04X"), randomNumber);
+ dirName = prefix + randomNumberString;
+ */
+ if(NFind::DoesFileExist(dirName))
+ continue;
+ if (MyCreateDirectory(dirName))
+ return true;
+ if (::GetLastError() != ERROR_ALREADY_EXISTS)
+ return false;
+ }
+}
+
+bool CTempDirectoryW::Create(LPCWSTR prefix)
+{
+ Remove();
+ return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
+}
+
+#endif
+
+}}}
diff --git a/CPP/Windows/FileDir.h b/CPP/Windows/FileDir.h
new file mode 100755
index 00000000..3ebf3e63
--- /dev/null
+++ b/CPP/Windows/FileDir.h
@@ -0,0 +1,178 @@
+// Windows/FileDir.h
+
+#ifndef __WINDOWS_FILEDIR_H
+#define __WINDOWS_FILEDIR_H
+
+#include "../Common/String.h"
+#include "Defs.h"
+
+namespace NWindows {
+namespace NFile {
+namespace NDirectory {
+
+#ifdef WIN_LONG_PATH
+bool GetLongPaths(LPCWSTR s1, LPCWSTR s2, UString &d1, UString &d2);
+#endif
+
+bool MyGetWindowsDirectory(CSysString &path);
+bool MyGetSystemDirectory(CSysString &path);
+#ifndef _UNICODE
+bool MyGetWindowsDirectory(UString &path);
+bool MyGetSystemDirectory(UString &path);
+#endif
+
+bool SetDirTime(LPCWSTR fileName, const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
+
+bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes);
+bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName);
+bool MyRemoveDirectory(LPCTSTR pathName);
+bool MyCreateDirectory(LPCTSTR pathName);
+bool CreateComplexDirectory(LPCTSTR pathName);
+bool DeleteFileAlways(LPCTSTR name);
+bool RemoveDirectoryWithSubItems(const CSysString &path);
+
+#ifndef _UNICODE
+bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes);
+bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName);
+bool MyRemoveDirectory(LPCWSTR pathName);
+bool MyCreateDirectory(LPCWSTR pathName);
+bool CreateComplexDirectory(LPCWSTR pathName);
+bool DeleteFileAlways(LPCWSTR name);
+bool RemoveDirectoryWithSubItems(const UString &path);
+#endif
+
+#ifndef _WIN32_WCE
+bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath);
+
+bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
+ int &fileNamePartStartIndex);
+bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath);
+bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
+bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
+#ifndef _UNICODE
+bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
+ int &fileNamePartStartIndex);
+bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath);
+bool GetOnlyName(LPCWSTR fileName, UString &resultName);
+bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName);
+#endif
+
+inline bool MySetCurrentDirectory(LPCTSTR path)
+ { return BOOLToBool(::SetCurrentDirectory(path)); }
+bool MyGetCurrentDirectory(CSysString &resultPath);
+#ifndef _UNICODE
+bool MySetCurrentDirectory(LPCWSTR path);
+bool MyGetCurrentDirectory(UString &resultPath);
+#endif
+#endif
+
+bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
+ CSysString &resultPath, UINT32 &filePart);
+#ifndef _UNICODE
+bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
+ UString &resultPath, UINT32 &filePart);
+#endif
+
+inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
+ CSysString &resultPath)
+{
+ UINT32 value;
+ return MySearchPath(path, fileName, extension, resultPath, value);
+}
+
+#ifndef _UNICODE
+inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
+ UString &resultPath)
+{
+ UINT32 value;
+ return MySearchPath(path, fileName, extension, resultPath, value);
+}
+#endif
+
+bool MyGetTempPath(CSysString &resultPath);
+#ifndef _UNICODE
+bool MyGetTempPath(UString &resultPath);
+#endif
+
+UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
+#ifndef _UNICODE
+UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
+#endif
+
+class CTempFile
+{
+ bool _mustBeDeleted;
+ CSysString _fileName;
+public:
+ CTempFile(): _mustBeDeleted(false) {}
+ ~CTempFile() { Remove(); }
+ void DisableDeleting() { _mustBeDeleted = false; }
+ UINT Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
+ bool Create(LPCTSTR prefix, CSysString &resultPath);
+ bool Remove();
+};
+
+#ifdef _UNICODE
+typedef CTempFile CTempFileW;
+#else
+class CTempFileW
+{
+ bool _mustBeDeleted;
+ UString _fileName;
+public:
+ CTempFileW(): _mustBeDeleted(false) {}
+ ~CTempFileW() { Remove(); }
+ void DisableDeleting() { _mustBeDeleted = false; }
+ UINT Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
+ bool Create(LPCWSTR prefix, UString &resultPath);
+ bool Remove();
+};
+#endif
+
+bool CreateTempDirectory(LPCTSTR prefixChars, CSysString &dirName);
+
+class CTempDirectory
+{
+ bool _mustBeDeleted;
+ CSysString _tempDir;
+public:
+ const CSysString &GetPath() const { return _tempDir; }
+ CTempDirectory(): _mustBeDeleted(false) {}
+ ~CTempDirectory() { Remove(); }
+ bool Create(LPCTSTR prefix) ;
+ bool Remove()
+ {
+ if (!_mustBeDeleted)
+ return true;
+ _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
+ return (!_mustBeDeleted);
+ }
+ void DisableDeleting() { _mustBeDeleted = false; }
+};
+
+#ifdef _UNICODE
+typedef CTempDirectory CTempDirectoryW;
+#else
+class CTempDirectoryW
+{
+ bool _mustBeDeleted;
+ UString _tempDir;
+public:
+ const UString &GetPath() const { return _tempDir; }
+ CTempDirectoryW(): _mustBeDeleted(false) {}
+ ~CTempDirectoryW() { Remove(); }
+ bool Create(LPCWSTR prefix) ;
+ bool Remove()
+ {
+ if (!_mustBeDeleted)
+ return true;
+ _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
+ return (!_mustBeDeleted);
+ }
+ void DisableDeleting() { _mustBeDeleted = false; }
+};
+#endif
+
+}}}
+
+#endif
diff --git a/CPP/Windows/FileFind.cpp b/CPP/Windows/FileFind.cpp
new file mode 100755
index 00000000..3b5bdf70
--- /dev/null
+++ b/CPP/Windows/FileFind.cpp
@@ -0,0 +1,408 @@
+// Windows/FileFind.cpp
+
+#include "StdAfx.h"
+
+#include "FileFind.h"
+#ifndef _UNICODE
+#include "../Common/StringConvert.h"
+#endif
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+namespace NFile {
+
+#if defined(WIN_LONG_PATH) && defined(_UNICODE)
+#define WIN_LONG_PATH2
+#endif
+
+bool GetLongPath(LPCWSTR fileName, UString &res);
+
+namespace NFind {
+
+static const TCHAR kDot = TEXT('.');
+
+bool CFileInfo::IsDots() const
+{
+ if (!IsDirectory() || Name.IsEmpty())
+ return false;
+ if (Name[0] != kDot)
+ return false;
+ return Name.Length() == 1 || (Name[1] == kDot && Name.Length() == 2);
+}
+
+#ifndef _UNICODE
+bool CFileInfoW::IsDots() const
+{
+ if (!IsDirectory() || Name.IsEmpty())
+ return false;
+ if (Name[0] != kDot)
+ return false;
+ return Name.Length() == 1 || (Name[1] == kDot && Name.Length() == 2);
+}
+#endif
+
+static void ConvertWIN32_FIND_DATA_To_FileInfo(
+ const WIN32_FIND_DATA &findData,
+ CFileInfo &fileInfo)
+{
+ fileInfo.Attributes = findData.dwFileAttributes;
+ fileInfo.CreationTime = findData.ftCreationTime;
+ fileInfo.LastAccessTime = findData.ftLastAccessTime;
+ fileInfo.LastWriteTime = findData.ftLastWriteTime;
+ fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
+ fileInfo.Name = findData.cFileName;
+ #ifndef _WIN32_WCE
+ fileInfo.ReparseTag = findData.dwReserved0;
+ #else
+ fileInfo.ObjectID = findData.dwOID;
+ #endif
+}
+
+#ifndef _UNICODE
+
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+
+static void ConvertWIN32_FIND_DATA_To_FileInfo(
+ const WIN32_FIND_DATAW &findData,
+ CFileInfoW &fileInfo)
+{
+ fileInfo.Attributes = findData.dwFileAttributes;
+ fileInfo.CreationTime = findData.ftCreationTime;
+ fileInfo.LastAccessTime = findData.ftLastAccessTime;
+ fileInfo.LastWriteTime = findData.ftLastWriteTime;
+ fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
+ fileInfo.Name = findData.cFileName;
+ #ifndef _WIN32_WCE
+ fileInfo.ReparseTag = findData.dwReserved0;
+ #else
+ fileInfo.ObjectID = findData.dwOID;
+ #endif
+}
+
+static void ConvertWIN32_FIND_DATA_To_FileInfo(
+ const WIN32_FIND_DATA &findData,
+ CFileInfoW &fileInfo)
+{
+ fileInfo.Attributes = findData.dwFileAttributes;
+ fileInfo.CreationTime = findData.ftCreationTime;
+ fileInfo.LastAccessTime = findData.ftLastAccessTime;
+ fileInfo.LastWriteTime = findData.ftLastWriteTime;
+ fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
+ fileInfo.Name = GetUnicodeString(findData.cFileName, GetCurrentCodePage());
+ #ifndef _WIN32_WCE
+ fileInfo.ReparseTag = findData.dwReserved0;
+ #else
+ fileInfo.ObjectID = findData.dwOID;
+ #endif
+}
+#endif
+
+////////////////////////////////
+// CFindFile
+
+bool CFindFile::Close()
+{
+ if (_handle == INVALID_HANDLE_VALUE)
+ return true;
+ if (!::FindClose(_handle))
+ return false;
+ _handle = INVALID_HANDLE_VALUE;
+ return true;
+}
+
+
+bool CFindFile::FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo)
+{
+ if (!Close())
+ return false;
+ WIN32_FIND_DATA findData;
+ _handle = ::FindFirstFile(wildcard, &findData);
+ #ifdef WIN_LONG_PATH2
+ if (_handle == INVALID_HANDLE_VALUE)
+ {
+ UString longPath;
+ if (GetLongPath(wildcard, longPath))
+ _handle = ::FindFirstFileW(longPath, &findData);
+ }
+ #endif
+ if (_handle == INVALID_HANDLE_VALUE)
+ return false;
+ ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
+ return true;
+}
+
+#ifndef _UNICODE
+bool CFindFile::FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo)
+{
+ if (!Close())
+ return false;
+ if (g_IsNT)
+ {
+ WIN32_FIND_DATAW findData;
+ _handle = ::FindFirstFileW(wildcard, &findData);
+ #ifdef WIN_LONG_PATH
+ if (_handle == INVALID_HANDLE_VALUE)
+ {
+ UString longPath;
+ if (GetLongPath(wildcard, longPath))
+ _handle = ::FindFirstFileW(longPath, &findData);
+ }
+ #endif
+ if (_handle != INVALID_HANDLE_VALUE)
+ ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
+ }
+ else
+ {
+ WIN32_FIND_DATAA findData;
+ _handle = ::FindFirstFileA(UnicodeStringToMultiByte(wildcard,
+ GetCurrentCodePage()), &findData);
+ if (_handle != INVALID_HANDLE_VALUE)
+ ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
+ }
+ return (_handle != INVALID_HANDLE_VALUE);
+}
+#endif
+
+bool CFindFile::FindNext(CFileInfo &fileInfo)
+{
+ WIN32_FIND_DATA findData;
+ bool result = BOOLToBool(::FindNextFile(_handle, &findData));
+ if (result)
+ ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
+ return result;
+}
+
+#ifndef _UNICODE
+bool CFindFile::FindNext(CFileInfoW &fileInfo)
+{
+ if (g_IsNT)
+ {
+ WIN32_FIND_DATAW findData;
+ if (!::FindNextFileW(_handle, &findData))
+ return false;
+ ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
+ }
+ else
+ {
+ WIN32_FIND_DATAA findData;
+ if (!::FindNextFileA(_handle, &findData))
+ return false;
+ ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
+ }
+ return true;
+}
+#endif
+
+bool FindFile(LPCTSTR wildcard, CFileInfo &fileInfo)
+{
+ CFindFile finder;
+ return finder.FindFirst(wildcard, fileInfo);
+}
+
+#ifndef _UNICODE
+bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo)
+{
+ CFindFile finder;
+ return finder.FindFirst(wildcard, fileInfo);
+}
+#endif
+
+bool DoesFileExist(LPCTSTR name)
+{
+ CFileInfo fileInfo;
+ return FindFile(name, fileInfo);
+}
+
+#ifndef _UNICODE
+bool DoesFileExist(LPCWSTR name)
+{
+ CFileInfoW fileInfo;
+ return FindFile(name, fileInfo);
+}
+#endif
+
+/////////////////////////////////////
+// CEnumerator
+
+bool CEnumerator::NextAny(CFileInfo &fileInfo)
+{
+ if (_findFile.IsHandleAllocated())
+ return _findFile.FindNext(fileInfo);
+ else
+ return _findFile.FindFirst(_wildcard, fileInfo);
+}
+
+bool CEnumerator::Next(CFileInfo &fileInfo)
+{
+ for (;;)
+ {
+ if (!NextAny(fileInfo))
+ return false;
+ if (!fileInfo.IsDots())
+ return true;
+ }
+}
+
+bool CEnumerator::Next(CFileInfo &fileInfo, bool &found)
+{
+ if (Next(fileInfo))
+ {
+ found = true;
+ return true;
+ }
+ found = false;
+ return (::GetLastError() == ERROR_NO_MORE_FILES);
+}
+
+#ifndef _UNICODE
+bool CEnumeratorW::NextAny(CFileInfoW &fileInfo)
+{
+ if (_findFile.IsHandleAllocated())
+ return _findFile.FindNext(fileInfo);
+ else
+ return _findFile.FindFirst(_wildcard, fileInfo);
+}
+
+bool CEnumeratorW::Next(CFileInfoW &fileInfo)
+{
+ for (;;)
+ {
+ if (!NextAny(fileInfo))
+ return false;
+ if (!fileInfo.IsDots())
+ return true;
+ }
+}
+
+bool CEnumeratorW::Next(CFileInfoW &fileInfo, bool &found)
+{
+ if (Next(fileInfo))
+ {
+ found = true;
+ return true;
+ }
+ found = false;
+ return (::GetLastError() == ERROR_NO_MORE_FILES);
+}
+
+#endif
+
+////////////////////////////////
+// CFindChangeNotification
+// FindFirstChangeNotification can return 0. MSDN doesn't tell about it.
+
+bool CFindChangeNotification::Close()
+{
+ if (!IsHandleAllocated())
+ return true;
+ if (!::FindCloseChangeNotification(_handle))
+ return false;
+ _handle = INVALID_HANDLE_VALUE;
+ return true;
+}
+
+HANDLE CFindChangeNotification::FindFirst(LPCTSTR pathName, bool watchSubtree, DWORD notifyFilter)
+{
+ _handle = ::FindFirstChangeNotification(pathName, BoolToBOOL(watchSubtree), notifyFilter);
+ #ifdef WIN_LONG_PATH2
+ if (!IsHandleAllocated())
+ {
+ UString longPath;
+ if (GetLongPath(pathName, longPath))
+ _handle = ::FindFirstChangeNotificationW(longPath, BoolToBOOL(watchSubtree), notifyFilter);
+ }
+ #endif
+ return _handle;
+}
+
+#ifndef _UNICODE
+HANDLE CFindChangeNotification::FindFirst(LPCWSTR pathName, bool watchSubtree, DWORD notifyFilter)
+{
+ if (!g_IsNT)
+ return FindFirst(UnicodeStringToMultiByte(pathName, GetCurrentCodePage()), watchSubtree, notifyFilter);
+ _handle = ::FindFirstChangeNotificationW(pathName, BoolToBOOL(watchSubtree), notifyFilter);
+ #ifdef WIN_LONG_PATH
+ if (!IsHandleAllocated())
+ {
+ UString longPath;
+ if (GetLongPath(pathName, longPath))
+ _handle = ::FindFirstChangeNotificationW(longPath, BoolToBOOL(watchSubtree), notifyFilter);
+ }
+ #endif
+ return _handle;
+}
+#endif
+
+#ifndef _WIN32_WCE
+bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings)
+{
+ driveStrings.Clear();
+ UINT32 size = GetLogicalDriveStrings(0, NULL);
+ if (size == 0)
+ return false;
+ CSysString buffer;
+ UINT32 newSize = GetLogicalDriveStrings(size, buffer.GetBuffer(size));
+ if (newSize == 0)
+ return false;
+ if (newSize > size)
+ return false;
+ CSysString string;
+ for(UINT32 i = 0; i < newSize; i++)
+ {
+ TCHAR c = buffer[i];
+ if (c == TEXT('\0'))
+ {
+ driveStrings.Add(string);
+ string.Empty();
+ }
+ else
+ string += c;
+ }
+ if (!string.IsEmpty())
+ return false;
+ return true;
+}
+
+#ifndef _UNICODE
+bool MyGetLogicalDriveStrings(UStringVector &driveStrings)
+{
+ driveStrings.Clear();
+ if (g_IsNT)
+ {
+ UINT32 size = GetLogicalDriveStringsW(0, NULL);
+ if (size == 0)
+ return false;
+ UString buffer;
+ UINT32 newSize = GetLogicalDriveStringsW(size, buffer.GetBuffer(size));
+ if (newSize == 0)
+ return false;
+ if (newSize > size)
+ return false;
+ UString string;
+ for(UINT32 i = 0; i < newSize; i++)
+ {
+ WCHAR c = buffer[i];
+ if (c == L'\0')
+ {
+ driveStrings.Add(string);
+ string.Empty();
+ }
+ else
+ string += c;
+ }
+ return string.IsEmpty();
+ }
+ CSysStringVector driveStringsA;
+ bool res = MyGetLogicalDriveStrings(driveStringsA);
+ for (int i = 0; i < driveStringsA.Size(); i++)
+ driveStrings.Add(GetUnicodeString(driveStringsA[i]));
+ return res;
+}
+#endif
+
+#endif
+
+}}}
diff --git a/CPP/Windows/FileFind.h b/CPP/Windows/FileFind.h
new file mode 100755
index 00000000..4d2439aa
--- /dev/null
+++ b/CPP/Windows/FileFind.h
@@ -0,0 +1,153 @@
+// Windows/FileFind.h
+
+#ifndef __WINDOWS_FILEFIND_H
+#define __WINDOWS_FILEFIND_H
+
+#include "../Common/String.h"
+#include "../Common/Types.h"
+#include "FileName.h"
+#include "Defs.h"
+
+namespace NWindows {
+namespace NFile {
+namespace NFind {
+
+namespace NAttributes
+{
+ inline bool IsReadOnly(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_READONLY) != 0; }
+ inline bool IsHidden(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_HIDDEN) != 0; }
+ inline bool IsSystem(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_SYSTEM) != 0; }
+ inline bool IsDirectory(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }
+ inline bool IsArchived(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_ARCHIVE) != 0; }
+ inline bool IsCompressed(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_COMPRESSED) != 0; }
+ inline bool IsEncrypted(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_ENCRYPTED) != 0; }
+}
+
+class CFileInfoBase
+{
+ bool MatchesMask(UINT32 mask) const { return ((Attributes & mask) != 0); }
+public:
+ DWORD Attributes;
+ FILETIME CreationTime;
+ FILETIME LastAccessTime;
+ FILETIME LastWriteTime;
+ UInt64 Size;
+
+ #ifndef _WIN32_WCE
+ UINT32 ReparseTag;
+ #else
+ DWORD ObjectID;
+ #endif
+
+ bool IsArchived() const { return MatchesMask(FILE_ATTRIBUTE_ARCHIVE); }
+ bool IsCompressed() const { return MatchesMask(FILE_ATTRIBUTE_COMPRESSED); }
+ bool IsDirectory() const { return MatchesMask(FILE_ATTRIBUTE_DIRECTORY); }
+ bool IsEncrypted() const { return MatchesMask(FILE_ATTRIBUTE_ENCRYPTED); }
+ bool IsHidden() const { return MatchesMask(FILE_ATTRIBUTE_HIDDEN); }
+ bool IsNormal() const { return MatchesMask(FILE_ATTRIBUTE_NORMAL); }
+ bool IsOffline() const { return MatchesMask(FILE_ATTRIBUTE_OFFLINE); }
+ bool IsReadOnly() const { return MatchesMask(FILE_ATTRIBUTE_READONLY); }
+ bool HasReparsePoint() const { return MatchesMask(FILE_ATTRIBUTE_REPARSE_POINT); }
+ bool IsSparse() const { return MatchesMask(FILE_ATTRIBUTE_SPARSE_FILE); }
+ bool IsSystem() const { return MatchesMask(FILE_ATTRIBUTE_SYSTEM); }
+ bool IsTemporary() const { return MatchesMask(FILE_ATTRIBUTE_TEMPORARY); }
+};
+
+class CFileInfo: public CFileInfoBase
+{
+public:
+ CSysString Name;
+ bool IsDots() const;
+};
+
+#ifdef _UNICODE
+typedef CFileInfo CFileInfoW;
+#else
+class CFileInfoW: public CFileInfoBase
+{
+public:
+ UString Name;
+ bool IsDots() const;
+};
+#endif
+
+class CFindFile
+{
+ friend class CEnumerator;
+ HANDLE _handle;
+public:
+ bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE; }
+ CFindFile(): _handle(INVALID_HANDLE_VALUE) {}
+ ~CFindFile() { Close(); }
+ bool FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo);
+ bool FindNext(CFileInfo &fileInfo);
+ #ifndef _UNICODE
+ bool FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo);
+ bool FindNext(CFileInfoW &fileInfo);
+ #endif
+ bool Close();
+};
+
+bool FindFile(LPCTSTR wildcard, CFileInfo &fileInfo);
+
+bool DoesFileExist(LPCTSTR name);
+#ifndef _UNICODE
+bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo);
+bool DoesFileExist(LPCWSTR name);
+#endif
+
+class CEnumerator
+{
+ CFindFile _findFile;
+ CSysString _wildcard;
+ bool NextAny(CFileInfo &fileInfo);
+public:
+ CEnumerator(): _wildcard(NName::kAnyStringWildcard) {}
+ CEnumerator(const CSysString &wildcard): _wildcard(wildcard) {}
+ bool Next(CFileInfo &fileInfo);
+ bool Next(CFileInfo &fileInfo, bool &found);
+};
+
+#ifdef _UNICODE
+typedef CEnumerator CEnumeratorW;
+#else
+class CEnumeratorW
+{
+ CFindFile _findFile;
+ UString _wildcard;
+ bool NextAny(CFileInfoW &fileInfo);
+public:
+ CEnumeratorW(): _wildcard(NName::kAnyStringWildcard) {}
+ CEnumeratorW(const UString &wildcard): _wildcard(wildcard) {}
+ bool Next(CFileInfoW &fileInfo);
+ bool Next(CFileInfoW &fileInfo, bool &found);
+};
+#endif
+
+class CFindChangeNotification
+{
+ HANDLE _handle;
+public:
+ operator HANDLE () { return _handle; }
+ bool IsHandleAllocated() const { return _handle != INVALID_HANDLE_VALUE && _handle != 0; }
+ CFindChangeNotification(): _handle(INVALID_HANDLE_VALUE) {}
+ ~CFindChangeNotification() { Close(); }
+ bool Close();
+ HANDLE FindFirst(LPCTSTR pathName, bool watchSubtree, DWORD notifyFilter);
+ #ifndef _UNICODE
+ HANDLE FindFirst(LPCWSTR pathName, bool watchSubtree, DWORD notifyFilter);
+ #endif
+ bool FindNext() { return BOOLToBool(::FindNextChangeNotification(_handle)); }
+};
+
+#ifndef _WIN32_WCE
+bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings);
+#ifndef _UNICODE
+bool MyGetLogicalDriveStrings(UStringVector &driveStrings);
+#endif
+#endif
+
+}}}
+
+#endif
+
diff --git a/CPP/Windows/FileIO.cpp b/CPP/Windows/FileIO.cpp
new file mode 100755
index 00000000..efad8582
--- /dev/null
+++ b/CPP/Windows/FileIO.cpp
@@ -0,0 +1,305 @@
+// Windows/FileIO.cpp
+
+#include "StdAfx.h"
+
+#include "FileIO.h"
+#include "Defs.h"
+#ifdef WIN_LONG_PATH
+#include "../Common/String.h"
+#endif
+#ifndef _UNICODE
+#include "../Common/StringConvert.h"
+#endif
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NWindows {
+namespace NFile {
+
+#if defined(WIN_LONG_PATH) && defined(_UNICODE)
+#define WIN_LONG_PATH2
+#endif
+
+#ifdef WIN_LONG_PATH
+bool GetLongPathBase(LPCWSTR s, UString &res)
+{
+ res.Empty();
+ int len = MyStringLen(s);
+ wchar_t c = s[0];
+ if (len < 1 || c == L'\\' || c == L'.' && (len == 1 || len == 2 && s[1] == L'.'))
+ return true;
+ UString curDir;
+ if (len > 3)
+ if (s[1] != L':' || s[2] != L'\\' || !(c >= L'a' && c <= L'z' || c >= L'A' && c <= L'Z'))
+ {
+ DWORD needLength = ::GetCurrentDirectoryW(MAX_PATH + 1, curDir.GetBuffer(MAX_PATH + 1));
+ curDir.ReleaseBuffer();
+ if (needLength == 0 || needLength > MAX_PATH)
+ return false;
+ if (curDir[curDir.Length() - 1] != L'\\')
+ curDir += L'\\';
+ }
+ res = UString(L"\\\\?\\") + curDir + s;
+ return true;
+}
+
+bool GetLongPath(LPCWSTR path, UString &longPath)
+{
+ if (GetLongPathBase(path, longPath))
+ return !longPath.IsEmpty();
+ return false;
+}
+#endif
+
+namespace NIO {
+
+CFileBase::~CFileBase() { Close(); }
+
+bool CFileBase::Create(LPCTSTR fileName, DWORD desiredAccess,
+ DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+{
+ if (!Close())
+ return false;
+ _handle = ::CreateFile(fileName, desiredAccess, shareMode,
+ (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
+ flagsAndAttributes, (HANDLE)NULL);
+ #ifdef WIN_LONG_PATH2
+ if (_handle == INVALID_HANDLE_VALUE)
+ {
+ UString longPath;
+ if (GetLongPath(fileName, longPath))
+ _handle = ::CreateFileW(longPath, desiredAccess, shareMode,
+ (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
+ flagsAndAttributes, (HANDLE)NULL);
+ }
+ #endif
+ return (_handle != INVALID_HANDLE_VALUE);
+}
+
+#ifndef _UNICODE
+bool CFileBase::Create(LPCWSTR fileName, DWORD desiredAccess,
+ DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+{
+ if (!g_IsNT)
+ return Create(UnicodeStringToMultiByte(fileName, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP),
+ desiredAccess, shareMode, creationDisposition, flagsAndAttributes);
+ if (!Close())
+ return false;
+ _handle = ::CreateFileW(fileName, desiredAccess, shareMode,
+ (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
+ flagsAndAttributes, (HANDLE)NULL);
+ #ifdef WIN_LONG_PATH
+ if (_handle == INVALID_HANDLE_VALUE)
+ {
+ UString longPath;
+ if (GetLongPath(fileName, longPath))
+ _handle = ::CreateFileW(longPath, desiredAccess, shareMode,
+ (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
+ flagsAndAttributes, (HANDLE)NULL);
+ }
+ #endif
+ return (_handle != INVALID_HANDLE_VALUE);
+}
+#endif
+
+bool CFileBase::Close()
+{
+ if (_handle == INVALID_HANDLE_VALUE)
+ return true;
+ if (!::CloseHandle(_handle))
+ return false;
+ _handle = INVALID_HANDLE_VALUE;
+ return true;
+}
+
+bool CFileBase::GetPosition(UInt64 &position) const
+{
+ return Seek(0, FILE_CURRENT, position);
+}
+
+bool CFileBase::GetLength(UInt64 &length) const
+{
+ DWORD sizeHigh;
+ DWORD sizeLow = ::GetFileSize(_handle, &sizeHigh);
+ if(sizeLow == 0xFFFFFFFF)
+ if(::GetLastError() != NO_ERROR)
+ return false;
+ length = (((UInt64)sizeHigh) << 32) + sizeLow;
+ return true;
+}
+
+bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const
+{
+ LARGE_INTEGER value;
+ value.QuadPart = distanceToMove;
+ value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod);
+ if (value.LowPart == 0xFFFFFFFF)
+ if(::GetLastError() != NO_ERROR)
+ return false;
+ newPosition = value.QuadPart;
+ return true;
+}
+
+bool CFileBase::Seek(UInt64 position, UInt64 &newPosition)
+{
+ return Seek(position, FILE_BEGIN, newPosition);
+}
+
+bool CFileBase::SeekToBegin()
+{
+ UInt64 newPosition;
+ return Seek(0, newPosition);
+}
+
+bool CFileBase::SeekToEnd(UInt64 &newPosition)
+{
+ return Seek(0, FILE_END, newPosition);
+}
+
+bool CFileBase::GetFileInformation(CByHandleFileInfo &fileInfo) const
+{
+ BY_HANDLE_FILE_INFORMATION winFileInfo;
+ if(!::GetFileInformationByHandle(_handle, &winFileInfo))
+ return false;
+ fileInfo.Attributes = winFileInfo.dwFileAttributes;
+ fileInfo.CreationTime = winFileInfo.ftCreationTime;
+ fileInfo.LastAccessTime = winFileInfo.ftLastAccessTime;
+ fileInfo.LastWriteTime = winFileInfo.ftLastWriteTime;
+ fileInfo.VolumeSerialNumber = winFileInfo.dwFileAttributes;
+ fileInfo.Size = (((UInt64)winFileInfo.nFileSizeHigh) << 32) + winFileInfo.nFileSizeLow;
+ fileInfo.NumberOfLinks = winFileInfo.nNumberOfLinks;
+ fileInfo.FileIndex = (((UInt64)winFileInfo.nFileIndexHigh) << 32) + winFileInfo.nFileIndexLow;
+ return true;
+}
+
+/////////////////////////
+// CInFile
+
+bool CInFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
+
+bool CInFile::Open(LPCTSTR fileName)
+ { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
+
+#ifndef _UNICODE
+bool CInFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
+
+bool CInFile::Open(LPCWSTR fileName)
+ { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
+#endif
+
+// ReadFile and WriteFile functions in Windows have BUG:
+// If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
+// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
+// (Insufficient system resources exist to complete the requested service).
+
+static UInt32 kChunkSizeMax = (1 << 24);
+
+bool CInFile::ReadPart(void *data, UInt32 size, UInt32 &processedSize)
+{
+ if (size > kChunkSizeMax)
+ size = kChunkSizeMax;
+ DWORD processedLoc = 0;
+ bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL));
+ processedSize = (UInt32)processedLoc;
+ return res;
+}
+
+bool CInFile::Read(void *data, UInt32 size, UInt32 &processedSize)
+{
+ processedSize = 0;
+ do
+ {
+ UInt32 processedLoc = 0;
+ bool res = ReadPart(data, size, processedLoc);
+ processedSize += processedLoc;
+ if (!res)
+ return false;
+ if (processedLoc == 0)
+ return true;
+ data = (void *)((unsigned char *)data + processedLoc);
+ size -= processedLoc;
+ }
+ while (size > 0);
+ return true;
+}
+
+/////////////////////////
+// COutFile
+
+bool COutFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
+
+static inline DWORD GetCreationDisposition(bool createAlways)
+ { return createAlways? CREATE_ALWAYS: CREATE_NEW; }
+
+bool COutFile::Open(LPCTSTR fileName, DWORD creationDisposition)
+ { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
+
+bool COutFile::Create(LPCTSTR fileName, bool createAlways)
+ { return Open(fileName, GetCreationDisposition(createAlways)); }
+
+#ifndef _UNICODE
+
+bool COutFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
+
+bool COutFile::Open(LPCWSTR fileName, DWORD creationDisposition)
+ { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
+
+bool COutFile::Create(LPCWSTR fileName, bool createAlways)
+ { return Open(fileName, GetCreationDisposition(createAlways)); }
+
+#endif
+
+bool COutFile::SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime)
+ { return BOOLToBool(::SetFileTime(_handle, creationTime, lastAccessTime, lastWriteTime)); }
+
+bool COutFile::SetLastWriteTime(const FILETIME *lastWriteTime)
+ { return SetTime(NULL, NULL, lastWriteTime); }
+
+bool COutFile::WritePart(const void *data, UInt32 size, UInt32 &processedSize)
+{
+ if (size > kChunkSizeMax)
+ size = kChunkSizeMax;
+ DWORD processedLoc = 0;
+ bool res = BOOLToBool(::WriteFile(_handle, data, size, &processedLoc, NULL));
+ processedSize = (UInt32)processedLoc;
+ return res;
+}
+
+bool COutFile::Write(const void *data, UInt32 size, UInt32 &processedSize)
+{
+ processedSize = 0;
+ do
+ {
+ UInt32 processedLoc = 0;
+ bool res = WritePart(data, size, processedLoc);
+ processedSize += processedLoc;
+ if (!res)
+ return false;
+ if (processedLoc == 0)
+ return true;
+ data = (const void *)((const unsigned char *)data + processedLoc);
+ size -= processedLoc;
+ }
+ while (size > 0);
+ return true;
+}
+
+bool COutFile::SetEndOfFile() { return BOOLToBool(::SetEndOfFile(_handle)); }
+
+bool COutFile::SetLength(UInt64 length)
+{
+ UInt64 newPosition;
+ if(!Seek(length, newPosition))
+ return false;
+ if(newPosition != length)
+ return false;
+ return SetEndOfFile();
+}
+
+}}}
diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h
new file mode 100755
index 00000000..ec936ac6
--- /dev/null
+++ b/CPP/Windows/FileIO.h
@@ -0,0 +1,97 @@
+// Windows/FileIO.h
+
+#ifndef __WINDOWS_FILEIO_H
+#define __WINDOWS_FILEIO_H
+
+#include "../Common/Types.h"
+
+namespace NWindows {
+namespace NFile {
+namespace NIO {
+
+struct CByHandleFileInfo
+{
+ DWORD Attributes;
+ FILETIME CreationTime;
+ FILETIME LastAccessTime;
+ FILETIME LastWriteTime;
+ DWORD VolumeSerialNumber;
+ UInt64 Size;
+ DWORD NumberOfLinks;
+ UInt64 FileIndex;
+};
+
+class CFileBase
+{
+protected:
+ HANDLE _handle;
+ bool Create(LPCTSTR fileName, DWORD desiredAccess,
+ DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ #ifndef _UNICODE
+ bool Create(LPCWSTR fileName, DWORD desiredAccess,
+ DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ #endif
+
+public:
+ CFileBase(): _handle(INVALID_HANDLE_VALUE){};
+ virtual ~CFileBase();
+
+ virtual bool Close();
+
+ bool GetPosition(UInt64 &position) const;
+ bool GetLength(UInt64 &length) const;
+
+ bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
+ bool Seek(UInt64 position, UInt64 &newPosition);
+ bool SeekToBegin();
+ bool SeekToEnd(UInt64 &newPosition);
+
+ bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
+};
+
+class CInFile: public CFileBase
+{
+public:
+ bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCTSTR fileName);
+ #ifndef _UNICODE
+ bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCWSTR fileName);
+ #endif
+ bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
+ bool Read(void *data, UInt32 size, UInt32 &processedSize);
+};
+
+class COutFile: public CFileBase
+{
+ // DWORD m_CreationDisposition;
+public:
+ // COutFile(): m_CreationDisposition(CREATE_NEW){};
+ bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCTSTR fileName, DWORD creationDisposition);
+ bool Create(LPCTSTR fileName, bool createAlways);
+
+ #ifndef _UNICODE
+ bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
+ bool Open(LPCWSTR fileName, DWORD creationDisposition);
+ bool Create(LPCWSTR fileName, bool createAlways);
+ #endif
+
+ /*
+ void SetOpenCreationDisposition(DWORD creationDisposition)
+ { m_CreationDisposition = creationDisposition; }
+ void SetOpenCreationDispositionCreateAlways()
+ { m_CreationDisposition = CREATE_ALWAYS; }
+ */
+
+ bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
+ bool SetLastWriteTime(const FILETIME *lastWriteTime);
+ bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
+ bool Write(const void *data, UInt32 size, UInt32 &processedSize);
+ bool SetEndOfFile();
+ bool SetLength(UInt64 length);
+};
+
+}}}
+
+#endif
diff --git a/Windows/FileMapping.cpp b/CPP/Windows/FileMapping.cpp
index d884afb1..d884afb1 100755
--- a/Windows/FileMapping.cpp
+++ b/CPP/Windows/FileMapping.cpp
diff --git a/Windows/FileMapping.h b/CPP/Windows/FileMapping.h
index 22db8f17..22db8f17 100755
--- a/Windows/FileMapping.h
+++ b/CPP/Windows/FileMapping.h
diff --git a/Windows/FileName.cpp b/CPP/Windows/FileName.cpp
index 49e957cf..49e957cf 100755
--- a/Windows/FileName.cpp
+++ b/CPP/Windows/FileName.cpp
diff --git a/Windows/FileName.h b/CPP/Windows/FileName.h
index f8567652..f8567652 100755
--- a/Windows/FileName.h
+++ b/CPP/Windows/FileName.h
diff --git a/Windows/FileSystem.cpp b/CPP/Windows/FileSystem.cpp
index 37c76856..37c76856 100755
--- a/Windows/FileSystem.cpp
+++ b/CPP/Windows/FileSystem.cpp
diff --git a/Windows/FileSystem.h b/CPP/Windows/FileSystem.h
index 25488804..25488804 100755
--- a/Windows/FileSystem.h
+++ b/CPP/Windows/FileSystem.h
diff --git a/Windows/Handle.h b/CPP/Windows/Handle.h
index d4d8aae5..d4d8aae5 100755
--- a/Windows/Handle.h
+++ b/CPP/Windows/Handle.h
diff --git a/Windows/Memory.cpp b/CPP/Windows/Memory.cpp
index 435ea999..435ea999 100755
--- a/Windows/Memory.cpp
+++ b/CPP/Windows/Memory.cpp
diff --git a/Windows/Memory.h b/CPP/Windows/Memory.h
index bd8773b8..bd8773b8 100755
--- a/Windows/Memory.h
+++ b/CPP/Windows/Memory.h
diff --git a/Windows/MemoryLock.cpp b/CPP/Windows/MemoryLock.cpp
index b468e528..b468e528 100755
--- a/Windows/MemoryLock.cpp
+++ b/CPP/Windows/MemoryLock.cpp
diff --git a/Windows/MemoryLock.h b/CPP/Windows/MemoryLock.h
index 03a88b41..03a88b41 100755
--- a/Windows/MemoryLock.h
+++ b/CPP/Windows/MemoryLock.h
diff --git a/Windows/Menu.cpp b/CPP/Windows/Menu.cpp
index 5869b365..5869b365 100755
--- a/Windows/Menu.cpp
+++ b/CPP/Windows/Menu.cpp
diff --git a/Windows/Menu.h b/CPP/Windows/Menu.h
index 11ba5537..11ba5537 100755
--- a/Windows/Menu.h
+++ b/CPP/Windows/Menu.h
diff --git a/Windows/NationalTime.cpp b/CPP/Windows/NationalTime.cpp
index 76060216..76060216 100755
--- a/Windows/NationalTime.cpp
+++ b/CPP/Windows/NationalTime.cpp
diff --git a/Windows/NationalTime.h b/CPP/Windows/NationalTime.h
index 4e40f84a..4e40f84a 100755
--- a/Windows/NationalTime.h
+++ b/CPP/Windows/NationalTime.h
diff --git a/Windows/Net.cpp b/CPP/Windows/Net.cpp
index 113cec94..113cec94 100755
--- a/Windows/Net.cpp
+++ b/CPP/Windows/Net.cpp
diff --git a/Windows/Net.h b/CPP/Windows/Net.h
index ff501d70..ff501d70 100755
--- a/Windows/Net.h
+++ b/CPP/Windows/Net.h
diff --git a/Windows/ProcessMessages.cpp b/CPP/Windows/ProcessMessages.cpp
index 2f2841c1..2f2841c1 100755
--- a/Windows/ProcessMessages.cpp
+++ b/CPP/Windows/ProcessMessages.cpp
diff --git a/Windows/ProcessMessages.h b/CPP/Windows/ProcessMessages.h
index 63f8ec8a..63f8ec8a 100755
--- a/Windows/ProcessMessages.h
+++ b/CPP/Windows/ProcessMessages.h
diff --git a/CPP/Windows/PropVariant.cpp b/CPP/Windows/PropVariant.cpp
new file mode 100755
index 00000000..690e2b6c
--- /dev/null
+++ b/CPP/Windows/PropVariant.cpp
@@ -0,0 +1,312 @@
+// Windows/PropVariant.cpp
+
+#include "StdAfx.h"
+
+#include "PropVariant.h"
+
+#include "../Common/Defs.h"
+
+namespace NWindows {
+namespace NCOM {
+
+CPropVariant::CPropVariant(const PROPVARIANT& varSrc)
+{
+ vt = VT_EMPTY;
+ InternalCopy(&varSrc);
+}
+
+CPropVariant::CPropVariant(const CPropVariant& varSrc)
+{
+ vt = VT_EMPTY;
+ InternalCopy(&varSrc);
+}
+
+CPropVariant::CPropVariant(BSTR bstrSrc)
+{
+ vt = VT_EMPTY;
+ *this = bstrSrc;
+}
+
+CPropVariant::CPropVariant(LPCOLESTR lpszSrc)
+{
+ vt = VT_EMPTY;
+ *this = lpszSrc;
+}
+
+CPropVariant& CPropVariant::operator=(const CPropVariant& varSrc)
+{
+ InternalCopy(&varSrc);
+ return *this;
+}
+CPropVariant& CPropVariant::operator=(const PROPVARIANT& varSrc)
+{
+ InternalCopy(&varSrc);
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(BSTR bstrSrc)
+{
+ *this = (LPCOLESTR)bstrSrc;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc)
+{
+ InternalClear();
+ vt = VT_BSTR;
+ wReserved1 = 0;
+ bstrVal = ::SysAllocString(lpszSrc);
+ if (bstrVal == NULL && lpszSrc != NULL)
+ {
+ vt = VT_ERROR;
+ scode = E_OUTOFMEMORY;
+ }
+ return *this;
+}
+
+
+CPropVariant& CPropVariant::operator=(bool bSrc)
+{
+ if (vt != VT_BOOL)
+ {
+ InternalClear();
+ vt = VT_BOOL;
+ }
+ boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(UInt32 value)
+{
+ if (vt != VT_UI4)
+ {
+ InternalClear();
+ vt = VT_UI4;
+ }
+ ulVal = value;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(UInt64 value)
+{
+ if (vt != VT_UI8)
+ {
+ InternalClear();
+ vt = VT_UI8;
+ }
+ uhVal.QuadPart = value;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(const FILETIME &value)
+{
+ if (vt != VT_FILETIME)
+ {
+ InternalClear();
+ vt = VT_FILETIME;
+ }
+ filetime = value;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(Int32 value)
+{
+ if (vt != VT_I4)
+ {
+ InternalClear();
+ vt = VT_I4;
+ }
+ lVal = value;
+
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(Byte value)
+{
+ if (vt != VT_UI1)
+ {
+ InternalClear();
+ vt = VT_UI1;
+ }
+ bVal = value;
+ return *this;
+}
+
+CPropVariant& CPropVariant::operator=(Int16 value)
+{
+ if (vt != VT_I2)
+ {
+ InternalClear();
+ vt = VT_I2;
+ }
+ iVal = value;
+ return *this;
+}
+
+/*
+CPropVariant& CPropVariant::operator=(LONG value)
+{
+ if (vt != VT_I4)
+ {
+ InternalClear();
+ vt = VT_I4;
+ }
+ lVal = value;
+ return *this;
+}
+*/
+
+static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
+{
+ switch(propVariant->vt)
+ {
+ case VT_UI1:
+ case VT_I1:
+ case VT_I2:
+ case VT_UI2:
+ case VT_BOOL:
+ case VT_I4:
+ case VT_UI4:
+ case VT_R4:
+ case VT_INT:
+ case VT_UINT:
+ case VT_ERROR:
+ case VT_FILETIME:
+ case VT_UI8:
+ case VT_R8:
+ case VT_CY:
+ case VT_DATE:
+ propVariant->vt = VT_EMPTY;
+ propVariant->wReserved1 = 0;
+ return S_OK;
+ }
+ return ::VariantClear((VARIANTARG *)propVariant);
+}
+
+HRESULT CPropVariant::Clear()
+{
+ return MyPropVariantClear(this);
+}
+
+HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
+{
+ ::VariantClear((tagVARIANT *)this);
+ switch(pSrc->vt)
+ {
+ case VT_UI1:
+ case VT_I1:
+ case VT_I2:
+ case VT_UI2:
+ case VT_BOOL:
+ case VT_I4:
+ case VT_UI4:
+ case VT_R4:
+ case VT_INT:
+ case VT_UINT:
+ case VT_ERROR:
+ case VT_FILETIME:
+ case VT_UI8:
+ case VT_R8:
+ case VT_CY:
+ case VT_DATE:
+ memmove((PROPVARIANT*)this, pSrc, sizeof(PROPVARIANT));
+ return S_OK;
+ }
+ return ::VariantCopy((tagVARIANT *)this, (tagVARIANT *)(pSrc));
+}
+
+
+HRESULT CPropVariant::Attach(PROPVARIANT* pSrc)
+{
+ HRESULT hr = Clear();
+ if (FAILED(hr))
+ return hr;
+ memcpy(this, pSrc, sizeof(PROPVARIANT));
+ pSrc->vt = VT_EMPTY;
+ return S_OK;
+}
+
+HRESULT CPropVariant::Detach(PROPVARIANT* pDest)
+{
+ HRESULT hr = MyPropVariantClear(pDest);
+ if (FAILED(hr))
+ return hr;
+ memcpy(pDest, this, sizeof(PROPVARIANT));
+ vt = VT_EMPTY;
+ return S_OK;
+}
+
+HRESULT CPropVariant::InternalClear()
+{
+ HRESULT hr = Clear();
+ if (FAILED(hr))
+ {
+ vt = VT_ERROR;
+ scode = hr;
+ }
+ return hr;
+}
+
+void CPropVariant::InternalCopy(const PROPVARIANT* pSrc)
+{
+ HRESULT hr = Copy(pSrc);
+ if (FAILED(hr))
+ {
+ vt = VT_ERROR;
+ scode = hr;
+ }
+}
+
+int CPropVariant::Compare(const CPropVariant &a)
+{
+ if(vt != a.vt)
+ return 0; // it's mean some bug
+ switch (vt)
+ {
+ case VT_EMPTY:
+ return 0;
+
+ /*
+ case VT_I1:
+ return MyCompare(cVal, a.cVal);
+ */
+ case VT_UI1:
+ return MyCompare(bVal, a.bVal);
+
+ case VT_I2:
+ return MyCompare(iVal, a.iVal);
+ case VT_UI2:
+ return MyCompare(uiVal, a.uiVal);
+
+ case VT_I4:
+ return MyCompare(lVal, a.lVal);
+ /*
+ case VT_INT:
+ return MyCompare(intVal, a.intVal);
+ */
+ case VT_UI4:
+ return MyCompare(ulVal, a.ulVal);
+ /*
+ case VT_UINT:
+ return MyCompare(uintVal, a.uintVal);
+ */
+ case VT_I8:
+ return MyCompare(hVal.QuadPart, a.hVal.QuadPart);
+ case VT_UI8:
+ return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart);
+
+ case VT_BOOL:
+ return -MyCompare(boolVal, a.boolVal);
+
+ case VT_FILETIME:
+ return ::CompareFileTime(&filetime, &a.filetime);
+ case VT_BSTR:
+ return 0; // Not implemented
+ // return MyCompare(aPropVarint.cVal);
+
+ default:
+ return 0;
+ }
+}
+
+}}
diff --git a/CPP/Windows/PropVariant.h b/CPP/Windows/PropVariant.h
new file mode 100755
index 00000000..d44215f0
--- /dev/null
+++ b/CPP/Windows/PropVariant.h
@@ -0,0 +1,57 @@
+// Windows/PropVariant.h
+
+#ifndef __WINDOWS_PROPVARIANT_H
+#define __WINDOWS_PROPVARIANT_H
+
+#include "../Common/MyWindows.h"
+#include "../Common/Types.h"
+
+namespace NWindows {
+namespace NCOM {
+
+class CPropVariant : public tagPROPVARIANT
+{
+public:
+ CPropVariant() { vt = VT_EMPTY; wReserved1 = 0; }
+ ~CPropVariant() { Clear(); }
+ CPropVariant(const PROPVARIANT& varSrc);
+ CPropVariant(const CPropVariant& varSrc);
+ CPropVariant(BSTR bstrSrc);
+ CPropVariant(LPCOLESTR lpszSrc);
+ CPropVariant(bool bSrc) { vt = VT_BOOL; wReserved1 = 0; boolVal = (bSrc ? VARIANT_TRUE : VARIANT_FALSE); };
+ CPropVariant(UInt32 value) { vt = VT_UI4; wReserved1 = 0; ulVal = value; }
+ CPropVariant(UInt64 value) { vt = VT_UI8; wReserved1 = 0; uhVal = *(ULARGE_INTEGER*)&value; }
+ CPropVariant(const FILETIME &value) { vt = VT_FILETIME; wReserved1 = 0; filetime = value; }
+ CPropVariant(Int32 value) { vt = VT_I4; wReserved1 = 0; lVal = value; }
+ CPropVariant(Byte value) { vt = VT_UI1; wReserved1 = 0; bVal = value; }
+ CPropVariant(Int16 value) { vt = VT_I2; wReserved1 = 0; iVal = value; }
+ // CPropVariant(LONG value, VARTYPE vtSrc = VT_I4) { vt = vtSrc; lVal = value; }
+
+ CPropVariant& operator=(const CPropVariant& varSrc);
+ CPropVariant& operator=(const PROPVARIANT& varSrc);
+ CPropVariant& operator=(BSTR bstrSrc);
+ CPropVariant& operator=(LPCOLESTR lpszSrc);
+ CPropVariant& operator=(bool bSrc);
+ CPropVariant& operator=(UInt32 value);
+ CPropVariant& operator=(UInt64 value);
+ CPropVariant& operator=(const FILETIME &value);
+
+ CPropVariant& operator=(Int32 value);
+ CPropVariant& operator=(Byte value);
+ CPropVariant& operator=(Int16 value);
+ // CPropVariant& operator=(LONG value);
+
+ HRESULT Clear();
+ HRESULT Copy(const PROPVARIANT* pSrc);
+ HRESULT Attach(PROPVARIANT* pSrc);
+ HRESULT Detach(PROPVARIANT* pDest);
+
+ HRESULT InternalClear();
+ void InternalCopy(const PROPVARIANT* pSrc);
+
+ int Compare(const CPropVariant &a1);
+};
+
+}}
+
+#endif
diff --git a/Windows/PropVariantConversions.cpp b/CPP/Windows/PropVariantConversions.cpp
index 80ba5ac2..80ba5ac2 100755
--- a/Windows/PropVariantConversions.cpp
+++ b/CPP/Windows/PropVariantConversions.cpp
diff --git a/Windows/PropVariantConversions.h b/CPP/Windows/PropVariantConversions.h
index a3f3ebbf..a3f3ebbf 100755
--- a/Windows/PropVariantConversions.h
+++ b/CPP/Windows/PropVariantConversions.h
diff --git a/Windows/Registry.cpp b/CPP/Windows/Registry.cpp
index 2c6b6afc..2c6b6afc 100755
--- a/Windows/Registry.cpp
+++ b/CPP/Windows/Registry.cpp
diff --git a/Windows/Registry.h b/CPP/Windows/Registry.h
index 435717bd..435717bd 100755
--- a/Windows/Registry.h
+++ b/CPP/Windows/Registry.h
diff --git a/Windows/ResourceString.cpp b/CPP/Windows/ResourceString.cpp
index 48dd4936..48dd4936 100755
--- a/Windows/ResourceString.cpp
+++ b/CPP/Windows/ResourceString.cpp
diff --git a/Windows/ResourceString.h b/CPP/Windows/ResourceString.h
index a74f925d..a74f925d 100755
--- a/Windows/ResourceString.h
+++ b/CPP/Windows/ResourceString.h
diff --git a/CPP/Windows/Security.cpp b/CPP/Windows/Security.cpp
new file mode 100755
index 00000000..05b3b640
--- /dev/null
+++ b/CPP/Windows/Security.cpp
@@ -0,0 +1,181 @@
+// Windows/Security.h
+
+#include "StdAfx.h"
+
+#include "Windows/Security.h"
+#include "Windows/Defs.h"
+
+#include "Common/StringConvert.h"
+#include "Defs.h"
+
+namespace NWindows {
+namespace NSecurity {
+
+/*
+bool MyLookupAccountSid(LPCTSTR systemName, PSID sid,
+ CSysString &accountName, CSysString &domainName, PSID_NAME_USE sidNameUse)
+{
+ DWORD accountNameSize = 0, domainNameSize = 0;
+
+ if (!::LookupAccountSid(systemName, sid,
+ accountName.GetBuffer(0), &accountNameSize,
+ domainName.GetBuffer(0), &domainNameSize, sidNameUse))
+ {
+ if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ return false;
+ }
+ bool result = BOOLToBool(::LookupAccountSid(systemName, sid,
+ accountName.GetBuffer(accountNameSize), &accountNameSize,
+ domainName.GetBuffer(domainNameSize), &domainNameSize, sidNameUse));
+ accountName.ReleaseBuffer();
+ domainName.ReleaseBuffer();
+ return result;
+}
+*/
+
+static void SetLsaString(LPWSTR src, PLSA_UNICODE_STRING dest)
+{
+ int len = (int)wcslen(src);
+ dest->Length = (USHORT)(len * sizeof(WCHAR));
+ dest->MaximumLength = (USHORT)((len + 1) * sizeof(WCHAR));
+ dest->Buffer = src;
+}
+
+/*
+static void MyLookupSids(CPolicy &policy, PSID ps)
+{
+ LSA_REFERENCED_DOMAIN_LIST *referencedDomains = NULL;
+ LSA_TRANSLATED_NAME *names = NULL;
+ NTSTATUS nts = policy.LookupSids(1, &ps, &referencedDomains, &names);
+ int res = LsaNtStatusToWinError(nts);
+ LsaFreeMemory(referencedDomains);
+ LsaFreeMemory(names);
+}
+*/
+
+#ifndef _UNICODE
+typedef BOOL (WINAPI * LookupAccountNameWP)(
+ LPCWSTR lpSystemName,
+ LPCWSTR lpAccountName,
+ PSID Sid,
+ LPDWORD cbSid,
+ LPWSTR ReferencedDomainName,
+ LPDWORD cchReferencedDomainName,
+ PSID_NAME_USE peUse
+ );
+#endif
+
+static PSID GetSid(LPWSTR accountName)
+{
+ #ifndef _UNICODE
+ HMODULE hModule = GetModuleHandle(TEXT("Advapi32.dll"));
+ if (hModule == NULL)
+ return NULL;
+ LookupAccountNameWP lookupAccountNameW = (LookupAccountNameWP)GetProcAddress(hModule, "LookupAccountNameW");
+ if (lookupAccountNameW == NULL)
+ return NULL;
+ #endif
+
+ DWORD sidLen = 0, domainLen = 0;
+ SID_NAME_USE sidNameUse;
+ if (!
+ #ifdef _UNICODE
+ ::LookupAccountNameW
+ #else
+ lookupAccountNameW
+ #endif
+ (NULL, accountName, NULL, &sidLen, NULL, &domainLen, &sidNameUse))
+ {
+ if(::GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ PSID pSid = ::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sidLen);
+ LPWSTR domainName = (LPWSTR)::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (domainLen + 1) * sizeof(WCHAR));
+ BOOL res =
+ #ifdef _UNICODE
+ ::LookupAccountNameW
+ #else
+ lookupAccountNameW
+ #endif
+ (NULL, accountName, pSid, &sidLen, domainName, &domainLen, &sidNameUse);
+ ::HeapFree(GetProcessHeap(), 0, domainName);
+ if (res)
+ return pSid;
+ }
+ }
+ return NULL;
+}
+
+bool AddLockMemoryPrivilege()
+{
+ CPolicy policy;
+ LSA_OBJECT_ATTRIBUTES attr;
+ attr.Length = sizeof(attr);
+ attr.RootDirectory = NULL;
+ attr.ObjectName = NULL;
+ attr.Attributes = 0;
+ attr.SecurityDescriptor = NULL;
+ attr.SecurityQualityOfService = NULL;
+ if (policy.Open(NULL, &attr,
+ // GENERIC_WRITE)
+ POLICY_ALL_ACCESS)
+ // STANDARD_RIGHTS_REQUIRED,
+ // GENERIC_READ | GENERIC_EXECUTE | POLICY_VIEW_LOCAL_INFORMATION | POLICY_LOOKUP_NAMES)
+ != 0)
+ return false;
+ LSA_UNICODE_STRING userRights;
+ UString s = GetUnicodeString(SE_LOCK_MEMORY_NAME);
+ SetLsaString((LPWSTR)(LPCWSTR)s, &userRights);
+ WCHAR userName[256 + 2];
+ DWORD size = 256;
+ if (!GetUserNameW(userName, &size))
+ return false;
+ PSID psid = GetSid(userName);
+ if (psid == NULL)
+ return false;
+ bool res = false;
+
+ /*
+ PLSA_UNICODE_STRING userRightsArray;
+ ULONG countOfRights;
+ NTSTATUS status = policy.EnumerateAccountRights(psid, &userRightsArray, &countOfRights);
+ if (status != 0)
+ return false;
+ bool finded = false;
+ for (ULONG i = 0; i < countOfRights; i++)
+ {
+ LSA_UNICODE_STRING &ur = userRightsArray[i];
+ if (ur.Length != s.Length() * sizeof(WCHAR))
+ continue;
+ if (wcsncmp(ur.Buffer, s, s.Length()) != 0)
+ continue;
+ finded = true;
+ res = true;
+ break;
+ }
+ if (!finded)
+ */
+ {
+ /*
+ LSA_ENUMERATION_INFORMATION *enums;
+ ULONG countReturned;
+ NTSTATUS status = policy.EnumerateAccountsWithUserRight(&userRights, &enums, &countReturned);
+ if (status == 0)
+ {
+ for (ULONG i = 0; i < countReturned; i++)
+ MyLookupSids(policy, enums[i].Sid);
+ if (enums)
+ ::LsaFreeMemory(enums);
+ res = true;
+ }
+ */
+ NTSTATUS status = policy.AddAccountRights(psid, &userRights);
+ if (status == 0)
+ res = true;
+ // ULONG res = LsaNtStatusToWinError(status);
+ }
+ HeapFree(GetProcessHeap(), 0, psid);
+ return res;
+}
+
+}}
+
diff --git a/Windows/Security.h b/CPP/Windows/Security.h
index ded31b74..ded31b74 100755
--- a/Windows/Security.h
+++ b/CPP/Windows/Security.h
diff --git a/Windows/Shell.cpp b/CPP/Windows/Shell.cpp
index 2906e2d4..2906e2d4 100755
--- a/Windows/Shell.cpp
+++ b/CPP/Windows/Shell.cpp
diff --git a/Windows/Shell.h b/CPP/Windows/Shell.h
index 4770a454..4770a454 100755
--- a/Windows/Shell.h
+++ b/CPP/Windows/Shell.h
diff --git a/Windows/StdAfx.h b/CPP/Windows/StdAfx.h
index e7924c8f..e7924c8f 100755
--- a/Windows/StdAfx.h
+++ b/CPP/Windows/StdAfx.h
diff --git a/Windows/Synchronization.cpp b/CPP/Windows/Synchronization.cpp
index 64b811da..64b811da 100755
--- a/Windows/Synchronization.cpp
+++ b/CPP/Windows/Synchronization.cpp
diff --git a/Windows/Synchronization.h b/CPP/Windows/Synchronization.h
index 89450276..89450276 100755
--- a/Windows/Synchronization.h
+++ b/CPP/Windows/Synchronization.h
diff --git a/Windows/System.h b/CPP/Windows/System.h
index e1a5abac..e1a5abac 100755
--- a/Windows/System.h
+++ b/CPP/Windows/System.h
diff --git a/CPP/Windows/Thread.h b/CPP/Windows/Thread.h
new file mode 100755
index 00000000..5b676027
--- /dev/null
+++ b/CPP/Windows/Thread.h
@@ -0,0 +1,51 @@
+// Windows/Thread.h
+
+#ifndef __WINDOWS_THREAD_H
+#define __WINDOWS_THREAD_H
+
+// #include <process.h>
+
+#include "Handle.h"
+#include "Defs.h"
+
+namespace NWindows {
+
+class CThread: public CHandle
+{
+ bool IsOpen() const { return _handle != 0; }
+public:
+ bool Create(LPSECURITY_ATTRIBUTES threadAttributes,
+ SIZE_T stackSize, LPTHREAD_START_ROUTINE startAddress,
+ LPVOID parameter, DWORD creationFlags, LPDWORD threadId)
+ {
+ _handle = ::CreateThread(threadAttributes, stackSize, startAddress,
+ parameter, creationFlags, threadId);
+ return (_handle != NULL);
+ }
+ bool Create(LPTHREAD_START_ROUTINE startAddress, LPVOID parameter)
+ {
+ DWORD threadId;
+ return Create(NULL, 0, startAddress, parameter, 0, &threadId);
+ /*
+ _handle = (HANDLE)_beginthreadex(NULL, 0, startAddress, parameter, 0, NULL);
+ return (_handle != NULL);
+ */
+ }
+
+ DWORD Resume() { return ::ResumeThread(_handle); }
+ DWORD Suspend() { return ::SuspendThread(_handle); }
+ bool Terminate(DWORD exitCode) { return BOOLToBool(::TerminateThread(_handle, exitCode)); }
+ int GetPriority() { return ::GetThreadPriority(_handle); }
+ bool SetPriority(int priority) { return BOOLToBool(::SetThreadPriority(_handle, priority)); }
+
+ bool Wait()
+ {
+ if (!IsOpen())
+ return true;
+ return (::WaitForSingleObject(_handle, INFINITE) == WAIT_OBJECT_0);
+ }
+};
+
+}
+
+#endif
diff --git a/Windows/Time.h b/CPP/Windows/Time.h
index fbba2ddb..fbba2ddb 100755
--- a/Windows/Time.h
+++ b/CPP/Windows/Time.h
diff --git a/Windows/Window.cpp b/CPP/Windows/Window.cpp
index b30ccdc3..b30ccdc3 100755
--- a/Windows/Window.cpp
+++ b/CPP/Windows/Window.cpp
diff --git a/Windows/Window.h b/CPP/Windows/Window.h
index 3df80191..3df80191 100755
--- a/Windows/Window.h
+++ b/CPP/Windows/Window.h
diff --git a/Common/AutoPtr.h b/Common/AutoPtr.h
deleted file mode 100755
index 8fc93573..00000000
--- a/Common/AutoPtr.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Common/AutoPtr.h
-
-#ifndef __COMMON_AUTOPTR_H
-#define __COMMON_AUTOPTR_H
-
-template<class T> class CMyAutoPtr
-{
- T *_p;
-public:
- CMyAutoPtr(T *p = 0) : _p(p) {}
- CMyAutoPtr(CMyAutoPtr<T>& p): _p(p.release()) {}
- CMyAutoPtr<T>& operator=(CMyAutoPtr<T>& p)
- {
- reset(p.release());
- return (*this);
- }
- ~CMyAutoPtr() { delete _p; }
- T& operator*() const { return *_p; }
- // T* operator->() const { return (&**this); }
- T* get() const {return _p; }
- T* release()
- {
- T *tmp = _p;
- _p = 0;
- return tmp;
- }
- void reset(T* p = 0)
- {
- if (p != _p)
- delete _p;
- _p = p;
- }
-};
-
-#endif
diff --git a/Common/Buffer.h b/Common/Buffer.h
deleted file mode 100755
index 9bd881cf..00000000
--- a/Common/Buffer.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// Common/Buffer.h
-
-#ifndef __COMMON_BUFFER_H
-#define __COMMON_BUFFER_H
-
-#include "Defs.h"
-
-template <class T> class CBuffer
-{
-protected:
- size_t _capacity;
- T *_items;
- void Free()
- {
- delete []_items;
- _items = 0;
- _capacity = 0;
- }
-public:
- CBuffer(): _capacity(0), _items(0) {};
- CBuffer(const CBuffer &buffer): _capacity(0), _items(0) { *this = buffer; }
- CBuffer(size_t size): _items(0), _capacity(0) { SetCapacity(size); }
- virtual ~CBuffer() { delete []_items; }
- operator T *() { return _items; };
- operator const T *() const { return _items; };
- size_t GetCapacity() const { return _capacity; }
- void SetCapacity(size_t newCapacity)
- {
- if (newCapacity == _capacity)
- return;
- T *newBuffer;
- if (newCapacity > 0)
- {
- newBuffer = new T[newCapacity];
- if(_capacity > 0)
- memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T));
- }
- else
- newBuffer = 0;
- delete []_items;
- _items = newBuffer;
- _capacity = newCapacity;
- }
- CBuffer& operator=(const CBuffer &buffer)
- {
- Free();
- if(buffer._capacity > 0)
- {
- SetCapacity(buffer._capacity);
- memmove(_items, buffer._items, buffer._capacity * sizeof(T));
- }
- return *this;
- }
-};
-
-template <class T>
-bool operator==(const CBuffer<T>& b1, const CBuffer<T>& b2)
-{
- if (b1.GetCapacity() != b2.GetCapacity())
- return false;
- for (size_t i = 0; i < b1.GetCapacity(); i++)
- if (b1[i] != b2[i])
- return false;
- return true;
-}
-
-template <class T>
-bool operator!=(const CBuffer<T>& b1, const CBuffer<T>& b2)
-{
- return !(b1 == b2);
-}
-
-typedef CBuffer<char> CCharBuffer;
-typedef CBuffer<wchar_t> CWCharBuffer;
-typedef CBuffer<unsigned char> CByteBuffer;
-
-#endif
diff --git a/Common/CRC.h b/Common/CRC.h
deleted file mode 100755
index 6b4f1b79..00000000
--- a/Common/CRC.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Common/CRC.h
-
-#ifndef __COMMON_CRC_H
-#define __COMMON_CRC_H
-
-#include <stddef.h>
-#include "Types.h"
-
-class CCRC
-{
- UInt32 _value;
-public:
- static UInt32 Table[256];
- static void InitTable();
-
- CCRC(): _value(0xFFFFFFFF){};
- void Init() { _value = 0xFFFFFFFF; }
- void UpdateByte(Byte v);
- void UpdateUInt16(UInt16 v);
- void UpdateUInt32(UInt32 v);
- void UpdateUInt64(UInt64 v);
- void Update(const void *data, size_t size);
- UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
- static UInt32 CalculateDigest(const void *data, size_t size)
- {
- CCRC crc;
- crc.Update(data, size);
- return crc.GetDigest();
- }
- static bool VerifyDigest(UInt32 digest, const void *data, size_t size)
- {
- return (CalculateDigest(data, size) == digest);
- }
-};
-
-#endif
diff --git a/Common/Lang.cpp b/Common/Lang.cpp
deleted file mode 100755
index 495a3f06..00000000
--- a/Common/Lang.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-// Common/Lang.cpp
-
-#include "StdAfx.h"
-
-#include "Common/Lang.h"
-#include "Common/TextConfig.h"
-
-#include "StdInStream.h"
-#include "UTFConvert.h"
-#include "Defs.h"
-
-/*
-static UInt32 HexStringToNumber(const char *string, int &finishPos)
-{
- UInt32 number = 0;
- for (finishPos = 0; finishPos < 8; finishPos++)
- {
- char c = string[finishPos];
- int a;
- if (c >= '0' && c <= '9')
- a = c - '0';
- else if (c >= 'A' && c <= 'F')
- a = 10 + c - 'A';
- else if (c >= 'a' && c <= 'f')
- a = 10 + c - 'a';
- else
- return number;
- number *= 0x10;
- number += a;
- }
- return number;
-}
-*/
-static bool HexStringToNumber(const UString &string, UInt32 &aResultValue)
-{
- aResultValue = 0;
- if (string.IsEmpty())
- return false;
- for (int i = 0; i < string.Length(); i++)
- {
- wchar_t c = string[i];
- int a;
- if (c >= L'0' && c <= L'9')
- a = c - L'0';
- else if (c >= L'A' && c <= L'F')
- a = 10 + c - L'A';
- else if (c >= L'a' && c <= L'f')
- a = 10 + c - L'a';
- else
- return false;
- aResultValue *= 0x10;
- aResultValue += a;
- }
- return true;
-}
-
-
-static bool WaitNextLine(const AString &string, int &pos)
-{
- for (;pos < string.Length(); pos++)
- if (string[pos] == 0x0A)
- return true;
- return false;
-}
-
-static int __cdecl CompareLangItems( const void *elem1, const void *elem2)
-{
- const CLangPair &langPair1 = *(*((const CLangPair **)elem1));
- const CLangPair &langPair2 = *(*((const CLangPair **)elem2));
- return MyCompare(langPair1.Value, langPair2.Value);
-}
-
-bool CLang::Open(LPCTSTR fileName)
-{
- _langPairs.Clear();
- CStdInStream file;
- if (!file.Open(fileName))
- return false;
- AString string;
- file.ReadToString(string);
- file.Close();
- int pos = 0;
- if (string.Length() >= 3)
- {
- if (Byte(string[0]) == 0xEF && Byte(string[1]) == 0xBB && Byte(string[2]) == 0xBF)
- pos += 3;
- }
-
- /////////////////////
- // read header
-
- AString stringID = ";!@Lang@!UTF-8!";
- if (string.Mid(pos, stringID.Length()) != stringID)
- return false;
- pos += stringID.Length();
-
- if (!WaitNextLine(string, pos))
- return false;
-
- CObjectVector<CTextConfigPair> pairs;
- if (!GetTextConfig(string.Mid(pos), pairs))
- return false;
-
- _langPairs.Reserve(_langPairs.Size());
- for (int i = 0; i < pairs.Size(); i++)
- {
- CTextConfigPair textConfigPair = pairs[i];
- CLangPair langPair;
- if (!HexStringToNumber(textConfigPair.ID, langPair.Value))
- return false;
- langPair.String = textConfigPair.String;
- _langPairs.Add(langPair);
- }
-
- CPointerVector &pointerVector = _langPairs;
- qsort(&pointerVector[0], _langPairs.Size(), sizeof(void *), CompareLangItems);
- return true;
-}
-
-int CLang::FindItem(UInt32 value) const
-{
- int left = 0, right = _langPairs.Size();
- while (left != right)
- {
- UInt32 mid = (left + right) / 2;
- UInt32 midValue = _langPairs[mid].Value;
- if (value == midValue)
- return mid;
- if (value < midValue)
- right = mid;
- else
- left = mid + 1;
- }
- return -1;
-}
-
-bool CLang::GetMessage(UInt32 value, UString &message) const
-{
- int index = FindItem(value);
- if (index < 0)
- return false;
- message = _langPairs[index].String;
- return true;
-}
diff --git a/Common/MyWindows.h b/Common/MyWindows.h
deleted file mode 100755
index e1ea41fb..00000000
--- a/Common/MyWindows.h
+++ /dev/null
@@ -1,200 +0,0 @@
-// MyWindows.h
-
-#ifndef __MYWINDOWS_H
-#define __MYWINDOWS_H
-
-#ifdef _WIN32
-
-#include <windows.h>
-
-#define CHAR_PATH_SEPARATOR '\\'
-#define WCHAR_PATH_SEPARATOR L'\\'
-#define STRING_PATH_SEPARATOR "\\"
-#define WSTRING_PATH_SEPARATOR L"\\"
-
-#else
-
-#define CHAR_PATH_SEPARATOR '/'
-#define WCHAR_PATH_SEPARATOR L'/'
-#define STRING_PATH_SEPARATOR "/"
-#define WSTRING_PATH_SEPARATOR L"/"
-
-#include <stddef.h> // for wchar_t
-#include <string.h>
-
-#include "MyGuidDef.h"
-
-typedef char CHAR;
-typedef unsigned char UCHAR;
-
-#undef BYTE
-typedef unsigned char BYTE;
-
-typedef short SHORT;
-typedef unsigned short USHORT;
-
-#undef WORD
-typedef unsigned short WORD;
-typedef short VARIANT_BOOL;
-
-typedef int INT;
-typedef Int32 INT32;
-typedef unsigned int UINT;
-typedef UInt32 UINT32;
-typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit
-typedef UINT32 ULONG;
-
-#undef DWORD
-typedef UINT32 DWORD;
-
-typedef Int64 LONGLONG;
-typedef UInt64 ULONGLONG;
-
-typedef struct LARGE_INTEGER { LONGLONG QuadPart; }LARGE_INTEGER;
-typedef struct _ULARGE_INTEGER { ULONGLONG QuadPart;} ULARGE_INTEGER;
-
-typedef const CHAR *LPCSTR;
-typedef CHAR TCHAR;
-typedef const TCHAR *LPCTSTR;
-typedef wchar_t WCHAR;
-typedef WCHAR OLECHAR;
-typedef const WCHAR *LPCWSTR;
-typedef OLECHAR *BSTR;
-typedef const OLECHAR *LPCOLESTR;
-typedef OLECHAR *LPOLESTR;
-
-typedef struct _FILETIME
-{
- DWORD dwLowDateTime;
- DWORD dwHighDateTime;
-}FILETIME;
-
-#define HRESULT LONG
-#define FAILED(Status) ((HRESULT)(Status)<0)
-typedef ULONG PROPID;
-typedef LONG SCODE;
-
-#define S_OK ((HRESULT)0x00000000L)
-#define S_FALSE ((HRESULT)0x00000001L)
-#define E_NOTIMPL ((HRESULT)0x80004001L)
-#define E_NOINTERFACE ((HRESULT)0x80004002L)
-#define E_ABORT ((HRESULT)0x80004004L)
-#define E_FAIL ((HRESULT)0x80004005L)
-#define STG_E_INVALIDFUNCTION ((HRESULT)0x80030001L)
-#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
-#define E_INVALIDARG ((HRESULT)0x80070057L)
-
-#ifdef _MSC_VER
-#define STDMETHODCALLTYPE __stdcall
-#else
-#define STDMETHODCALLTYPE
-#endif
-
-#define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f
-#define STDMETHOD(f) STDMETHOD_(HRESULT, f)
-#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
-#define STDMETHODIMP STDMETHODIMP_(HRESULT)
-
-#define PURE = 0
-
-#define MIDL_INTERFACE(x) struct
-
-struct IUnknown
-{
- STDMETHOD(QueryInterface) (REFIID iid, void **outObject) PURE;
- STDMETHOD_(ULONG, AddRef)() PURE;
- STDMETHOD_(ULONG, Release)() PURE;
-};
-
-typedef IUnknown *LPUNKNOWN;
-
-#define VARIANT_TRUE ((VARIANT_BOOL)-1)
-#define VARIANT_FALSE ((VARIANT_BOOL)0)
-
-enum VARENUM
-{
- VT_EMPTY = 0,
- VT_NULL = 1,
- VT_I2 = 2,
- VT_I4 = 3,
- VT_R4 = 4,
- VT_R8 = 5,
- VT_CY = 6,
- VT_DATE = 7,
- VT_BSTR = 8,
- VT_DISPATCH = 9,
- VT_ERROR = 10,
- VT_BOOL = 11,
- VT_VARIANT = 12,
- VT_UNKNOWN = 13,
- VT_DECIMAL = 14,
- VT_I1 = 16,
- VT_UI1 = 17,
- VT_UI2 = 18,
- VT_UI4 = 19,
- VT_I8 = 20,
- VT_UI8 = 21,
- VT_INT = 22,
- VT_UINT = 23,
- VT_VOID = 24,
- VT_HRESULT = 25,
- VT_FILETIME = 64
-};
-
-typedef unsigned short VARTYPE;
-typedef WORD PROPVAR_PAD1;
-typedef WORD PROPVAR_PAD2;
-typedef WORD PROPVAR_PAD3;
-
-typedef struct tagPROPVARIANT
-{
- VARTYPE vt;
- PROPVAR_PAD1 wReserved1;
- PROPVAR_PAD2 wReserved2;
- PROPVAR_PAD3 wReserved3;
- union
- {
- CHAR cVal;
- UCHAR bVal;
- SHORT iVal;
- USHORT uiVal;
- LONG lVal;
- ULONG ulVal;
- INT intVal;
- UINT uintVal;
- LARGE_INTEGER hVal;
- ULARGE_INTEGER uhVal;
- VARIANT_BOOL boolVal;
- SCODE scode;
- FILETIME filetime;
- BSTR bstrVal;
- };
-} PROPVARIANT;
-
-typedef PROPVARIANT tagVARIANT;
-typedef tagVARIANT VARIANT;
-typedef VARIANT VARIANTARG;
-
-MY_EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len);
-MY_EXTERN_C BSTR SysAllocString(const OLECHAR *sz);
-MY_EXTERN_C void SysFreeString(BSTR bstr);
-MY_EXTERN_C UINT SysStringByteLen(BSTR bstr);
-MY_EXTERN_C UINT SysStringLen(BSTR bstr);
-
-MY_EXTERN_C DWORD GetLastError();
-MY_EXTERN_C HRESULT VariantClear(VARIANTARG *prop);
-MY_EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src);
-MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2);
-
-#define CP_ACP 0
-#define CP_OEMCP 1
-
-typedef enum tagSTREAM_SEEK
-{
- STREAM_SEEK_SET = 0,
- STREAM_SEEK_CUR = 1,
- STREAM_SEEK_END = 2
-} STREAM_SEEK;
-
-#endif
-#endif
diff --git a/Common/String.h b/Common/String.h
deleted file mode 100755
index d38cc462..00000000
--- a/Common/String.h
+++ /dev/null
@@ -1,631 +0,0 @@
-// Common/String.h
-
-#ifndef __COMMON_STRING_H
-#define __COMMON_STRING_H
-
-#include <string.h>
-// #include <wchar.h>
-
-#include "Vector.h"
-
-#ifdef _WIN32
-#include "MyWindows.h"
-#endif
-
-static const char *kTrimDefaultCharSet = " \n\t";
-
-template <class T>
-inline int MyStringLen(const T *s)
-{
- int i;
- for (i = 0; s[i] != '\0'; i++);
- return i;
-}
-
-template <class T>
-inline T * MyStringCopy(T *dest, const T *src)
-{
- T *destStart = dest;
- while((*dest++ = *src++) != 0);
- return destStart;
-}
-
-inline wchar_t* MyStringGetNextCharPointer(wchar_t *p)
- { return (p + 1); }
-inline const wchar_t* MyStringGetNextCharPointer(const wchar_t *p)
- { return (p + 1); }
-inline wchar_t* MyStringGetPrevCharPointer(const wchar_t *, wchar_t *p)
- { return (p - 1); }
-inline const wchar_t* MyStringGetPrevCharPointer(const wchar_t *, const wchar_t *p)
- { return (p - 1); }
-
-#ifdef _WIN32
-
-inline char* MyStringGetNextCharPointer(char *p)
- { return CharNextA(p); }
-inline const char* MyStringGetNextCharPointer(const char *p)
- { return CharNextA(p); }
-
-inline char* MyStringGetPrevCharPointer(char *base, char *p)
- { return CharPrevA(base, p); }
-inline const char* MyStringGetPrevCharPointer(const char *base, const char *p)
- { return CharPrevA(base, p); }
-
-inline char MyCharUpper(char c)
- { return (char)(unsigned int)(UINT_PTR)CharUpperA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); }
-#ifdef _UNICODE
-inline wchar_t MyCharUpper(wchar_t c)
- { return (wchar_t)CharUpperW((LPWSTR)c); }
-#else
-wchar_t MyCharUpper(wchar_t c);
-#endif
-
-inline char MyCharLower(char c)
- { return (char)(unsigned int)(UINT_PTR)CharLowerA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); }
-#ifdef _UNICODE
-inline wchar_t MyCharLower(wchar_t c)
- { return (wchar_t)CharLowerW((LPWSTR)c); }
-#else
-wchar_t MyCharLower(wchar_t c);
-#endif
-
-inline char * MyStringUpper(char *s) { return CharUpperA(s); }
-#ifdef _UNICODE
-inline wchar_t * MyStringUpper(wchar_t *s) { return CharUpperW(s); }
-#else
-wchar_t * MyStringUpper(wchar_t *s);
-#endif
-
-inline char * MyStringLower(char *s) { return CharLowerA(s); }
-#ifdef _UNICODE
-inline wchar_t * MyStringLower(wchar_t *s) { return CharLowerW(s); }
-#else
-wchar_t * MyStringLower(wchar_t *s);
-#endif
-
-#else // Standard-C
-wchar_t MyCharUpper(wchar_t c);
-#endif
-
-//////////////////////////////////////
-// Compare
-
-/*
-#ifndef _WIN32_WCE
-int MyStringCollate(const char *s1, const char *s2);
-int MyStringCollateNoCase(const char *s1, const char *s2);
-#endif
-int MyStringCollate(const wchar_t *s1, const wchar_t *s2);
-int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2);
-*/
-
-int MyStringCompare(const char *s1, const char *s2);
-int MyStringCompare(const wchar_t *s1, const wchar_t *s2);
-
-#ifdef _WIN32
-int MyStringCompareNoCase(const char *s1, const char *s2);
-#endif
-
-int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2);
-
-template <class T>
-class CStringBase
-{
- void TrimLeftWithCharSet(const CStringBase &charSet)
- {
- const T *p = _chars;
- while (charSet.Find(*p) >= 0 && (*p != 0))
- p = GetNextCharPointer(p);
- Delete(0, (int)(p - _chars));
- }
- void TrimRightWithCharSet(const CStringBase &charSet)
- {
- const T *p = _chars;
- const T *pLast = NULL;
- while (*p != 0)
- {
- if (charSet.Find(*p) >= 0)
- {
- if (pLast == NULL)
- pLast = p;
- }
- else
- pLast = NULL;
- p = GetNextCharPointer(p);
- }
- if(pLast != NULL)
- {
- int i = (int)(pLast - _chars);
- Delete(i, _length - i);
- }
-
- }
- void MoveItems(int destIndex, int srcIndex)
- {
- memmove(_chars + destIndex, _chars + srcIndex,
- sizeof(T) * (_length - srcIndex + 1));
- }
-
- void InsertSpace(int &index, int size)
- {
- CorrectIndex(index);
- GrowLength(size);
- MoveItems(index + size, index);
- }
-
- static T *GetNextCharPointer(T *p)
- { return MyStringGetNextCharPointer(p); }
- static const T *GetNextCharPointer(const T *p)
- { return MyStringGetNextCharPointer(p); }
- static T *GetPrevCharPointer(T *base, T *p)
- { return MyStringGetPrevCharPointer(base, p); }
- static const T *GetPrevCharPointer(const T *base, const T *p)
- { return MyStringGetPrevCharPointer(base, p); }
-protected:
- T *_chars;
- int _length;
- int _capacity;
-
- void SetCapacity(int newCapacity)
- {
- int realCapacity = newCapacity + 1;
- if(realCapacity == _capacity)
- return;
- /*
- const int kMaxStringSize = 0x20000000;
- #ifndef _WIN32_WCE
- if(newCapacity > kMaxStringSize || newCapacity < _length)
- throw 1052337;
- #endif
- */
- T *newBuffer = new T[realCapacity];
- if(_capacity > 0)
- {
- for (int i = 0; i < (_length + 1); i++)
- newBuffer[i] = _chars[i];
- delete []_chars;
- _chars = newBuffer;
- }
- else
- {
- _chars = newBuffer;
- _chars[0] = 0;
- }
- _capacity = realCapacity;
- }
-
- void GrowLength(int n)
- {
- int freeSize = _capacity - _length - 1;
- if (n <= freeSize)
- return;
- int delta;
- if (_capacity > 64)
- delta = _capacity / 2;
- else if (_capacity > 8)
- delta = 16;
- else
- delta = 4;
- if (freeSize + delta < n)
- delta = n - freeSize;
- SetCapacity(_capacity + delta);
- }
-
- void CorrectIndex(int &index) const
- {
- if (index > _length)
- index = _length;
- }
-
-public:
- CStringBase(): _chars(0), _length(0), _capacity(0)
- { SetCapacity(16 - 1); }
- CStringBase(T c): _chars(0), _length(0), _capacity(0)
- {
- SetCapacity(1);
- _chars[0] = c;
- _chars[1] = 0;
- _length = 1;
- }
- CStringBase(const T *chars): _chars(0), _length(0), _capacity(0)
- {
- int length = MyStringLen(chars);
- SetCapacity(length);
- MyStringCopy(_chars, chars); // can be optimized by memove()
- _length = length;
- }
- CStringBase(const CStringBase &s): _chars(0), _length(0), _capacity(0)
- {
- SetCapacity(s._length);
- MyStringCopy(_chars, s._chars);
- _length = s._length;
- }
- ~CStringBase() { delete []_chars; }
-
- operator const T*() const { return _chars;}
-
- // The minimum size of the character buffer in characters.
- // This value does not include space for a null terminator.
- T* GetBuffer(int minBufLength)
- {
- if(minBufLength >= _capacity)
- SetCapacity(minBufLength + 1);
- return _chars;
- }
- void ReleaseBuffer() { ReleaseBuffer(MyStringLen(_chars)); }
- void ReleaseBuffer(int newLength)
- {
- /*
- #ifndef _WIN32_WCE
- if(newLength >= _capacity)
- throw 282217;
- #endif
- */
- _chars[newLength] = 0;
- _length = newLength;
- }
-
- CStringBase& operator=(T c)
- {
- Empty();
- SetCapacity(1);
- _chars[0] = c;
- _chars[1] = 0;
- _length = 1;
- return *this;
- }
- CStringBase& operator=(const T *chars)
- {
- Empty();
- int length = MyStringLen(chars);
- SetCapacity(length);
- MyStringCopy(_chars, chars);
- _length = length;
- return *this;
- }
- CStringBase& operator=(const CStringBase& s)
- {
- if(&s == this)
- return *this;
- Empty();
- SetCapacity(s._length);
- MyStringCopy(_chars, s._chars);
- _length = s._length;
- return *this;
- }
-
- CStringBase& operator+=(T c)
- {
- GrowLength(1);
- _chars[_length] = c;
- _chars[++_length] = 0;
- return *this;
- }
- CStringBase& operator+=(const T *s)
- {
- int len = MyStringLen(s);
- GrowLength(len);
- MyStringCopy(_chars + _length, s);
- _length += len;
- return *this;
- }
- CStringBase& operator+=(const CStringBase &s)
- {
- GrowLength(s._length);
- MyStringCopy(_chars + _length, s._chars);
- _length += s._length;
- return *this;
- }
- void Empty()
- {
- _length = 0;
- _chars[0] = 0;
- }
- int Length() const { return _length; }
- bool IsEmpty() const { return (_length == 0); }
-
- CStringBase Mid(int startIndex) const
- { return Mid(startIndex, _length - startIndex); }
- CStringBase Mid(int startIndex, int count ) const
- {
- if (startIndex + count > _length)
- count = _length - startIndex;
-
- if (startIndex == 0 && startIndex + count == _length)
- return *this;
-
- CStringBase<T> result;
- result.SetCapacity(count);
- // MyStringNCopy(result._chars, _chars + startIndex, count);
- for (int i = 0; i < count; i++)
- result._chars[i] = _chars[startIndex + i];
- result._chars[count] = 0;
- result._length = count;
- return result;
- }
- CStringBase Left(int count) const
- { return Mid(0, count); }
- CStringBase Right(int count) const
- {
- if (count > _length)
- count = _length;
- return Mid(_length - count, count);
- }
-
- void MakeUpper()
- { MyStringUpper(_chars); }
- void MakeLower()
- { MyStringLower(_chars); }
-
- int Compare(const CStringBase& s) const
- { return MyStringCompare(_chars, s._chars); }
-
- int CompareNoCase(const CStringBase& s) const
- { return MyStringCompareNoCase(_chars, s._chars); }
- /*
- int Collate(const CStringBase& s) const
- { return MyStringCollate(_chars, s._chars); }
- int CollateNoCase(const CStringBase& s) const
- { return MyStringCollateNoCase(_chars, s._chars); }
- */
-
- int Find(T c) const { return Find(c, 0); }
- int Find(T c, int startIndex) const
- {
- T *p = _chars + startIndex;
- for (;;)
- {
- if (*p == c)
- return (int)(p - _chars);
- if (*p == 0)
- return -1;
- p = GetNextCharPointer(p);
- }
- }
- int Find(const CStringBase &s) const { return Find(s, 0); }
- int Find(const CStringBase &s, int startIndex) const
- {
- if (s.IsEmpty())
- return startIndex;
- for (; startIndex < _length; startIndex++)
- {
- int j;
- for (j = 0; j < s._length && startIndex + j < _length; j++)
- if (_chars[startIndex+j] != s._chars[j])
- break;
- if (j == s._length)
- return startIndex;
- }
- return -1;
- }
- int ReverseFind(T c) const
- {
- if (_length == 0)
- return -1;
- T *p = _chars + _length - 1;
- for (;;)
- {
- if (*p == c)
- return (int)(p - _chars);
- if (p == _chars)
- return -1;
- p = GetPrevCharPointer(_chars, p);
- }
- }
- int FindOneOf(const CStringBase &s) const
- {
- for(int i = 0; i < _length; i++)
- if (s.Find(_chars[i]) >= 0)
- return i;
- return -1;
- }
-
- void TrimLeft(T c)
- {
- const T *p = _chars;
- while (c == *p)
- p = GetNextCharPointer(p);
- Delete(0, p - _chars);
- }
- private:
- CStringBase GetTrimDefaultCharSet()
- {
- CStringBase<T> charSet;
- for(int i = 0; i < (int)(sizeof(kTrimDefaultCharSet) /
- sizeof(kTrimDefaultCharSet[0])); i++)
- charSet += (T)kTrimDefaultCharSet[i];
- return charSet;
- }
- public:
-
- void TrimLeft()
- {
- TrimLeftWithCharSet(GetTrimDefaultCharSet());
- }
- void TrimRight()
- {
- TrimRightWithCharSet(GetTrimDefaultCharSet());
- }
- void TrimRight(T c)
- {
- const T *p = _chars;
- const T *pLast = NULL;
- while (*p != 0)
- {
- if (*p == c)
- {
- if (pLast == NULL)
- pLast = p;
- }
- else
- pLast = NULL;
- p = GetNextCharPointer(p);
- }
- if(pLast != NULL)
- {
- int i = pLast - _chars;
- Delete(i, _length - i);
- }
- }
- void Trim()
- {
- TrimRight();
- TrimLeft();
- }
-
- int Insert(int index, T c)
- {
- InsertSpace(index, 1);
- _chars[index] = c;
- _length++;
- return _length;
- }
- int Insert(int index, const CStringBase &s)
- {
- CorrectIndex(index);
- if (s.IsEmpty())
- return _length;
- int numInsertChars = s.Length();
- InsertSpace(index, numInsertChars);
- for(int i = 0; i < numInsertChars; i++)
- _chars[index + i] = s[i];
- _length += numInsertChars;
- return _length;
- }
-
- // !!!!!!!!!!!!!!! test it if newChar = '\0'
- int Replace(T oldChar, T newChar)
- {
- if (oldChar == newChar)
- return 0;
- int number = 0;
- int pos = 0;
- while (pos < Length())
- {
- pos = Find(oldChar, pos);
- if (pos < 0)
- break;
- _chars[pos] = newChar;
- pos++;
- number++;
- }
- return number;
- }
- int Replace(const CStringBase &oldString, const CStringBase &newString)
- {
- if (oldString.IsEmpty())
- return 0;
- if (oldString == newString)
- return 0;
- int oldStringLength = oldString.Length();
- int newStringLength = newString.Length();
- int number = 0;
- int pos = 0;
- while (pos < _length)
- {
- pos = Find(oldString, pos);
- if (pos < 0)
- break;
- Delete(pos, oldStringLength);
- Insert(pos, newString);
- pos += newStringLength;
- number++;
- }
- return number;
- }
- int Delete(int index, int count = 1 )
- {
- if (index + count > _length)
- count = _length - index;
- if (count > 0)
- {
- MoveItems(index, index + count);
- _length -= count;
- }
- return _length;
- }
-};
-
-template <class T>
-CStringBase<T> operator+(const CStringBase<T>& s1, const CStringBase<T>& s2)
-{
- CStringBase<T> result(s1);
- result += s2;
- return result;
-}
-
-template <class T>
-CStringBase<T> operator+(const CStringBase<T>& s, T c)
-{
- CStringBase<T> result(s);
- result += c;
- return result;
-}
-
-template <class T>
-CStringBase<T> operator+(T c, const CStringBase<T>& s)
-{
- CStringBase<T> result(c);
- result += s;
- return result;
-}
-
-template <class T>
-CStringBase<T> operator+(const CStringBase<T>& s, const T * chars)
-{
- CStringBase<T> result(s);
- result += chars;
- return result;
-}
-
-template <class T>
-CStringBase<T> operator+(const T * chars, const CStringBase<T>& s)
-{
- CStringBase<T> result(chars);
- result += s;
- return result;
-}
-
-template <class T>
-bool operator==(const CStringBase<T>& s1, const CStringBase<T>& s2)
- { return (s1.Compare(s2) == 0); }
-
-template <class T>
-bool operator<(const CStringBase<T>& s1, const CStringBase<T>& s2)
- { return (s1.Compare(s2) < 0); }
-
-template <class T>
-bool operator==(const T *s1, const CStringBase<T>& s2)
- { return (s2.Compare(s1) == 0); }
-
-template <class T>
-bool operator==(const CStringBase<T>& s1, const T *s2)
- { return (s1.Compare(s2) == 0); }
-
-template <class T>
-bool operator!=(const CStringBase<T>& s1, const CStringBase<T>& s2)
- { return (s1.Compare(s2) != 0); }
-
-template <class T>
-bool operator!=(const T *s1, const CStringBase<T>& s2)
- { return (s2.Compare(s1) != 0); }
-
-template <class T>
-bool operator!=(const CStringBase<T>& s1, const T *s2)
- { return (s1.Compare(s2) != 0); }
-
-typedef CStringBase<char> AString;
-typedef CStringBase<wchar_t> UString;
-
-typedef CObjectVector<AString> AStringVector;
-typedef CObjectVector<UString> UStringVector;
-
-#ifdef _UNICODE
- typedef UString CSysString;
-#else
- typedef AString CSysString;
-#endif
-
-typedef CObjectVector<CSysString> CSysStringVector;
-
-#endif
diff --git a/Common/StringConvert.cpp b/Common/StringConvert.cpp
deleted file mode 100755
index d6d05d6c..00000000
--- a/Common/StringConvert.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-// Common/StringConvert.cpp
-
-#include "StdAfx.h"
-
-#include "StringConvert.h"
-
-#ifndef _WIN32
-#include <stdlib.h>
-#endif
-
-#ifdef _WIN32
-UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
-{
- UString resultString;
- if(!srcString.IsEmpty())
- {
- int numChars = MultiByteToWideChar(codePage, 0, srcString,
- srcString.Length(), resultString.GetBuffer(srcString.Length()),
- srcString.Length() + 1);
- #ifndef _WIN32_WCE
- if(numChars == 0)
- throw 282228;
- #endif
- resultString.ReleaseBuffer(numChars);
- }
- return resultString;
-}
-
-AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
-{
- AString resultString;
- if(!srcString.IsEmpty())
- {
- int numRequiredBytes = srcString.Length() * 2;
- int numChars = WideCharToMultiByte(codePage, 0, srcString,
- srcString.Length(), resultString.GetBuffer(numRequiredBytes),
- numRequiredBytes + 1, NULL, NULL);
- #ifndef _WIN32_WCE
- if(numChars == 0)
- throw 282229;
- #endif
- resultString.ReleaseBuffer(numChars);
- }
- return resultString;
-}
-
-#ifndef _WIN32_WCE
-AString SystemStringToOemString(const CSysString &srcString)
-{
- AString result;
- CharToOem(srcString, result.GetBuffer(srcString.Length() * 2));
- result.ReleaseBuffer();
- return result;
-}
-#endif
-
-#else
-
-UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
-{
- UString resultString;
- for (int i = 0; i < srcString.Length(); i++)
- resultString += wchar_t(srcString[i]);
- /*
- if(!srcString.IsEmpty())
- {
- int numChars = mbstowcs(resultString.GetBuffer(srcString.Length()), srcString, srcString.Length() + 1);
- if (numChars < 0) throw "Your environment does not support UNICODE";
- resultString.ReleaseBuffer(numChars);
- }
- */
- return resultString;
-}
-
-AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
-{
- AString resultString;
- for (int i = 0; i < srcString.Length(); i++)
- resultString += char(srcString[i]);
- /*
- if(!srcString.IsEmpty())
- {
- int numRequiredBytes = srcString.Length() * 6 + 1;
- int numChars = wcstombs(resultString.GetBuffer(numRequiredBytes), srcString, numRequiredBytes);
- if (numChars < 0) throw "Your environment does not support UNICODE";
- resultString.ReleaseBuffer(numChars);
- }
- */
- return resultString;
-}
-
-#endif
-
diff --git a/Common/Vector.h b/Common/Vector.h
deleted file mode 100755
index ee374cf3..00000000
--- a/Common/Vector.h
+++ /dev/null
@@ -1,229 +0,0 @@
-// Common/Vector.h
-
-#ifndef __COMMON_VECTOR_H
-#define __COMMON_VECTOR_H
-
-#include "Defs.h"
-
-class CBaseRecordVector
-{
- void MoveItems(int destIndex, int srcIndex);
-protected:
- int _capacity;
- int _size;
- void *_items;
- size_t _itemSize;
-
- void ReserveOnePosition();
- void InsertOneItem(int index);
- void TestIndexAndCorrectNum(int index, int &num) const
- { if (index + num > _size) num = _size - index; }
-public:
- CBaseRecordVector(size_t itemSize):
- _capacity(0), _size(0), _items(0), _itemSize(itemSize) {}
- virtual ~CBaseRecordVector();
- void Free();
- int Size() const { return _size; }
- bool IsEmpty() const { return (_size == 0); }
- void Reserve(int newCapacity);
- virtual void Delete(int index, int num = 1);
- void Clear();
- void DeleteFrom(int index);
- void DeleteBack();
-};
-
-template <class T>
-class CRecordVector: public CBaseRecordVector
-{
-public:
- CRecordVector():CBaseRecordVector(sizeof(T)){};
- CRecordVector(const CRecordVector &v):
- CBaseRecordVector(sizeof(T)) { *this = v;}
- CRecordVector& operator=(const CRecordVector &v)
- {
- Clear();
- return (*this += v);
- }
- CRecordVector& operator+=(const CRecordVector &v)
- {
- int size = v.Size();
- Reserve(Size() + size);
- for(int i = 0; i < size; i++)
- Add(v[i]);
- return *this;
- }
- int Add(T item)
- {
- ReserveOnePosition();
- ((T *)_items)[_size] = item;
- return _size++;
- }
- void Insert(int index, T item)
- {
- InsertOneItem(index);
- ((T *)_items)[index] = item;
- }
- // T* GetPointer() const { return (T*)_items; }
- // operator const T *() const { return _items; };
- const T& operator[](int index) const { return ((T *)_items)[index]; }
- T& operator[](int index) { return ((T *)_items)[index]; }
- const T& Front() const { return operator[](0); }
- T& Front() { return operator[](0); }
- const T& Back() const { return operator[](_size - 1); }
- T& Back() { return operator[](_size - 1); }
-
- void Swap(int i, int j)
- {
- T temp = operator[](i);
- operator[](i) = operator[](j);
- operator[](j) = temp;
- }
-
- int FindInSorted(const T& item) const
- {
- int left = 0, right = Size();
- while (left != right)
- {
- int mid = (left + right) / 2;
- const T& midValue = (*this)[mid];
- if (item == midValue)
- return mid;
- if (item < midValue)
- right = mid;
- else
- left = mid + 1;
- }
- return -1;
- }
-
- void Sort(int left, int right)
- {
- if (right - left < 2)
- return;
- Swap(left, (left + right) / 2);
- int last = left;
- for (int i = left; i < right; i++)
- if (operator[](i) < operator[](left))
- Swap(++last, i);
- Swap(left, last);
- Sort(left, last);
- Sort(last + 1, right);
- }
- void Sort() { Sort(0, Size()); }
- void Sort(int left, int right, int (*compare)(const T*, const T*, void *), void *param)
- {
- if (right - left < 2)
- return;
- Swap(left, (left + right) / 2);
- int last = left;
- for (int i = left; i < right; i++)
- if (compare(&operator[](i), &operator[](left), param) < 0)
- Swap(++last, i);
- Swap(left, last);
- Sort(left, last, compare, param);
- Sort(last + 1, right, compare, param);
- }
-
- void Sort(int (*compare)(const T*, const T*, void *), void *param)
- {
- Sort(0, Size(), compare, param);
- }
-};
-
-typedef CRecordVector<int> CIntVector;
-typedef CRecordVector<unsigned int> CUIntVector;
-typedef CRecordVector<bool> CBoolVector;
-typedef CRecordVector<unsigned char> CByteVector;
-typedef CRecordVector<void *> CPointerVector;
-
-template <class T>
-class CObjectVector: public CPointerVector
-{
-public:
- CObjectVector(){};
- ~CObjectVector() { Clear(); }
- CObjectVector(const CObjectVector &objectVector)
- { *this = objectVector; }
- CObjectVector& operator=(const CObjectVector &objectVector)
- {
- Clear();
- return (*this += objectVector);
- }
- CObjectVector& operator+=(const CObjectVector &objectVector)
- {
- int size = objectVector.Size();
- Reserve(Size() + size);
- for(int i = 0; i < size; i++)
- Add(objectVector[i]);
- return *this;
- }
- const T& operator[](int index) const { return *((T *)CPointerVector::operator[](index)); }
- T& operator[](int index) { return *((T *)CPointerVector::operator[](index)); }
- T& Front() { return operator[](0); }
- const T& Front() const { return operator[](0); }
- T& Back() { return operator[](_size - 1); }
- const T& Back() const { return operator[](_size - 1); }
- int Add(const T& item)
- { return CPointerVector::Add(new T(item)); }
- void Insert(int index, const T& item)
- { CPointerVector::Insert(index, new T(item)); }
- virtual void Delete(int index, int num = 1)
- {
- TestIndexAndCorrectNum(index, num);
- for(int i = 0; i < num; i++)
- delete (T *)(((void **)_items)[index + i]);
- CPointerVector::Delete(index, num);
- }
- int Find(const T& item) const
- {
- for(int i = 0; i < Size(); i++)
- if (item == (*this)[i])
- return i;
- return -1;
- }
- int FindInSorted(const T& item) const
- {
- int left = 0, right = Size();
- while (left != right)
- {
- int mid = (left + right) / 2;
- const T& midValue = (*this)[mid];
- if (item == midValue)
- return mid;
- if (item < midValue)
- right = mid;
- else
- left = mid + 1;
- }
- return -1;
- }
- int AddToSorted(const T& item)
- {
- int left = 0, right = Size();
- while (left != right)
- {
- int mid = (left + right) / 2;
- const T& midValue = (*this)[mid];
- if (item == midValue)
- {
- right = mid + 1;
- break;
- }
- if (item < midValue)
- right = mid;
- else
- left = mid + 1;
- }
- Insert(right, item);
- return right;
- }
-
- void Sort(int (*compare)(void *const *, void *const *, void *), void *param)
- { CPointerVector::Sort(compare, param); }
-
- static int CompareObjectItems(void *const *a1, void *const *a2, void * /* param */)
- { return MyCompare(*(*((const T **)a1)), *(*((const T **)a2))); }
- void Sort() { CPointerVector::Sort(CompareObjectItems, 0); }
-};
-
-#endif
diff --git a/DOC/7zip.nsi b/DOC/7zip.nsi
index 572ef197..0d5456e5 100755
--- a/DOC/7zip.nsi
+++ b/DOC/7zip.nsi
@@ -2,7 +2,7 @@
;Defines
!define VERSION_MAJOR 4
-!define VERSION_MINOR 43
+!define VERSION_MINOR 44
!define VERSION_POSTFIX_FULL " beta"
!ifdef WIN64
!ifdef IA64
@@ -184,8 +184,10 @@ Section
File ar.txt
File ast.txt
File az.txt
+ File ba.txt
File be.txt
File bg.txt
+ File bn.txt
File br.txt
File ca.txt
File cs.txt
@@ -220,6 +222,7 @@ Section
File mn.txt
File mr.txt
File ms.txt
+ File ne.txt
File nl.txt
File no.txt
File pl.txt
@@ -395,8 +398,10 @@ Section "Uninstall"
Delete $INSTDIR\Lang\ar.txt
Delete $INSTDIR\Lang\ast.txt
Delete $INSTDIR\Lang\az.txt
+ Delete $INSTDIR\Lang\ba.txt
Delete $INSTDIR\Lang\be.txt
Delete $INSTDIR\Lang\bg.txt
+ Delete $INSTDIR\Lang\bn.txt
Delete $INSTDIR\Lang\br.txt
Delete $INSTDIR\Lang\ca.txt
Delete $INSTDIR\Lang\cs.txt
@@ -431,6 +436,7 @@ Section "Uninstall"
Delete $INSTDIR\Lang\mn.txt
Delete $INSTDIR\Lang\mr.txt
Delete $INSTDIR\Lang\ms.txt
+ Delete $INSTDIR\Lang\ne.txt
Delete $INSTDIR\Lang\nl.txt
Delete $INSTDIR\Lang\no.txt
Delete $INSTDIR\Lang\pl.txt
diff --git a/DOC/7zip.wxs b/DOC/7zip.wxs
index 6bf7f903..c2b4e9d9 100755
--- a/DOC/7zip.wxs
+++ b/DOC/7zip.wxs
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<?define VerMajor = "4" ?>
-<?define VerMinor = "43" ?>
-<?define VerBuild = "07" ?>
+<?define VerMinor = "44" ?>
+<?define VerBuild = "03" ?>
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
<?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?>
<?define MmmmVer = "$(var.MmVer).$(var.VerBuild).0" ?>
@@ -271,8 +271,10 @@
<File Id="ar.txt" Name="ar.txt" />
<File Id="ast.txt" Name="ast.txt" />
<File Id="az.txt" Name="az.txt" />
+ <File Id="ba.txt" Name="ba.txt" />
<File Id="be.txt" Name="be.txt" />
<File Id="bg.txt" Name="bg.txt" />
+ <File Id="bn.txt" Name="bn.txt" />
<File Id="br.txt" Name="br.txt" />
<File Id="ca.txt" Name="ca.txt" />
<File Id="cs.txt" Name="cs.txt" />
@@ -307,6 +309,7 @@
<File Id="mn.txt" Name="mn.txt" />
<File Id="mr.txt" Name="mr.txt" />
<File Id="ms.txt" Name="ms.txt" />
+ <File Id="ne.txt" Name="ne.txt" />
<File Id="nl.txt" Name="nl.txt" />
<File Id="no.txt" Name="no.txt" />
<File Id="pl.txt" Name="pl.txt" />
diff --git a/DOC/License.txt b/DOC/License.txt
new file mode 100755
index 00000000..1cadc586
--- /dev/null
+++ b/DOC/License.txt
@@ -0,0 +1,79 @@
+ 7-Zip
+ ~~~~~
+ License for use and distribution
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ 7-Zip Copyright (C) 1999-2007 Igor Pavlov.
+
+ Licenses for files are:
+
+ 1) Rar29.dll: GNU LGPL + unRAR restriction
+ 2) AES.dll and 7za.exe: GNU LGPL + AES code license
+ 3) All other files: GNU LGPL
+
+ GNU LGPL + unRAR restriction means that you must follow both GNU LGPL rules
+ and unRAR restriction rules.
+
+ GNU LGPL + AES code license means that you must follow both GNU LGPL rules
+ and AES code license rules.
+
+
+ Notes:
+ You can use 7-Zip on any computers, including computers in commercial
+ organizations. You don't need to register or pay for 7-Zip.
+
+
+ GNU LGPL information
+ --------------------
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+ unRAR restriction
+ -----------------
+
+ The unRAR sources cannot be used to re-create the RAR compression algorithm,
+ which is proprietary. Distribution of modified unRAR sources in separate form
+ or as a part of other software is permitted, provided that it is clearly
+ stated in the documentation and source comments that the code may
+ not be used to develop a RAR (WinRAR) compatible archiver.
+
+
+ AES code license
+ ----------------
+
+ Copyright (c) 2001, Dr Brian Gladman
+
+ LICENSE TERMS
+
+ The free distribution and use of this software in both source and binary
+ form is allowed (with or without changes) provided that:
+
+ 1. distributions of this source code include the above copyright
+ notice, this list of conditions and the following disclaimer;
+
+ 2. distributions in binary form include the above copyright
+ notice, this list of conditions and the following disclaimer
+ in the documentation and/or other associated materials;
+
+ 3. the copyright holder's name is not used to endorse products
+ built using this software without specific written permission.
+
+ DISCLAIMER
+
+ This software is provided 'as is' with no explicit or implied warranties
+ in respect of its properties, including, but not limited to, correctness
+ and fitness for purpose.
+
diff --git a/DOC/lzma.txt b/DOC/lzma.txt
index a65fc1e6..054b36fd 100755
--- a/DOC/lzma.txt
+++ b/DOC/lzma.txt
@@ -1,7 +1,7 @@
-LZMA SDK 4.43
+LZMA SDK 4.44
-------------
-LZMA SDK Copyright (C) 1999-2006 Igor Pavlov
+LZMA SDK Copyright (C) 1999-2007 Igor Pavlov
LZMA SDK provides the documentation, samples, header files, libraries,
and tools you need to develop applications that use LZMA compression.
@@ -117,7 +117,8 @@ LIB = -lm -static
Files
---------------------
-C - C / CPP source code
+C - C source code
+CPP - CPP source code
CS - C# source code
Java - Java source code
lzma.txt - LZMA SDK description (this file)
@@ -133,20 +134,11 @@ history.txt - history of the LZMA SDK
Source code structure
---------------------
-C - C / CPP files
- Common - common files for C++ projects
- Windows - common files for Windows related code
- 7zip - files related to 7-Zip Project
- Common - common files for 7-Zip
+C - C files
Compress - files related to compression/decompression
- LZ - files related to LZ (Lempel-Ziv) compression algorithm
- BinTree - Binary Tree Match Finder for LZ algorithm
- HashChain - Hash Chain Match Finder for LZ algorithm
- Patricia - Patricia Match Finder for LZ algorithm
- RangeCoder - Range Coder (special code of compression/decompression)
- LZMA - LZMA compression/decompression on C++
- LZMA_Alone - file->file LZMA compression/decompression
- LZMA_C - ANSI-C compatible LZMA decompressor
+ Lz - files related to LZ (Lempel-Ziv) compression algorithm
+ Lzma - ANSI-C compatible LZMA decompressor
+
LzmaDecode.h - interface for LZMA decoding on ANSI-C
LzmaDecode.c - LZMA decoding on ANSI-C (new fastest version)
LzmaDecodeSize.c - LZMA decoding on ANSI-C (old size-optimized version)
@@ -155,10 +147,52 @@ C - C / CPP files
LzmaStateDecode.h - interface for LZMA decoding (State version)
LzmaStateDecode.c - LZMA decoding on ANSI-C (State version)
LzmaStateTest.c - test application (State version)
+
Branch - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
+
Archive - files related to archiving
7z_C - 7z ANSI-C Decoder
+
+CPP -- CPP files
+
+ Common - common files for C++ projects
+ Windows - common files for Windows related code
+ 7zip - files related to 7-Zip Project
+
+ Common - common files for 7-Zip
+
+ Compress - files related to compression/decompression
+
+ LZ - files related to LZ (Lempel-Ziv) compression algorithm
+
+ Copy - Copy coder
+ RangeCoder - Range Coder (special code of compression/decompression)
+ LZMA - LZMA compression/decompression on C++
+ LZMA_Alone - file->file LZMA compression/decompression
+
+ Branch - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
+
+ Archive - files related to archiving
+
+ Common - common files for archive handling
+ 7z - 7z C++ Encoder/Decoder
+
+ Bundle - Modules that are bundles of other modules
+
+ Alone7z - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2
+
+ Format7zR - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2
+ Format7zExtractR - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2.
+
+ UI - User Interface files
+
+ Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll
+ Common - Common UI files
+ Console - Code for console archiver
+
+
+
CS - C# files
7zip
Common - some common files for 7-Zip
@@ -178,10 +212,10 @@ Java - Java files
C/C++ source code of LZMA SDK is part of 7-Zip project.
You can find ANSI-C LZMA decompressing code at folder
- C/7zip/Compress/LZMA_C
+ C/7zip/Compress/Lzma
7-Zip doesn't use that ANSI-C LZMA code and that code was developed
-specially for this SDK. And files from LZMA_C do not need files from
-other directories of SDK for compiling.
+specially for this SDK. And files from C/7zip/Compress/Lzma do not need
+files from other directories of SDK for compiling.
7-Zip source code can be downloaded from 7-Zip's SourceForge page:
@@ -232,7 +266,7 @@ Usage: LZMA <e|d> inputFile outputFile [<switches>...]
errors in most cases). Benchmark uses these settings:
(-a1, -d21, -fb32, -mfbt4). You can change only -d. Also you
can change number of iterations. Example for 30 iterations:
- LZMA b 30
+ LZMA b 30
Default number of iterations is 10.
<Switches>
diff --git a/DOC/readme.txt b/DOC/readme.txt
index cd0c8c43..20b0f881 100755
--- a/DOC/readme.txt
+++ b/DOC/readme.txt
@@ -1,52 +1,19 @@
-7-Zip 4.43 Sources
+7-Zip 4.44 Sources
------------------
-7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP.
+7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP/Vista.
-7-Zip Copyright (C) 1999-2006 Igor Pavlov.
+7-Zip Copyright (C) 1999-2007 Igor Pavlov.
License Info
------------
-Most of 7-Zip source code is under GNU LGPL.
+7-Zip is free software distributed under the GNU LGPL
+(except for files Rar29.dll and AES code).
+read License.txt for more infomation about license.
-Files in folders
- 7zip/Compress/Rar20
- 7zip/Compress/Rar29
- 7zip/Compress/Rar29/Original
-are licensed under "unRAR license + GNU LGPL" license.
-Source code files in all other folders of this package are under GNU LGPL.
-
-"unRAR license + GNU LGPL" means that you must follow
-GNU LGPL in all aspects while it is in agreement
-with unRAR license. But you can not break unRAR license rules.
-It means that unRAR license is main license in that pair.
-
-You can find unRAR license in file unrarLicense.txt
-You can find GNU LGPL license in file copying.txt
-
-
-GNU LGPL information:
----------------------
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-unRAR license + GNU LGPL Notes
-------------------------------
+Notes about unRAR license:
Please check main restriction from unRar license:
@@ -66,20 +33,9 @@ In brief it means:
3) You can not use unRAR sources to re-create the RAR compression algorithm.
-7zip\Compress\Rar29\Original folder contains files that are modified
-versions of original unRAR source code files.
+LZMA SDK
+--------
-
-License notes
--------------
-
-You can support development of 7-Zip by registering.
-
-7-Zip is free software distributed under the GNU LGPL.
-If you need license with other conditions, write to
-http://www.7-zip.org/support.html
-
----
Also this package contains files from LZMA SDK
you can download LZMA SDK from this page:
http://www.7-zip.org/sdk.html
@@ -145,6 +101,9 @@ DOC Documentation
7zip.nsi - installer script for NSIS
+C - Source code in C
+CPP - Source code in CPP
+
Common Common modules
Windows Win32 wrappers
@@ -188,9 +147,6 @@ Windows Win32 wrappers
Compress
--------
BZip2 BZip2 compressor
- Original Download BZip2 compression sources from
- http://sources.redhat.com/bzip2/index.html
- to that folder.
Branch Branch converter
ByteSwap Byte Swap converter
Copy Copy coder
@@ -200,10 +156,6 @@ Windows Win32 wrappers
LZMA
PPMd Dmitry Shkarin's PPMdH with small changes.
LZ Lempel - Ziv
- MT Multi Thread Match finder
- BinTree Match Finder based on Binary Tree
- Patricia Match Finder based on Patricia algoritm
- HashChain Match Finder based on Hash Chains
Crypto Crypto modules
------
@@ -220,7 +172,3 @@ Windows Win32 wrappers
Igor Pavlov
http://www.7-zip.org
-
----
-End of document
-
diff --git a/Windows/Control/ListView.h b/Windows/Control/ListView.h
deleted file mode 100755
index a66b272b..00000000
--- a/Windows/Control/ListView.h
+++ /dev/null
@@ -1,138 +0,0 @@
-// Windows/Control/ListView.h
-
-#ifndef __WINDOWS_CONTROL_LISTVIEW_H
-#define __WINDOWS_CONTROL_LISTVIEW_H
-
-#include "Windows/Window.h"
-#include "Windows/Defs.h"
-
-#include <commctrl.h>
-
-namespace NWindows {
-namespace NControl {
-
-class CListView: public NWindows::CWindow
-{
-public:
- bool CreateEx(DWORD exStyle, DWORD style,
- int x, int y, int width, int height,
- HWND parentWindow, HMENU idOrHMenu,
- HINSTANCE instance, LPVOID createParam);
-
- bool SetUnicodeFormat(bool fUnicode)
- { return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); }
-
- bool DeleteAllItems()
- { return BOOLToBool(ListView_DeleteAllItems(_window)); }
- int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo)
- { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
- #ifndef _UNICODE
- int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo)
- { return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
- #endif
- bool DeleteColumn(int columnIndex)
- { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
-
- int InsertItem(const LVITEM* item)
- { return ListView_InsertItem(_window, item); }
- #ifndef _UNICODE
- int InsertItem(const LV_ITEMW* item)
- { return (int)SendMessage(LVM_INSERTITEMW, 0, (LPARAM)item); }
- #endif
-
- bool SetItem(const LVITEM* item)
- { return BOOLToBool(ListView_SetItem(_window, item)); }
- #ifndef _UNICODE
- bool SetItem(const LV_ITEMW* item)
- { return BOOLToBool((BOOL)SendMessage(LVM_SETITEMW, 0, (LPARAM)item)); }
- #endif
-
- bool DeleteItem(int itemIndex)
- { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
-
- UINT GetSelectedCount() const
- { return ListView_GetSelectedCount(_window); }
- int GetItemCount() const
- { return ListView_GetItemCount(_window); }
-
- INT GetSelectionMark() const
- { return ListView_GetSelectionMark(_window); }
-
- void SetItemCount(int numItems)
- { ListView_SetItemCount(_window, numItems); }
- void SetItemCountEx(int numItems, DWORD flags)
- { ListView_SetItemCountEx(_window, numItems, flags); }
-
- int GetNextItem(int startIndex, UINT flags) const
- { return ListView_GetNextItem(_window, startIndex, flags); }
- int GetNextSelectedItem(int startIndex) const
- { return GetNextItem(startIndex, LVNI_SELECTED); }
- int GetFocusedItem() const
- { return GetNextItem(-1, LVNI_FOCUSED); }
-
- bool GetItem(LVITEM* item) const
- { return BOOLToBool(ListView_GetItem(_window, item)); }
- bool GetItemParam(int itemIndex, LPARAM &param) const;
- void GetItemText(int itemIndex, int aSubItemIndex, LPTSTR aText, int aTextSizeMax) const
- { ListView_GetItemText(_window, itemIndex, aSubItemIndex, aText, aTextSizeMax); }
- bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
- { return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
-
- void SetItemState(int index, UINT state, UINT mask)
- { ListView_SetItemState(_window, index, state, mask); }
- UINT GetItemState(int index, UINT mask) const
- { return ListView_GetItemState(_window, index, mask); }
-
- bool GetColumn(int columnIndex, LVCOLUMN* columnInfo) const
- { return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
-
- HIMAGELIST SetImageList(HIMAGELIST imageList, int imageListType)
- { return ListView_SetImageList(_window, imageList, imageListType); }
-
- // version 4.70: NT5 | (NT4 + ie3) | w98 | (w95 + ie3)
- DWORD GetExtendedListViewStyle()
- { return ListView_GetExtendedListViewStyle(_window); }
- void SetExtendedListViewStyle(DWORD exStyle)
- { ListView_SetExtendedListViewStyle(_window, exStyle); }
- void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle)
- { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
-
- #ifndef _WIN32_WCE
- void SetCheckState(UINT index, bool checkState)
- { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); }
- #endif
- bool GetCheckState(UINT index)
- { return BOOLToBool(ListView_GetCheckState(_window, index)); }
-
-
- bool EnsureVisible(int index, bool partialOK)
- { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
-
- bool GetItemRect(int index, RECT *rect, int code)
- { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); }
-
- HWND GetEditControl()
- { return ListView_GetEditControl(_window) ; }
- HWND EditLabel(int itemIndex)
- { return ListView_EditLabel(_window, itemIndex) ; }
-
- bool RedrawItems(int firstIndex, int lastIndex)
- { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
- bool RedrawAllItems()
- {
- if (GetItemCount() > 0)
- return RedrawItems(0, GetItemCount() - 1);
- return true;
- }
- bool RedrawItem(int index)
- { return RedrawItems(index, index); }
-
- int HitTest(LPLVHITTESTINFO info)
- { return ListView_HitTest(_window, info); }
-
- COLORREF GetBkColor()
- { return ListView_GetBkColor(_window); }
-};
-
-}}
-#endif \ No newline at end of file
diff --git a/Windows/Control/Window2.cpp b/Windows/Control/Window2.cpp
deleted file mode 100755
index 7857d503..00000000
--- a/Windows/Control/Window2.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-// Windows/Control/Window2.cpp
-
-#include "StdAfx.h"
-
-#ifndef _UNICODE
-#include "Common/StringConvert.h"
-#endif
-#include "Windows/Control/Window2.h"
-
-// extern HINSTANCE g_hInstance;
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-namespace NWindows {
-
-#ifndef _UNICODE
-ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
-#endif
-
-namespace NControl {
-
-static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- CWindow tempWindow(aHWND);
- if (message == WM_NCCREATE)
- tempWindow.SetUserDataLongPtr(
- LONG_PTR(((LPCREATESTRUCT)lParam)->lpCreateParams));
- CWindow2 *window = (CWindow2*)(tempWindow.GetUserDataLongPtr());
- if (window != NULL && message == WM_NCCREATE)
- window->Attach(aHWND);
- if (window == 0)
- {
- #ifndef _UNICODE
- if (g_IsNT)
- return DefWindowProcW(aHWND, message, wParam, lParam);
- else
- #endif
- return DefWindowProc(aHWND, message, wParam, lParam);
- }
- return window->OnMessage(message, wParam, lParam);
-}
-
-bool CWindow2::CreateEx(DWORD exStyle, LPCTSTR className,
- LPCTSTR windowName, DWORD style,
- int x, int y, int width, int height,
- HWND parentWindow, HMENU idOrHMenu,
- HINSTANCE instance)
-{
- WNDCLASS windowClass;
- if(!::GetClassInfo(instance, className, &windowClass))
- {
- // windowClass.style = CS_HREDRAW | CS_VREDRAW;
- windowClass.style = 0;
-
- windowClass.lpfnWndProc = WindowProcedure;
- windowClass.cbClsExtra = NULL;
- windowClass.cbWndExtra = NULL;
- windowClass.hInstance = instance;
- windowClass.hIcon = NULL;
- windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- windowClass.lpszMenuName = NULL;
- windowClass.lpszClassName = className;
- if (::RegisterClass(&windowClass) == 0)
- return false;
- }
- return CWindow::CreateEx(exStyle, className, windowName,
- style, x, y, width, height, parentWindow,
- idOrHMenu, instance, this);
-}
-
-#ifndef _UNICODE
-
-bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className,
- LPCWSTR windowName, DWORD style,
- int x, int y, int width, int height,
- HWND parentWindow, HMENU idOrHMenu,
- HINSTANCE instance)
-{
- bool needRegister;
- if(g_IsNT)
- {
- WNDCLASSW windowClass;
- needRegister = ::GetClassInfoW(instance, className, &windowClass) == 0;
- }
- else
- {
- WNDCLASSA windowClassA;
- AString classNameA;
- LPCSTR classNameP;
- if (IS_INTRESOURCE(className))
- classNameP = (LPCSTR)className;
- else
- {
- classNameA = GetSystemString(className);
- classNameP = classNameA;
- }
- needRegister = ::GetClassInfoA(instance, classNameP, &windowClassA) == 0;
- }
- if (needRegister)
- {
- WNDCLASSW windowClass;
- // windowClass.style = CS_HREDRAW | CS_VREDRAW;
- windowClass.style = 0;
- windowClass.lpfnWndProc = WindowProcedure;
- windowClass.cbClsExtra = NULL;
- windowClass.cbWndExtra = NULL;
- windowClass.hInstance = instance;
- windowClass.hIcon = NULL;
- windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- windowClass.lpszMenuName = NULL;
- windowClass.lpszClassName = className;
- if (MyRegisterClass(&windowClass) == 0)
- return false;
- }
- return CWindow::CreateEx(exStyle, className, windowName,
- style, x, y, width, height, parentWindow,
- idOrHMenu, instance, this);
-
-}
-#endif
-
-LRESULT CWindow2::DefProc(UINT message, WPARAM wParam, LPARAM lParam)
-{
- #ifndef _UNICODE
- if (g_IsNT)
- return DefWindowProcW(_window, message, wParam, lParam);
- else
- #endif
- return DefWindowProc(_window, message, wParam, lParam);
-}
-
-LRESULT CWindow2::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
-{
- LRESULT result;
- switch (message)
- {
- case WM_CREATE:
- if (!OnCreate((CREATESTRUCT *)lParam))
- return -1;
- break;
- case WM_COMMAND:
- if (OnCommand(wParam, lParam, result))
- return result;
- break;
- case WM_NOTIFY:
- if (OnNotify((UINT)wParam, (LPNMHDR) lParam, result))
- return result;
- break;
- case WM_DESTROY:
- OnDestroy();
- break;
- case WM_CLOSE:
- OnClose();
- return 0;
- case WM_SIZE:
- if (OnSize(wParam, LOWORD(lParam), HIWORD(lParam)))
- return 0;
- }
- return DefProc(message, wParam, lParam);
-}
-
-bool CWindow2::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT &result)
-{
- return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam, result);
-}
-
-bool CWindow2::OnCommand(int /* code */, int /* itemID */, LPARAM /* lParam */, LRESULT & /* result */)
-{
- return false;
- // return DefProc(message, wParam, lParam);
- /*
- if (code == BN_CLICKED)
- return OnButtonClicked(itemID, (HWND)lParam);
- */
-}
-
-/*
-bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
- switch(aButtonID)
- {
- case IDOK:
- OnOK();
- break;
- case IDCANCEL:
- OnCancel();
- break;
- case IDHELP:
- OnHelp();
- break;
- default:
- return false;
- }
- return true;
-}
-
-*/
-
-}}
diff --git a/Windows/FileDir.cpp b/Windows/FileDir.cpp
deleted file mode 100755
index 23174daf..00000000
--- a/Windows/FileDir.cpp
+++ /dev/null
@@ -1,693 +0,0 @@
-// Windows/FileDir.cpp
-
-#include "StdAfx.h"
-
-#include "FileDir.h"
-#include "FileName.h"
-#include "FileFind.h"
-#include "Defs.h"
-#ifndef _UNICODE
-#include "../Common/StringConvert.h"
-#endif
-
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-namespace NWindows {
-namespace NFile {
-namespace NDirectory {
-
-#ifndef _UNICODE
-static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-static UString GetUnicodePath(const CSysString &sysPath)
- { return MultiByteToUnicodeString(sysPath, GetCurrentCodePage()); }
-static CSysString GetSysPath(LPCWSTR sysPath)
- { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
-#endif
-
-bool MyGetWindowsDirectory(CSysString &path)
-{
- UINT needLength = ::GetWindowsDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
- path.ReleaseBuffer();
- return (needLength > 0 && needLength <= MAX_PATH);
-}
-
-bool MyGetSystemDirectory(CSysString &path)
-{
- UINT needLength = ::GetSystemDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
- path.ReleaseBuffer();
- return (needLength > 0 && needLength <= MAX_PATH);
-}
-
-#ifndef _UNICODE
-bool MyGetWindowsDirectory(UString &path)
-{
- if (g_IsNT)
- {
- UINT needLength = ::GetWindowsDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
- path.ReleaseBuffer();
- return (needLength > 0 && needLength <= MAX_PATH);
- }
- CSysString sysPath;
- if (!MyGetWindowsDirectory(sysPath))
- return false;
- path = GetUnicodePath(sysPath);
- return true;
-}
-
-bool MyGetSystemDirectory(UString &path)
-{
- if (g_IsNT)
- {
- UINT needLength = ::GetSystemDirectoryW(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
- path.ReleaseBuffer();
- return (needLength > 0 && needLength <= MAX_PATH);
- }
- CSysString sysPath;
- if (!MyGetSystemDirectory(sysPath))
- return false;
- path = GetUnicodePath(sysPath);
- return true;
-}
-#endif
-
-bool SetDirTime(LPCWSTR fileName, const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime)
-{
- #ifndef _UNICODE
- if (!g_IsNT)
- {
- ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return false;
- }
- #endif
- HANDLE hDir = CreateFileW(fileName, GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
-
- bool res = false;
- if (hDir != INVALID_HANDLE_VALUE)
- {
- res = BOOLToBool(::SetFileTime(hDir, creationTime, lastAccessTime, lastWriteTime));
- ::CloseHandle(hDir);
- }
- return res;
-}
-
-
-#ifndef _UNICODE
-bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes)
-{
- if (g_IsNT)
- return BOOLToBool(::SetFileAttributesW(fileName, fileAttributes));
- return MySetFileAttributes(GetSysPath(fileName), fileAttributes);
-}
-
-bool MyRemoveDirectory(LPCWSTR pathName)
-{
- if (g_IsNT)
- return BOOLToBool(::RemoveDirectoryW(pathName));
- return MyRemoveDirectory(GetSysPath(pathName));
-}
-
-bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName)
-{
- if (g_IsNT)
- return BOOLToBool(::MoveFileW(existFileName, newFileName));
- return MyMoveFile(GetSysPath(existFileName), GetSysPath(newFileName));
-}
-#endif
-
-bool MyCreateDirectory(LPCTSTR pathName) { return BOOLToBool(::CreateDirectory(pathName, NULL)); }
-
-#ifndef _UNICODE
-bool MyCreateDirectory(LPCWSTR pathName)
-{
- if (g_IsNT)
- return BOOLToBool(::CreateDirectoryW(pathName, NULL));
- return MyCreateDirectory(GetSysPath(pathName));
-}
-#endif
-
-/*
-bool CreateComplexDirectory(LPCTSTR pathName)
-{
- NName::CParsedPath path;
- path.ParsePath(pathName);
- CSysString fullPath = path.Prefix;
- DWORD errorCode = ERROR_SUCCESS;
- for(int i = 0; i < path.PathParts.Size(); i++)
- {
- const CSysString &string = path.PathParts[i];
- if(string.IsEmpty())
- {
- if(i != path.PathParts.Size() - 1)
- return false;
- return true;
- }
- fullPath += path.PathParts[i];
- if(!MyCreateDirectory(fullPath))
- {
- DWORD errorCode = GetLastError();
- if(errorCode != ERROR_ALREADY_EXISTS)
- return false;
- }
- fullPath += NName::kDirDelimiter;
- }
- return true;
-}
-*/
-
-bool CreateComplexDirectory(LPCTSTR _aPathName)
-{
- CSysString pathName = _aPathName;
- int pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
- if (pos > 0 && pos == pathName.Length() - 1)
- {
- if (pathName.Length() == 3 && pathName[1] == ':')
- return true; // Disk folder;
- pathName.Delete(pos);
- }
- CSysString pathName2 = pathName;
- pos = pathName.Length();
- for (;;)
- {
- if(MyCreateDirectory(pathName))
- break;
- if(::GetLastError() == ERROR_ALREADY_EXISTS)
- {
- NFind::CFileInfo fileInfo;
- if (!NFind::FindFile(pathName, fileInfo)) // For network folders
- return true;
- if (!fileInfo.IsDirectory())
- return false;
- break;
- }
- pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
- if (pos < 0 || pos == 0)
- return false;
- if (pathName[pos - 1] == ':')
- return false;
- pathName = pathName.Left(pos);
- }
- pathName = pathName2;
- while(pos < pathName.Length())
- {
- pos = pathName.Find(TEXT(CHAR_PATH_SEPARATOR), pos + 1);
- if (pos < 0)
- pos = pathName.Length();
- if(!MyCreateDirectory(pathName.Left(pos)))
- return false;
- }
- return true;
-}
-
-#ifndef _UNICODE
-
-bool CreateComplexDirectory(LPCWSTR _aPathName)
-{
- UString pathName = _aPathName;
- int pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR);
- if (pos > 0 && pos == pathName.Length() - 1)
- {
- if (pathName.Length() == 3 && pathName[1] == L':')
- return true; // Disk folder;
- pathName.Delete(pos);
- }
- UString pathName2 = pathName;
- pos = pathName.Length();
- for (;;)
- {
- if(MyCreateDirectory(pathName))
- break;
- if(::GetLastError() == ERROR_ALREADY_EXISTS)
- {
- NFind::CFileInfoW fileInfo;
- if (!NFind::FindFile(pathName, fileInfo)) // For network folders
- return true;
- if (!fileInfo.IsDirectory())
- return false;
- break;
- }
- pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR);
- if (pos < 0 || pos == 0)
- return false;
- if (pathName[pos - 1] == L':')
- return false;
- pathName = pathName.Left(pos);
- }
- pathName = pathName2;
- while(pos < pathName.Length())
- {
- pos = pathName.Find(WCHAR_PATH_SEPARATOR, pos + 1);
- if (pos < 0)
- pos = pathName.Length();
- if(!MyCreateDirectory(pathName.Left(pos)))
- return false;
- }
- return true;
-}
-
-#endif
-
-bool DeleteFileAlways(LPCTSTR name)
-{
- if(!::SetFileAttributes(name, 0))
- return false;
- return BOOLToBool(::DeleteFile(name));
-}
-
-#ifndef _UNICODE
-bool DeleteFileAlways(LPCWSTR name)
-{
- if (g_IsNT)
- {
- if(!MySetFileAttributes(name, 0))
- return false;
- return BOOLToBool(::DeleteFileW(name));
- }
- return DeleteFileAlways(GetSysPath(name));
-}
-#endif
-
-static bool RemoveDirectorySubItems2(const CSysString pathPrefix, const NFind::CFileInfo &fileInfo)
-{
- if(fileInfo.IsDirectory())
- return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
- return DeleteFileAlways(pathPrefix + fileInfo.Name);
-}
-
-bool RemoveDirectoryWithSubItems(const CSysString &path)
-{
- NFind::CFileInfo fileInfo;
- CSysString pathPrefix = path + NName::kDirDelimiter;
- {
- NFind::CEnumerator enumerator(pathPrefix + TCHAR(NName::kAnyStringWildcard));
- while(enumerator.Next(fileInfo))
- if(!RemoveDirectorySubItems2(pathPrefix, fileInfo))
- return false;
- }
- if(!BOOLToBool(::SetFileAttributes(path, 0)))
- return false;
- return BOOLToBool(::RemoveDirectory(path));
-}
-
-#ifndef _UNICODE
-static bool RemoveDirectorySubItems2(const UString pathPrefix, const NFind::CFileInfoW &fileInfo)
-{
- if(fileInfo.IsDirectory())
- return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
- return DeleteFileAlways(pathPrefix + fileInfo.Name);
-}
-bool RemoveDirectoryWithSubItems(const UString &path)
-{
- NFind::CFileInfoW fileInfo;
- UString pathPrefix = path + UString(NName::kDirDelimiter);
- {
- NFind::CEnumeratorW enumerator(pathPrefix + UString(NName::kAnyStringWildcard));
- while(enumerator.Next(fileInfo))
- if(!RemoveDirectorySubItems2(pathPrefix, fileInfo))
- return false;
- }
- if(!MySetFileAttributes(path, 0))
- return false;
- return MyRemoveDirectory(path);
-}
-#endif
-
-#ifndef _WIN32_WCE
-
-bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath)
-{
- DWORD needLength = ::GetShortPathName(longPath, shortPath.GetBuffer(MAX_PATH + 1), MAX_PATH + 1);
- shortPath.ReleaseBuffer();
- return (needLength > 0 && needLength < MAX_PATH);
-}
-
-bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, int &fileNamePartStartIndex)
-{
- resultPath.Empty();
- LPTSTR fileNamePointer = 0;
- LPTSTR buffer = resultPath.GetBuffer(MAX_PATH);
- DWORD needLength = ::GetFullPathName(fileName, MAX_PATH + 1, buffer, &fileNamePointer);
- resultPath.ReleaseBuffer();
- if (needLength == 0 || needLength >= MAX_PATH)
- return false;
- if (fileNamePointer == 0)
- fileNamePartStartIndex = lstrlen(fileName);
- else
- fileNamePartStartIndex = (int)(fileNamePointer - buffer);
- return true;
-}
-
-#ifndef _UNICODE
-bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex)
-{
- resultPath.Empty();
- if (g_IsNT)
- {
- LPWSTR fileNamePointer = 0;
- LPWSTR buffer = resultPath.GetBuffer(MAX_PATH);
- DWORD needLength = ::GetFullPathNameW(fileName, MAX_PATH + 1, buffer, &fileNamePointer);
- resultPath.ReleaseBuffer();
- if (needLength == 0 || needLength >= MAX_PATH)
- return false;
- if (fileNamePointer == 0)
- fileNamePartStartIndex = MyStringLen(fileName);
- else
- fileNamePartStartIndex = (int)(fileNamePointer - buffer);
- }
- else
- {
- CSysString sysPath;
- if (!MyGetFullPathName(GetSysPath(fileName), sysPath, fileNamePartStartIndex))
- return false;
- UString resultPath1 = GetUnicodePath(sysPath.Left(fileNamePartStartIndex));
- UString resultPath2 = GetUnicodePath(sysPath.Mid(fileNamePartStartIndex));
- fileNamePartStartIndex = resultPath1.Length();
- resultPath = resultPath1 + resultPath2;
- }
- return true;
-}
-#endif
-
-
-bool MyGetFullPathName(LPCTSTR fileName, CSysString &path)
-{
- int index;
- return MyGetFullPathName(fileName, path, index);
-}
-
-#ifndef _UNICODE
-bool MyGetFullPathName(LPCWSTR fileName, UString &path)
-{
- int index;
- return MyGetFullPathName(fileName, path, index);
-}
-#endif
-
-bool GetOnlyName(LPCTSTR fileName, CSysString &resultName)
-{
- int index;
- if (!MyGetFullPathName(fileName, resultName, index))
- return false;
- resultName = resultName.Mid(index);
- return true;
-}
-
-#ifndef _UNICODE
-bool GetOnlyName(LPCWSTR fileName, UString &resultName)
-{
- int index;
- if (!MyGetFullPathName(fileName, resultName, index))
- return false;
- resultName = resultName.Mid(index);
- return true;
-}
-#endif
-
-bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName)
-{
- int index;
- if (!MyGetFullPathName(fileName, resultName, index))
- return false;
- resultName = resultName.Left(index);
- return true;
-}
-
-#ifndef _UNICODE
-bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName)
-{
- int index;
- if (!MyGetFullPathName(fileName, resultName, index))
- return false;
- resultName = resultName.Left(index);
- return true;
-}
-#endif
-
-bool MyGetCurrentDirectory(CSysString &path)
-{
- DWORD needLength = ::GetCurrentDirectory(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
- path.ReleaseBuffer();
- return (needLength > 0 && needLength <= MAX_PATH);
-}
-
-#ifndef _UNICODE
-bool MySetCurrentDirectory(LPCWSTR path)
-{
- if (g_IsNT)
- return BOOLToBool(::SetCurrentDirectoryW(path));
- return MySetCurrentDirectory(GetSysPath(path));
-}
-bool MyGetCurrentDirectory(UString &path)
-{
- if (g_IsNT)
- {
- DWORD needLength = ::GetCurrentDirectoryW(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
- path.ReleaseBuffer();
- return (needLength > 0 && needLength <= MAX_PATH);
- }
- CSysString sysPath;
- if (!MyGetCurrentDirectory(sysPath))
- return false;
- path = GetUnicodePath(sysPath);
- return true;
-}
-#endif
-#endif
-
-bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
- CSysString &resultPath, UINT32 &filePart)
-{
- LPTSTR filePartPointer;
- DWORD value = ::SearchPath(path, fileName, extension,
- MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
- filePart = (UINT32)(filePartPointer - (LPCTSTR)resultPath);
- resultPath.ReleaseBuffer();
- return (value > 0 && value <= MAX_PATH);
-}
-
-#ifndef _UNICODE
-bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
- UString &resultPath, UINT32 &filePart)
-{
- if (g_IsNT)
- {
- LPWSTR filePartPointer = 0;
- DWORD value = ::SearchPathW(path, fileName, extension,
- MAX_PATH, resultPath.GetBuffer(MAX_PATH + 1), &filePartPointer);
- filePart = (UINT32)(filePartPointer - (LPCWSTR)resultPath);
- resultPath.ReleaseBuffer();
- return (value > 0 && value <= MAX_PATH);
- }
-
- CSysString sysPath;
- if (!MySearchPath(
- path != 0 ? (LPCTSTR)GetSysPath(path): 0,
- fileName != 0 ? (LPCTSTR)GetSysPath(fileName): 0,
- extension != 0 ? (LPCTSTR)GetSysPath(extension): 0,
- sysPath, filePart))
- return false;
- UString resultPath1 = GetUnicodePath(sysPath.Left(filePart));
- UString resultPath2 = GetUnicodePath(sysPath.Mid(filePart));
- filePart = resultPath1.Length();
- resultPath = resultPath1 + resultPath2;
- return true;
-}
-#endif
-
-bool MyGetTempPath(CSysString &path)
-{
- DWORD needLength = ::GetTempPath(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
- path.ReleaseBuffer();
- return (needLength > 0 && needLength <= MAX_PATH);
-}
-
-#ifndef _UNICODE
-bool MyGetTempPath(UString &path)
-{
- path.Empty();
- if (g_IsNT)
- {
- DWORD needLength = ::GetTempPathW(MAX_PATH + 1, path.GetBuffer(MAX_PATH + 1));
- path.ReleaseBuffer();
- return (needLength > 0 && needLength <= MAX_PATH);
- }
- CSysString sysPath;
- if (!MyGetTempPath(sysPath))
- return false;
- path = GetUnicodePath(sysPath);
- return true;
-}
-#endif
-
-UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &path)
-{
- UINT number = ::GetTempFileName(dirPath, prefix, 0, path.GetBuffer(MAX_PATH + 1));
- path.ReleaseBuffer();
- return number;
-}
-
-#ifndef _UNICODE
-UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &path)
-{
- if (g_IsNT)
- {
- UINT number = ::GetTempFileNameW(dirPath, prefix, 0, path.GetBuffer(MAX_PATH));
- path.ReleaseBuffer();
- return number;
- }
- CSysString sysPath;
- UINT number = MyGetTempFileName(
- dirPath ? (LPCTSTR)GetSysPath(dirPath): 0,
- prefix ? (LPCTSTR)GetSysPath(prefix): 0,
- sysPath);
- path = GetUnicodePath(sysPath);
- return number;
-}
-#endif
-
-UINT CTempFile::Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath)
-{
- Remove();
- UINT number = MyGetTempFileName(dirPath, prefix, resultPath);
- if(number != 0)
- {
- _fileName = resultPath;
- _mustBeDeleted = true;
- }
- return number;
-}
-
-bool CTempFile::Create(LPCTSTR prefix, CSysString &resultPath)
-{
- CSysString tempPath;
- if(!MyGetTempPath(tempPath))
- return false;
- if (Create(tempPath, prefix, resultPath) != 0)
- return true;
- if(!MyGetWindowsDirectory(tempPath))
- return false;
- return (Create(tempPath, prefix, resultPath) != 0);
-}
-
-bool CTempFile::Remove()
-{
- if (!_mustBeDeleted)
- return true;
- _mustBeDeleted = !DeleteFileAlways(_fileName);
- return !_mustBeDeleted;
-}
-
-#ifndef _UNICODE
-
-UINT CTempFileW::Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath)
-{
- Remove();
- UINT number = MyGetTempFileName(dirPath, prefix, resultPath);
- if(number != 0)
- {
- _fileName = resultPath;
- _mustBeDeleted = true;
- }
- return number;
-}
-
-bool CTempFileW::Create(LPCWSTR prefix, UString &resultPath)
-{
- UString tempPath;
- if(!MyGetTempPath(tempPath))
- return false;
- if (Create(tempPath, prefix, resultPath) != 0)
- return true;
- if(!MyGetWindowsDirectory(tempPath))
- return false;
- return (Create(tempPath, prefix, resultPath) != 0);
-}
-
-bool CTempFileW::Remove()
-{
- if (!_mustBeDeleted)
- return true;
- _mustBeDeleted = !DeleteFileAlways(_fileName);
- return !_mustBeDeleted;
-}
-
-#endif
-
-bool CreateTempDirectory(LPCTSTR prefix, CSysString &dirName)
-{
- /*
- CSysString prefix = tempPath + prefixChars;
- CRandom random;
- random.Init();
- */
- for (;;)
- {
- CTempFile tempFile;
- if (!tempFile.Create(prefix, dirName))
- return false;
- if (!::DeleteFile(dirName))
- return false;
- /*
- UINT32 randomNumber = random.Generate();
- TCHAR randomNumberString[32];
- _stprintf(randomNumberString, _T("%04X"), randomNumber);
- dirName = prefix + randomNumberString;
- */
- if(NFind::DoesFileExist(dirName))
- continue;
- if (MyCreateDirectory(dirName))
- return true;
- if (::GetLastError() != ERROR_ALREADY_EXISTS)
- return false;
- }
-}
-
-bool CTempDirectory::Create(LPCTSTR prefix)
-{
- Remove();
- return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
-}
-
-#ifndef _UNICODE
-
-bool CreateTempDirectory(LPCWSTR prefix, UString &dirName)
-{
- /*
- CSysString prefix = tempPath + prefixChars;
- CRandom random;
- random.Init();
- */
- for (;;)
- {
- CTempFileW tempFile;
- if (!tempFile.Create(prefix, dirName))
- return false;
- if (!DeleteFileAlways(dirName))
- return false;
- /*
- UINT32 randomNumber = random.Generate();
- TCHAR randomNumberString[32];
- _stprintf(randomNumberString, _T("%04X"), randomNumber);
- dirName = prefix + randomNumberString;
- */
- if(NFind::DoesFileExist(dirName))
- continue;
- if (MyCreateDirectory(dirName))
- return true;
- if (::GetLastError() != ERROR_ALREADY_EXISTS)
- return false;
- }
-}
-
-bool CTempDirectoryW::Create(LPCWSTR prefix)
-{
- Remove();
- return (_mustBeDeleted = CreateTempDirectory(prefix, _tempDir));
-}
-
-#endif
-
-}}}
diff --git a/Windows/FileDir.h b/Windows/FileDir.h
deleted file mode 100755
index 64e11a63..00000000
--- a/Windows/FileDir.h
+++ /dev/null
@@ -1,191 +0,0 @@
-// Windows/FileDir.h
-
-#ifndef __WINDOWS_FILEDIR_H
-#define __WINDOWS_FILEDIR_H
-
-#include "../Common/String.h"
-#include "Defs.h"
-
-namespace NWindows {
-namespace NFile {
-namespace NDirectory {
-
-bool MyGetWindowsDirectory(CSysString &path);
-bool MyGetSystemDirectory(CSysString &path);
-#ifndef _UNICODE
-bool MyGetWindowsDirectory(UString &path);
-bool MyGetSystemDirectory(UString &path);
-#endif
-
-bool SetDirTime(LPCWSTR fileName, const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
-
-inline bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes)
- { return BOOLToBool(::SetFileAttributes(fileName, fileAttributes)); }
-#ifndef _UNICODE
-bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes);
-#endif
-
-inline bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName)
- { return BOOLToBool(::MoveFile(existFileName, newFileName)); }
-#ifndef _UNICODE
-bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName);
-#endif
-
-inline bool MyRemoveDirectory(LPCTSTR pathName)
- { return BOOLToBool(::RemoveDirectory(pathName)); }
-#ifndef _UNICODE
-bool MyRemoveDirectory(LPCWSTR pathName);
-#endif
-
-bool MyCreateDirectory(LPCTSTR pathName);
-bool CreateComplexDirectory(LPCTSTR pathName);
-#ifndef _UNICODE
-bool MyCreateDirectory(LPCWSTR pathName);
-bool CreateComplexDirectory(LPCWSTR pathName);
-#endif
-
-bool DeleteFileAlways(LPCTSTR name);
-#ifndef _UNICODE
-bool DeleteFileAlways(LPCWSTR name);
-#endif
-
-bool RemoveDirectoryWithSubItems(const CSysString &path);
-#ifndef _UNICODE
-bool RemoveDirectoryWithSubItems(const UString &path);
-#endif
-
-#ifndef _WIN32_WCE
-bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath);
-
-bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath,
- int &fileNamePartStartIndex);
-bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath);
-bool GetOnlyName(LPCTSTR fileName, CSysString &resultName);
-bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName);
-#ifndef _UNICODE
-bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath,
- int &fileNamePartStartIndex);
-bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath);
-bool GetOnlyName(LPCWSTR fileName, UString &resultName);
-bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName);
-#endif
-
-inline bool MySetCurrentDirectory(LPCTSTR path)
- { return BOOLToBool(::SetCurrentDirectory(path)); }
-bool MyGetCurrentDirectory(CSysString &resultPath);
-#ifndef _UNICODE
-bool MySetCurrentDirectory(LPCWSTR path);
-bool MyGetCurrentDirectory(UString &resultPath);
-#endif
-#endif
-
-bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
- CSysString &resultPath, UINT32 &filePart);
-#ifndef _UNICODE
-bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
- UString &resultPath, UINT32 &filePart);
-#endif
-
-inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension,
- CSysString &resultPath)
-{
- UINT32 value;
- return MySearchPath(path, fileName, extension, resultPath, value);
-}
-
-#ifndef _UNICODE
-inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension,
- UString &resultPath)
-{
- UINT32 value;
- return MySearchPath(path, fileName, extension, resultPath, value);
-}
-#endif
-
-bool MyGetTempPath(CSysString &resultPath);
-#ifndef _UNICODE
-bool MyGetTempPath(UString &resultPath);
-#endif
-
-UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
-#ifndef _UNICODE
-UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
-#endif
-
-class CTempFile
-{
- bool _mustBeDeleted;
- CSysString _fileName;
-public:
- CTempFile(): _mustBeDeleted(false) {}
- ~CTempFile() { Remove(); }
- void DisableDeleting() { _mustBeDeleted = false; }
- UINT Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath);
- bool Create(LPCTSTR prefix, CSysString &resultPath);
- bool Remove();
-};
-
-#ifdef _UNICODE
-typedef CTempFile CTempFileW;
-#else
-class CTempFileW
-{
- bool _mustBeDeleted;
- UString _fileName;
-public:
- CTempFileW(): _mustBeDeleted(false) {}
- ~CTempFileW() { Remove(); }
- void DisableDeleting() { _mustBeDeleted = false; }
- UINT Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath);
- bool Create(LPCWSTR prefix, UString &resultPath);
- bool Remove();
-};
-#endif
-
-bool CreateTempDirectory(LPCTSTR prefixChars, CSysString &dirName);
-
-class CTempDirectory
-{
- bool _mustBeDeleted;
- CSysString _tempDir;
-public:
- const CSysString &GetPath() const { return _tempDir; }
- CTempDirectory(): _mustBeDeleted(false) {}
- ~CTempDirectory() { Remove(); }
- bool Create(LPCTSTR prefix) ;
- bool Remove()
- {
- if (!_mustBeDeleted)
- return true;
- _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
- return (!_mustBeDeleted);
- }
- void DisableDeleting() { _mustBeDeleted = false; }
-};
-
-#ifdef _UNICODE
-typedef CTempDirectory CTempDirectoryW;
-#else
-class CTempDirectoryW
-{
- bool _mustBeDeleted;
- UString _tempDir;
-public:
- const UString &GetPath() const { return _tempDir; }
- CTempDirectoryW(): _mustBeDeleted(false) {}
- ~CTempDirectoryW() { Remove(); }
- bool Create(LPCWSTR prefix) ;
- bool Remove()
- {
- if (!_mustBeDeleted)
- return true;
- _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir);
- return (!_mustBeDeleted);
- }
- void DisableDeleting() { _mustBeDeleted = false; }
-};
-#endif
-
-}}}
-
-#endif
diff --git a/Windows/FileFind.cpp b/Windows/FileFind.cpp
deleted file mode 100755
index 9f36c056..00000000
--- a/Windows/FileFind.cpp
+++ /dev/null
@@ -1,368 +0,0 @@
-// Windows/FileFind.cpp
-
-#include "StdAfx.h"
-
-#include "FileFind.h"
-#ifndef _UNICODE
-#include "../Common/StringConvert.h"
-#endif
-
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-namespace NWindows {
-namespace NFile {
-namespace NFind {
-
-static const TCHAR kDot = TEXT('.');
-
-bool CFileInfo::IsDots() const
-{
- if (!IsDirectory() || Name.IsEmpty())
- return false;
- if (Name[0] != kDot)
- return false;
- return Name.Length() == 1 || (Name[1] == kDot && Name.Length() == 2);
-}
-
-#ifndef _UNICODE
-bool CFileInfoW::IsDots() const
-{
- if (!IsDirectory() || Name.IsEmpty())
- return false;
- if (Name[0] != kDot)
- return false;
- return Name.Length() == 1 || (Name[1] == kDot && Name.Length() == 2);
-}
-#endif
-
-static void ConvertWIN32_FIND_DATA_To_FileInfo(
- const WIN32_FIND_DATA &findData,
- CFileInfo &fileInfo)
-{
- fileInfo.Attributes = findData.dwFileAttributes;
- fileInfo.CreationTime = findData.ftCreationTime;
- fileInfo.LastAccessTime = findData.ftLastAccessTime;
- fileInfo.LastWriteTime = findData.ftLastWriteTime;
- fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
- fileInfo.Name = findData.cFileName;
- #ifndef _WIN32_WCE
- fileInfo.ReparseTag = findData.dwReserved0;
- #else
- fileInfo.ObjectID = findData.dwOID;
- #endif
-}
-
-#ifndef _UNICODE
-
-static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-
-static void ConvertWIN32_FIND_DATA_To_FileInfo(
- const WIN32_FIND_DATAW &findData,
- CFileInfoW &fileInfo)
-{
- fileInfo.Attributes = findData.dwFileAttributes;
- fileInfo.CreationTime = findData.ftCreationTime;
- fileInfo.LastAccessTime = findData.ftLastAccessTime;
- fileInfo.LastWriteTime = findData.ftLastWriteTime;
- fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
- fileInfo.Name = findData.cFileName;
- #ifndef _WIN32_WCE
- fileInfo.ReparseTag = findData.dwReserved0;
- #else
- fileInfo.ObjectID = findData.dwOID;
- #endif
-}
-
-static void ConvertWIN32_FIND_DATA_To_FileInfo(
- const WIN32_FIND_DATA &findData,
- CFileInfoW &fileInfo)
-{
- fileInfo.Attributes = findData.dwFileAttributes;
- fileInfo.CreationTime = findData.ftCreationTime;
- fileInfo.LastAccessTime = findData.ftLastAccessTime;
- fileInfo.LastWriteTime = findData.ftLastWriteTime;
- fileInfo.Size = (((UInt64)findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
- fileInfo.Name = GetUnicodeString(findData.cFileName, GetCurrentCodePage());
- #ifndef _WIN32_WCE
- fileInfo.ReparseTag = findData.dwReserved0;
- #else
- fileInfo.ObjectID = findData.dwOID;
- #endif
-}
-#endif
-
-////////////////////////////////
-// CFindFile
-
-bool CFindFile::Close()
-{
- if(!_handleAllocated)
- return true;
- bool result = BOOLToBool(::FindClose(_handle));
- _handleAllocated = !result;
- return result;
-}
-
-bool CFindFile::FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo)
-{
- Close();
- WIN32_FIND_DATA findData;
- _handle = ::FindFirstFile(wildcard, &findData);
- _handleAllocated = (_handle != INVALID_HANDLE_VALUE);
- if (_handleAllocated)
- ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
- return _handleAllocated;
-}
-
-#ifndef _UNICODE
-bool CFindFile::FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo)
-{
- Close();
- if (g_IsNT)
- {
- WIN32_FIND_DATAW findData;
- _handle = ::FindFirstFileW(wildcard, &findData);
- _handleAllocated = (_handle != INVALID_HANDLE_VALUE);
- if (_handleAllocated)
- ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
- }
- else
- {
- WIN32_FIND_DATAA findData;
- _handle = ::FindFirstFileA(UnicodeStringToMultiByte(wildcard,
- GetCurrentCodePage()), &findData);
- _handleAllocated = (_handle != INVALID_HANDLE_VALUE);
- if (_handleAllocated)
- ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
- }
- return _handleAllocated;
-}
-#endif
-
-bool CFindFile::FindNext(CFileInfo &fileInfo)
-{
- WIN32_FIND_DATA findData;
- bool result = BOOLToBool(::FindNextFile(_handle, &findData));
- if (result)
- ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
- return result;
-}
-
-#ifndef _UNICODE
-bool CFindFile::FindNext(CFileInfoW &fileInfo)
-{
- if (g_IsNT)
- {
- WIN32_FIND_DATAW findData;
- if (!::FindNextFileW(_handle, &findData))
- return false;
- ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
- }
- else
- {
- WIN32_FIND_DATAA findData;
- if (!::FindNextFileA(_handle, &findData))
- return false;
- ConvertWIN32_FIND_DATA_To_FileInfo(findData, fileInfo);
- }
- return true;
-}
-#endif
-
-bool FindFile(LPCTSTR wildcard, CFileInfo &fileInfo)
-{
- CFindFile finder;
- return finder.FindFirst(wildcard, fileInfo);
-}
-
-#ifndef _UNICODE
-bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo)
-{
- CFindFile finder;
- return finder.FindFirst(wildcard, fileInfo);
-}
-#endif
-
-bool DoesFileExist(LPCTSTR name)
-{
- CFileInfo fileInfo;
- return FindFile(name, fileInfo);
-}
-
-#ifndef _UNICODE
-bool DoesFileExist(LPCWSTR name)
-{
- CFileInfoW fileInfo;
- return FindFile(name, fileInfo);
-}
-#endif
-
-/////////////////////////////////////
-// CEnumerator
-
-bool CEnumerator::NextAny(CFileInfo &fileInfo)
-{
- if(_findFile.IsHandleAllocated())
- return _findFile.FindNext(fileInfo);
- else
- return _findFile.FindFirst(_wildcard, fileInfo);
-}
-
-bool CEnumerator::Next(CFileInfo &fileInfo)
-{
- for (;;)
- {
- if(!NextAny(fileInfo))
- return false;
- if(!fileInfo.IsDots())
- return true;
- }
-}
-
-bool CEnumerator::Next(CFileInfo &fileInfo, bool &found)
-{
- if (Next(fileInfo))
- {
- found = true;
- return true;
- }
- found = false;
- return (::GetLastError() == ERROR_NO_MORE_FILES);
-}
-
-#ifndef _UNICODE
-bool CEnumeratorW::NextAny(CFileInfoW &fileInfo)
-{
- if(_findFile.IsHandleAllocated())
- return _findFile.FindNext(fileInfo);
- else
- return _findFile.FindFirst(_wildcard, fileInfo);
-}
-
-bool CEnumeratorW::Next(CFileInfoW &fileInfo)
-{
- for (;;)
- {
- if(!NextAny(fileInfo))
- return false;
- if(!fileInfo.IsDots())
- return true;
- }
-}
-
-bool CEnumeratorW::Next(CFileInfoW &fileInfo, bool &found)
-{
- if (Next(fileInfo))
- {
- found = true;
- return true;
- }
- found = false;
- return (::GetLastError() == ERROR_NO_MORE_FILES);
-}
-
-#endif
-
-////////////////////////////////
-// CFindChangeNotification
-
-bool CFindChangeNotification::Close()
-{
- if(_handle == INVALID_HANDLE_VALUE || _handle == 0)
- return true;
- bool result = BOOLToBool(::FindCloseChangeNotification(_handle));
- if (result)
- _handle = INVALID_HANDLE_VALUE;
- return result;
-}
-
-HANDLE CFindChangeNotification::FindFirst(LPCTSTR pathName, bool watchSubtree,
- DWORD notifyFilter)
-{
- _handle = ::FindFirstChangeNotification(pathName,
- BoolToBOOL(watchSubtree), notifyFilter);
- return _handle;
-}
-
-#ifndef _UNICODE
-HANDLE CFindChangeNotification::FindFirst(LPCWSTR pathName, bool watchSubtree,
- DWORD notifyFilter)
-{
- if (g_IsNT)
- return (_handle = ::FindFirstChangeNotificationW(pathName, BoolToBOOL(watchSubtree), notifyFilter));
- return FindFirst(UnicodeStringToMultiByte(pathName, GetCurrentCodePage()), watchSubtree, notifyFilter);
-}
-#endif
-
-#ifndef _WIN32_WCE
-bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings)
-{
- driveStrings.Clear();
- UINT32 size = GetLogicalDriveStrings(0, NULL);
- if(size == 0)
- return false;
- CSysString buffer;
- UINT32 newSize = GetLogicalDriveStrings(size, buffer.GetBuffer(size));
- if(newSize == 0)
- return false;
- if(newSize > size)
- return false;
- CSysString string;
- for(UINT32 i = 0; i < newSize; i++)
- {
- TCHAR c = buffer[i];
- if(c == TEXT('\0'))
- {
- driveStrings.Add(string);
- string.Empty();
- }
- else
- string += c;
- }
- if(!string.IsEmpty())
- return false;
- return true;
-}
-
-#ifndef _UNICODE
-bool MyGetLogicalDriveStrings(UStringVector &driveStrings)
-{
- driveStrings.Clear();
- if (g_IsNT)
- {
- UINT32 size = GetLogicalDriveStringsW(0, NULL);
- if (size == 0)
- return false;
- UString buffer;
- UINT32 newSize = GetLogicalDriveStringsW(size, buffer.GetBuffer(size));
- if(newSize == 0)
- return false;
- if(newSize > size)
- return false;
- UString string;
- for(UINT32 i = 0; i < newSize; i++)
- {
- WCHAR c = buffer[i];
- if(c == L'\0')
- {
- driveStrings.Add(string);
- string.Empty();
- }
- else
- string += c;
- }
- return string.IsEmpty();
- }
- CSysStringVector driveStringsA;
- bool res = MyGetLogicalDriveStrings(driveStringsA);
- for (int i = 0; i < driveStringsA.Size(); i++)
- driveStrings.Add(GetUnicodeString(driveStringsA[i]));
- return res;
-}
-#endif
-
-#endif
-
-}}}
diff --git a/Windows/FileFind.h b/Windows/FileFind.h
deleted file mode 100755
index 7da15a14..00000000
--- a/Windows/FileFind.h
+++ /dev/null
@@ -1,176 +0,0 @@
-// Windows/FileFind.h
-
-#ifndef __WINDOWS_FILEFIND_H
-#define __WINDOWS_FILEFIND_H
-
-#include "../Common/String.h"
-#include "../Common/Types.h"
-#include "FileName.h"
-#include "Defs.h"
-
-namespace NWindows {
-namespace NFile {
-namespace NFind {
-
-namespace NAttributes
-{
- inline bool IsReadOnly(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_READONLY) != 0; }
- inline bool IsHidden(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_HIDDEN) != 0; }
- inline bool IsSystem(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_SYSTEM) != 0; }
- inline bool IsDirectory(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }
- inline bool IsArchived(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_ARCHIVE) != 0; }
- inline bool IsCompressed(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_COMPRESSED) != 0; }
- inline bool IsEncrypted(DWORD attributes) { return (attributes & FILE_ATTRIBUTE_ENCRYPTED) != 0; }
-}
-
-class CFileInfoBase
-{
- bool MatchesMask(UINT32 mask) const { return ((Attributes & mask) != 0); }
-public:
- DWORD Attributes;
- FILETIME CreationTime;
- FILETIME LastAccessTime;
- FILETIME LastWriteTime;
- UInt64 Size;
-
- #ifndef _WIN32_WCE
- UINT32 ReparseTag;
- #else
- DWORD ObjectID;
- #endif
-
- bool IsArchived() const { return MatchesMask(FILE_ATTRIBUTE_ARCHIVE); }
- bool IsCompressed() const { return MatchesMask(FILE_ATTRIBUTE_COMPRESSED); }
- bool IsDirectory() const { return MatchesMask(FILE_ATTRIBUTE_DIRECTORY); }
- bool IsEncrypted() const { return MatchesMask(FILE_ATTRIBUTE_ENCRYPTED); }
- bool IsHidden() const { return MatchesMask(FILE_ATTRIBUTE_HIDDEN); }
- bool IsNormal() const { return MatchesMask(FILE_ATTRIBUTE_NORMAL); }
- bool IsOffline() const { return MatchesMask(FILE_ATTRIBUTE_OFFLINE); }
- bool IsReadOnly() const { return MatchesMask(FILE_ATTRIBUTE_READONLY); }
- bool HasReparsePoint() const { return MatchesMask(FILE_ATTRIBUTE_REPARSE_POINT); }
- bool IsSparse() const { return MatchesMask(FILE_ATTRIBUTE_SPARSE_FILE); }
- bool IsSystem() const { return MatchesMask(FILE_ATTRIBUTE_SYSTEM); }
- bool IsTemporary() const { return MatchesMask(FILE_ATTRIBUTE_TEMPORARY); }
-};
-
-class CFileInfo: public CFileInfoBase
-{
-public:
- CSysString Name;
- bool IsDots() const;
-};
-
-#ifdef _UNICODE
-typedef CFileInfo CFileInfoW;
-#else
-class CFileInfoW: public CFileInfoBase
-{
-public:
- UString Name;
- bool IsDots() const;
-};
-#endif
-
-class CFindFile
-{
- friend class CEnumerator;
- HANDLE _handle;
- bool _handleAllocated;
-public:
- bool IsHandleAllocated() const { return _handleAllocated; }
- CFindFile(): _handleAllocated(false) {}
- ~CFindFile() { Close(); }
- bool FindFirst(LPCTSTR wildcard, CFileInfo &fileInfo);
- bool FindNext(CFileInfo &fileInfo);
- #ifndef _UNICODE
- bool FindFirst(LPCWSTR wildcard, CFileInfoW &fileInfo);
- bool FindNext(CFileInfoW &fileInfo);
- #endif
- bool Close();
-};
-
-bool FindFile(LPCTSTR wildcard, CFileInfo &fileInfo);
-
-bool DoesFileExist(LPCTSTR name);
-#ifndef _UNICODE
-bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo);
-bool DoesFileExist(LPCWSTR name);
-#endif
-
-class CEnumerator
-{
- CFindFile _findFile;
- CSysString _wildcard;
- bool NextAny(CFileInfo &fileInfo);
-public:
- CEnumerator(): _wildcard(NName::kAnyStringWildcard) {}
- CEnumerator(const CSysString &wildcard): _wildcard(wildcard) {}
- bool Next(CFileInfo &fileInfo);
- bool Next(CFileInfo &fileInfo, bool &found);
-};
-
-#ifdef _UNICODE
-typedef CEnumerator CEnumeratorW;
-#else
-class CEnumeratorW
-{
- CFindFile _findFile;
- UString _wildcard;
- bool NextAny(CFileInfoW &fileInfo);
-public:
- CEnumeratorW(): _wildcard(NName::kAnyStringWildcard) {}
- CEnumeratorW(const UString &wildcard): _wildcard(wildcard) {}
- bool Next(CFileInfoW &fileInfo);
- bool Next(CFileInfoW &fileInfo, bool &found);
-};
-#endif
-
-class CFindChangeNotification
-{
- HANDLE _handle;
-public:
- operator HANDLE () { return _handle; }
- CFindChangeNotification(): _handle(INVALID_HANDLE_VALUE) {}
- ~CFindChangeNotification() { Close(); }
- bool Close();
- HANDLE FindFirst(LPCTSTR pathName, bool watchSubtree, DWORD notifyFilter);
- #ifndef _UNICODE
- HANDLE FindFirst(LPCWSTR pathName, bool watchSubtree, DWORD notifyFilter);
- #endif
- bool FindNext()
- { return BOOLToBool(::FindNextChangeNotification(_handle)); }
-};
-
-#ifndef _WIN32_WCE
-bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings);
-#ifndef _UNICODE
-bool MyGetLogicalDriveStrings(UStringVector &driveStrings);
-#endif
-#endif
-
-inline bool MyGetCompressedFileSize(LPCTSTR fileName, UInt64 &size)
-{
- DWORD highPart;
- DWORD lowPart = ::GetCompressedFileSize(fileName, &highPart);
- if (lowPart == INVALID_FILE_SIZE)
- if (::GetLastError() != NO_ERROR)
- return false;
- size = (UInt64(highPart) << 32) | lowPart;
- return true;
-}
-
-inline bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
-{
- DWORD highPart;
- DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
- if (lowPart == INVALID_FILE_SIZE)
- if (::GetLastError() != NO_ERROR)
- return false;
- size = (UInt64(highPart) << 32) | lowPart;
- return true;
-}
-
-}}}
-
-#endif
-
diff --git a/Windows/FileIO.cpp b/Windows/FileIO.cpp
deleted file mode 100755
index 203de843..00000000
--- a/Windows/FileIO.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-// Windows/FileIO.cpp
-
-#include "StdAfx.h"
-
-#include "FileIO.h"
-#include "Defs.h"
-#ifndef _UNICODE
-#include "../Common/StringConvert.h"
-#endif
-
-#ifndef _UNICODE
-extern bool g_IsNT;
-#endif
-
-namespace NWindows {
-namespace NFile {
-namespace NIO {
-
-CFileBase::~CFileBase() { Close(); }
-
-bool CFileBase::Create(LPCTSTR fileName, DWORD desiredAccess,
- DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
-{
- Close();
- _handle = ::CreateFile(fileName, desiredAccess, shareMode,
- (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
- flagsAndAttributes, (HANDLE) NULL);
- return (_fileIsOpen = (_handle != INVALID_HANDLE_VALUE));
-}
-
-#ifndef _UNICODE
-bool CFileBase::Create(LPCWSTR fileName, DWORD desiredAccess,
- DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
-{
- if (g_IsNT)
- {
- Close();
- _handle = ::CreateFileW(fileName, desiredAccess, shareMode,
- (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
- flagsAndAttributes, (HANDLE) NULL);
- return (_fileIsOpen = (_handle != INVALID_HANDLE_VALUE));
- }
- return Create(UnicodeStringToMultiByte(fileName, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP),
- desiredAccess, shareMode, creationDisposition, flagsAndAttributes);
-}
-#endif
-
-bool CFileBase::Close()
-{
- if(!_fileIsOpen)
- return true;
- bool result = BOOLToBool(::CloseHandle(_handle));
- _fileIsOpen = !result;
- return result;
-}
-
-bool CFileBase::GetPosition(UInt64 &position) const
-{
- return Seek(0, FILE_CURRENT, position);
-}
-
-bool CFileBase::GetLength(UInt64 &length) const
-{
- DWORD sizeHigh;
- DWORD sizeLow = ::GetFileSize(_handle, &sizeHigh);
- if(sizeLow == 0xFFFFFFFF)
- if(::GetLastError() != NO_ERROR)
- return false;
- length = (((UInt64)sizeHigh) << 32) + sizeLow;
- return true;
-}
-
-bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const
-{
- LARGE_INTEGER value;
- value.QuadPart = distanceToMove;
- value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod);
- if (value.LowPart == 0xFFFFFFFF)
- if(::GetLastError() != NO_ERROR)
- return false;
- newPosition = value.QuadPart;
- return true;
-}
-
-bool CFileBase::Seek(UInt64 position, UInt64 &newPosition)
-{
- return Seek(position, FILE_BEGIN, newPosition);
-}
-
-bool CFileBase::SeekToBegin()
-{
- UInt64 newPosition;
- return Seek(0, newPosition);
-}
-
-bool CFileBase::SeekToEnd(UInt64 &newPosition)
-{
- return Seek(0, FILE_END, newPosition);
-}
-
-bool CFileBase::GetFileInformation(CByHandleFileInfo &fileInfo) const
-{
- BY_HANDLE_FILE_INFORMATION winFileInfo;
- if(!::GetFileInformationByHandle(_handle, &winFileInfo))
- return false;
- fileInfo.Attributes = winFileInfo.dwFileAttributes;
- fileInfo.CreationTime = winFileInfo.ftCreationTime;
- fileInfo.LastAccessTime = winFileInfo.ftLastAccessTime;
- fileInfo.LastWriteTime = winFileInfo.ftLastWriteTime;
- fileInfo.VolumeSerialNumber = winFileInfo.dwFileAttributes;
- fileInfo.Size = (((UInt64)winFileInfo.nFileSizeHigh) << 32) + winFileInfo.nFileSizeLow;
- fileInfo.NumberOfLinks = winFileInfo.nNumberOfLinks;
- fileInfo.FileIndex = (((UInt64)winFileInfo.nFileIndexHigh) << 32) + winFileInfo.nFileIndexLow;
- return true;
-}
-
-/////////////////////////
-// CInFile
-
-bool CInFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
- { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
-
-bool CInFile::Open(LPCTSTR fileName)
- { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
-
-#ifndef _UNICODE
-bool CInFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
- { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
-
-bool CInFile::Open(LPCWSTR fileName)
- { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
-#endif
-
-// ReadFile and WriteFile functions in Windows have BUG:
-// If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
-// from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
-// (Insufficient system resources exist to complete the requested service).
-
-static UInt32 kChunkSizeMax = (1 << 24);
-
-bool CInFile::ReadPart(void *data, UInt32 size, UInt32 &processedSize)
-{
- if (size > kChunkSizeMax)
- size = kChunkSizeMax;
- DWORD processedLoc = 0;
- bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL));
- processedSize = (UInt32)processedLoc;
- return res;
-}
-
-bool CInFile::Read(void *data, UInt32 size, UInt32 &processedSize)
-{
- processedSize = 0;
- do
- {
- UInt32 processedLoc = 0;
- bool res = ReadPart(data, size, processedLoc);
- processedSize += processedLoc;
- if (!res)
- return false;
- if (processedLoc == 0)
- return true;
- data = (void *)((unsigned char *)data + processedLoc);
- size -= processedLoc;
- }
- while (size > 0);
- return true;
-}
-
-/////////////////////////
-// COutFile
-
-bool COutFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
- { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
-
-static inline DWORD GetCreationDisposition(bool createAlways)
- { return createAlways? CREATE_ALWAYS: CREATE_NEW; }
-
-bool COutFile::Open(LPCTSTR fileName, DWORD creationDisposition)
- { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
-
-bool COutFile::Create(LPCTSTR fileName, bool createAlways)
- { return Open(fileName, GetCreationDisposition(createAlways)); }
-
-#ifndef _UNICODE
-
-bool COutFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
- { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
-
-bool COutFile::Open(LPCWSTR fileName, DWORD creationDisposition)
- { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
-
-bool COutFile::Create(LPCWSTR fileName, bool createAlways)
- { return Open(fileName, GetCreationDisposition(createAlways)); }
-
-#endif
-
-bool COutFile::SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime)
- { return BOOLToBool(::SetFileTime(_handle, creationTime, lastAccessTime, lastWriteTime)); }
-
-bool COutFile::SetLastWriteTime(const FILETIME *lastWriteTime)
- { return SetTime(NULL, NULL, lastWriteTime); }
-
-bool COutFile::WritePart(const void *data, UInt32 size, UInt32 &processedSize)
-{
- if (size > kChunkSizeMax)
- size = kChunkSizeMax;
- DWORD processedLoc = 0;
- bool res = BOOLToBool(::WriteFile(_handle, data, size, &processedLoc, NULL));
- processedSize = (UInt32)processedLoc;
- return res;
-}
-
-bool COutFile::Write(const void *data, UInt32 size, UInt32 &processedSize)
-{
- processedSize = 0;
- do
- {
- UInt32 processedLoc = 0;
- bool res = WritePart(data, size, processedLoc);
- processedSize += processedLoc;
- if (!res)
- return false;
- if (processedLoc == 0)
- return true;
- data = (const void *)((const unsigned char *)data + processedLoc);
- size -= processedLoc;
- }
- while (size > 0);
- return true;
-}
-
-bool COutFile::SetEndOfFile() { return BOOLToBool(::SetEndOfFile(_handle)); }
-
-bool COutFile::SetLength(UInt64 length)
-{
- UInt64 newPosition;
- if(!Seek(length, newPosition))
- return false;
- if(newPosition != length)
- return false;
- return SetEndOfFile();
-}
-
-}}}
diff --git a/Windows/FileIO.h b/Windows/FileIO.h
deleted file mode 100755
index 18014844..00000000
--- a/Windows/FileIO.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Windows/FileIO.h
-
-#ifndef __WINDOWS_FILEIO_H
-#define __WINDOWS_FILEIO_H
-
-#include "../Common/Types.h"
-
-namespace NWindows {
-namespace NFile {
-namespace NIO {
-
-struct CByHandleFileInfo
-{
- DWORD Attributes;
- FILETIME CreationTime;
- FILETIME LastAccessTime;
- FILETIME LastWriteTime;
- DWORD VolumeSerialNumber;
- UInt64 Size;
- DWORD NumberOfLinks;
- UInt64 FileIndex;
-};
-
-class CFileBase
-{
-protected:
- bool _fileIsOpen;
- HANDLE _handle;
- bool Create(LPCTSTR fileName, DWORD desiredAccess,
- DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
- #ifndef _UNICODE
- bool Create(LPCWSTR fileName, DWORD desiredAccess,
- DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
- #endif
-
-public:
- CFileBase(): _fileIsOpen(false){};
- virtual ~CFileBase();
-
- virtual bool Close();
-
- bool GetPosition(UInt64 &position) const;
- bool GetLength(UInt64 &length) const;
-
- bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
- bool Seek(UInt64 position, UInt64 &newPosition);
- bool SeekToBegin();
- bool SeekToEnd(UInt64 &newPosition);
-
- bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
-};
-
-class CInFile: public CFileBase
-{
-public:
- bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
- bool Open(LPCTSTR fileName);
- #ifndef _UNICODE
- bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
- bool Open(LPCWSTR fileName);
- #endif
- bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
- bool Read(void *data, UInt32 size, UInt32 &processedSize);
-};
-
-class COutFile: public CFileBase
-{
- // DWORD m_CreationDisposition;
-public:
- // COutFile(): m_CreationDisposition(CREATE_NEW){};
- bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
- bool Open(LPCTSTR fileName, DWORD creationDisposition);
- bool Create(LPCTSTR fileName, bool createAlways);
-
- #ifndef _UNICODE
- bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
- bool Open(LPCWSTR fileName, DWORD creationDisposition);
- bool Create(LPCWSTR fileName, bool createAlways);
- #endif
-
- /*
- void SetOpenCreationDisposition(DWORD creationDisposition)
- { m_CreationDisposition = creationDisposition; }
- void SetOpenCreationDispositionCreateAlways()
- { m_CreationDisposition = CREATE_ALWAYS; }
- */
-
- bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
- bool SetLastWriteTime(const FILETIME *lastWriteTime);
- bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
- bool Write(const void *data, UInt32 size, UInt32 &processedSize);
- bool SetEndOfFile();
- bool SetLength(UInt64 length);
-};
-
-}}}
-
-#endif
diff --git a/Windows/PropVariant.cpp b/Windows/PropVariant.cpp
deleted file mode 100755
index 48321bc2..00000000
--- a/Windows/PropVariant.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-// Windows/PropVariant.cpp
-
-#include "StdAfx.h"
-
-#include "PropVariant.h"
-
-#include "../Common/Defs.h"
-
-namespace NWindows {
-namespace NCOM {
-
-CPropVariant::CPropVariant(const PROPVARIANT& varSrc)
-{
- vt = VT_EMPTY;
- InternalCopy(&varSrc);
-}
-
-CPropVariant::CPropVariant(const CPropVariant& varSrc)
-{
- vt = VT_EMPTY;
- InternalCopy(&varSrc);
-}
-
-CPropVariant::CPropVariant(BSTR bstrSrc)
-{
- vt = VT_EMPTY;
- *this = bstrSrc;
-}
-
-CPropVariant::CPropVariant(LPCOLESTR lpszSrc)
-{
- vt = VT_EMPTY;
- *this = lpszSrc;
-}
-
-CPropVariant& CPropVariant::operator=(const CPropVariant& varSrc)
-{
- InternalCopy(&varSrc);
- return *this;
-}
-CPropVariant& CPropVariant::operator=(const PROPVARIANT& varSrc)
-{
- InternalCopy(&varSrc);
- return *this;
-}
-
-CPropVariant& CPropVariant::operator=(BSTR bstrSrc)
-{
- *this = (LPCOLESTR)bstrSrc;
- return *this;
-}
-
-CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc)
-{
- InternalClear();
- vt = VT_BSTR;
- bstrVal = ::SysAllocString(lpszSrc);
- if (bstrVal == NULL && lpszSrc != NULL)
- {
- vt = VT_ERROR;
- scode = E_OUTOFMEMORY;
- }
- return *this;
-}
-
-
-CPropVariant& CPropVariant::operator=(bool bSrc)
-{
- if (vt != VT_BOOL)
- {
- InternalClear();
- vt = VT_BOOL;
- }
- boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
- return *this;
-}
-
-CPropVariant& CPropVariant::operator=(UInt32 value)
-{
- if (vt != VT_UI4)
- {
- InternalClear();
- vt = VT_UI4;
- }
- ulVal = value;
- return *this;
-}
-
-CPropVariant& CPropVariant::operator=(UInt64 value)
-{
- if (vt != VT_UI8)
- {
- InternalClear();
- vt = VT_UI8;
- }
- uhVal.QuadPart = value;
- return *this;
-}
-
-CPropVariant& CPropVariant::operator=(const FILETIME &value)
-{
- if (vt != VT_FILETIME)
- {
- InternalClear();
- vt = VT_FILETIME;
- }
- filetime = value;
- return *this;
-}
-
-CPropVariant& CPropVariant::operator=(Int32 value)
-{
- if (vt != VT_I4)
- {
- InternalClear();
- vt = VT_I4;
- }
- lVal = value;
-
- return *this;
-}
-
-CPropVariant& CPropVariant::operator=(Byte value)
-{
- if (vt != VT_UI1)
- {
- InternalClear();
- vt = VT_UI1;
- }
- bVal = value;
- return *this;
-}
-
-CPropVariant& CPropVariant::operator=(Int16 value)
-{
- if (vt != VT_I2)
- {
- InternalClear();
- vt = VT_I2;
- }
- iVal = value;
- return *this;
-}
-
-/*
-CPropVariant& CPropVariant::operator=(LONG value)
-{
- if (vt != VT_I4)
- {
- InternalClear();
- vt = VT_I4;
- }
- lVal = value;
- return *this;
-}
-*/
-
-static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
-{
- switch(propVariant->vt)
- {
- case VT_UI1:
- case VT_I1:
- case VT_I2:
- case VT_UI2:
- case VT_BOOL:
- case VT_I4:
- case VT_UI4:
- case VT_R4:
- case VT_INT:
- case VT_UINT:
- case VT_ERROR:
- case VT_FILETIME:
- case VT_UI8:
- case VT_R8:
- case VT_CY:
- case VT_DATE:
- propVariant->vt = VT_EMPTY;
- return S_OK;
- }
- return ::VariantClear((VARIANTARG *)propVariant);
-}
-
-HRESULT CPropVariant::Clear()
-{
- return MyPropVariantClear(this);
-}
-
-HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
-{
- ::VariantClear((tagVARIANT *)this);
- switch(pSrc->vt)
- {
- case VT_UI1:
- case VT_I1:
- case VT_I2:
- case VT_UI2:
- case VT_BOOL:
- case VT_I4:
- case VT_UI4:
- case VT_R4:
- case VT_INT:
- case VT_UINT:
- case VT_ERROR:
- case VT_FILETIME:
- case VT_UI8:
- case VT_R8:
- case VT_CY:
- case VT_DATE:
- memmove((PROPVARIANT*)this, pSrc, sizeof(PROPVARIANT));
- return S_OK;
- }
- return ::VariantCopy((tagVARIANT *)this, (tagVARIANT *)(pSrc));
-}
-
-
-HRESULT CPropVariant::Attach(PROPVARIANT* pSrc)
-{
- HRESULT hr = Clear();
- if (FAILED(hr))
- return hr;
- memcpy(this, pSrc, sizeof(PROPVARIANT));
- pSrc->vt = VT_EMPTY;
- return S_OK;
-}
-
-HRESULT CPropVariant::Detach(PROPVARIANT* pDest)
-{
- HRESULT hr = MyPropVariantClear(pDest);
- if (FAILED(hr))
- return hr;
- memcpy(pDest, this, sizeof(PROPVARIANT));
- vt = VT_EMPTY;
- return S_OK;
-}
-
-HRESULT CPropVariant::InternalClear()
-{
- HRESULT hr = Clear();
- if (FAILED(hr))
- {
- vt = VT_ERROR;
- scode = hr;
- }
- return hr;
-}
-
-void CPropVariant::InternalCopy(const PROPVARIANT* pSrc)
-{
- HRESULT hr = Copy(pSrc);
- if (FAILED(hr))
- {
- vt = VT_ERROR;
- scode = hr;
- }
-}
-
-int CPropVariant::Compare(const CPropVariant &a)
-{
- if(vt != a.vt)
- return 0; // it's mean some bug
- switch (vt)
- {
- case VT_EMPTY:
- return 0;
-
- /*
- case VT_I1:
- return MyCompare(cVal, a.cVal);
- */
- case VT_UI1:
- return MyCompare(bVal, a.bVal);
-
- case VT_I2:
- return MyCompare(iVal, a.iVal);
- case VT_UI2:
- return MyCompare(uiVal, a.uiVal);
-
- case VT_I4:
- return MyCompare(lVal, a.lVal);
- /*
- case VT_INT:
- return MyCompare(intVal, a.intVal);
- */
- case VT_UI4:
- return MyCompare(ulVal, a.ulVal);
- /*
- case VT_UINT:
- return MyCompare(uintVal, a.uintVal);
- */
- case VT_I8:
- return MyCompare(hVal.QuadPart, a.hVal.QuadPart);
- case VT_UI8:
- return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart);
-
- case VT_BOOL:
- return -MyCompare(boolVal, a.boolVal);
-
- case VT_FILETIME:
- return ::CompareFileTime(&filetime, &a.filetime);
- case VT_BSTR:
- return 0; // Not implemented
- // return MyCompare(aPropVarint.cVal);
-
- default:
- return 0;
- }
-}
-
-}}
diff --git a/Windows/PropVariant.h b/Windows/PropVariant.h
deleted file mode 100755
index 71035073..00000000
--- a/Windows/PropVariant.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Windows/PropVariant.h
-
-#ifndef __WINDOWS_PROPVARIANT_H
-#define __WINDOWS_PROPVARIANT_H
-
-#include "../Common/MyWindows.h"
-#include "../Common/Types.h"
-
-namespace NWindows {
-namespace NCOM {
-
-class CPropVariant : public tagPROPVARIANT
-{
-public:
- CPropVariant() { vt = VT_EMPTY; }
- ~CPropVariant() { Clear(); }
- CPropVariant(const PROPVARIANT& varSrc);
- CPropVariant(const CPropVariant& varSrc);
- CPropVariant(BSTR bstrSrc);
- CPropVariant(LPCOLESTR lpszSrc);
- CPropVariant(bool bSrc) { vt = VT_BOOL; boolVal = (bSrc ? VARIANT_TRUE : VARIANT_FALSE); };
- CPropVariant(UInt32 value) { vt = VT_UI4; ulVal = value; }
- CPropVariant(UInt64 value) { vt = VT_UI8; uhVal = *(ULARGE_INTEGER*)&value; }
- CPropVariant(const FILETIME &value) { vt = VT_FILETIME; filetime = value; }
- CPropVariant(Int32 value) { vt = VT_I4; lVal = value; }
- CPropVariant(Byte value) { vt = VT_UI1; bVal = value; }
- CPropVariant(Int16 value) { vt = VT_I2; iVal = value; }
- // CPropVariant(LONG value, VARTYPE vtSrc = VT_I4) { vt = vtSrc; lVal = value; }
-
- CPropVariant& operator=(const CPropVariant& varSrc);
- CPropVariant& operator=(const PROPVARIANT& varSrc);
- CPropVariant& operator=(BSTR bstrSrc);
- CPropVariant& operator=(LPCOLESTR lpszSrc);
- CPropVariant& operator=(bool bSrc);
- CPropVariant& operator=(UInt32 value);
- CPropVariant& operator=(UInt64 value);
- CPropVariant& operator=(const FILETIME &value);
-
- CPropVariant& operator=(Int32 value);
- CPropVariant& operator=(Byte value);
- CPropVariant& operator=(Int16 value);
- // CPropVariant& operator=(LONG value);
-
- HRESULT Clear();
- HRESULT Copy(const PROPVARIANT* pSrc);
- HRESULT Attach(PROPVARIANT* pSrc);
- HRESULT Detach(PROPVARIANT* pDest);
-
- HRESULT InternalClear();
- void InternalCopy(const PROPVARIANT* pSrc);
-
- int Compare(const CPropVariant &a1);
-};
-
-}}
-
-#endif
diff --git a/Windows/Security.cpp b/Windows/Security.cpp
deleted file mode 100755
index 80cf15be..00000000
--- a/Windows/Security.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-// Windows/Security.h
-
-#include "StdAfx.h"
-
-#include "Windows/Security.h"
-#include "Windows/Defs.h"
-
-#include "Common/StringConvert.h"
-#include "Defs.h"
-
-namespace NWindows {
-namespace NSecurity {
-
-/*
-bool MyLookupAccountSid(LPCTSTR systemName, PSID sid,
- CSysString &accountName, CSysString &domainName, PSID_NAME_USE sidNameUse)
-{
- DWORD accountNameSize = 0, domainNameSize = 0;
-
- if (!::LookupAccountSid(systemName, sid,
- accountName.GetBuffer(0), &accountNameSize,
- domainName.GetBuffer(0), &domainNameSize, sidNameUse))
- {
- if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER)
- return false;
- }
- bool result = BOOLToBool(::LookupAccountSid(systemName, sid,
- accountName.GetBuffer(accountNameSize), &accountNameSize,
- domainName.GetBuffer(domainNameSize), &domainNameSize, sidNameUse));
- accountName.ReleaseBuffer();
- domainName.ReleaseBuffer();
- return result;
-}
-*/
-
-static void SetLsaString(LPWSTR src, PLSA_UNICODE_STRING dest)
-{
- int len = (int)wcslen(src);
- dest->Length = (USHORT)(len * sizeof(WCHAR));
- dest->MaximumLength = (USHORT)((len + 1) * sizeof(WCHAR));
- dest->Buffer = src;
-}
-
-/*
-static void MyLookupSids(CPolicy &policy, PSID ps)
-{
- LSA_REFERENCED_DOMAIN_LIST *referencedDomains = NULL;
- LSA_TRANSLATED_NAME *names = NULL;
- NTSTATUS nts = policy.LookupSids(1, &ps, &referencedDomains, &names);
- int res = LsaNtStatusToWinError(nts);
- LsaFreeMemory(referencedDomains);
- LsaFreeMemory(names);
-}
-*/
-
-#ifndef _UNICODE
-typedef BOOL (WINAPI * LookupAccountNameWP)(
- LPCWSTR lpSystemName,
- LPCWSTR lpAccountName,
- PSID Sid,
- LPDWORD cbSid,
- LPWSTR ReferencedDomainName,
- LPDWORD cchReferencedDomainName,
- PSID_NAME_USE peUse
- );
-#endif
-
-static PSID GetSid(LPWSTR accountName)
-{
- #ifndef _UNICODE
- HMODULE hModule = GetModuleHandle(TEXT("Advapi32.dll"));
- if (hModule == NULL)
- return NULL;
- LookupAccountNameWP lookupAccountNameW = (LookupAccountNameWP)GetProcAddress(hModule, "LookupAccountNameW");
- if (lookupAccountNameW == NULL)
- return NULL;
- #endif
-
- DWORD sidLen = 0, domainLen = 0;
- SID_NAME_USE sidNameUse;
- if (!
- #ifdef _UNICODE
- ::LookupAccountNameW
- #else
- lookupAccountNameW
- #endif
- (NULL, accountName, NULL, &sidLen, NULL, &domainLen, &sidNameUse))
- {
- if(::GetLastError() == ERROR_INSUFFICIENT_BUFFER)
- {
- PSID pSid = ::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sidLen);
- LPWSTR domainName = (LPWSTR)::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (domainLen + 1) * sizeof(WCHAR));
- BOOL res =
- #ifdef _UNICODE
- ::LookupAccountNameW
- #else
- lookupAccountNameW
- #endif
- (NULL, accountName, pSid, &sidLen, domainName, &domainLen, &sidNameUse);
- ::HeapFree(GetProcessHeap(), 0, domainName);
- if (res)
- return pSid;
- }
- }
- return NULL;
-}
-
-bool AddLockMemoryPrivilege()
-{
- CPolicy policy;
- LSA_OBJECT_ATTRIBUTES attr;
- attr.Length = sizeof(attr);
- attr.RootDirectory = NULL;
- attr.ObjectName = NULL;
- attr.Attributes = 0;
- attr.SecurityDescriptor = NULL;
- attr.SecurityQualityOfService = NULL;
- if (policy.Open(NULL, &attr,
- // GENERIC_WRITE)
- POLICY_ALL_ACCESS)
- // STANDARD_RIGHTS_REQUIRED,
- // GENERIC_READ | GENERIC_EXECUTE | POLICY_VIEW_LOCAL_INFORMATION | POLICY_LOOKUP_NAMES)
- != 0)
- return false;
- LSA_UNICODE_STRING userRights;
- UString s = GetUnicodeString(SE_LOCK_MEMORY_NAME);
- SetLsaString((LPWSTR)(LPCWSTR)s, &userRights);
- WCHAR userName[256 + 2];
- DWORD size = 256;
- if (!GetUserNameW(userName, &size))
- return false;
- PSID psid = GetSid(userName);
- if (psid == NULL)
- return false;
- bool res = false;
-
- /*
- PLSA_UNICODE_STRING userRightsArray;
- ULONG countOfRights;
- NTSTATUS status = policy.EnumerateAccountRights(psid, &userRightsArray, &countOfRights);
- if (status != 0)
- return false;
- bool finded = false;
- for (ULONG i = 0; i < countOfRights; i++)
- {
- LSA_UNICODE_STRING &ur = userRightsArray[i];
- if (ur.Length != s.Length() * sizeof(WCHAR))
- continue;
- if (wcsncmp(ur.Buffer, s, s.Length()) != 0)
- continue;
- finded = true;
- res = true;
- break;
- }
- if (!finded)
- */
- {
- /*
- LSA_ENUMERATION_INFORMATION *enums;
- ULONG countReturned;
- NTSTATUS status = policy.EnumerateAccountsWithUserRight(&userRights, &enums, &countReturned);
- if (status == 0)
- {
- for (ULONG i = 0; i < countReturned; i++)
- MyLookupSids(policy, enums[i].Sid);
- if (enums)
- ::LsaFreeMemory(enums);
- res = true;
- }
- */
- NTSTATUS status = policy.AddAccountRights(psid, &userRights);
- if (status == 0)
- res = true;
- // ULONG res = LsaNtStatusToWinError(status);
- }
- HeapFree(GetProcessHeap(), 0, psid);
- return res;
-}
-
-}}
-
diff --git a/Windows/Thread.h b/Windows/Thread.h
deleted file mode 100755
index 8ecc13f1..00000000
--- a/Windows/Thread.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Windows/Thread.h
-
-#ifndef __WINDOWS_THREAD_H
-#define __WINDOWS_THREAD_H
-
-#include "Handle.h"
-#include "Defs.h"
-
-namespace NWindows {
-
-class CThread: public CHandle
-{
- bool IsOpen() const { return _handle != 0; }
-public:
- bool Create(LPSECURITY_ATTRIBUTES threadAttributes,
- SIZE_T stackSize, LPTHREAD_START_ROUTINE startAddress,
- LPVOID parameter, DWORD creationFlags, LPDWORD threadId)
- {
- _handle = ::CreateThread(threadAttributes, stackSize, startAddress,
- parameter, creationFlags, threadId);
- return (_handle != NULL);
- }
- bool Create(LPTHREAD_START_ROUTINE startAddress, LPVOID parameter)
- {
- DWORD threadId;
- return Create(NULL, 0, startAddress, parameter, 0, &threadId);
- }
-
- DWORD Resume()
- { return ::ResumeThread(_handle); }
- DWORD Suspend()
- { return ::SuspendThread(_handle); }
- bool Terminate(DWORD exitCode)
- { return BOOLToBool(::TerminateThread(_handle, exitCode)); }
-
- int GetPriority()
- { return ::GetThreadPriority(_handle); }
- bool SetPriority(int priority)
- { return BOOLToBool(::SetThreadPriority(_handle, priority)); }
-
- bool Wait()
- {
- if (!IsOpen())
- return true;
- return (::WaitForSingleObject(_handle, INFINITE) == WAIT_OBJECT_0);
- }
-
-};
-
-}
-
-#endif