From 3901bf0ab88106a5b031cba7bc18d60cdebf7eef Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Mon, 5 May 2008 00:00:00 +0000 Subject: 4.58 beta --- CPP/7zip/Archive/7z/7z.dsp | 644 --------- CPP/7zip/Archive/7z/7z.dsw | 29 - CPP/7zip/Archive/7z/7zIn.cpp | 14 +- CPP/7zip/Archive/7z/7zProperties.cpp | 9 +- CPP/7zip/Archive/7z/makefile | 111 -- CPP/7zip/Archive/7z/resource.rc | 5 - CPP/7zip/Archive/ArchiveExports.cpp | 4 +- CPP/7zip/Archive/Arj/ArjIn.cpp | 8 +- CPP/7zip/Archive/BZip2/BZip2Handler.cpp | 11 +- CPP/7zip/Archive/Cab/CabBlockInStream.cpp | 20 +- CPP/7zip/Archive/Chm/ChmHandler.cpp | 2 +- CPP/7zip/Archive/Com/ComHandler.cpp | 8 +- CPP/7zip/Archive/Com/ComIn.cpp | 22 +- CPP/7zip/Archive/Common/CoderMixer2MT.cpp | 6 +- CPP/7zip/Archive/Common/CoderMixerMT.cpp | 6 +- CPP/7zip/Archive/Common/HandlerOut.cpp | 32 +- CPP/7zip/Archive/Common/ParseProperties.cpp | 7 +- CPP/7zip/Archive/Cpio/CpioIn.cpp | 7 +- CPP/7zip/Archive/Deb/DebIn.cpp | 21 +- CPP/7zip/Archive/Deb/DebIn.h | 1 - CPP/7zip/Archive/GZip/GZipIn.cpp | 7 +- CPP/7zip/Archive/GZip/GZipOut.cpp | 6 +- CPP/7zip/Archive/Iso/IsoIn.cpp | 14 +- CPP/7zip/Archive/Iso/IsoIn.h | 1 - CPP/7zip/Archive/Iso/IsoItem.h | 4 +- CPP/7zip/Archive/Lzh/LzhIn.cpp | 4 +- CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp | 14 + CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp | 86 ++ CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h | 26 + CPP/7zip/Archive/Lzma/LzmaHandler.cpp | 243 ++++ CPP/7zip/Archive/Lzma/LzmaHandler.h | 69 + CPP/7zip/Archive/Lzma/LzmaIn.cpp | 56 + CPP/7zip/Archive/Lzma/LzmaIn.h | 16 + CPP/7zip/Archive/Lzma/LzmaItem.h | 27 + CPP/7zip/Archive/Lzma/StdAfx.h | 8 + CPP/7zip/Archive/Lzma/lzma.ico | Bin 0 -> 3638 bytes CPP/7zip/Archive/Nsis/NsisDecode.cpp | 4 +- CPP/7zip/Archive/Nsis/NsisDecode.h | 2 +- CPP/7zip/Archive/Nsis/NsisHandler.cpp | 32 +- CPP/7zip/Archive/Nsis/NsisIn.cpp | 232 +++- CPP/7zip/Archive/Nsis/NsisIn.h | 53 +- CPP/7zip/Archive/RPM/RpmHandler.cpp | 30 +- CPP/7zip/Archive/RPM/RpmHandler.h | 1 + CPP/7zip/Archive/RPM/RpmIn.cpp | 10 +- CPP/7zip/Archive/RPM/RpmRegister.cpp | 2 +- CPP/7zip/Archive/Rar/RarHandler.cpp | 13 +- CPP/7zip/Archive/Rar/RarIn.cpp | 21 +- CPP/7zip/Archive/Rar/RarIn.h | 2 - CPP/7zip/Archive/Tar/TarHeader.h | 9 + CPP/7zip/Archive/Tar/TarIn.cpp | 23 +- CPP/7zip/Archive/Tar/TarIn.h | 2 +- CPP/7zip/Archive/Tar/TarItem.h | 16 +- CPP/7zip/Archive/Tar/TarOut.cpp | 6 +- CPP/7zip/Archive/Wim/WimHandler.cpp | 4 +- CPP/7zip/Archive/Wim/WimIn.cpp | 81 +- CPP/7zip/Archive/Z/ZHandler.cpp | 5 +- CPP/7zip/Archive/Zip/ZipAddCommon.cpp | 2 +- CPP/7zip/Archive/Zip/ZipHandler.cpp | 64 +- CPP/7zip/Archive/Zip/ZipHandler.h | 7 + CPP/7zip/Archive/Zip/ZipHandlerOut.cpp | 171 ++- CPP/7zip/Archive/Zip/ZipHeader.h | 18 +- CPP/7zip/Archive/Zip/ZipIn.cpp | 12 +- CPP/7zip/Archive/Zip/ZipItem.cpp | 34 + CPP/7zip/Archive/Zip/ZipItem.h | 48 +- CPP/7zip/Archive/Zip/ZipOut.cpp | 17 +- CPP/7zip/Archive/Zip/ZipUpdate.cpp | 14 +- CPP/7zip/Archive/Zip/ZipUpdate.h | 8 +- CPP/7zip/Bundles/Alone/Alone.dsp | 458 +++++-- CPP/7zip/Bundles/Alone/makefile | 60 +- CPP/7zip/Bundles/Alone7z/Alone.dsp | 1453 --------------------- CPP/7zip/Bundles/Alone7z/Alone.dsw | 29 - CPP/7zip/Bundles/Alone7z/makefile | 62 +- CPP/7zip/Bundles/Format7z/makefile | 44 +- CPP/7zip/Bundles/Format7zExtract/makefile | 35 +- CPP/7zip/Bundles/Format7zExtractR/makefile | 31 +- CPP/7zip/Bundles/Format7zF/Format7z.dsp | 393 +++--- CPP/7zip/Bundles/Format7zF/makefile | 61 +- CPP/7zip/Bundles/Format7zF/resource.rc | 3 +- CPP/7zip/Bundles/Format7zR/makefile | 45 +- CPP/7zip/Bundles/SFXCon/SFXCon.dsp | 46 +- CPP/7zip/Bundles/SFXCon/makefile | 24 +- CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp | 25 +- CPP/7zip/Bundles/SFXSetup/makefile | 12 +- CPP/7zip/Bundles/SFXWin/Main.cpp | 2 + CPP/7zip/Bundles/SFXWin/SFXWin.dsp | 46 +- CPP/7zip/Bundles/SFXWin/makefile | 24 +- CPP/7zip/Common/FileStreams.cpp | 2 +- CPP/7zip/Common/FilterCoder.cpp | 26 +- CPP/7zip/Common/InOutTempBuffer.cpp | 4 +- CPP/7zip/Common/MemBlocks.cpp | 7 +- CPP/7zip/Common/StreamObjects.cpp | 34 +- CPP/7zip/Common/StreamUtils.cpp | 44 +- CPP/7zip/Common/StreamUtils.h | 6 +- CPP/7zip/Common/VirtThread.cpp | 2 +- CPP/7zip/Common/VirtThread.h | 2 +- CPP/7zip/Compress/Arj/ArjDecoder1.cpp | 4 +- CPP/7zip/Compress/Arj/ArjDecoder1.h | 8 +- CPP/7zip/Compress/Arj/ArjDecoder2.cpp | 4 +- CPP/7zip/Compress/Arj/ArjDecoder2.h | 7 +- CPP/7zip/Compress/BWT/BlockSort.cpp | 486 ------- CPP/7zip/Compress/BWT/BlockSort.h | 21 - CPP/7zip/Compress/BZip2/BZip2.dsp | 316 ----- CPP/7zip/Compress/BZip2/BZip2.dsw | 29 - CPP/7zip/Compress/BZip2/BZip2Decoder.cpp | 30 +- CPP/7zip/Compress/BZip2/BZip2Decoder.h | 12 +- CPP/7zip/Compress/BZip2/BZip2Encoder.cpp | 38 +- CPP/7zip/Compress/BZip2/BZip2Encoder.h | 10 +- CPP/7zip/Compress/BZip2/makefile | 58 - CPP/7zip/Compress/BZip2/resource.rc | 3 - CPP/7zip/Compress/Branch/ARM.cpp | 19 - CPP/7zip/Compress/Branch/ARM.h | 10 - CPP/7zip/Compress/Branch/ARMThumb.cpp | 20 - CPP/7zip/Compress/Branch/ARMThumb.h | 10 - CPP/7zip/Compress/Branch/Branch.dsp | 433 ------- CPP/7zip/Compress/Branch/Branch.dsw | 29 - CPP/7zip/Compress/Branch/BranchMisc.cpp | 39 + CPP/7zip/Compress/Branch/BranchMisc.h | 14 + CPP/7zip/Compress/Branch/BranchRegister.cpp | 20 +- CPP/7zip/Compress/Branch/IA64.cpp | 19 - CPP/7zip/Compress/Branch/IA64.h | 10 - CPP/7zip/Compress/Branch/PPC.cpp | 19 - CPP/7zip/Compress/Branch/PPC.h | 10 - CPP/7zip/Compress/Branch/SPARC.cpp | 19 - CPP/7zip/Compress/Branch/SPARC.h | 10 - CPP/7zip/Compress/Branch/makefile | 63 - CPP/7zip/Compress/Branch/resource.rc | 3 - CPP/7zip/Compress/Branch/x86.h | 2 +- CPP/7zip/Compress/ByteSwap/ByteSwap.dsp | 133 -- CPP/7zip/Compress/ByteSwap/ByteSwap.dsw | 29 - CPP/7zip/Compress/ByteSwap/makefile | 25 - CPP/7zip/Compress/ByteSwap/resource.rc | 3 - CPP/7zip/Compress/CodecExports.cpp | 4 +- CPP/7zip/Compress/Copy/Copy.dsp | 158 --- CPP/7zip/Compress/Copy/Copy.dsw | 29 - CPP/7zip/Compress/Copy/CopyCoder.cpp | 2 +- CPP/7zip/Compress/Copy/makefile | 37 - CPP/7zip/Compress/Copy/resource.rc | 3 - CPP/7zip/Compress/Deflate/Deflate.dsp | 350 ----- CPP/7zip/Compress/Deflate/Deflate.dsw | 29 - CPP/7zip/Compress/Deflate/DeflateEncoder.cpp | 64 +- CPP/7zip/Compress/Deflate/DeflateEncoder.h | 4 +- CPP/7zip/Compress/Deflate/makefile | 63 - CPP/7zip/Compress/Deflate/resource.rc | 3 - CPP/7zip/Compress/Huffman/HuffmanDecoder.h | 3 +- CPP/7zip/Compress/LZMA/LZMA.dsp | 367 ------ CPP/7zip/Compress/LZMA/LZMA.dsw | 29 - CPP/7zip/Compress/LZMA/LZMA.h | 82 -- CPP/7zip/Compress/LZMA/LZMADecoder.cpp | 426 ++---- CPP/7zip/Compress/LZMA/LZMADecoder.h | 208 +-- CPP/7zip/Compress/LZMA/LZMAEncoder.cpp | 1512 ++-------------------- CPP/7zip/Compress/LZMA/LZMAEncoder.h | 415 +----- CPP/7zip/Compress/LZMA/makefile | 70 - CPP/7zip/Compress/LZMA/resource.rc | 3 - CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp | 76 +- CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp | 72 +- CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp | 10 +- CPP/7zip/Compress/LZMA_Alone/LzmaRam.cpp | 226 ---- CPP/7zip/Compress/LZMA_Alone/LzmaRam.h | 46 - CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.c | 78 -- CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.h | 55 - CPP/7zip/Compress/LZMA_Alone/makefile | 85 +- CPP/7zip/Compress/LZMA_Alone/makefile.gcc | 44 +- CPP/7zip/Compress/Lzx/LzxDecoder.cpp | 12 +- CPP/7zip/Compress/Lzx/LzxDecoder.h | 8 +- CPP/7zip/Compress/PPMD/PPMD.dsp | 242 ---- CPP/7zip/Compress/PPMD/PPMD.dsw | 29 - CPP/7zip/Compress/PPMD/PPMDEncoder.cpp | 2 +- CPP/7zip/Compress/PPMD/makefile | 43 - CPP/7zip/Compress/PPMD/resource.rc | 3 - CPP/7zip/Compress/RangeCoder/RangeCoder.h | 7 +- CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp | 72 +- CPP/7zip/Compress/RangeCoder/RangeCoderBit.h | 19 +- CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h | 4 +- CPP/7zip/Compress/Rar/Rar29.dsp | 8 +- CPP/7zip/Compress/Rar/Rar2Decoder.cpp | 14 +- CPP/7zip/Compress/Rar/Rar2Decoder.h | 8 +- CPP/7zip/Compress/Rar/Rar3Decoder.cpp | 6 +- CPP/7zip/Compress/Rar/Rar3Vm.h | 46 +- CPP/7zip/Compress/Rar/makefile | 2 +- CPP/7zip/Crypto/7zAES/7zAES.cpp | 29 +- CPP/7zip/Crypto/AES/MyAES.cpp | 12 +- CPP/7zip/Crypto/AES/MyAES.h | 2 +- CPP/7zip/Crypto/Hash/RotateDefs.h | 19 - CPP/7zip/Crypto/Hash/Sha1.cpp | 5 +- CPP/7zip/Crypto/Hash/Sha256.cpp | 210 --- CPP/7zip/Crypto/Hash/Sha256.h | 30 - CPP/7zip/Crypto/RarAES/RarAES.cpp | 6 +- CPP/7zip/Crypto/RarAES/RarAES.h | 2 +- CPP/7zip/Crypto/WzAES/WzAES.cpp | 37 +- CPP/7zip/Crypto/WzAES/WzAES.h | 2 +- CPP/7zip/Crypto/Zip/ZipCipher.cpp | 11 +- CPP/7zip/ICoder.h | 1 + CPP/7zip/MyVersion.h | 12 +- CPP/7zip/PropID.h | 1 + CPP/7zip/UI/Agent/AgentOut.cpp | 7 +- CPP/7zip/UI/Agent/AgentProxy.cpp | 13 + CPP/7zip/UI/Client7z/Client7z.cpp | 8 +- CPP/7zip/UI/Common/ArchiveExtractCallback.h | 2 +- CPP/7zip/UI/Common/DirItem.h | 13 +- CPP/7zip/UI/Common/LoadCodecs.cpp | 10 +- CPP/7zip/UI/Common/LoadCodecs.h | 8 +- CPP/7zip/UI/Common/OpenArchive.cpp | 25 +- CPP/7zip/UI/Common/SetProperties.cpp | 18 +- CPP/7zip/UI/Common/Update.cpp | 51 +- CPP/7zip/UI/Common/UpdatePair.cpp | 24 +- CPP/7zip/UI/Console/List.cpp | 11 +- CPP/7zip/UI/Console/Main.cpp | 4 +- CPP/7zip/UI/Console/MainAr.cpp | 6 +- CPP/7zip/UI/Console/UpdateCallbackConsole.cpp | 2 - CPP/7zip/UI/Explorer/ContextMenu.cpp | 2 +- CPP/7zip/UI/Far/ExtractEngine.cpp | 4 +- CPP/7zip/UI/Far/Plugin.cpp | 15 +- CPP/7zip/UI/FileManager/App.cpp | 19 + CPP/7zip/UI/FileManager/ExtractCallback.cpp | 4 +- CPP/7zip/UI/FileManager/FM.cpp | 34 +- CPP/7zip/UI/FileManager/Panel.cpp | 2 +- CPP/7zip/UI/FileManager/PanelItemOpen.cpp | 7 +- CPP/7zip/UI/FileManager/PanelListNotify.cpp | 95 +- CPP/7zip/UI/FileManager/ProgressDialog2.rc | 2 +- CPP/7zip/UI/GUI/CompressDialog.cpp | 19 +- CPP/Build.mak | 17 +- CPP/Common/CRC.cpp | 6 +- CPP/Common/ListFileUtils.cpp | 1 + CPP/Common/StringConvert.cpp | 28 +- CPP/Common/StringConvert.h | 2 + CPP/Common/Types.h | 50 +- CPP/Windows/PropVariantConversions.cpp | 5 + CPP/Windows/Synchronization.h | 40 +- CPP/Windows/Thread.h | 6 +- 229 files changed, 3018 insertions(+), 10435 deletions(-) delete mode 100755 CPP/7zip/Archive/7z/7z.dsp delete mode 100755 CPP/7zip/Archive/7z/7z.dsw delete mode 100755 CPP/7zip/Archive/7z/makefile delete mode 100755 CPP/7zip/Archive/7z/resource.rc create mode 100755 CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp create mode 100755 CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp create mode 100755 CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h create mode 100755 CPP/7zip/Archive/Lzma/LzmaHandler.cpp create mode 100755 CPP/7zip/Archive/Lzma/LzmaHandler.h create mode 100755 CPP/7zip/Archive/Lzma/LzmaIn.cpp create mode 100755 CPP/7zip/Archive/Lzma/LzmaIn.h create mode 100755 CPP/7zip/Archive/Lzma/LzmaItem.h create mode 100755 CPP/7zip/Archive/Lzma/StdAfx.h create mode 100755 CPP/7zip/Archive/Lzma/lzma.ico delete mode 100755 CPP/7zip/Bundles/Alone7z/Alone.dsp delete mode 100755 CPP/7zip/Bundles/Alone7z/Alone.dsw delete mode 100755 CPP/7zip/Compress/BWT/BlockSort.cpp delete mode 100755 CPP/7zip/Compress/BWT/BlockSort.h delete mode 100755 CPP/7zip/Compress/BZip2/BZip2.dsp delete mode 100755 CPP/7zip/Compress/BZip2/BZip2.dsw delete mode 100755 CPP/7zip/Compress/BZip2/makefile delete mode 100755 CPP/7zip/Compress/BZip2/resource.rc delete mode 100755 CPP/7zip/Compress/Branch/ARM.cpp delete mode 100755 CPP/7zip/Compress/Branch/ARM.h delete mode 100755 CPP/7zip/Compress/Branch/ARMThumb.cpp delete mode 100755 CPP/7zip/Compress/Branch/ARMThumb.h delete mode 100755 CPP/7zip/Compress/Branch/Branch.dsp delete mode 100755 CPP/7zip/Compress/Branch/Branch.dsw create mode 100755 CPP/7zip/Compress/Branch/BranchMisc.cpp create mode 100755 CPP/7zip/Compress/Branch/BranchMisc.h delete mode 100755 CPP/7zip/Compress/Branch/IA64.cpp delete mode 100755 CPP/7zip/Compress/Branch/IA64.h delete mode 100755 CPP/7zip/Compress/Branch/PPC.cpp delete mode 100755 CPP/7zip/Compress/Branch/PPC.h delete mode 100755 CPP/7zip/Compress/Branch/SPARC.cpp delete mode 100755 CPP/7zip/Compress/Branch/SPARC.h delete mode 100755 CPP/7zip/Compress/Branch/makefile delete mode 100755 CPP/7zip/Compress/Branch/resource.rc delete mode 100755 CPP/7zip/Compress/ByteSwap/ByteSwap.dsp delete mode 100755 CPP/7zip/Compress/ByteSwap/ByteSwap.dsw delete mode 100755 CPP/7zip/Compress/ByteSwap/makefile delete mode 100755 CPP/7zip/Compress/ByteSwap/resource.rc delete mode 100755 CPP/7zip/Compress/Copy/Copy.dsp delete mode 100755 CPP/7zip/Compress/Copy/Copy.dsw delete mode 100755 CPP/7zip/Compress/Copy/makefile delete mode 100755 CPP/7zip/Compress/Copy/resource.rc delete mode 100755 CPP/7zip/Compress/Deflate/Deflate.dsp delete mode 100755 CPP/7zip/Compress/Deflate/Deflate.dsw delete mode 100755 CPP/7zip/Compress/Deflate/makefile delete mode 100755 CPP/7zip/Compress/Deflate/resource.rc delete mode 100755 CPP/7zip/Compress/LZMA/LZMA.dsp delete mode 100755 CPP/7zip/Compress/LZMA/LZMA.dsw delete mode 100755 CPP/7zip/Compress/LZMA/LZMA.h delete mode 100755 CPP/7zip/Compress/LZMA/makefile delete mode 100755 CPP/7zip/Compress/LZMA/resource.rc delete mode 100755 CPP/7zip/Compress/LZMA_Alone/LzmaRam.cpp delete mode 100755 CPP/7zip/Compress/LZMA_Alone/LzmaRam.h delete mode 100755 CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.c delete mode 100755 CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.h delete mode 100755 CPP/7zip/Compress/PPMD/PPMD.dsp delete mode 100755 CPP/7zip/Compress/PPMD/PPMD.dsw delete mode 100755 CPP/7zip/Compress/PPMD/makefile delete mode 100755 CPP/7zip/Compress/PPMD/resource.rc delete mode 100755 CPP/7zip/Crypto/Hash/RotateDefs.h delete mode 100755 CPP/7zip/Crypto/Hash/Sha256.cpp delete mode 100755 CPP/7zip/Crypto/Hash/Sha256.h (limited to 'CPP') diff --git a/CPP/7zip/Archive/7z/7z.dsp b/CPP/7zip/Archive/7z/7z.dsp deleted file mode 100755 index fc4c3698..00000000 --- a/CPP/7zip/Archive/7z/7z.dsp +++ /dev/null @@ -1,644 +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 "7z.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "7z.mak" CFG="7z - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "7z - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "7z - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "7z - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-zip\Formats\7z.dll" /opt:NOWIN98 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "7z - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-zip\Formats\7z.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "7z - Win32 Release" -# Name "7z - Win32 Debug" -# Begin Group "Spec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\Archive.def -# End Source File -# Begin Source File - -SOURCE=..\ArchiveExports.cpp -# End Source File -# Begin Source File - -SOURCE=..\DllExports.cpp -# End Source File -# Begin Source File - -SOURCE=.\resource.rc -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"StdAfx.h" -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Group "Engine" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\7zCompressionMode.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zCompressionMode.h -# End Source File -# Begin Source File - -SOURCE=.\7zDecode.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zDecode.h -# End Source File -# Begin Source File - -SOURCE=.\7zEncode.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zEncode.h -# End Source File -# Begin Source File - -SOURCE=.\7zExtract.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zFolderInStream.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zFolderInStream.h -# End Source File -# Begin Source File - -SOURCE=.\7zFolderOutStream.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zFolderOutStream.h -# End Source File -# Begin Source File - -SOURCE=.\7zHandler.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zHandler.h -# End Source File -# Begin Source File - -SOURCE=.\7zHandlerOut.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zHeader.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zHeader.h -# End Source File -# Begin Source File - -SOURCE=.\7zIn.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zIn.h -# End Source File -# Begin Source File - -SOURCE=.\7zItem.h -# End Source File -# Begin Source File - -SOURCE=.\7zOut.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zOut.h -# End Source File -# Begin Source File - -SOURCE=.\7zProperties.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zProperties.h -# End Source File -# Begin Source File - -SOURCE=.\7zRegister.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zSpecStream.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zSpecStream.h -# End Source File -# Begin Source File - -SOURCE=.\7zUpdate.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zUpdate.h -# End Source File -# End Group -# Begin Group "Interface" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\IArchive.h -# End Source File -# Begin Source File - -SOURCE=..\..\ICoder.h -# End Source File -# Begin Source File - -SOURCE=..\..\IMyUnknown.h -# End Source File -# Begin Source File - -SOURCE=..\..\IPassword.h -# End Source File -# Begin Source File - -SOURCE=..\..\IProgress.h -# End Source File -# Begin Source File - -SOURCE=..\..\IStream.h -# End Source File -# Begin Source File - -SOURCE=..\..\PropID.h -# End Source File -# End Group -# Begin Group "Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\Common\Buffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\CRC.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\DynamicBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\IntToString.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\IntToString.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyString.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyString.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyVector.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyVector.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\NewHandler.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\NewHandler.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\StringConvert.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\StringConvert.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\StringToInt.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\StringToInt.h -# End Source File -# End Group -# Begin Group "Archive Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\Common\CoderMixer2.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\CoderMixer2.h -# End Source File -# Begin Source File - -SOURCE=..\Common\CoderMixer2MT.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\CoderMixer2MT.h -# End Source File -# Begin Source File - -SOURCE=..\Common\CrossThreadProgress.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\CrossThreadProgress.h -# End Source File -# Begin Source File - -SOURCE=..\Common\HandlerOut.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\HandlerOut.h -# End Source File -# Begin Source File - -SOURCE=..\Common\InStreamWithCRC.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\InStreamWithCRC.h -# End Source File -# Begin Source File - -SOURCE=..\Common\ItemNameUtils.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\ItemNameUtils.h -# End Source File -# Begin Source File - -SOURCE=..\Common\MultiStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\MultiStream.h -# End Source File -# Begin Source File - -SOURCE=..\Common\OutStreamWithCRC.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\OutStreamWithCRC.h -# End Source File -# Begin Source File - -SOURCE=..\Common\ParseProperties.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\ParseProperties.h -# End Source File -# End Group -# Begin Group "7-Zip Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Common\CreateCoder.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\CreateCoder.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\FilterCoder.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\FilterCoder.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\InOutTempBuffer.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\InOutTempBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\LimitedStreams.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\LimitedStreams.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\LockedStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\LockedStream.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\MethodId.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\MethodId.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\MethodProps.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\MethodProps.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\OutBuffer.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\OutBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\ProgressUtils.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\ProgressUtils.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\RegisterArc.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\RegisterCodec.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamBinder.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamBinder.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamObjects.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamObjects.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamUtils.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamUtils.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\VirtThread.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\VirtThread.h -# End Source File -# End Group -# Begin Group "Windows" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\Windows\DLL.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\DLL.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\FileDir.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\FileDir.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\FileFind.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\FileFind.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\FileIO.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\FileIO.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\FileName.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\Handle.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\PropVariant.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\PropVariant.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\Synchronization.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\Synchronization.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\System.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\System.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\Thread.h -# End Source File -# End Group -# Begin Group "Compress" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Compress\Copy\CopyCoder.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Copy\CopyCoder.h -# End Source File -# End Group -# Begin Group "C" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\..\C\7zCrc.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\7zCrc.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Threads.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Threads.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\7z.ico -# End Source File -# End Target -# End Project diff --git a/CPP/7zip/Archive/7z/7z.dsw b/CPP/7zip/Archive/7z/7z.dsw deleted file mode 100755 index 702a86c7..00000000 --- a/CPP/7zip/Archive/7z/7z.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: "7z"=".\7z.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp index a4292545..f892e0cd 100755 --- a/CPP/7zip/Archive/7z/7zIn.cpp +++ b/CPP/7zip/Archive/7z/7zIn.cpp @@ -9,6 +9,7 @@ extern "C" { #include "../../../../C/7zCrc.h" +#include "../../../../C/CpuArch.h" } // define FORMAT_7Z_RECOVERY if you want to recover multivolume archives with empty StartHeader @@ -96,11 +97,7 @@ void CStreamSwitch::Set(CInArchive *archive, const CObjectVector *d } } -#if defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(__i386__) || defined(__x86_64__) -#define SZ_LITTLE_ENDIAN_UNALIGN -#endif - -#ifdef SZ_LITTLE_ENDIAN_UNALIGN +#ifdef LITTLE_ENDIAN_UNALIGN static inline UInt16 GetUInt16FromMem(const Byte *p) { return *(const UInt16 *)p; } static inline UInt32 GetUInt32FromMem(const Byte *p) { return *(const UInt32 *)p; } static inline UInt64 GetUInt64FromMem(const Byte *p) { return *(const UInt64 *)p; } @@ -220,10 +217,8 @@ static inline bool TestSignatureCandidate(const Byte *p) HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit) { - UInt32 processedSize; - RINOK(ReadStream(stream, _header, kHeaderSize, &processedSize)); - if (processedSize != kHeaderSize) - return S_FALSE; + RINOK(ReadStream_FALSE(stream, _header, kHeaderSize)); + if (TestSignatureCandidate(_header)) return S_OK; @@ -240,6 +235,7 @@ HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *search if (curTestPos - _arhiveBeginStreamPosition > *searchHeaderSizeLimit) break; UInt32 numReadBytes = kBufferSize - numPrevBytes; + UInt32 processedSize; RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize)); UInt32 numBytesInBuffer = numPrevBytes + processedSize; if (numBytesInBuffer < kHeaderSize) diff --git a/CPP/7zip/Archive/7z/7zProperties.cpp b/CPP/7zip/Archive/7z/7zProperties.cpp index 3452a030..f5b5ba98 100755 --- a/CPP/7zip/Archive/7z/7zProperties.cpp +++ b/CPP/7zip/Archive/7z/7zProperties.cpp @@ -40,8 +40,9 @@ CPropMap kPropMap[] = { NID::kCRC, NULL, kpidCRC, VT_UI4}, { NID::kAnti, NULL, kpidIsAnti, VT_BOOL}, - // { 97, NULL, kpidSolid, VT_BOOL}, + #ifndef _SFX + { 97, NULL, kpidEncrypted, VT_BOOL}, { 98, NULL, kpidMethod, VT_BSTR}, { 99, NULL, kpidBlock, VT_UI4} #endif @@ -119,6 +120,7 @@ void CHandler::FillPopIDs() _fileInfoPopIDs += fileInfoPopIDs; #ifndef _SFX + _fileInfoPopIDs.Add(97); _fileInfoPopIDs.Add(98); _fileInfoPopIDs.Add(99); #endif @@ -144,10 +146,9 @@ STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties) return S_OK; } -STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, - BSTR *name, PROPID *propID, VARTYPE *varType) +STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) { - if((int)index >= _fileInfoPopIDs.Size()) + if ((int)index >= _fileInfoPopIDs.Size()) return E_INVALIDARG; int indexInMap = FindPropInMap(_fileInfoPopIDs[index]); if (indexInMap == -1) diff --git a/CPP/7zip/Archive/7z/makefile b/CPP/7zip/Archive/7z/makefile deleted file mode 100755 index 1a72da0e..00000000 --- a/CPP/7zip/Archive/7z/makefile +++ /dev/null @@ -1,111 +0,0 @@ -PROG = 7z.dll -DEF_FILE = ../Archive.def -CFLAGS = $(CFLAGS) -I ../../../ \ - -DCOMPRESS_MT \ - -DEXTERNAL_CODECS \ - -LIBS = $(LIBS) oleaut32.lib user32.lib - -AR_OBJS = \ - $O\ArchiveExports.obj \ - $O\DllExports.obj \ - -7Z_OBJS = \ - $O\7zCompressionMode.obj \ - $O\7zDecode.obj \ - $O\7zEncode.obj \ - $O\7zExtract.obj \ - $O\7zFolderInStream.obj \ - $O\7zFolderOutStream.obj \ - $O\7zHandler.obj \ - $O\7zHandlerOut.obj \ - $O\7zHeader.obj \ - $O\7zIn.obj \ - $O\7zOut.obj \ - $O\7zProperties.obj \ - $O\7zSpecStream.obj \ - $O\7zUpdate.obj \ - $O\7zRegister.obj \ - -COMMON_OBJS = \ - $O\CRC.obj \ - $O\IntToString.obj \ - $O\NewHandler.obj \ - $O\MyString.obj \ - $O\StringConvert.obj \ - $O\StringToInt.obj \ - $O\MyVector.obj \ - -WIN_OBJS = \ - $O\DLL.obj \ - $O\FileDir.obj \ - $O\FileFind.obj \ - $O\FileIO.obj \ - $O\PropVariant.obj \ - $O\Synchronization.obj \ - $O\System.obj \ - -7ZIP_COMMON_OBJS = \ - $O\CreateCoder.obj \ - $O\InOutTempBuffer.obj \ - $O\FilterCoder.obj \ - $O\LimitedStreams.obj \ - $O\LockedStream.obj \ - $O\MethodId.obj \ - $O\MethodProps.obj \ - $O\OutBuffer.obj \ - $O\ProgressUtils.obj \ - $O\StreamBinder.obj \ - $O\StreamObjects.obj \ - $O\StreamUtils.obj \ - $O\VirtThread.obj \ - -AR_COMMON_OBJS = \ - $O\CoderMixer2.obj \ - $O\CoderMixer2MT.obj \ - $O\CrossThreadProgress.obj \ - $O\HandlerOut.obj \ - $O\InStreamWithCRC.obj \ - $O\ItemNameUtils.obj \ - $O\MultiStream.obj \ - $O\OutStreamWithCRC.obj \ - $O\ParseProperties.obj \ - -C_OBJS = \ - $O\Alloc.obj \ - $O\Threads.obj \ - -!include "../../Crc2.mak" - -OBJS = \ - $O\StdAfx.obj \ - $(AR_OBJS) \ - $(7Z_OBJS) \ - $(COMMON_OBJS) \ - $(WIN_OBJS) \ - $(7ZIP_COMMON_OBJS) \ - $(AR_COMMON_OBJS) \ - $O\CopyCoder.obj \ - $(C_OBJS) \ - $(CRC_OBJS) \ - $O\resource.res - -!include "../../../Build.mak" - -$(AR_OBJS): ../$(*B).cpp - $(COMPL) -$(7Z_OBJS): $(*B).cpp - $(COMPL) -$(COMMON_OBJS): ../../../Common/$(*B).cpp - $(COMPL) -$(WIN_OBJS): ../../../Windows/$(*B).cpp - $(COMPL) -$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp - $(COMPL) -$(AR_COMMON_OBJS): ../Common/$(*B).cpp - $(COMPL) -$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp - $(COMPL) -$(C_OBJS): ../../../../C/$(*B).c - $(COMPL_O2) -!include "../../Crc.mak" diff --git a/CPP/7zip/Archive/7z/resource.rc b/CPP/7zip/Archive/7z/resource.rc deleted file mode 100755 index 8868173c..00000000 --- a/CPP/7zip/Archive/7z/resource.rc +++ /dev/null @@ -1,5 +0,0 @@ -#include "../../MyVersionInfo.rc" - -MY_VERSION_INFO_DLL("7z Plugin", "7z") - -101 ICON "7z.ico" diff --git a/CPP/7zip/Archive/ArchiveExports.cpp b/CPP/7zip/Archive/ArchiveExports.cpp index a60303a5..3c51a3f5 100755 --- a/CPP/7zip/Archive/ArchiveExports.cpp +++ b/CPP/7zip/Archive/ArchiveExports.cpp @@ -44,9 +44,9 @@ int FindFormatCalssId(const GUID *clsID) if (cls != CLSID_CArchiveHandler) return -1; Byte id = CLS_ARC_ID_ITEM(*clsID); - for (UInt32 i = 0; i < g_NumArcs; i++) + for (unsigned i = 0; i < g_NumArcs; i++) if (g_Arcs[i]->ClassId == id) - return i; + return (int)i; return -1; } diff --git a/CPP/7zip/Archive/Arj/ArjIn.cpp b/CPP/7zip/Archive/Arj/ArjIn.cpp index 146f4f09..cc7cde49 100755 --- a/CPP/7zip/Archive/Arj/ArjIn.cpp +++ b/CPP/7zip/Archive/Arj/ArjIn.cpp @@ -19,10 +19,10 @@ namespace NArj { HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize) { - UInt32 realProcessedSize; - HRESULT result = ReadStream(_stream, data, size, &realProcessedSize); - if(processedSize != NULL) - *processedSize = realProcessedSize; + size_t realProcessedSize = size; + HRESULT result = ReadStream(_stream, data, &realProcessedSize); + if (processedSize != NULL) + *processedSize = (UInt32)realProcessedSize; IncreasePositionValue(realProcessedSize); return result; } diff --git a/CPP/7zip/Archive/BZip2/BZip2Handler.cpp b/CPP/7zip/Archive/BZip2/BZip2Handler.cpp index 0b790c68..c88c883f 100755 --- a/CPP/7zip/Archive/BZip2/BZip2Handler.cpp +++ b/CPP/7zip/Archive/BZip2/BZip2Handler.cpp @@ -56,10 +56,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream, 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; + RINOK(ReadStream_FALSE(stream, buffer, kSignatureSize)); if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h') return S_FALSE; @@ -166,9 +163,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, const int kSignatureSize = 3; Byte buffer[kSignatureSize]; - UInt32 processedSize; - RINOK(ReadStream(_stream, buffer, kSignatureSize, &processedSize)); - if (processedSize < kSignatureSize) + size_t processedSize = kSignatureSize; + RINOK(ReadStream(_stream, buffer, &processedSize)); + if (processedSize != kSignatureSize) { if (firstItem) return E_FAIL; diff --git a/CPP/7zip/Archive/Cab/CabBlockInStream.cpp b/CPP/7zip/Archive/Cab/CabBlockInStream.cpp index 570ce058..343ef821 100755 --- a/CPP/7zip/Archive/Cab/CabBlockInStream.cpp +++ b/CPP/7zip/Archive/Cab/CabBlockInStream.cpp @@ -116,19 +116,14 @@ HRESULT CCabBlockInStream::PreRead(UInt32 &packSize, UInt32 &unpackSize) { CTempCabInBuffer2 inBuffer; inBuffer.Pos = 0; - UInt32 processedSizeLoc; - RINOK(ReadStream(_stream, inBuffer.Buffer, kDataBlockHeaderSize, &processedSizeLoc)) - if (processedSizeLoc != kDataBlockHeaderSize) - return S_FALSE; // bad block + RINOK(ReadStream_FALSE(_stream, inBuffer.Buffer, kDataBlockHeaderSize)) UInt32 checkSum = inBuffer.ReadUInt32(); packSize = inBuffer.ReadUInt16(); unpackSize = inBuffer.ReadUInt16(); if (ReservedSize != 0) { - RINOK(ReadStream(_stream, _buffer, ReservedSize, &processedSizeLoc)); - if(ReservedSize != processedSizeLoc) - return S_FALSE; // bad block; + RINOK(ReadStream_FALSE(_stream, _buffer, ReservedSize)); } _pos = 0; CCheckSum2 checkSumCalc; @@ -139,9 +134,7 @@ HRESULT CCabBlockInStream::PreRead(UInt32 &packSize, UInt32 &unpackSize) if (packSize < 2) return S_FALSE; // bad block; Byte sig[2]; - RINOK(ReadStream(_stream, sig, 2, &processedSizeLoc)); - if(processedSizeLoc != 2) - return S_FALSE; + RINOK(ReadStream_FALSE(_stream, sig, 2)); if (sig[0] != 0x43 || sig[1] != 0x4B) return S_FALSE; packSize2 -= 2; @@ -154,9 +147,10 @@ HRESULT CCabBlockInStream::PreRead(UInt32 &packSize, UInt32 &unpackSize) UInt32 curSize = packSize2; if (curSize != 0) { - RINOK(ReadStream(_stream, _buffer + _size, curSize, &processedSizeLoc)); - checkSumCalc.Update(_buffer + _size, processedSizeLoc); - _size += processedSizeLoc; + size_t processedSizeLoc = curSize; + RINOK(ReadStream(_stream, _buffer + _size, &processedSizeLoc)); + checkSumCalc.Update(_buffer + _size, (UInt32)processedSizeLoc); + _size += (UInt32)processedSizeLoc; if (processedSizeLoc != curSize) return S_FALSE; } diff --git a/CPP/7zip/Archive/Chm/ChmHandler.cpp b/CPP/7zip/Archive/Chm/ChmHandler.cpp index d1499328..7f3b1837 100755 --- a/CPP/7zip/Archive/Chm/ChmHandler.cpp +++ b/CPP/7zip/Archive/Chm/ChmHandler.cpp @@ -473,7 +473,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (!testMode) { UInt32 size = m_Database.NewFormatString.Length(); - RINOK(WriteStream(realOutStream, (const char *)m_Database.NewFormatString, size, 0)); + RINOK(WriteStream(realOutStream, (const char *)m_Database.NewFormatString, size)); } RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); continue; diff --git a/CPP/7zip/Archive/Com/ComHandler.cpp b/CPP/7zip/Archive/Com/ComHandler.cpp index aa9bf859..2255c021 100755 --- a/CPP/7zip/Archive/Com/ComHandler.cpp +++ b/CPP/7zip/Archive/Com/ComHandler.cpp @@ -217,16 +217,14 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, size = (UInt32)rem; RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL)); - UInt32 realProcessedSize; - RINOK(ReadStream(_stream, sect, size, &realProcessedSize)); + size_t realProcessedSize = size; + RINOK(ReadStream(_stream, sect, &realProcessedSize)); if (realProcessedSize != size) break; if (realOutStream) { - RINOK(WriteStream(realOutStream, sect, size, &realProcessedSize)); - if (realProcessedSize != size) - break; + RINOK(WriteStream(realOutStream, sect, size)); } pos += size; } diff --git a/CPP/7zip/Archive/Com/ComIn.cpp b/CPP/7zip/Archive/Com/ComIn.cpp index c3549609..b8dfdb81 100755 --- a/CPP/7zip/Archive/Com/ComIn.cpp +++ b/CPP/7zip/Archive/Com/ComIn.cpp @@ -7,6 +7,8 @@ extern "C" #include "../../../../C/Alloc.h" } +#include "../../../../C/CpuArch.h" + #include "Common/MyCom.h" #include "../../Common/StreamUtils.h" #include "Common/IntToString.h" @@ -19,22 +21,6 @@ namespace NCom{ static const UInt32 kSignatureSize = 8; static const Byte kSignature[kSignatureSize] = { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 }; -static HRESULT ReadBytes(ISequentialInStream *inStream, void *data, UInt32 size) -{ - UInt32 realProcessedSize; - RINOK(ReadStream(inStream, data, size, &realProcessedSize)); - return (realProcessedSize == size) ? S_OK : S_FALSE; -} - -#ifdef LITTLE_ENDIAN_UNALIGN -#define GetUi16(p) (*(const UInt16 *)(p)) -#define GetUi32(p) (*(const UInt32 *)(p)) -#else -#define GetUi16(p) ((p)[0] | ((UInt16)(p)[1] << 8)) -#define GetUi32(p) ((p)[0] | ((UInt32)(p)[1] << 8) | ((UInt32)(p)[2] << 16) | ((UInt32)(p)[3] << 24)) -#endif - - void CUInt32Buf::Free() { MyFree(_buf); @@ -56,7 +42,7 @@ bool CUInt32Buf::Allocate(UInt32 numItems) static HRESULT ReadSector(IInStream *inStream, Byte *buf, int sectorSizeBits, UInt32 sid) { RINOK(inStream->Seek((((UInt64)sid + 1) << sectorSizeBits), STREAM_SEEK_SET, NULL)); - return ReadBytes(inStream, buf, (UInt32)1 << sectorSizeBits); + return ReadStream_FALSE(inStream, buf, (UInt32)1 << sectorSizeBits); } static HRESULT ReadIDs(IInStream *inStream, Byte *buf, int sectorSizeBits, UInt32 sid, UInt32 *dest) @@ -219,7 +205,7 @@ HRESULT OpenArchive(IInStream *inStream, CDatabase &db) { static const UInt32 kHeaderSize = 512; Byte p[kHeaderSize]; - RINOK(ReadBytes(inStream, p, kHeaderSize)); + RINOK(ReadStream_FALSE(inStream, p, kHeaderSize)); if (memcmp(p, kSignature, kSignatureSize) != 0) return S_FALSE; UInt16 majorVer = GetUi16(p + 0x1A); diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp index 2ef1fa95..e1030976 100755 --- a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp +++ b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp @@ -208,14 +208,16 @@ STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams, RINOK(ReturnIfError(E_ABORT)); RINOK(ReturnIfError(E_OUTOFMEMORY)); - RINOK(ReturnIfError(S_FALSE)); for (i = 0; i < _coders.Size(); i++) { HRESULT result = _coders[i].Result; - if (result != S_OK && result != E_FAIL) + if (result != S_OK && result != E_FAIL && result != S_FALSE) return result; } + + RINOK(ReturnIfError(S_FALSE)); + for (i = 0; i < _coders.Size(); i++) { HRESULT result = _coders[i].Result; diff --git a/CPP/7zip/Archive/Common/CoderMixerMT.cpp b/CPP/7zip/Archive/Common/CoderMixerMT.cpp index 6319c5da..85cf0a52 100755 --- a/CPP/7zip/Archive/Common/CoderMixerMT.cpp +++ b/CPP/7zip/Archive/Common/CoderMixerMT.cpp @@ -77,14 +77,16 @@ STDMETHODIMP CCoderMixerMT::Code(ISequentialInStream *inStream, RINOK(ReturnIfError(E_ABORT)); RINOK(ReturnIfError(E_OUTOFMEMORY)); - RINOK(ReturnIfError(S_FALSE)); for (i = 0; i < _coders.Size(); i++) { HRESULT result = _coders[i].Result; - if (result != S_OK && result != E_FAIL) + if (result != S_OK && result != E_FAIL && result != S_FALSE) return result; } + + RINOK(ReturnIfError(S_FALSE)); + for (i = 0; i < _coders.Size(); i++) { HRESULT result = _coders[i].Result; diff --git a/CPP/7zip/Archive/Common/HandlerOut.cpp b/CPP/7zip/Archive/Common/HandlerOut.cpp index 0dcf449e..082a484d 100755 --- a/CPP/7zip/Archive/Common/HandlerOut.cpp +++ b/CPP/7zip/Archive/Common/HandlerOut.cpp @@ -380,15 +380,6 @@ HRESULT COutHandler::SetParams(COneMethodInfo &oneMethodInfo, const UString &src HRESULT COutHandler::SetSolidSettings(const UString &s) { - bool res; - if (StringToBool(s, res)) - { - if (res) - InitSolid(); - else - _numSolidFiles = 1; - return S_OK; - } UString s2 = s; s2.MakeUpper(); for (int i = 0; i < s2.Length();) @@ -439,16 +430,27 @@ HRESULT COutHandler::SetSolidSettings(const UString &s) HRESULT COutHandler::SetSolidSettings(const PROPVARIANT &value) { + bool isSolid; switch(value.vt) { case VT_EMPTY: - InitSolid(); - return S_OK; + isSolid = true; + break; + case VT_BOOL: + isSolid = (value.boolVal != VARIANT_FALSE); + break; case VT_BSTR: + if (StringToBool(value.bstrVal, isSolid)) + break; return SetSolidSettings(value.bstrVal); default: return E_INVALIDARG; } + if (isSolid) + InitSolid(); + else + _numSolidFiles = 1; + return S_OK; } void COutHandler::Init() @@ -587,6 +589,14 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val if (number <= mainDicMethodIndex) mainDicSize = dicSize; } + else if (realName.Left(1).CompareNoCase(L"B") == 0) + { + UInt32 blockSize; + RINOK(ParsePropDictionaryValue(realName.Mid(1), value, blockSize)); + property.Id = NCoderPropID::kBlockSize; + property.Value = blockSize; + oneMethodInfo.Properties.Add(property); + } else if (realName.Left(3).CompareNoCase(L"MEM") == 0) { UInt32 dicSize; diff --git a/CPP/7zip/Archive/Common/ParseProperties.cpp b/CPP/7zip/Archive/Common/ParseProperties.cpp index f0d4e29c..83d51241 100755 --- a/CPP/7zip/Archive/Common/ParseProperties.cpp +++ b/CPP/7zip/Archive/Common/ParseProperties.cpp @@ -99,12 +99,12 @@ HRESULT ParsePropDictionaryValue(const UString &name, const PROPVARIANT &prop, U bool StringToBool(const UString &s, bool &res) { - if (s.IsEmpty() || s.CompareNoCase(L"ON") == 0) + if (s.IsEmpty() || s.CompareNoCase(L"ON") == 0 || s.Compare(L"+") == 0) { res = true; return true; } - if (s.CompareNoCase(L"OFF") == 0) + if (s.CompareNoCase(L"OFF") == 0 || s.Compare(L"-") == 0) { res = false; return true; @@ -119,6 +119,9 @@ HRESULT SetBoolProperty(bool &dest, const PROPVARIANT &value) case VT_EMPTY: dest = true; return S_OK; + case VT_BOOL: + dest = (value.boolVal != VARIANT_FALSE); + return S_OK; /* case VT_UI4: dest = (value.ulVal != 0); diff --git a/CPP/7zip/Archive/Cpio/CpioIn.cpp b/CPP/7zip/Archive/Cpio/CpioIn.cpp index 91399362..4732a32e 100755 --- a/CPP/7zip/Archive/Cpio/CpioIn.cpp +++ b/CPP/7zip/Archive/Cpio/CpioIn.cpp @@ -16,7 +16,9 @@ namespace NCpio { HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize) { - RINOK(ReadStream(m_Stream, data, size, &processedSize)); + size_t realProcessedSize = size; + RINOK(ReadStream(m_Stream, data, &realProcessedSize)); + processedSize = (UInt32)realProcessedSize; m_Position += processedSize; return S_OK; } @@ -240,8 +242,7 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item) } if (nameSize == 0 || nameSize >= (1 << 27)) return E_FAIL; - RINOK(ReadBytes(item.Name.GetBuffer(nameSize), - nameSize, processedSize)); + RINOK(ReadBytes(item.Name.GetBuffer(nameSize), nameSize, processedSize)); if (processedSize != nameSize) return E_FAIL; item.Name.ReleaseBuffer(); diff --git a/CPP/7zip/Archive/Deb/DebIn.cpp b/CPP/7zip/Archive/Deb/DebIn.cpp index c2221d12..41aaeb8a 100755 --- a/CPP/7zip/Archive/Deb/DebIn.cpp +++ b/CPP/7zip/Archive/Deb/DebIn.cpp @@ -15,22 +15,12 @@ namespace NDeb { using namespace NHeader; -HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize) -{ - RINOK(ReadStream(m_Stream, data, size, &processedSize)); - m_Position += processedSize; - return S_OK; -} - HRESULT CInArchive::Open(IInStream *inStream) { RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position)); char signature[kSignatureLen]; - UInt32 processedSize; - RINOK(ReadStream(inStream, signature, kSignatureLen, &processedSize)); - m_Position += processedSize; - if (processedSize != kSignatureLen) - return S_FALSE; + RINOK(ReadStream_FALSE(inStream, signature, kSignatureLen)); + m_Position += kSignatureLen; if (memcmp(signature, kSignature, kSignatureLen) != 0) return S_FALSE; m_Stream = inStream; @@ -100,10 +90,11 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item) char header[NHeader::kHeaderSize]; const char *cur = header; - UInt32 processedSize; + size_t processedSize = sizeof(header); item.HeaderPosition = m_Position; - RINOK(ReadBytes(header, sizeof(header), processedSize)); - if (processedSize < sizeof(header)) + RINOK(ReadStream(m_Stream, header, &processedSize)); + m_Position += processedSize; + if (processedSize != sizeof(header)) return S_OK; char tempString[kNameSize + 1]; diff --git a/CPP/7zip/Archive/Deb/DebIn.h b/CPP/7zip/Archive/Deb/DebIn.h index c1b72b6e..7d33fa59 100755 --- a/CPP/7zip/Archive/Deb/DebIn.h +++ b/CPP/7zip/Archive/Deb/DebIn.h @@ -15,7 +15,6 @@ class CInArchive CMyComPtr m_Stream; UInt64 m_Position; - HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize); HRESULT GetNextItemReal(bool &filled, CItemEx &itemInfo); HRESULT Skeep(UInt64 numBytes); public: diff --git a/CPP/7zip/Archive/GZip/GZipIn.cpp b/CPP/7zip/Archive/GZip/GZipIn.cpp index 44ed62f6..33b0ac47 100755 --- a/CPP/7zip/Archive/GZip/GZipIn.cpp +++ b/CPP/7zip/Archive/GZip/GZipIn.cpp @@ -20,11 +20,8 @@ namespace NGZip { HRESULT CInArchive::ReadBytes(ISequentialInStream *inStream, void *data, UInt32 size) { - UInt32 realProcessedSize; - RINOK(ReadStream(inStream, data, size, &realProcessedSize)); - m_Position += realProcessedSize; - if(realProcessedSize != size) - return S_FALSE; + RINOK(ReadStream_FALSE(inStream, data, size)); + m_Position += size; return S_OK; } diff --git a/CPP/7zip/Archive/GZip/GZipOut.cpp b/CPP/7zip/Archive/GZip/GZipOut.cpp index af01c79f..3d0d4f7a 100755 --- a/CPP/7zip/Archive/GZip/GZipOut.cpp +++ b/CPP/7zip/Archive/GZip/GZipOut.cpp @@ -12,11 +12,7 @@ namespace NGZip { HRESULT COutArchive::WriteBytes(const void *buffer, UInt32 size) { - UInt32 processedSize; - RINOK(WriteStream(m_Stream, buffer, size, &processedSize)); - if(processedSize != size) - return E_FAIL; - return S_OK; + return WriteStream(m_Stream, buffer, size); } HRESULT COutArchive::WriteByte(Byte value) diff --git a/CPP/7zip/Archive/Iso/IsoIn.cpp b/CPP/7zip/Archive/Iso/IsoIn.cpp index 213b3014..f4896d37 100755 --- a/CPP/7zip/Archive/Iso/IsoIn.cpp +++ b/CPP/7zip/Archive/Iso/IsoIn.cpp @@ -12,19 +12,14 @@ namespace NArchive { namespace NIso { -HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize) -{ - return ReadStream(_stream, data, size, &processedSize); -} - Byte CInArchive::ReadByte() { if (m_BufferPos >= BlockSize) m_BufferPos = 0; if (m_BufferPos == 0) { - UInt32 processedSize; - if (ReadBytes(m_Buffer, BlockSize, processedSize) != S_OK) + size_t processedSize = BlockSize; + if (ReadStream(_stream, m_Buffer, &processedSize) != S_OK) throw 1; if (processedSize != BlockSize) throw 1; @@ -192,7 +187,10 @@ void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len) void CInArchive::ReadDirRecord(CDirRecord &r) { - Byte len = ReadByte(); + Byte len = ReadByte(); + // Some CDs can have incorrect value len = 48 ('0') in VolumeDescriptor. + // But maybe we must use real "len" for other records. + len = 34; ReadDirRecord2(r, len); } diff --git a/CPP/7zip/Archive/Iso/IsoIn.h b/CPP/7zip/Archive/Iso/IsoIn.h index ab850bd9..4f9705c4 100755 --- a/CPP/7zip/Archive/Iso/IsoIn.h +++ b/CPP/7zip/Archive/Iso/IsoIn.h @@ -232,7 +232,6 @@ class CInArchive bool _bootIsDefined; CBootRecordDescriptor _bootDesc; - HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize); void Skeep(size_t size); void SkeepZeros(size_t size); Byte ReadByte(); diff --git a/CPP/7zip/Archive/Iso/IsoItem.h b/CPP/7zip/Archive/Iso/IsoItem.h index e899d616..fcb9531f 100755 --- a/CPP/7zip/Archive/Iso/IsoItem.h +++ b/CPP/7zip/Archive/Iso/IsoItem.h @@ -36,9 +36,9 @@ struct CRecordingDateTime if (!SystemTimeToFileTime(&st, &ft)) return false; UInt64 value = (((UInt64)ft.dwHighDateTime) << 32) + ft.dwLowDateTime; - value += (UInt64)((Int64)(int)GmtOffset * 15 * 60); + value -= (UInt64)((Int64)GmtOffset * 15 * 60 * 10000000); ft.dwLowDateTime = (DWORD)value; - ft.dwHighDateTime = DWORD(value >> 32); + ft.dwHighDateTime = (DWORD)(value >> 32); return true; } }; diff --git a/CPP/7zip/Archive/Lzh/LzhIn.cpp b/CPP/7zip/Archive/Lzh/LzhIn.cpp index 9c531848..6783654c 100755 --- a/CPP/7zip/Archive/Lzh/LzhIn.cpp +++ b/CPP/7zip/Archive/Lzh/LzhIn.cpp @@ -14,7 +14,9 @@ namespace NLzh { HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize) { - RINOK(ReadStream(m_Stream, data, size, &processedSize)); + size_t realProcessedSize = size; + RINOK(ReadStream(m_Stream, data, &realProcessedSize)); + processedSize = (UInt32)realProcessedSize; m_Position += processedSize; return S_OK; } diff --git a/CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp b/CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp new file mode 100755 index 00000000..bbeb177b --- /dev/null +++ b/CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp @@ -0,0 +1,14 @@ +// LzmaArcRegister.cpp + +#include "StdAfx.h" + +#include "../../Common/RegisterArc.h" + +#include "LzmaHandler.h" + +static IInArchive *CreateArc() { return new NArchive::NLzma::CHandler; } + +static CArcInfo g_ArcInfo = + { L"Lzma", L"lzma lzma86", 0, 0xA, {0 }, 0, true, CreateArc, NULL }; + +REGISTER_ARC(Lzma) diff --git a/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp b/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp new file mode 100755 index 00000000..d3450616 --- /dev/null +++ b/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp @@ -0,0 +1,86 @@ +// LzmaFiltersDecode.cpp + +#include "StdAfx.h" + +#include "LzmaFiltersDecode.h" + +namespace NArchive { +namespace NLzma { + +static const UInt64 k_LZMA = 0x030101; +static const UInt64 k_BCJ = 0x03030103; + +HRESULT CDecoder::Code( + DECL_EXTERNAL_CODECS_LOC_VARS + const CHeader &block, + ISequentialInStream *inStream, ISequentialOutStream *outStream, + UInt64 *inProcessedSize, ICompressProgressInfo *progress) +{ + *inProcessedSize = (UInt64)(Int64)-1; + + if (block.FilterMethod > 1) + return E_NOTIMPL; + + if (!_lzmaDecoder) + { + RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS k_LZMA, _lzmaDecoder, false)); + if (_lzmaDecoder == 0) + return E_NOTIMPL; + } + + { + CMyComPtr setDecoderProperties; + _lzmaDecoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties); + if (!setDecoderProperties) + return E_NOTIMPL; + RINOK(setDecoderProperties->SetDecoderProperties2(block.LzmaProps, 5)); + } + + bool filteredMode = (block.FilterMethod == 1); + + CMyComPtr setOutStream; + + if (filteredMode) + { + if (!_bcjStream) + { + CMyComPtr coder; + RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS k_BCJ, coder, false)); + if (!coder) + return E_NOTIMPL; + coder.QueryInterface(IID_ISequentialOutStream, &_bcjStream); + if (!_bcjStream) + return E_NOTIMPL; + } + + _bcjStream.QueryInterface(IID_ICompressSetOutStream, &setOutStream); + if (!setOutStream) + return E_NOTIMPL; + RINOK(setOutStream->SetOutStream(outStream)); + outStream = _bcjStream; + } + + const UInt64 *unpackSize = block.HasUnpackSize() ? &block.UnpackSize : NULL; + RINOK(_lzmaDecoder->Code(inStream, outStream, NULL, unpackSize, progress)); + + if (filteredMode) + { + CMyComPtr flush; + _bcjStream.QueryInterface(IID_IOutStreamFlush, &flush); + if (flush) + { + RINOK(flush->Flush()); + } + RINOK(setOutStream->ReleaseOutStream()); + } + + CMyComPtr getInStreamProcessedSize; + _lzmaDecoder.QueryInterface(IID_ICompressGetInStreamProcessedSize, &getInStreamProcessedSize); + if (getInStreamProcessedSize) + { + RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(inProcessedSize)); + } + return S_OK; +} + +}} diff --git a/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h b/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h new file mode 100755 index 00000000..a9f4927b --- /dev/null +++ b/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h @@ -0,0 +1,26 @@ +// LzmaFiltersDecode.h + +#ifndef __LZMA_FILTERS_DECODE_H +#define __LZMA_FILTERS_DECODE_H + +#include "../../Common/CreateCoder.h" + +#include "LzmaItem.h" + +namespace NArchive { +namespace NLzma { + +class CDecoder +{ + CMyComPtr _lzmaDecoder; + CMyComPtr _bcjStream; +public: + HRESULT Code(DECL_EXTERNAL_CODECS_LOC_VARS + const CHeader &block, + ISequentialInStream *inStream, ISequentialOutStream *outStream, + UInt64 *inProcessedSize, ICompressProgressInfo *progress); +}; + +}} + +#endif diff --git a/CPP/7zip/Archive/Lzma/LzmaHandler.cpp b/CPP/7zip/Archive/Lzma/LzmaHandler.cpp new file mode 100755 index 00000000..70126aa4 --- /dev/null +++ b/CPP/7zip/Archive/Lzma/LzmaHandler.cpp @@ -0,0 +1,243 @@ +// LzmaHandler.cpp + +#include "StdAfx.h" + +#include "LzmaHandler.h" + +#include "Common/Defs.h" +#include "Common/StringConvert.h" +#include "Common/ComTry.h" +#include "Common/IntToString.h" + +#include "Windows/PropVariant.h" + +#include "../../Common/ProgressUtils.h" +#include "../../Common/StreamUtils.h" +#include "../Common/DummyOutStream.h" + +#include "LzmaFiltersDecode.h" + +namespace NArchive { +namespace NLzma { + +STATPROPSTG kProps[] = +{ + { NULL, kpidSize, VT_UI8}, + { NULL, kpidPackedSize, VT_UI8}, + { NULL, kpidMethod, VT_UI1} +}; + +IMP_IInArchive_Props +IMP_IInArchive_ArcProps_NO + +STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) +{ + *numItems = 1; + return S_OK; +} + +static void ConvertUInt32ToString(UInt32 value, wchar_t *s) +{ + ConvertUInt64ToString(value, s + MyStringLen(s)); +} + +static void DictSizeToString(UInt32 value, wchar_t *s) +{ + for (int i = 0; i <= 31; i++) + if ((UInt32(1) << i) == value) + { + ConvertUInt32ToString(i, s); + return; + } + wchar_t c = L'b'; + if ((value & ((1 << 20) - 1)) == 0) + { + value >>= 20; + c = L'm'; + } + else if ((value & ((1 << 10) - 1)) == 0) + { + value >>= 10; + c = L'k'; + } + ConvertUInt32ToString(value, s); + int p = MyStringLen(s); + s[p++] = c; + s[p++] = L'\0'; +} + +static void MyStrCat(wchar_t *d, const wchar_t *s) +{ + MyStringCopy(d + MyStringLen(d), s); +} + +STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) +{ + if (index != 0) + return E_INVALIDARG; + NWindows::NCOM::CPropVariant propVariant; + switch(propID) + { + case kpidSize: + if (m_StreamInfo.HasUnpackSize()) + propVariant = (UInt64)m_StreamInfo.UnpackSize; + break; + case kpidPackedSize: + propVariant = (UInt64)m_PackSize; + break; + case kpidMethod: + { + wchar_t s[64]; + s[0] = '\0'; + if (m_StreamInfo.IsThereFilter) + { + const wchar_t *f; + if (m_StreamInfo.FilterMethod == 0) + f = L"Copy"; + else if (m_StreamInfo.FilterMethod == 1) + f = L"BCJ"; + else + f = L"Unknown"; + MyStrCat(s, f); + MyStrCat(s, L" "); + } + MyStrCat(s, L"LZMA:"); + DictSizeToString(m_StreamInfo.GetDicSize(), s); + propVariant = s; + break; + } + } + propVariant.Detach(value); + return S_OK; +} + +STDMETHODIMP CHandler::Open(IInStream *inStream, + const UInt64 * /* maxCheckStartPosition */, + IArchiveOpenCallback * /* openArchiveCallback */) +{ + { + RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition)); + + HRESULT res = ReadStreamHeader(inStream, m_StreamInfo); + if (res != S_OK) + return S_FALSE; + + Byte b; + RINOK(ReadStream_FALSE(inStream, &b, 1)); + if (b != 0) + return S_FALSE; + + UInt64 endPos; + RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos)); + m_PackSize = endPos - m_StreamStartPosition - m_StreamInfo.GetHeaderSize(); + + m_Stream = inStream; + } + return S_OK; +} + +STDMETHODIMP CHandler::Close() +{ + m_Stream.Release(); + return S_OK; +} + + +STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, + Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +{ + COM_TRY_BEGIN + bool allFilesMode = (numItems == UInt32(-1)); + if (!allFilesMode) + { + if (numItems == 0) + return S_OK; + if (numItems != 1) + return E_INVALIDARG; + if (indices[0] != 0) + return E_INVALIDARG; + } + + bool testMode = (_aTestMode != 0); + + RINOK(extractCallback->SetTotal(m_PackSize)); + + UInt64 currentTotalPacked = 0; + + CDummyOutStream *outStreamSpec = new CDummyOutStream; + CMyComPtr outStream(outStreamSpec); + + { + CMyComPtr realOutStream; + Int32 askMode = testMode ? + NArchive::NExtract::NAskMode::kTest : + NArchive::NExtract::NAskMode::kExtract; + + RINOK(extractCallback->GetStream(0, &realOutStream, askMode)); + + outStreamSpec->SetStream(realOutStream); + outStreamSpec->Init(); + if(!testMode && !realOutStream) + return S_OK; + extractCallback->PrepareOperation(askMode); + } + + CLocalProgress *lps = new CLocalProgress; + CMyComPtr progress = lps; + lps->Init(extractCallback, true); + + CDecoder decoder; + RINOK(m_Stream->Seek(m_StreamStartPosition, STREAM_SEEK_SET, NULL)); + UInt64 streamPos = m_StreamStartPosition; + Int32 opRes = NArchive::NExtract::NOperationResult::kOK; + bool firstItem = true; + for (;;) + { + CHeader st; + HRESULT result = ReadStreamHeader(m_Stream, st); + if (result != S_OK) + { + if (firstItem) + return E_FAIL; + break; + } + firstItem = false; + + lps->OutSize = outStreamSpec->GetSize(); + lps->InSize = currentTotalPacked; + RINOK(lps->SetCur()); + + streamPos += st.GetHeaderSize(); + UInt64 packProcessed; + + { + result = decoder.Code( + EXTERNAL_CODECS_VARS + st, m_Stream, outStream, &packProcessed, progress); + if (result == E_NOTIMPL) + { + opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + break; + } + if (result == S_FALSE) + { + opRes = NArchive::NExtract::NOperationResult::kDataError; + break; + } + RINOK(result); + } + + if (packProcessed == (UInt64)(Int64)-1) + break; + RINOK(m_Stream->Seek(streamPos + packProcessed, STREAM_SEEK_SET, NULL)); + currentTotalPacked += packProcessed; + streamPos += packProcessed; + } + outStream.Release(); + return extractCallback->SetOperationResult(opRes); + COM_TRY_END +} + +IMPL_ISetCompressCodecsInfo + +}} diff --git a/CPP/7zip/Archive/Lzma/LzmaHandler.h b/CPP/7zip/Archive/Lzma/LzmaHandler.h new file mode 100755 index 00000000..e4078309 --- /dev/null +++ b/CPP/7zip/Archive/Lzma/LzmaHandler.h @@ -0,0 +1,69 @@ +// Lzma/Handler.h + +#ifndef __GZIP_HANDLER_H +#define __GZIP_HANDLER_H + +#include "Common/MyCom.h" + +#include "../IArchive.h" +#include "../../Common/CreateCoder.h" + +#include "LzmaIn.h" + +namespace NArchive { +namespace NLzma { + +// const UInt64 k_LZMA = 0x030101; + +class CHandler: + public IInArchive, + PUBLIC_ISetCompressCodecsInfo + public CMyUnknownImp +{ +public: + MY_QUERYINTERFACE_BEGIN + MY_QUERYINTERFACE_ENTRY(IInArchive) + QUERY_ENTRY_ISetCompressCodecsInfo + MY_QUERYINTERFACE_END + MY_ADDREF_RELEASE + + STDMETHOD(Open)(IInStream *inStream, + const UInt64 *maxCheckStartPosition, + IArchiveOpenCallback *openArchiveCallback); + STDMETHOD(Close)(); + + STDMETHOD(GetNumberOfItems)(UInt32 *numItems); + STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value); + STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback); + + STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value); + + STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties); + STDMETHOD(GetPropertyInfo)(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType); + + STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties); + STDMETHOD(GetArchivePropertyInfo)(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType); + + UString GetMethodString(); +public: + CHandler() { } + +private: + CHeader m_StreamInfo; + UInt64 m_StreamStartPosition; + UInt64 m_PackSize; + + CMyComPtr m_Stream; + + DECL_EXTERNAL_CODECS_VARS + + DECL_ISetCompressCodecsInfo + +}; + +}} + +#endif diff --git a/CPP/7zip/Archive/Lzma/LzmaIn.cpp b/CPP/7zip/Archive/Lzma/LzmaIn.cpp new file mode 100755 index 00000000..342b01e1 --- /dev/null +++ b/CPP/7zip/Archive/Lzma/LzmaIn.cpp @@ -0,0 +1,56 @@ +// Archive/LzmaIn.cpp + +#include "StdAfx.h" + +#include "LzmaIn.h" + +#include "../../Common/StreamUtils.h" + +namespace NArchive { +namespace NLzma { + +static bool CheckDictSize(const Byte *p) +{ + UInt32 dicSize = GetUi32(p); + int i; + for (i = 1; i <= 30; i++) + if (dicSize == ((UInt32)2 << i) || dicSize == ((UInt32)3 << i)) + return true; + return false; +} + +HRESULT ReadStreamHeader(ISequentialInStream *inStream, CHeader &block) +{ + Byte sig[5 + 9]; + RINOK(ReadStream_FALSE(inStream, sig, 5 + 8)); + + const Byte kMaxProp0Val = 5 * 5 * 9 - 1; + if (sig[0] > kMaxProp0Val) + return S_FALSE; + + for (int i = 0; i < 5; i++) + block.LzmaProps[i] = sig[i]; + + block.IsThereFilter = false; + block.FilterMethod = 0; + + if (!CheckDictSize(sig + 1)) + { + if (sig[0] > 1 || sig[1] > kMaxProp0Val) + return S_FALSE; + block.IsThereFilter = true; + block.FilterMethod = sig[0]; + for (int i = 0; i < 5; i++) + block.LzmaProps[i] = sig[i + 1]; + if (!CheckDictSize(block.LzmaProps + 1)) + return S_FALSE; + RINOK(ReadStream_FALSE(inStream, sig + 5 + 8, 1)); + } + UInt32 unpOffset = 5 + (block.IsThereFilter ? 1 : 0); + block.UnpackSize = GetUi64(sig + unpOffset); + if (block.HasUnpackSize() && block.UnpackSize >= ((UInt64)1 << 56)) + return S_FALSE; + return S_OK; +} + +}} diff --git a/CPP/7zip/Archive/Lzma/LzmaIn.h b/CPP/7zip/Archive/Lzma/LzmaIn.h new file mode 100755 index 00000000..6f237f2d --- /dev/null +++ b/CPP/7zip/Archive/Lzma/LzmaIn.h @@ -0,0 +1,16 @@ +// Archive/LzmaIn.h + +#ifndef __ARCHIVE_LZMA_IN_H +#define __ARCHIVE_LZMA_IN_H + +#include "LzmaItem.h" +#include "../../IStream.h" + +namespace NArchive { +namespace NLzma { + +HRESULT ReadStreamHeader(ISequentialInStream *inStream, CHeader &st); + +}} + +#endif diff --git a/CPP/7zip/Archive/Lzma/LzmaItem.h b/CPP/7zip/Archive/Lzma/LzmaItem.h new file mode 100755 index 00000000..8fcae210 --- /dev/null +++ b/CPP/7zip/Archive/Lzma/LzmaItem.h @@ -0,0 +1,27 @@ +// Archive/LzmaItem.h + +#ifndef __ARCHIVE_LZMA_ITEM_H +#define __ARCHIVE_LZMA_ITEM_H + +#include "Common/Types.h" + +#include "../../../../C/CpuArch.h" + +namespace NArchive { +namespace NLzma { + +struct CHeader +{ + UInt64 UnpackSize; + bool IsThereFilter; + Byte FilterMethod; + Byte LzmaProps[5]; + + UInt32 GetDicSize() const { return GetUi32(LzmaProps + 1); } + bool HasUnpackSize() const { return (UnpackSize != (UInt64)(Int64)-1); } + unsigned GetHeaderSize() const { return 5 + 8 + (IsThereFilter ? 1 : 0); } +}; + +}} + +#endif diff --git a/CPP/7zip/Archive/Lzma/StdAfx.h b/CPP/7zip/Archive/Lzma/StdAfx.h new file mode 100755 index 00000000..e7fb6986 --- /dev/null +++ b/CPP/7zip/Archive/Lzma/StdAfx.h @@ -0,0 +1,8 @@ +// StdAfx.h + +#ifndef __STDAFX_H +#define __STDAFX_H + +#include "../../../Common/MyWindows.h" + +#endif diff --git a/CPP/7zip/Archive/Lzma/lzma.ico b/CPP/7zip/Archive/Lzma/lzma.ico new file mode 100755 index 00000000..1f4f754c Binary files /dev/null and b/CPP/7zip/Archive/Lzma/lzma.ico differ diff --git a/CPP/7zip/Archive/Nsis/NsisDecode.cpp b/CPP/7zip/Archive/Nsis/NsisDecode.cpp index b50ec5e0..7e126bd4 100755 --- a/CPP/7zip/Archive/Nsis/NsisDecode.cpp +++ b/CPP/7zip/Archive/Nsis/NsisDecode.cpp @@ -133,9 +133,9 @@ HRESULT CDecoder::Init( return S_OK; } -HRESULT CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize) +HRESULT CDecoder::Read(void *data, size_t *processedSize) { - return ReadStream(_decoderInStream, data, size, processedSize);; + return ReadStream(_decoderInStream, data, processedSize);; } }} diff --git a/CPP/7zip/Archive/Nsis/NsisDecode.h b/CPP/7zip/Archive/Nsis/NsisDecode.h index 1a2fa41f..36aeb2b1 100755 --- a/CPP/7zip/Archive/Nsis/NsisDecode.h +++ b/CPP/7zip/Archive/Nsis/NsisDecode.h @@ -39,7 +39,7 @@ public: HRESULT Init( DECL_EXTERNAL_CODECS_LOC_VARS IInStream *inStream, NMethodType::EEnum method, bool thereIsFilterFlag, bool &useFilter); - HRESULT Read(void *data, UInt32 size, UInt32 *processedSize); + HRESULT Read(void *data, size_t *processedSize); }; }} diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.cpp b/CPP/7zip/Archive/Nsis/NsisHandler.cpp index 62c7ab38..b24d966d 100755 --- a/CPP/7zip/Archive/Nsis/NsisHandler.cpp +++ b/CPP/7zip/Archive/Nsis/NsisHandler.cpp @@ -12,6 +12,7 @@ #include "Windows/PropVariant.h" #include "../Common/ItemNameUtils.h" +#include "../../Common/StreamUtils.h" using namespace NWindows; @@ -233,8 +234,14 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val { case kpidPath: { - const UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetReducedName(), CP_ACP)); - prop = (const wchar_t *)s; + UString s; + if (_archive.IsUnicode) + s = item.GetReducedNameU(); + else + s = MultiByteToUnicodeString(item.GetReducedNameA(), CP_ACP); + s = NItemName::WinNameToOSName(s); + if (!s.IsEmpty()) + prop = (const wchar_t *)s; break; } case kpidIsFolder: @@ -348,7 +355,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, continue; RINOK(extractCallback->PrepareOperation(askMode)); if (!testMode) - RINOK(realOutStream->Write((const char *)_archive.Script, (UInt32)_archive.Script.Length(), NULL)); + RINOK(WriteStream(realOutStream, (const char *)_archive.Script, (UInt32)_archive.Script.Length())); } else #endif @@ -379,9 +386,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, UInt64 pos = _archive.GetPosOfSolidItem(index); while(streamPos < pos) { - UInt32 curSize = (UInt32)MyMin(pos - streamPos, (UInt64)kBufferLength); - UInt32 processedSize; - HRESULT res = _archive.Decoder.Read(buffer, curSize, &processedSize); + size_t processedSize = (UInt32)MyMin(pos - streamPos, (UInt64)kBufferLength); + HRESULT res = _archive.Decoder.Read(buffer, &processedSize); if (res != S_OK) { if (res != S_FALSE) @@ -398,8 +404,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, } if (streamPos == pos) { - UInt32 processedSize; - RINOK(_archive.Decoder.Read(buffer, 4, &processedSize)); + size_t processedSize = 4; + RINOK(_archive.Decoder.Read(buffer, &processedSize)); if (processedSize != 4) return E_FAIL; streamPos += processedSize; @@ -433,8 +439,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, UInt32 curSize = kBufferLength; if (sizeIsKnown && curSize > fullSize) curSize = fullSize; - UInt32 processedSize; - HRESULT res = _archive.Decoder.Read(buffer, curSize, &processedSize); + size_t processedSize = curSize; + HRESULT res = _archive.Decoder.Read(buffer, &processedSize); if (res != S_OK) { if (res != S_FALSE) @@ -449,7 +455,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, break; } - fullSize -= processedSize; + fullSize -= (UInt32)processedSize; streamPos += processedSize; offset += processedSize; @@ -460,7 +466,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, completed = currentTotalSize + offset; RINOK(extractCallback->SetCompleted(&completed)); if (!testMode) - RINOK(realOutStream->Write(buffer, processedSize, NULL)); + RINOK(WriteStream(realOutStream, buffer, processedSize)); } } else @@ -478,7 +484,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, fullSize -= processedSize; streamPos += processedSize; if (!testMode) - RINOK(realOutStream->Write(buffer, processedSize, 0)); + RINOK(WriteStream(realOutStream, buffer, processedSize)); } } } diff --git a/CPP/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp index 83080448..5c5c872f 100755 --- a/CPP/7zip/Archive/Nsis/NsisIn.cpp +++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp @@ -2,6 +2,8 @@ #include "StdAfx.h" +// #include + #include "NsisIn.h" #include "NsisDecode.h" @@ -9,6 +11,7 @@ #include "../../Common/StreamUtils.h" +#include "Common/StringConvert.h" #include "Common/IntToString.h" namespace NArchive { @@ -27,6 +30,14 @@ public: static const char *kCrLf = "\x0D\x0A"; #endif +#define NS_UN_SKIP_CODE 0xE000 +#define NS_UN_VAR_CODE 0xE001 +#define NS_UN_SHELL_CODE 0xE002 +#define NS_UN_LANG_CODE 0xE003 +#define NS_UN_CODES_START NS_UN_SKIP_CODE +#define NS_UN_CODES_END NS_UN_LANG_CODE + + UInt32 GetUInt32FromMemLE(const Byte *p) { return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24); @@ -60,12 +71,20 @@ static int CompareItems(void *const *p1, void *const *p2, void * /* param */) const CItem &i1 = **(CItem **)p1; const CItem &i2 = **(CItem **)p2; RINOZ(MyCompare(i1.Pos, i2.Pos)); - RINOZ(i1.Prefix.Compare(i2.Prefix)); - RINOZ(i1.Name.Compare(i2.Name)); + if (i1.IsUnicode) + { + RINOZ(i1.PrefixU.Compare(i2.PrefixU)); + RINOZ(i1.NameU.Compare(i2.NameU)); + } + else + { + RINOZ(i1.PrefixA.Compare(i2.PrefixA)); + RINOZ(i1.NameA.Compare(i2.NameA)); + } return 0; } -AString CInArchive::ReadString(UInt32 pos) +AString CInArchive::ReadStringA(UInt32 pos) { AString s; UInt32 offset = GetOffset() + _stringsPos + pos; @@ -81,6 +100,24 @@ AString CInArchive::ReadString(UInt32 pos) return s; } +UString CInArchive::ReadStringU(UInt32 pos) +{ + UString s; + UInt32 offset = GetOffset() + _stringsPos + (pos * 2); + for (;;) + { + if (offset >= _size || offset + 1 >= _size) + throw 1; + char c0 = _data[offset++]; + char c1 = _data[offset++]; + wchar_t c = (c0 | ((wchar_t)c1 << 8)); + if (c == 0) + break; + s += c; + } + return s; +} + /* static AString ParsePrefix(const AString &prefix) { @@ -466,13 +503,27 @@ static AString GetVar(UInt32 index) return res; } -// $0..$9, $INSTDIR, etc are encoded as ASCII bytes starting from this value. #define NS_SKIP_CODE 252 #define NS_VAR_CODE 253 #define NS_SHELL_CODE 254 #define NS_LANG_CODE 255 #define NS_CODES_START NS_SKIP_CODE +static AString GetShellString(int index) +{ + AString res = "$"; + if (index < kNumShellStrings) + { + const char *sz = kShellStrings[index]; + if (sz[0] != 0) + return res + sz; + } + res += "SHELL["; + res += UIntToString(index); + res += "]"; + return res; +} + // Based on Dave Laundon's simplified process_string AString GetNsisString(const AString &s) { @@ -487,26 +538,7 @@ AString GetNsisString(const AString &s) nData |= (((int)(c1 & 0x7F)) << 7); if (nVarIdx == NS_SHELL_CODE) - { - UInt32 index = c1; - bool needPrint = true; - res += "$"; - if (index < kNumShellStrings) - { - const char *sz = kShellStrings[index]; - if (sz[0] != 0) - { - res += sz; - needPrint = false; - } - } - if (needPrint) - { - res += "SHELL["; - res += UIntToString(index); - res += "]"; - } - } + res += GetShellString(c1); else if (nVarIdx == NS_VAR_CODE) res += GetVar(nData); else if (nVarIdx == NS_LANG_CODE) @@ -523,9 +555,53 @@ AString GetNsisString(const AString &s) return res; } +UString GetNsisString(const UString &s) +{ + UString res; + for (int i = 0; i < s.Length();) + { + wchar_t nVarIdx = s[i++]; + if (nVarIdx > NS_UN_CODES_START && nVarIdx <= NS_UN_CODES_END) + { + if (i == s.Length()) + break; + int nData = s[i++] & 0x7FFF; + + if (nVarIdx == NS_UN_SHELL_CODE) + res += GetUnicodeString(GetShellString(nData >> 8)); + else if (nVarIdx == NS_UN_VAR_CODE) + res += GetUnicodeString(GetVar(nData)); + else if (nVarIdx == NS_UN_LANG_CODE) + res += L"NS_LANG_CODE"; + } + else if (nVarIdx == NS_UN_SKIP_CODE) + { + if (i == s.Length()) + break; + res += s[i++]; + } + else // Normal char + res += (char)nVarIdx; + } + return res; +} + +AString CInArchive::ReadString2A(UInt32 pos) +{ + return GetNsisString(ReadStringA(pos)); +} + +UString CInArchive::ReadString2U(UInt32 pos) +{ + return GetNsisString(ReadStringU(pos)); +} + AString CInArchive::ReadString2(UInt32 pos) { - return GetNsisString(ReadString(pos)); + if (IsUnicode) + return UnicodeStringToMultiByte(ReadString2U(pos)); + else + return ReadString2A(pos); } #define DEL_DIR 1 @@ -566,7 +642,8 @@ AString CEntry::GetParamsString(int numParams) HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) { _posInData = bh.Offset + GetOffset(); - AString prefix; + AString prefixA; + UString prefixU; for (UInt32 i = 0; i < bh.Num; i++) { CEntry e; @@ -585,11 +662,22 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) { case EW_CREATEDIR: { - prefix.Empty(); - prefix = ReadString2(e.Params[0]); + if (IsUnicode) + { + prefixU.Empty(); + prefixU = ReadString2U(e.Params[0]); + } + else + { + prefixA.Empty(); + prefixA = ReadString2A(e.Params[0]); + } #ifdef NSIS_SCRIPT Script += " "; - Script += prefix; + if (IsUnicode) + Script += UnicodeStringToMultiByte(prefixU); + else + Script += prefixA; #endif break; } @@ -597,9 +685,18 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) case EW_EXTRACTFILE: { CItem item; - item.Prefix = prefix; + item.IsUnicode = IsUnicode; + if (IsUnicode) + { + item.PrefixU = prefixU; + item.NameU = ReadString2U(e.Params[1]); + } + else + { + item.PrefixA = prefixA; + item.NameA = ReadString2A(e.Params[1]); + } /* UInt32 overwriteFlag = e.Params[0]; */ - item.Name = ReadString2(e.Params[1]); item.Pos = e.Params[2]; item.DateTime.dwLowDateTime = e.Params[3]; item.DateTime.dwHighDateTime = e.Params[4]; @@ -614,7 +711,11 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) Items.Add(item); #ifdef NSIS_SCRIPT Script += " "; - Script += item.Name; + + if (IsUnicode) + Script += UnicodeStringToMultiByte(item.NameU); + else + Script += item.NameA; #endif break; } @@ -908,7 +1009,10 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) // if (IsSolid) for (i = 0; i + 1 < Items.Size();) { - if (Items[i].Pos == Items[i + 1].Pos && (IsSolid || Items[i].Name == Items[i + 1].Name)) + bool sameName = IsUnicode ? + (Items[i].NameU == Items[i + 1].NameU) : + (Items[i].NameA == Items[i + 1].NameA); + if (Items[i].Pos == Items[i + 1].Pos && (IsSolid || sameName)) Items.Delete(i + 1); else i++; @@ -927,8 +1031,8 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) RINOK(_stream->Seek(GetPosOfNonSolidItem(i), STREAM_SEEK_SET, NULL)); const UInt32 kSigSize = 4 + 1 + 5; BYTE sig[kSigSize]; - UInt32 processedSize; - RINOK(ReadStream(_stream, sig, kSigSize, &processedSize)); + size_t processedSize = kSigSize; + RINOK(ReadStream(_stream, sig, &processedSize)); if (processedSize < 4) return S_FALSE; UInt32 size = GetUInt32FromMemLE(sig); @@ -977,7 +1081,37 @@ HRESULT CInArchive::Parse() ReadBlockHeader(bhData); _stringsPos = bhStrings.Offset; + UInt32 pos = GetOffset() + _stringsPos; + int numZeros0 = 0; + int numZeros1 = 0; + int i; + const kBlockSize = 256; + for (i = 0; i < kBlockSize; i++) + { + if (pos >= _size || pos + 1 >= _size) + break; + char c0 = _data[pos++]; + char c1 = _data[pos++]; + wchar_t c = (c0 | ((wchar_t)c1 << 8)); + if (c >= NS_UN_CODES_START && c < NS_UN_CODES_END) + { + if (pos >= _size || pos + 1 >= _size) + break; + pos += 2; + numZeros1++; + } + else + { + if (c0 == 0 && c1 != 0) + numZeros0++; + if (c1 == 0) + numZeros1++; + } + // printf("\nnumZeros0 = %2x %2x", _data[pos + 0], _data[pos + 1]); + } + IsUnicode = (numZeros1 > numZeros0 * 3 + kBlockSize / 16); + // printf("\nnumZeros0 = %3d numZeros1 = %3d", numZeros0, numZeros1); return ReadEntries(bhEntries); } @@ -1010,10 +1144,7 @@ HRESULT CInArchive::Open2( const UInt32 kSigSize = 4 + 1 + 5 + 1; // size, flag, lzma props, lzma first byte BYTE sig[kSigSize]; - UInt32 processedSize; - RINOK(ReadStream(_stream, sig, kSigSize, &processedSize)); - if (processedSize != kSigSize) - return S_FALSE; + RINOK(ReadStream_FALSE(_stream, sig, kSigSize)); UInt64 position; RINOK(_stream->Seek(StreamOffset, STREAM_SEEK_SET, &position)); @@ -1065,11 +1196,11 @@ HRESULT CInArchive::Open2( RINOK(Decoder.Init( EXTERNAL_CODECS_LOC_VARS _stream, Method, FilterFlag, UseFilter)); - UInt32 processedSize; - RINOK(Decoder.Read(_data, unpackSize, &processedSize)); + size_t processedSize = unpackSize; + RINOK(Decoder.Read(_data, &processedSize)); if (processedSize != unpackSize) return S_FALSE; - _size = (size_t)processedSize; + _size = processedSize; if (IsSolid) { UInt32 size2 = ReadUInt32(); @@ -1081,9 +1212,7 @@ HRESULT CInArchive::Open2( { _data.SetCapacity(unpackSize); _size = (size_t)unpackSize; - RINOK(ReadStream(_stream, (Byte *)_data, unpackSize, &processedSize)); - if (processedSize != unpackSize) - return S_FALSE; + RINOK(ReadStream_FALSE(_stream, (Byte *)_data, unpackSize)); } return Parse(); } @@ -1138,22 +1267,17 @@ HRESULT CInArchive::Open( UInt64 headerPosition = 0; while (position <= maxSize) { - UInt32 processedSize; - RINOK(ReadStream(inStream, buffer, kStartHeaderSize, &processedSize)); - if (processedSize != kStartHeaderSize) - return S_FALSE; + RINOK(ReadStream_FALSE(inStream, buffer, kStartHeaderSize)); headerPosition = position; - position += processedSize; + position += kStartHeaderSize; if(memcmp(buffer + 4, kSignature, kSignatureSize) == 0) { found = true; break; } const UInt32 kRem = kStep - kStartHeaderSize; - RINOK(ReadStream(inStream, buffer + kStartHeaderSize, kRem, &processedSize)); - if (processedSize != kRem) - return S_FALSE; - position += processedSize; + RINOK(ReadStream_FALSE(inStream, buffer + kStartHeaderSize, kRem)); + position += kRem; } if (!found) return S_FALSE; diff --git a/CPP/7zip/Archive/Nsis/NsisIn.h b/CPP/7zip/Archive/Nsis/NsisIn.h index 22c050f1..e7908862 100755 --- a/CPP/7zip/Archive/Nsis/NsisIn.h +++ b/CPP/7zip/Archive/Nsis/NsisIn.h @@ -56,41 +56,56 @@ struct CBlockHeader struct CItem { - AString Prefix; - AString Name; - UInt32 Pos; + AString PrefixA; + UString PrefixU; + AString NameA; + UString NameU; + FILETIME DateTime; + bool IsUnicode; + bool UseFilter; + bool IsCompressed; bool SizeIsDefined; bool CompressedSizeIsDefined; bool EstimatedSizeIsDefined; + UInt32 Pos; 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) {} + + CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false), + CompressedSizeIsDefined(false), EstimatedSizeIsDefined(false), Size(0) {} bool IsINSTDIR() const { - if (Prefix.Length() < 3) - return false; - return true; + return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3); } - AString GetReducedName() const + AString GetReducedNameA() const { - AString prefix = Prefix; + AString prefix = PrefixA; if (prefix.Length() > 0) if (prefix[prefix.Length() - 1] != '\\') prefix += '\\'; - AString s2 = prefix + Name; + AString s2 = prefix + NameA; const int len = 9; if (s2.Left(len).CompareNoCase("$INSTDIR\\") == 0) s2 = s2.Mid(len); return s2; } + + UString GetReducedNameU() const + { + UString prefix = PrefixU; + if (prefix.Length() > 0) + if (prefix[prefix.Length() - 1] != L'\\') + prefix += L'\\'; + UString s2 = prefix + NameU; + const int len = 9; + if (s2.Left(len).CompareNoCase(L"$INSTDIR\\") == 0) + s2 = s2.Mid(len); + return s2; + } }; @@ -105,7 +120,10 @@ class CInArchive DECL_EXTERNAL_CODECS_LOC_VARS2 ); void ReadBlockHeader(CBlockHeader &bh); - AString ReadString(UInt32 pos); + AString ReadStringA(UInt32 pos); + UString ReadStringU(UInt32 pos); + AString ReadString2A(UInt32 pos); + UString ReadString2U(UInt32 pos); AString ReadString2(UInt32 pos); HRESULT ReadEntries(const CBlockHeader &bh); HRESULT Parse(); @@ -129,12 +147,13 @@ public: UInt64 StreamOffset; CDecoder Decoder; CObjectVector Items; - bool IsSolid; CFirstHeader FirstHeader; NMethodType::EEnum Method; - bool UseFilter; UInt32 DictionarySize; + bool IsSolid; + bool UseFilter; bool FilterFlag; + bool IsUnicode; #ifdef NSIS_SCRIPT AString Script; diff --git a/CPP/7zip/Archive/RPM/RpmHandler.cpp b/CPP/7zip/Archive/RPM/RpmHandler.cpp index 7cd881a1..9a9f9af4 100755 --- a/CPP/7zip/Archive/RPM/RpmHandler.cpp +++ b/CPP/7zip/Archive/RPM/RpmHandler.cpp @@ -5,20 +5,15 @@ #include "RpmHandler.h" #include "RpmIn.h" -#include "Common/Defs.h" -#include "Common/StringConvert.h" -#include "Common/NewHandler.h" #include "Common/ComTry.h" +#include "Common/MyString.h" #include "Windows/PropVariant.h" -#include "Windows/Defs.h" -#include "../../Common/StreamObjects.h" #include "../../Common/ProgressUtils.h" -#include "../../Common/LimitedStreams.h" +#include "../../Common/StreamUtils.h" #include "../../Compress/Copy/CopyCoder.h" -#include "../Common/ItemNameUtils.h" using namespace NWindows; @@ -44,10 +39,14 @@ STDMETHODIMP CHandler::Open(IInStream *inStream, if(OpenArchive(inStream) != S_OK) return S_FALSE; RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Pos)); - m_InStream = inStream; UInt64 endPosition; RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPosition)); m_Size = endPosition - m_Pos; + + RINOK(inStream->Seek(m_Pos, STREAM_SEEK_SET, NULL)); + RINOK(ReadStream_FALSE(inStream, _sig, sizeof(_sig) / sizeof(_sig[0]))); + + m_InStream = inStream; return S_OK; } catch(...) @@ -78,6 +77,21 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIAN case kpidPackedSize: prop = m_Size; break; + case kpidExtension: + { + wchar_t s[32]; + MyStringCopy(s, L"cpio."); + const wchar_t *ext; + if (_sig[0] == 0x1F && _sig[1] == 0x8B) + ext = L"gz"; + else if (_sig[0] == 'B' && _sig[1] == 'Z' && _sig[2] == 'h') + ext = L"bz2"; + else + ext = L"lzma"; + MyStringCopy(s + MyStringLen(s), ext); + prop = s; + break; + } } prop.Detach(value); return S_OK; diff --git a/CPP/7zip/Archive/RPM/RpmHandler.h b/CPP/7zip/Archive/RPM/RpmHandler.h index c78e8ce3..92efc107 100755 --- a/CPP/7zip/Archive/RPM/RpmHandler.h +++ b/CPP/7zip/Archive/RPM/RpmHandler.h @@ -22,6 +22,7 @@ private: CMyComPtr m_InStream; UInt64 m_Pos; UInt64 m_Size; + Byte _sig[4]; }; }} diff --git a/CPP/7zip/Archive/RPM/RpmIn.cpp b/CPP/7zip/Archive/RPM/RpmIn.cpp index c1600894..db7a6f63 100755 --- a/CPP/7zip/Archive/RPM/RpmIn.cpp +++ b/CPP/7zip/Archive/RPM/RpmIn.cpp @@ -32,10 +32,7 @@ static HRESULT RedSigHeaderSig(IInStream *inStream, CSigHeaderSig &h) { char dat[kCSigHeaderSigSize]; char *cur = dat; - UInt32 processedSize; - RINOK(ReadStream(inStream, dat, kCSigHeaderSigSize, &processedSize)); - if (kCSigHeaderSigSize != processedSize) - return S_FALSE; + RINOK(ReadStream_FALSE(inStream, dat, kCSigHeaderSigSize)); memmove(h.Magic, cur, 4); cur += 4; cur += 4; @@ -51,10 +48,7 @@ HRESULT OpenArchive(IInStream *inStream) char leadData[kLeadSize]; char *cur = leadData; CLead lead; - UInt32 processedSize; - RINOK(ReadStream(inStream, leadData, kLeadSize, &processedSize)); - if (kLeadSize != processedSize) - return S_FALSE; + RINOK(ReadStream_FALSE(inStream, leadData, kLeadSize)); memmove(lead.Magic, cur, 4); cur += 4; lead.Major = *cur++; diff --git a/CPP/7zip/Archive/RPM/RpmRegister.cpp b/CPP/7zip/Archive/RPM/RpmRegister.cpp index 76eb2470..61082bac 100755 --- a/CPP/7zip/Archive/RPM/RpmRegister.cpp +++ b/CPP/7zip/Archive/RPM/RpmRegister.cpp @@ -8,6 +8,6 @@ static IInArchive *CreateArc() { return new NArchive::NRpm::CHandler; } static CArcInfo g_ArcInfo = - { L"Rpm", L"rpm", L".cpio.gz", 0xEB, { 0}, 0, false, CreateArc, 0 }; + { L"Rpm", L"rpm", 0, 0xEB, { 0}, 0, false, CreateArc, 0 }; REGISTER_ARC(Rpm) diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp index fd0952d1..435c5c17 100755 --- a/CPP/7zip/Archive/Rar/RarHandler.cpp +++ b/CPP/7zip/Archive/Rar/RarHandler.cpp @@ -167,7 +167,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va case kpidIsFolder: prop = item.IsDirectory(); break; case kpidSize: prop = item.UnPackSize; break; case kpidPackedSize: prop = GetPackSize(index); break; - case kpidLastWriteTime: RarTimeToProp(item.LastWriteTime, prop); + case kpidLastWriteTime: RarTimeToProp(item.LastWriteTime, prop); break; case kpidCreationTime: if (item.IsCreationTimeDefined) RarTimeToProp(item.CreationTime, prop); break; case kpidLastAccessTime: if (item.IsLastAccessTimeDefined) RarTimeToProp(item.LastAccessTime, prop); break; case kpidAttributes: prop = item.GetWinAttributes(); break; @@ -243,6 +243,17 @@ public: { _afterPart = L".rar"; basePart = name.Left(dotPos); + } + else if (!_newStyle) + { + if (ext.CompareNoCase(L"000") == 0 || ext.CompareNoCase(L"001") == 0) + { + _afterPart.Empty(); + _first = false; + _changedPart = ext; + _unchangedPart = name.Left(dotPos + 1); + return true; + } } } diff --git a/CPP/7zip/Archive/Rar/RarIn.cpp b/CPP/7zip/Archive/Rar/RarIn.cpp index 0af72a48..efb87fb7 100755 --- a/CPP/7zip/Archive/Rar/RarIn.cpp +++ b/CPP/7zip/Archive/Rar/RarIn.cpp @@ -118,9 +118,7 @@ bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size) ((Byte *)data)[i] = bufData[m_CryptoPos++]; return (i == size); } - UInt32 processedSize; - ReadStream(m_Stream, data, size, &processedSize); - return (processedSize == size); + return (ReadStream_FALSE(m_Stream, data, size) == S_OK); } void CInArchive::ReadBytesAndTestResult(void *data, UInt32 size) @@ -131,10 +129,10 @@ void CInArchive::ReadBytesAndTestResult(void *data, UInt32 size) HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize) { - UInt32 realProcessedSize; - HRESULT result = ReadStream(m_Stream, data, size, &realProcessedSize); - if(processedSize != NULL) - *processedSize = realProcessedSize; + size_t realProcessedSize = size; + HRESULT result = ReadStream(m_Stream, data, &realProcessedSize); + if (processedSize != NULL) + *processedSize = (UInt32)realProcessedSize; AddToSeekValue(realProcessedSize); return result; } @@ -465,7 +463,9 @@ HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPa m_DecryptedData.SetCapacity(kDecryptedBufferSize); } RINOK(m_RarAES->Init()); - RINOK(ReadStream(m_Stream, (Byte *)m_DecryptedData, kDecryptedBufferSize, &m_DecryptedDataSize)); + size_t decryptedDataSizeT = kDecryptedBufferSize; + RINOK(ReadStream(m_Stream, (Byte *)m_DecryptedData, &decryptedDataSizeT)); + m_DecryptedDataSize = (UInt32)decryptedDataSizeT; m_DecryptedDataSize = m_RarAES->Filter((Byte *)m_DecryptedData, m_DecryptedDataSize); m_CryptoMode = true; @@ -529,11 +529,6 @@ HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPa } } -void CInArchive::DirectGetBytes(void *data, UInt32 size) -{ - ReadStream(m_Stream, data, size, NULL); -} - bool CInArchive::SeekInArchive(UInt64 position) { UInt64 newPosition; diff --git a/CPP/7zip/Archive/Rar/RarIn.h b/CPP/7zip/Archive/Rar/RarIn.h index f1dee321..94cea223 100755 --- a/CPP/7zip/Archive/Rar/RarIn.h +++ b/CPP/7zip/Archive/Rar/RarIn.h @@ -112,8 +112,6 @@ public: void GetArchiveInfo(CInArchiveInfo &archiveInfo) const; - void DirectGetBytes(void *data, UInt32 size); - bool SeekInArchive(UInt64 position); ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size); }; diff --git a/CPP/7zip/Archive/Tar/TarHeader.h b/CPP/7zip/Archive/Tar/TarHeader.h index 0ab31e52..19bb1cac 100755 --- a/CPP/7zip/Archive/Tar/TarHeader.h +++ b/CPP/7zip/Archive/Tar/TarHeader.h @@ -75,6 +75,15 @@ namespace NFileHeader const char kDirectory = '5'; // Directory const char kFIFO = '6'; // FIFO special file const char kContiguous = '7'; // Contiguous file + + const char kDumpDir = 'D'; /* GNUTYPE_DUMPDIR. + data: list of files created by the --incremental (-G) option + Each file name is preceded by either + - 'Y' (file should be in this archive) + - 'N' (file is a directory, or is not stored in the archive.) + Each file name is terminated by a null + an additional null after + the last file name. */ + } // Further link types may be defined later. diff --git a/CPP/7zip/Archive/Tar/TarIn.cpp b/CPP/7zip/Archive/Tar/TarIn.cpp index bae1db86..1318613a 100755 --- a/CPP/7zip/Archive/Tar/TarIn.cpp +++ b/CPP/7zip/Archive/Tar/TarIn.cpp @@ -13,9 +13,10 @@ namespace NArchive { namespace NTar { -HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize) +HRESULT CInArchive::ReadBytes(void *data, size_t size, size_t &processedSize) { - RINOK(ReadStream(m_Stream, data, size, &processedSize)); + processedSize = size; + RINOK(ReadStream(m_Stream, data, &processedSize)); m_Position += processedSize; return S_OK; } @@ -93,7 +94,7 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item) filled = false; - UInt32 processedSize; + size_t processedSize; item.HeaderPosition = m_Position; RINOK(ReadBytes(record, NFileHeader::kRecordSize, processedSize)); if (processedSize == 0 || @@ -174,7 +175,8 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item) AString prefix; ReadString(cur, NFileHeader::kPrefixSize, prefix); cur += NFileHeader::kPrefixSize; - if (!prefix.IsEmpty() && item.IsMagic()) + if (!prefix.IsEmpty() && item.IsMagic() && + (item.LinkFlag != 'L' /* || prefix != "00000000000" */ )) item.Name = prefix + AString('/') + item.Name; if (item.LinkFlag == NFileHeader::NLinkFlag::kLink) @@ -205,10 +207,12 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item) return S_FALSE; UInt64 headerPosition = item.HeaderPosition; - UInt32 processedSize; + size_t processedSize; AString fullName; - char *buffer = fullName.GetBuffer((UInt32)item.Size + 1); - RINOK(ReadBytes(buffer, (UInt32)item.Size, processedSize)); + if (item.Size > (1 << 15)) + return S_FALSE; + char *buffer = fullName.GetBuffer((int)item.Size + 1); + RINOK(ReadBytes(buffer, (size_t)item.Size, processedSize)); buffer[item.Size] = '\0'; fullName.ReleaseBuffer(); if (processedSize != item.Size) @@ -224,6 +228,11 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item) // pax Extended Header return S_OK; } + else if (item.LinkFlag == NFileHeader::NLinkFlag::kDumpDir) + { + // GNU Extensions to the Archive Format + return S_OK; + } else if (item.LinkFlag > '7' || (item.LinkFlag < '0' && item.LinkFlag != 0)) return S_FALSE; return S_OK; diff --git a/CPP/7zip/Archive/Tar/TarIn.h b/CPP/7zip/Archive/Tar/TarIn.h index 28781375..20c030ef 100755 --- a/CPP/7zip/Archive/Tar/TarIn.h +++ b/CPP/7zip/Archive/Tar/TarIn.h @@ -16,7 +16,7 @@ class CInArchive CMyComPtr m_Stream; UInt64 m_Position; - HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize); + HRESULT ReadBytes(void *data, size_t size, size_t &processedSize); public: HRESULT Open(IInStream *inStream); HRESULT GetNextItemReal(bool &filled, CItemEx &itemInfo); diff --git a/CPP/7zip/Archive/Tar/TarItem.h b/CPP/7zip/Archive/Tar/TarItem.h index 10b57cd0..451d74bc 100755 --- a/CPP/7zip/Archive/Tar/TarItem.h +++ b/CPP/7zip/Archive/Tar/TarItem.h @@ -35,16 +35,18 @@ public: UInt32 DeviceMinor; bool IsDirectory() const - { - if (LinkFlag == NFileHeader::NLinkFlag::kDirectory) + { + switch(LinkFlag) + { + case NFileHeader::NLinkFlag::kDirectory: + case NFileHeader::NLinkFlag::kDumpDir: return true; - if (LinkFlag == NFileHeader::NLinkFlag::kOldNormal || - LinkFlag == NFileHeader::NLinkFlag::kNormal) - { + case NFileHeader::NLinkFlag::kOldNormal: + case NFileHeader::NLinkFlag::kNormal: return NItemName::HasTailSlash(Name, CP_OEMCP); - } - return false; } + return false; + } bool IsMagic() const { diff --git a/CPP/7zip/Archive/Tar/TarOut.cpp b/CPP/7zip/Archive/Tar/TarOut.cpp index e278edda..a697b4d2 100755 --- a/CPP/7zip/Archive/Tar/TarOut.cpp +++ b/CPP/7zip/Archive/Tar/TarOut.cpp @@ -14,11 +14,7 @@ namespace NTar { HRESULT COutArchive::WriteBytes(const void *buffer, UInt32 size) { - UInt32 processedSize; - RINOK(WriteStream(m_Stream, buffer, size, &processedSize)); - if(processedSize != size) - return E_FAIL; - return S_OK; + return WriteStream(m_Stream, buffer, size); } void COutArchive::Create(ISequentialOutStream *outStream) diff --git a/CPP/7zip/Archive/Wim/WimHandler.cpp b/CPP/7zip/Archive/Wim/WimHandler.cpp index 38c1c6ae..baa2c824 100755 --- a/CPP/7zip/Archive/Wim/WimHandler.cpp +++ b/CPP/7zip/Archive/Wim/WimHandler.cpp @@ -76,7 +76,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) { UInt16 volIndex = m_Xmls[0].VolIndex; if (volIndex < m_Volumes.Size()) - prop = m_Volumes[volIndex].Header.PartNumber; + prop = (UInt32)m_Volumes[volIndex].Header.PartNumber; } break; case kpidNumVolumes: if (m_Volumes.Size() > 0) prop = (UInt32)(m_Volumes.Size() - 1); @@ -413,7 +413,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, currentItemUnPacked = data.GetCapacity(); if (realOutStream) { - RINOK(WriteStream(realOutStream, (const Byte *)data, (UInt32)data.GetCapacity(), NULL)); + RINOK(WriteStream(realOutStream, (const Byte *)data, data.GetCapacity())); realOutStream.Release(); } RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); diff --git a/CPP/7zip/Archive/Wim/WimIn.cpp b/CPP/7zip/Archive/Wim/WimIn.cpp index 951fc79b..e9efdaa4 100755 --- a/CPP/7zip/Archive/Wim/WimIn.cpp +++ b/CPP/7zip/Archive/Wim/WimIn.cpp @@ -21,27 +21,10 @@ namespace NWim{ static const int kChunkSizeBits = 15; static const UInt32 kChunkSize = (1 << kChunkSizeBits); -static HRESULT ReadBytes(ISequentialInStream *inStream, void *data, UInt32 size) -{ - UInt32 realProcessedSize; - RINOK(ReadStream(inStream, data, size, &realProcessedSize)); - return (realProcessedSize == size) ? S_OK : S_FALSE; -} - -#ifdef LITTLE_ENDIAN_UNALIGN -static inline UInt16 GetUInt16FromMem(const Byte *p) { return *(const UInt16 *)p; } -static inline UInt32 GetUInt32FromMem(const Byte *p) { return *(const UInt32 *)p; } -static inline UInt64 GetUInt64FromMem(const Byte *p) { return *(const UInt64 *)p; } -#else -static UInt16 GetUInt16FromMem(const Byte *p) { return p[0] | ((UInt16)p[1] << 8); } -static UInt32 GetUInt32FromMem(const Byte *p) { return p[0] | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16) | ((UInt32)p[3] << 24); } -static UInt64 GetUInt64FromMem(const Byte *p) { return GetUInt32FromMem(p) | ((UInt64)GetUInt32FromMem(p + 4) << 32); } -#endif - static void GetFileTimeFromMem(const Byte *p, FILETIME *ft) { - ft->dwLowDateTime = GetUInt32FromMem(p); - ft->dwHighDateTime = GetUInt32FromMem(p + 4); + ft->dwLowDateTime = GetUi32(p); + ft->dwHighDateTime = GetUi32(p + 4); } HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, @@ -70,7 +53,7 @@ HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, UInt64 numChunks = (resource.UnpackSize + kChunkSize - 1) >> kChunkSizeBits; unsigned entrySize = ((resource.UnpackSize > (UInt64)1 << 32) ? 8 : 4); UInt64 sizesBufSize64 = entrySize * (numChunks - 1); - UInt32 sizesBufSize = (UInt32)sizesBufSize64; + size_t sizesBufSize = (size_t)sizesBufSize64; if (sizesBufSize != sizesBufSize64) return E_OUTOFMEMORY; if (sizesBufSize > sizesBuf.GetCapacity()) @@ -78,7 +61,7 @@ HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, sizesBuf.Free(); sizesBuf.SetCapacity(sizesBufSize); } - RINOK(ReadBytes(inStream, (Byte *)sizesBuf, sizesBufSize)); + RINOK(ReadStream_FALSE(inStream, (Byte *)sizesBuf, sizesBufSize)); const Byte *p = (const Byte *)sizesBuf; if (!lzxDecoder) @@ -96,17 +79,17 @@ HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, if (i > 0) { if (entrySize == 4) - offset = GetUInt32FromMem(p); + offset = GetUi32(p); else - offset = GetUInt64FromMem(p); + offset = GetUi64(p); p += entrySize; } UInt64 nextOffset = resource.PackSize - sizesBufSize64; if (i + 1 < (UInt32)numChunks) if (entrySize == 4) - nextOffset = GetUInt32FromMem(p); + nextOffset = GetUi32(p); else - nextOffset = GetUInt64FromMem(p); + nextOffset = GetUi64(p); if (nextOffset < offset) return S_FALSE; @@ -166,16 +149,16 @@ static const Byte kSignature[kSignatureSize] = { 'M', 'S', 'W', 'I', 'M', 0, 0, static void GetResource(const Byte *p, CResource &res) { res.Flags = p[7]; - res.PackSize = GetUInt64FromMem(p) & (((UInt64)1 << 56) - 1); - res.Offset = GetUInt64FromMem(p + 8); - res.UnpackSize = GetUInt64FromMem(p + 16); + res.PackSize = GetUi64(p) & (((UInt64)1 << 56) - 1); + res.Offset = GetUi64(p + 8); + res.UnpackSize = GetUi64(p + 16); } static void GetStream(const Byte *p, CStreamInfo &s) { GetResource(p, s.Resource); - s.PartNumber = GetUInt16FromMem(p + 24); - s.RefCount = GetUInt32FromMem(p + 26); + s.PartNumber = GetUi16(p + 24); + s.RefCount = GetUi32(p + 26); memcpy(s.Hash, p + 30, kHashSize); } @@ -187,22 +170,22 @@ static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size, if (pos + 8 > size) return S_FALSE; const Byte *p = base + pos; - UInt64 length = GetUInt64FromMem(p); + UInt64 length = GetUi64(p); if (length == 0) return S_OK; if (pos + 102 > size || pos + length + 8 > size || length > ((UInt64)1 << 62)) return S_FALSE; CItem item; - item.Attributes = GetUInt32FromMem(p + 8); - // item.SecurityId = GetUInt32FromMem(p + 0xC); - UInt64 subdirOffset = GetUInt64FromMem(p + 0x10); + item.Attributes = GetUi32(p + 8); + // item.SecurityId = GetUi32(p + 0xC); + UInt64 subdirOffset = GetUi64(p + 0x10); GetFileTimeFromMem(p + 0x28, &item.CreationTime); GetFileTimeFromMem(p + 0x30, &item.LastAccessTime); GetFileTimeFromMem(p + 0x38, &item.LastWriteTime); memcpy(item.Hash, p + 0x40, kHashSize); - // UInt16 shortNameLen = GetUInt16FromMem(p + 98); - UInt16 fileNameLen = GetUInt16FromMem(p + 100); + // UInt16 shortNameLen = GetUi16(p + 98); + UInt16 fileNameLen = GetUi16(p + 100); size_t tempPos = pos + 102; if (tempPos + fileNameLen > size) @@ -212,7 +195,7 @@ static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size, MyStringCopy(sz, (const wchar_t *)prefix); sz += prefix.Length(); for (UInt16 i = 0; i + 2 <= fileNameLen; i += 2) - *sz++ = GetUInt16FromMem(base + tempPos + i); + *sz++ = GetUi16(base + tempPos + i); *sz++ = '\0'; item.Name.ReleaseBuffer(); if (fileNameLen == 0 && item.IsDirectory() && !item.HasStream()) @@ -238,8 +221,8 @@ static HRESULT ParseDir(const Byte *base, size_t size, if (pos + 8 > size) return S_FALSE; const Byte *p = base + pos; - UInt32 totalLength = GetUInt32FromMem(p); - // UInt32 numEntries = GetUInt32FromMem(p + 4); + UInt32 totalLength = GetUi32(p); + // UInt32 numEntries = GetUi32(p + 4); pos += 8; { /* @@ -249,7 +232,7 @@ static HRESULT ParseDir(const Byte *base, size_t size, { if (pos + 8 > size) return S_FALSE; - UInt64 len = GetUInt64FromMem(p + pos); + UInt64 len = GetUi64(p + pos); entryLens.Add(len); sum += len; pos += 8; @@ -322,25 +305,25 @@ HRESULT ReadHeader(IInStream *inStream, CHeader &h) { const UInt32 kHeaderSizeMax = 0xD0; Byte p[kHeaderSizeMax]; - RINOK(ReadBytes(inStream, p, kHeaderSizeMax)); - UInt32 haderSize = GetUInt32FromMem(p + 8); + RINOK(ReadStream_FALSE(inStream, p, kHeaderSizeMax)); + UInt32 haderSize = GetUi32(p + 8); if (memcmp(p, kSignature, kSignatureSize) != 0) return S_FALSE; if (haderSize < 0x74) return S_FALSE; - h.Version = GetUInt32FromMem(p + 0x0C); - h.Flags = GetUInt32FromMem(p + 0x10); + h.Version = GetUi32(p + 0x0C); + h.Flags = GetUi32(p + 0x10); if (!h.IsSupported()) return S_FALSE; - if (GetUInt32FromMem(p + 0x14) != kChunkSize) + if (GetUi32(p + 0x14) != kChunkSize) return S_FALSE; memcpy(h.Guid, p + 0x18, 16); - h.PartNumber = GetUInt16FromMem(p + 0x28); - h.NumParts = GetUInt16FromMem(p + 0x2A); + h.PartNumber = GetUi16(p + 0x28); + h.NumParts = GetUi16(p + 0x2A); int offset = 0x2C; if (h.IsNewVersion()) { - h.NumImages = GetUInt32FromMem(p + offset); + h.NumImages = GetUi32(p + offset); offset += 4; } GetResource(p + offset, h.OffsetResource); @@ -352,7 +335,7 @@ HRESULT ReadHeader(IInStream *inStream, CHeader &h) if (haderSize < 0xD0) return S_FALSE; GetResource(p + offset + 0x4C, h.IntegrityResource); - h.BootIndex = GetUInt32FromMem(p + 0x48); + h.BootIndex = GetUi32(p + 0x48); } */ return S_OK; diff --git a/CPP/7zip/Archive/Z/ZHandler.cpp b/CPP/7zip/Archive/Z/ZHandler.cpp index 73f391f7..81289050 100755 --- a/CPP/7zip/Archive/Z/ZHandler.cpp +++ b/CPP/7zip/Archive/Z/ZHandler.cpp @@ -55,10 +55,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream, { RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_streamStartPosition)); Byte buffer[kSignatureSize]; - UInt32 processedSize; - RINOK(ReadStream(stream, buffer, kSignatureSize, &processedSize)); - if (processedSize != kSignatureSize) - return S_FALSE; + RINOK(ReadStream_FALSE(stream, buffer, kSignatureSize)); if (buffer[0] != 0x1F || buffer[1] != 0x9D) return S_FALSE; _properties = buffer[2]; diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp index 0344f776..0f76b04a 100755 --- a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp +++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp @@ -43,7 +43,7 @@ static HRESULT GetStreamCRC(ISequentialInStream *inStream, UInt32 &resultCRC) resultCRC = CRC_GET_DIGEST(crc); return S_OK; } - crc = CrcUpdate(crc, buffer, realProcessedSize); + crc = CrcUpdate(crc, buffer, (size_t)realProcessedSize); } } diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp index c3576eeb..7d478a36 100755 --- a/CPP/7zip/Archive/Zip/ZipHandler.cpp +++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp @@ -81,6 +81,9 @@ STATPROPSTG kProps[] = { NULL, kpidSize, VT_UI8}, { NULL, kpidPackedSize, VT_UI8}, { NULL, kpidLastWriteTime, VT_FILETIME}, + { NULL, kpidCreationTime, VT_FILETIME}, + { NULL, kpidLastAccessTime, VT_FILETIME}, + { NULL, kpidAttributes, VT_UI4}, { NULL, kpidEncrypted, VT_BOOL}, @@ -150,17 +153,18 @@ CHandler::CHandler(): InitMethodProperties(); } -static void StringToProp(const CByteBuffer &data, UINT codePage, NWindows::NCOM::CPropVariant &prop) +static AString BytesToString(const CByteBuffer &data) { - int size = (int)data.GetCapacity(); - if (size <= 0) - return; AString s; - char *p = s.GetBuffer(size + 1); - memcpy(p, (const Byte *)data, size); - p[size] = '\0'; - s.ReleaseBuffer(); - prop = MultiByteToUnicodeString(s, codePage); + int size = (int)data.GetCapacity(); + if (size > 0) + { + char *p = s.GetBuffer(size + 1); + memcpy(p, (const Byte *)data, size); + p[size] = '\0'; + s.ReleaseBuffer(); + } + return s; } IMP_IInArchive_Props @@ -173,10 +177,8 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) switch(propID) { case kpidComment: - { - StringToProp(m_Archive.m_ArchiveInfo.Comment, CP_ACP, prop); + prop = MultiByteToUnicodeString(BytesToString(m_Archive.m_ArchiveInfo.Comment), CP_ACP); break; - } } prop.Detach(value); COM_TRY_END @@ -197,8 +199,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val switch(propID) { case kpidPath: - prop = NItemName::GetOSName2( - MultiByteToUnicodeString(item.Name, item.GetCodePage())); + prop = NItemName::GetOSName2(item.GetUnicodeString(item.Name)); break; case kpidIsFolder: prop = item.IsDirectory(); @@ -209,16 +210,39 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val case kpidPackedSize: prop = item.PackSize; break; + case kpidTimeType: + FILETIME utcFileTime; + if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kTagTime, utcFileTime)) + prop = (UInt32)NFileTimeType::kWindows; + break; + case kpidCreationTime: + { + FILETIME ft; + if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kCTime, ft)) + prop = ft; + break; + } + case kpidLastAccessTime: + { + FILETIME ft; + if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kATime, ft)) + prop = ft; + break; + } case kpidLastWriteTime: { - FILETIME localFileTime, utcFileTime; - if (DosTimeToFileTime(item.Time, localFileTime)) + FILETIME utcFileTime; + if (!item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kMTime, utcFileTime)) { - if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime)) + FILETIME localFileTime; + if (DosTimeToFileTime(item.Time, localFileTime)) + { + if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime)) + utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0; + } + else utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0; } - else - utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0; prop = utcFileTime; break; } @@ -230,7 +254,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val break; case kpidComment: { - StringToProp(item.Comment, item.GetCodePage(), prop); + prop = item.GetUnicodeString(BytesToString(item.Comment)); break; } case kpidCRC: diff --git a/CPP/7zip/Archive/Zip/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h index 28f44196..c8fa392c 100755 --- a/CPP/7zip/Archive/Zip/ZipHandler.h +++ b/CPP/7zip/Archive/Zip/ZipHandler.h @@ -59,6 +59,10 @@ private: bool m_IsAesMode; Byte m_AesKeyMode; + bool m_WriteNtfsTimeExtra; + bool m_ForseLocal; + bool m_ForseUtf8; + #ifdef COMPRESS_MT UInt32 _numThreads; #endif @@ -77,6 +81,9 @@ private: m_NumMatchFinderCyclesDefined = false; m_IsAesMode = false; m_AesKeyMode = 3; // aes-256 + m_WriteNtfsTimeExtra = false; + m_ForseLocal = false; + m_ForseUtf8 = false; #ifdef COMPRESS_MT _numThreads = NWindows::NSystem::GetNumberOfProcessors();; #endif diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp index 453c37a3..2846c988 100755 --- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp +++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp @@ -66,138 +66,179 @@ static bool IsAsciiString(const UString &s) catch(const CSystemException &e) { return e.ErrorCode; } \ catch(...) { return E_OUTOFMEMORY; } +static HRESULT GetTime(IArchiveUpdateCallback *callback, int index, PROPID propID, FILETIME &filetime) +{ + filetime.dwHighDateTime = filetime.dwLowDateTime = 0; + NCOM::CPropVariant prop; + RINOK(callback->GetProperty(index, propID, &prop)); + if (prop.vt == VT_FILETIME) + filetime = prop.filetime; + else if (prop.vt != VT_EMPTY) + return E_INVALIDARG; + return S_OK; +} + STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems, - IArchiveUpdateCallback *updateCallback) + IArchiveUpdateCallback *callback) { COM_TRY_BEGIN2 CObjectVector updateItems; for(UInt32 i = 0; i < numItems; i++) { - CUpdateItem updateItem; + CUpdateItem ui; Int32 newData; Int32 newProperties; UInt32 indexInArchive; - if (!updateCallback) + if (!callback) return E_FAIL; - RINOK(updateCallback->GetUpdateItemInfo(i, + RINOK(callback->GetUpdateItemInfo(i, &newData, // 1 - compress 0 - copy &newProperties, &indexInArchive)); - updateItem.NewProperties = IntToBool(newProperties); - updateItem.NewData = IntToBool(newData); - updateItem.IndexInArchive = indexInArchive; - updateItem.IndexInClient = i; + ui.NewProperties = IntToBool(newProperties); + ui.NewData = IntToBool(newData); + ui.IndexInArchive = indexInArchive; + ui.IndexInClient = i; // bool existInArchive = (indexInArchive != UInt32(-1)); if (IntToBool(newProperties)) { - FILETIME utcFileTime; UString name; bool isDirectoryStatusDefined; { - NCOM::CPropVariant propVariant; - RINOK(updateCallback->GetProperty(i, kpidAttributes, &propVariant)); - if (propVariant.vt == VT_EMPTY) - updateItem.Attributes = 0; - else if (propVariant.vt != VT_UI4) + NCOM::CPropVariant prop; + RINOK(callback->GetProperty(i, kpidAttributes, &prop)); + if (prop.vt == VT_EMPTY) + ui.Attributes = 0; + else if (prop.vt != VT_UI4) return E_INVALIDARG; else - updateItem.Attributes = propVariant.ulVal; - } - { - NCOM::CPropVariant propVariant; - RINOK(updateCallback->GetProperty(i, kpidLastWriteTime, &propVariant)); - if (propVariant.vt != VT_FILETIME) - return E_INVALIDARG; - utcFileTime = propVariant.filetime; + ui.Attributes = prop.ulVal; } + { - NCOM::CPropVariant propVariant; - RINOK(updateCallback->GetProperty(i, kpidPath, &propVariant)); - if (propVariant.vt == VT_EMPTY) + NCOM::CPropVariant prop; + RINOK(callback->GetProperty(i, kpidPath, &prop)); + if (prop.vt == VT_EMPTY) name.Empty(); - else if (propVariant.vt != VT_BSTR) + else if (prop.vt != VT_BSTR) return E_INVALIDARG; else - name = propVariant.bstrVal; + name = prop.bstrVal; } { - NCOM::CPropVariant propVariant; - RINOK(updateCallback->GetProperty(i, kpidIsFolder, &propVariant)); - if (propVariant.vt == VT_EMPTY) + NCOM::CPropVariant prop; + RINOK(callback->GetProperty(i, kpidIsFolder, &prop)); + if (prop.vt == VT_EMPTY) isDirectoryStatusDefined = false; - else if (propVariant.vt != VT_BOOL) + else if (prop.vt != VT_BOOL) return E_INVALIDARG; else { - updateItem.IsDirectory = (propVariant.boolVal != VARIANT_FALSE); + ui.IsDirectory = (prop.boolVal != VARIANT_FALSE); isDirectoryStatusDefined = true; } } - FILETIME localFileTime; - if(!FileTimeToLocalFileTime(&utcFileTime, &localFileTime)) - return E_INVALIDARG; - if(!FileTimeToDosTime(localFileTime, updateItem.Time)) + + { + CPropVariant prop; + RINOK(callback->GetProperty(i, kpidTimeType, &prop)); + if (prop.vt == VT_UI4) + ui.NtfsTimeIsDefined = (prop.ulVal == NFileTimeType::kWindows); + else + ui.NtfsTimeIsDefined = m_WriteNtfsTimeExtra; + } + RINOK(GetTime(callback, i, kpidLastWriteTime, ui.NtfsMTime)); + RINOK(GetTime(callback, i, kpidLastAccessTime, ui.NtfsATime)); + RINOK(GetTime(callback, i, kpidCreationTime, ui.NtfsCTime)); + { - // return E_INVALIDARG; + FILETIME localFileTime = { 0, 0 }; + if (ui.NtfsMTime.dwHighDateTime != 0 || + ui.NtfsMTime.dwLowDateTime != 0) + if (!FileTimeToLocalFileTime(&ui.NtfsMTime, &localFileTime)) + return E_INVALIDARG; + FileTimeToDosTime(localFileTime, ui.Time); } if (!isDirectoryStatusDefined) - updateItem.IsDirectory = ((updateItem.Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0); + ui.IsDirectory = ((ui.Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0); name = NItemName::MakeLegalName(name); - bool needSlash = updateItem.IsDirectory; + bool needSlash = ui.IsDirectory; const wchar_t kSlash = L'/'; if (!name.IsEmpty()) { if (name[name.Length() - 1] == kSlash) { - if (!updateItem.IsDirectory) + if (!ui.IsDirectory) return E_INVALIDARG; needSlash = false; } } if (needSlash) name += kSlash; - updateItem.Name = UnicodeStringToMultiByte(name, CP_OEMCP); - if (updateItem.Name.Length() > 0xFFFF) + + bool tryUtf8 = true; + if (m_ForseLocal || !m_ForseUtf8) + { + bool defaultCharWasUsed; + ui.Name = UnicodeStringToMultiByte(name, CP_OEMCP, '_', defaultCharWasUsed); + tryUtf8 = (!m_ForseLocal && defaultCharWasUsed); + } + + if (tryUtf8) + { + bool needUtf = false; + for (int i = 0; i < name.Length(); i++) + if ((unsigned)name[i] >= 0x80) + { + needUtf = true; + break; + } + ui.IsUtf8 = needUtf; + if (!ConvertUnicodeToUTF8(name, ui.Name)) + return E_INVALIDARG; + } + + if (ui.Name.Length() > 0xFFFF) return E_INVALIDARG; - updateItem.IndexInClient = i; + ui.IndexInClient = i; /* if(existInArchive) { const CItemEx &itemInfo = m_Items[indexInArchive]; - // updateItem.Commented = itemInfo.IsCommented(); - updateItem.Commented = false; - if(updateItem.Commented) + // ui.Commented = itemInfo.IsCommented(); + ui.Commented = false; + if(ui.Commented) { - updateItem.CommentRange.Position = itemInfo.GetCommentPosition(); - updateItem.CommentRange.Size = itemInfo.CommentSize; + ui.CommentRange.Position = itemInfo.GetCommentPosition(); + ui.CommentRange.Size = itemInfo.CommentSize; } } else - updateItem.Commented = false; + ui.Commented = false; */ } if (IntToBool(newData)) { UInt64 size; { - NCOM::CPropVariant propVariant; - RINOK(updateCallback->GetProperty(i, kpidSize, &propVariant)); - if (propVariant.vt != VT_UI8) + NCOM::CPropVariant prop; + RINOK(callback->GetProperty(i, kpidSize, &prop)); + if (prop.vt != VT_UI8) return E_INVALIDARG; - size = propVariant.uhVal.QuadPart; + size = prop.uhVal.QuadPart; } - updateItem.Size = size; + ui.Size = size; } - updateItems.Add(updateItem); + updateItems.Add(ui); } CMyComPtr getTextPassword; if (!getTextPassword) { - CMyComPtr udateCallBack2(updateCallback); + CMyComPtr udateCallBack2(callback); udateCallBack2.QueryInterface(IID_ICryptoGetTextPassword2, &getTextPassword); } CCompressionMethodMode options; @@ -281,7 +322,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt return Update( EXTERNAL_CODECS_VARS m_Items, updateItems, outStream, - m_ArchiveIsOpen ? &m_Archive : NULL, &options, updateCallback); + m_ArchiveIsOpen ? &m_Archive : NULL, &options, callback); COM_TRY_END2 } @@ -406,6 +447,22 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v RINOK(ParsePropValue(name.Mid(1), prop, num)); m_Algo = num; } + else if (name.CompareNoCase(L"TC") == 0) + return SetBoolProperty(m_WriteNtfsTimeExtra, prop); + else if (name.CompareNoCase(L"CL") == 0) + { + RINOK(SetBoolProperty(m_ForseLocal, prop)); + if (m_ForseLocal) + m_ForseUtf8 = false; + return S_OK; + } + else if (name.CompareNoCase(L"CU") == 0) + { + RINOK(SetBoolProperty(m_ForseUtf8, prop)); + if (m_ForseUtf8) + m_ForseLocal = false; + return S_OK; + } else return E_INVALIDARG; } diff --git a/CPP/7zip/Archive/Zip/ZipHeader.h b/CPP/7zip/Archive/Zip/ZipHeader.h index 98ad17a3..0c978a7c 100755 --- a/CPP/7zip/Archive/Zip/ZipHeader.h +++ b/CPP/7zip/Archive/Zip/ZipHeader.h @@ -86,11 +86,23 @@ namespace NFileHeader enum { kZip64 = 0x01, + kNTFS = 0x0A, kStrongEncrypt = 0x17, kWzAES = 0x9901 }; } + namespace NNtfsExtra + { + const UInt16 kTagTime = 1; + enum + { + kMTime = 0, + kATime = 1, + kCTime = 2 + }; + } + const UInt32 kLocalBlockSize = 26; /* struct CLocalBlock @@ -156,13 +168,11 @@ namespace NFileHeader namespace NFlags { - const int kNumUsedBits = 4; - const int kUsedBitsMask = (1 << kNumUsedBits) - 1; - const int kEncrypted = 1 << 0; const int kDescriptorUsedMask = 1 << 3; const int kStrongEncrypted = 1 << 6; - + const int kUtf8 = 1 << 11; + const int kImplodeDictionarySizeMask = 1 << 1; const int kImplodeLiteralsOnMask = 1 << 2; diff --git a/CPP/7zip/Archive/Zip/ZipIn.cpp b/CPP/7zip/Archive/Zip/ZipIn.cpp index b579f9b4..f8e81c59 100755 --- a/CPP/7zip/Archive/Zip/ZipIn.cpp +++ b/CPP/7zip/Archive/Zip/ZipIn.cpp @@ -114,10 +114,10 @@ bool CInArchive::FindAndReadMarker(const UInt64 *searchHeaderSizeLimit) HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize) { - UInt32 realProcessedSize; - HRESULT result = ReadStream(m_Stream, data, size, &realProcessedSize); + size_t realProcessedSize = size; + HRESULT result = ReadStream(m_Stream, data, &realProcessedSize); if(processedSize != NULL) - *processedSize = realProcessedSize; + *processedSize = (UInt32)realProcessedSize; m_Position += realProcessedSize; return result; } @@ -304,7 +304,7 @@ HRESULT CInArchive::ReadLocalItem(CItemEx &item) { item.ExtractVersion.Version = ReadByte(); item.ExtractVersion.HostOS = ReadByte(); - item.Flags = ReadUInt16(); // & NFileHeader::NFlags::kUsedBitsMask; + item.Flags = ReadUInt16(); item.CompressionMethod = ReadUInt16(); item.Time = ReadUInt32(); item.FileCRC = ReadUInt32(); @@ -467,7 +467,7 @@ HRESULT CInArchive::ReadCdItem(CItemEx &item) item.MadeByVersion.HostOS = ReadByte(); item.ExtractVersion.Version = ReadByte(); item.ExtractVersion.HostOS = ReadByte(); - item.Flags = ReadUInt16(); // & NFileHeader::NFlags::kUsedBitsMask; + item.Flags = ReadUInt16(); item.CompressionMethod = ReadUInt16(); item.Time = ReadUInt32(); item.FileCRC = ReadUInt32(); @@ -772,7 +772,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector &items, CProgressVirt *pr return S_FALSE; UInt16 thisDiskNumber16 = ReadUInt16(); - if (!isZip64 || thisDiskNumber16) + if (!isZip64 || thisDiskNumber16 != 0xFFFF) thisDiskNumber = thisDiskNumber16; UInt16 startCDDiskNumber16 = ReadUInt16(); diff --git a/CPP/7zip/Archive/Zip/ZipItem.cpp b/CPP/7zip/Archive/Zip/ZipItem.cpp index 480a1abb..484696f5 100755 --- a/CPP/7zip/Archive/Zip/ZipItem.cpp +++ b/CPP/7zip/Archive/Zip/ZipItem.cpp @@ -5,6 +5,7 @@ #include "ZipHeader.h" #include "ZipItem.h" #include "../Common/ItemNameUtils.h" +#include "../../../../C/CpuArch.h" namespace NArchive { namespace NZip { @@ -19,6 +20,37 @@ bool operator!=(const CVersion &v1, const CVersion &v2) return !(v1 == v2); } +bool CExtraSubBlock::ExtractNtfsTime(int index, FILETIME &ft) const +{ + ft.dwHighDateTime = ft.dwLowDateTime = 0; + UInt32 size = (UInt32)Data.GetCapacity(); + if (ID != NFileHeader::NExtraID::kNTFS || size < 32) + return false; + const Byte *p = (const Byte *)Data; + p += 4; // for reserved + size -= 4; + while (size > 4) + { + UInt16 tag = GetUi16(p); + UInt32 attrSize = GetUi16(p + 2); + p += 4; + size -= 4; + if (attrSize > size) + attrSize = size; + + if (tag == NFileHeader::NNtfsExtra::kTagTime && attrSize >= 24) + { + p += 8 * index; + ft.dwLowDateTime = GetUi32(p); + ft.dwHighDateTime = GetUi32(p + 4); + return true; + } + p += attrSize; + size -= attrSize; + } + return false; +} + bool CLocalItem::IsImplodeBigDictionary() const { if (CompressionMethod != NFileHeader::NCompressionMethod::kImploded) @@ -126,5 +158,7 @@ void CLocalItem::SetBitMask(int bitMask, bool enable) void CLocalItem::SetEncrypted(bool encrypted) { SetBitMask(NFileHeader::NFlags::kEncrypted, encrypted); } +void CLocalItem::SetUtf8(bool isUtf8) + { SetBitMask(NFileHeader::NFlags::kUtf8, isUtf8); } }} diff --git a/CPP/7zip/Archive/Zip/ZipItem.h b/CPP/7zip/Archive/Zip/ZipItem.h index 350e81b6..8d7cc3b4 100755 --- a/CPP/7zip/Archive/Zip/ZipItem.h +++ b/CPP/7zip/Archive/Zip/ZipItem.h @@ -6,6 +6,8 @@ #include "Common/Types.h" #include "Common/MyString.h" #include "Common/Buffer.h" +#include "Common/UTFConvert.h" +#include "Common/StringConvert.h" #include "ZipHeader.h" @@ -25,6 +27,7 @@ struct CExtraSubBlock { UInt16 ID; CByteBuffer Data; + bool ExtractNtfsTime(int index, FILETIME &ft) const; }; struct CWzAesExtraField @@ -137,6 +140,17 @@ struct CExtraBlock return GetWzAesField(aesField); } + bool GetNtfsTime(int index, FILETIME &ft) const + { + for (int i = 0; i < SubBlocks.Size(); i++) + { + const CExtraSubBlock &sb = SubBlocks[i]; + if (sb.ID == NFileHeader::NExtraID::kNTFS) + return sb.ExtractNtfsTime(index, ft); + } + return false; + } + /* bool HasStrongCryptoField() const { @@ -147,14 +161,9 @@ struct CExtraBlock void RemoveUnknownSubBlocks() { - for (int i = SubBlocks.Size() - 1; i >= 0;) - { - const CExtraSubBlock &subBlock = SubBlocks[i]; - if (subBlock.ID != NFileHeader::NExtraID::kWzAES) + for (int i = SubBlocks.Size() - 1; i >= 0; i--) + if (SubBlocks[i].ID != NFileHeader::NExtraID::kWzAES) SubBlocks.Delete(i); - else - i--; - } } }; @@ -173,6 +182,8 @@ public: AString Name; CExtraBlock LocalExtra; + + bool IsUtf8() const { return (Flags & NFileHeader::NFlags::kUtf8) != 0; } bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kEncrypted) != 0; } bool IsStrongEncrypted() const { return IsEncrypted() && (Flags & NFileHeader::NFlags::kStrongEncrypted) != 0; }; @@ -186,6 +197,16 @@ public: bool HasDescriptor() const { return (Flags & NFileHeader::NFlags::kDescriptorUsedMask) != 0; } + UString GetUnicodeString(const AString &s) const + { + UString res; + if (IsUtf8()) + if (!ConvertUTF8ToUnicode(s, res)) + res.Empty(); + if (res.IsEmpty()) + res = MultiByteToUnicodeString(s, GetCodePage()); + return res; + } private: void SetFlagBits(int startBitNumber, int numBits, int value); @@ -193,11 +214,9 @@ private: public: void ClearFlags() { Flags = 0; } void SetEncrypted(bool encrypted); + void SetUtf8(bool isUtf8); - WORD GetCodePage() const - { - return CP_OEMCP; - } + WORD GetCodePage() const { return CP_OEMCP; } }; class CItem: public CLocalItem @@ -209,11 +228,16 @@ public: UInt64 LocalHeaderPosition; + FILETIME NtfsMTime; + FILETIME NtfsATime; + FILETIME NtfsCTime; + CExtraBlock CentralExtra; CByteBuffer Comment; bool FromLocal; bool FromCentral; + bool NtfsTimeIsDefined; bool IsDirectory() const; UInt32 GetWinAttributes() const; @@ -235,7 +259,7 @@ public: || MadeByVersion.HostOS == NFileHeader::NHostOS::kNTFS ) ? CP_OEMCP : CP_ACP); } - CItem() : FromLocal(false), FromCentral(false) {} + CItem() : FromLocal(false), FromCentral(false), NtfsTimeIsDefined(false) {} }; }} diff --git a/CPP/7zip/Archive/Zip/ZipOut.cpp b/CPP/7zip/Archive/Zip/ZipOut.cpp index d5e6895e..fd89b1e8 100755 --- a/CPP/7zip/Archive/Zip/ZipOut.cpp +++ b/CPP/7zip/Archive/Zip/ZipOut.cpp @@ -172,7 +172,8 @@ void COutArchive::WriteCentralHeader(const CItem &item) WriteUInt32(isUnPack64 ? 0xFFFFFFFF: (UInt32)item.UnPackSize); WriteUInt16((UInt16)item.Name.Length()); UInt16 zip64ExtraSize = (UInt16)((isUnPack64 ? 8: 0) + (isPack64 ? 8: 0) + (isPosition64 ? 8: 0)); - UInt16 centralExtraSize = (UInt16)(isZip64 ? (4 + zip64ExtraSize) : 0); + const UInt16 kNtfsExtraSize = 4 + 2 + 2 + (3 * 8); + UInt16 centralExtraSize = (UInt16)(isZip64 ? (4 + zip64ExtraSize) : 0) + (item.NtfsTimeIsDefined ? (4 + kNtfsExtraSize) : 0); centralExtraSize = (UInt16)(centralExtraSize + item.CentralExtra.GetSize()); WriteUInt16(centralExtraSize); // test it; WriteUInt16((UInt16)item.Comment.GetCapacity()); @@ -192,6 +193,20 @@ void COutArchive::WriteCentralHeader(const CItem &item) if(isPosition64) WriteUInt64(item.LocalHeaderPosition); } + if (item.NtfsTimeIsDefined) + { + WriteUInt16(NFileHeader::NExtraID::kNTFS); + WriteUInt16(kNtfsExtraSize); + WriteUInt32(0); // reserved + WriteUInt16(NFileHeader::NNtfsExtra::kTagTime); + WriteUInt16(8 * 3); + WriteUInt32(item.NtfsMTime.dwLowDateTime); + WriteUInt32(item.NtfsMTime.dwHighDateTime); + WriteUInt32(item.NtfsATime.dwLowDateTime); + WriteUInt32(item.NtfsATime.dwHighDateTime); + WriteUInt32(item.NtfsCTime.dwLowDateTime); + WriteUInt32(item.NtfsCTime.dwHighDateTime); + } WriteExtra(item.CentralExtra); if (item.Comment.GetCapacity() > 0) WriteBytes(item.Comment, (UInt32)item.Comment.GetCapacity()); diff --git a/CPP/7zip/Archive/Zip/ZipUpdate.cpp b/CPP/7zip/Archive/Zip/ZipUpdate.cpp index 6cfa64e2..2ec08981 100755 --- a/CPP/7zip/Archive/Zip/ZipUpdate.cpp +++ b/CPP/7zip/Archive/Zip/ZipUpdate.cpp @@ -69,12 +69,19 @@ static void SetFileHeader( item.UnPackSize = updateItem.Size; bool isDirectory; + item.ClearFlags(); + if (updateItem.NewProperties) { isDirectory = updateItem.IsDirectory; item.Name = updateItem.Name; + item.SetUtf8(updateItem.IsUtf8); item.ExternalAttributes = updateItem.Attributes; item.Time = updateItem.Time; + item.NtfsMTime = updateItem.NtfsMTime; + item.NtfsATime = updateItem.NtfsATime; + item.NtfsCTime = updateItem.NtfsCTime; + item.NtfsTimeIsDefined = updateItem.NtfsTimeIsDefined; } else isDirectory = item.IsDirectory(); @@ -86,7 +93,6 @@ static void SetFileHeader( item.ExtractVersion.HostOS = kExtractHostOS; item.InternalAttributes = 0; // test it - item.ClearFlags(); item.SetEncrypted(!isDirectory && options.PasswordIsDefined); if (isDirectory) { @@ -341,7 +347,13 @@ static HRESULT UpdateItemOldData(COutArchive &archive, // item.ExternalAttributes = updateItem.Attributes; // Test it item.Name = updateItem.Name; + item.SetUtf8(updateItem.IsUtf8); item.Time = updateItem.Time; + item.NtfsMTime = updateItem.NtfsMTime; + item.NtfsATime = updateItem.NtfsATime; + item.NtfsCTime = updateItem.NtfsCTime; + item.NtfsTimeIsDefined = updateItem.NtfsTimeIsDefined; + item.CentralExtra.RemoveUnknownSubBlocks(); item.LocalExtra.RemoveUnknownSubBlocks(); diff --git a/CPP/7zip/Archive/Zip/ZipUpdate.h b/CPP/7zip/Archive/Zip/ZipUpdate.h index 168eedd6..5e67bead 100755 --- a/CPP/7zip/Archive/Zip/ZipUpdate.h +++ b/CPP/7zip/Archive/Zip/ZipUpdate.h @@ -27,6 +27,8 @@ struct CUpdateItem bool NewData; bool NewProperties; bool IsDirectory; + bool NtfsTimeIsDefined; + bool IsUtf8; int IndexInArchive; int IndexInClient; UInt32 Attributes; @@ -35,7 +37,11 @@ struct CUpdateItem AString Name; // bool Commented; // CUpdateRange CommentRange; - CUpdateItem(): Size(0) {} + FILETIME NtfsMTime; + FILETIME NtfsATime; + FILETIME NtfsCTime; + + CUpdateItem(): NtfsTimeIsDefined(false), IsUtf8(false), Size(0) {} }; HRESULT Update( diff --git a/CPP/7zip/Bundles/Alone/Alone.dsp b/CPP/7zip/Bundles/Alone/Alone.dsp index 49a7f037..d50fb15e 100755 --- a/CPP/7zip/Bundles/Alone/Alone.dsp +++ b/CPP/7zip/Bundles/Alone/Alone.dsp @@ -708,22 +708,6 @@ SOURCE=..\..\Common\VirtThread.h # PROP Default_Filter "" # Begin Source File -SOURCE=..\..\Compress\Branch\ARM.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\ARM.h -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\ARMThumb.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\ARMThumb.h -# End Source File -# Begin Source File - SOURCE=..\..\Compress\Branch\BCJ2Register.cpp # End Source File # Begin Source File @@ -740,35 +724,19 @@ SOURCE=..\..\Compress\Branch\BranchCoder.h # End Source File # Begin Source File -SOURCE=..\..\Compress\Branch\BranchRegister.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\Coder.h -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\IA64.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\IA64.h -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\PPC.cpp +SOURCE=..\..\Compress\Branch\BranchMisc.cpp # End Source File # Begin Source File -SOURCE=..\..\Compress\Branch\PPC.h +SOURCE=..\..\Compress\Branch\BranchMisc.h # End Source File # Begin Source File -SOURCE=..\..\Compress\Branch\SPARC.cpp +SOURCE=..\..\Compress\Branch\BranchRegister.cpp # End Source File # Begin Source File -SOURCE=..\..\Compress\Branch\SPARC.h +SOURCE=..\..\Compress\Branch\Coder.h # End Source File # Begin Source File @@ -1272,31 +1240,6 @@ SOURCE=..\..\Compress\Z\ZDecoder.h # 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 @@ -1852,6 +1795,42 @@ SOURCE=..\..\Archive\Cab\CabItem.h SOURCE=..\..\Archive\Cab\CabRegister.cpp # End Source File # End Group +# Begin Group "Lzma - Ar" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaArcRegister.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaFiltersDecode.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaFiltersDecode.h +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaHandler.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaHandler.h +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaIn.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaIn.h +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaItem.h +# End Source File +# End Group # End Group # Begin Group "UI Common" @@ -2213,28 +2192,6 @@ SOURCE=..\..\Crypto\Hash\Sha1.cpp 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" @@ -2268,113 +2225,302 @@ SOURCE=..\..\PropID.h # Begin Group "C" # PROP Default_Filter "" -# Begin Group "C-Compress" +# Begin Source File -# PROP Default_Filter "" -# Begin Group "C Lz" +SOURCE=..\..\..\..\C\7zCrc.c -# PROP Default_Filter "" +!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\Compress\Lz\LzHash.h +SOURCE=..\..\..\..\C\7zCrc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.c +SOURCE=..\..\..\..\C\Aes.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\Compress\Lz\MatchFinderMt.c -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=..\..\..\..\C\Aes.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.h +SOURCE=..\..\..\..\C\Alloc.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 -# End Group -# Begin Group "C Huffman" +# Begin Source File -# PROP Default_Filter "" +SOURCE=..\..\..\..\C\Alloc.h +# End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Huffman\HuffmanEncode.c +SOURCE=..\..\..\..\C\Bcj2.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\Compress\Huffman\HuffmanEncode.h +SOURCE=..\..\..\..\C\Bcj2.h # End Source File -# End Group -# Begin Group "C Branch" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchARM.c +SOURCE=..\..\..\..\C\Bra.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\Compress\Branch\BranchARM.h +SOURCE=..\..\..\..\C\Bra.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchARMThumb.c +SOURCE=..\..\..\..\C\Bra86.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\Compress\Branch\BranchARMThumb.h +SOURCE=..\..\..\..\C\BraIA64.c +# SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchIA64.c +SOURCE=..\..\..\..\C\BwtSort.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\BwtSort.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchIA64.h +SOURCE=..\..\..\..\C\CpuArch.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchPPC.c +SOURCE=..\..\..\..\C\HuffEnc.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\Compress\Branch\BranchPPC.h +SOURCE=..\..\..\..\C\HuffEnc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchSPARC.c -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=..\..\..\..\C\IStream.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchSPARC.h +SOURCE=..\..\..\..\C\LzFind.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\Compress\Branch\BranchTypes.h +SOURCE=..\..\..\..\C\LzFind.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c +SOURCE=..\..\..\..\C\LzFindMt.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\Compress\Branch\BranchX86.h +SOURCE=..\..\..\..\C\LzFindMt.h # End Source File -# End Group -# End Group -# Begin Group "C-Crypto" +# Begin Source File -# PROP Default_Filter "" +SOURCE=..\..\..\..\C\LzHash.h +# End Source File # Begin Source File -SOURCE=..\..\..\..\C\Crypto\Aes.c +SOURCE=..\..\..\..\C\LzmaDec.c !IF "$(CFG)" == "Alone - Win32 Release" @@ -2398,30 +2544,67 @@ SOURCE=..\..\..\..\C\Crypto\Aes.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Crypto\Aes.h +SOURCE=..\..\..\..\C\LzmaDec.h # End Source File -# End Group # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.c +SOURCE=..\..\..\..\C\LzmaEnc.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\7zCrc.h +SOURCE=..\..\..\..\C\LzmaEnc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=..\..\..\..\C\RotateDefs.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.h +SOURCE=..\..\..\..\C\Sha256.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\IStream.h +SOURCE=..\..\..\..\C\Sha256.h # End Source File # Begin Source File @@ -2454,7 +2637,26 @@ SOURCE=..\..\..\..\C\Sort.h # Begin Source File SOURCE=..\..\..\..\C\Threads.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 diff --git a/CPP/7zip/Bundles/Alone/makefile b/CPP/7zip/Bundles/Alone/makefile index de5f7e3f..e3dc8e5e 100755 --- a/CPP/7zip/Bundles/Alone/makefile +++ b/CPP/7zip/Bundles/Alone/makefile @@ -1,6 +1,5 @@ PROG = 7za.exe LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib - CFLAGS = $(CFLAGS) -I ../../../ \ -DWIN_LONG_PATH \ -DCOMPRESS_MT \ @@ -146,6 +145,12 @@ GZ_OBJS = \ $O\GZipUpdate.obj \ $O\GZipRegister.obj \ +LZM_OBJS = \ + $O\LzmaArcRegister.obj \ + $O\LzmaFiltersDecode.obj \ + $O\LzmaHandler.obj \ + $O\LzmaIn.obj \ + SPLIT_OBJS = \ $O\SplitHandler.obj \ $O\SplitHandlerOut.obj \ @@ -177,14 +182,10 @@ ZIP_OBJS = \ BRANCH_OPT_OBJS = \ - $O\BranchCoder.obj \ $O\x86.obj \ $O\x86_2.obj \ - $O\ARM.obj \ - $O\ARMThumb.obj \ - $O\IA64.obj \ - $O\PPC.obj \ - $O\SPARC.obj \ + $O\BranchCoder.obj \ + $O\BranchMisc.obj \ $O\BranchRegister.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ @@ -255,7 +256,6 @@ CRYPTO_HASH_OBJS = \ $O\Pbkdf2HmacSha1.obj \ $O\RandGen.obj \ $O\Sha1.obj \ - $O\Sha256.obj \ CRYPTO_WZAES_OBJS = \ $O\WzAES.obj \ @@ -266,23 +266,19 @@ CRYPTO_ZIP_OBJS = \ C_OBJS = \ $O\Alloc.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\BwtSort.obj \ + $O\HuffEnc.obj \ + $O\LzFind.obj \ + $O\LzFindMt.obj \ + $O\LzmaDec.obj \ + $O\LzmaEnc.obj \ $O\Sort.obj \ $O\Threads.obj \ - -C_LZ_OBJS = \ - $O\MatchFinder.obj \ - $O\MatchFinderMt.obj \ - -C_BRANCH_OBJS = \ - $O\BranchARM.obj \ - $O\BranchARMThumb.obj \ - $O\BranchIA64.obj \ - $O\BranchPPC.obj \ - $O\BranchSPARC.obj \ - $O\BranchX86.obj \ - -C_CRYPTO = \ $O\Aes.obj \ + $O\Sha256.obj \ !include "../../Crc2.mak" @@ -299,6 +295,7 @@ OBJS = \ $(BZ2_OBJS) \ $(CAB_OBJS) \ $(GZ_OBJS) \ + $(LZM_OBJS) \ $(SPLIT_OBJS) \ $(TAR_OBJS) \ $(Z_OBJS) \ @@ -318,10 +315,6 @@ OBJS = \ $(SHRINK_OBJS) \ $(COMPRESS_Z_OBJS) \ $(C_OBJS) \ - $(C_LZ_OBJS) \ - $(C_BRANCH_OBJS) \ - $O\BlockSort.obj \ - $O\HuffmanEncode.obj \ $O\RangeCoderBit.obj \ $(7ZAES_OPT_OBJS) \ $(AES_OPT_OBJS) \ @@ -329,7 +322,6 @@ OBJS = \ $(CRYPTO_ZIP_OBJS) \ $(CRYPTO_WZAES_OBJS) \ $O\QuantumDecoder.obj \ - $(C_CRYPTO) \ $(CRC_OBJS) \ $O\resource.res @@ -358,6 +350,8 @@ $(CAB_OBJS): ../../Archive/Cab/$(*B).cpp $(COMPL) $(GZ_OBJS): ../../Archive/GZip/$(*B).cpp $(COMPL) +$(LZM_OBJS): ../../Archive/Lzma/$(*B).cpp + $(COMPL) $(SPLIT_OBJS): ../../Archive/Split/$(*B).cpp $(COMPL) $(TAR_OBJS): ../../Archive/Tar/$(*B).cpp @@ -397,8 +391,6 @@ $(SHRINK_OBJS): ../../Compress/Shrink/$(*B).cpp $(COMPRESS_Z_OBJS): ../../Compress/Z/$(*B).cpp $(COMPL) -$O\BlockSort.obj: ../../Compress/BWT/$(*B).cpp - $(COMPL_O2) $O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp $(COMPL) $O\QuantumDecoder.obj: ../../Compress/Quantum/$(*B).cpp @@ -417,12 +409,4 @@ $(CRYPTO_WZAES_OBJS): ../../Crypto/WzAES/$(*B).cpp $(C_OBJS): ../../../../C/$(*B).c $(COMPL_O2) -$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c - $(COMPL_O2) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O2) -$O\HuffmanEncode.obj: ../../../../C/Compress/Huffman/$(*B).c - $(COMPL_O2) -$(C_CRYPTO): ../../../../C/Crypto/$(*B).c - $(COMPL_O2) -!include "../../Crc.mak" \ No newline at end of file +!include "../../Crc.mak" diff --git a/CPP/7zip/Bundles/Alone7z/Alone.dsp b/CPP/7zip/Bundles/Alone7z/Alone.dsp deleted file mode 100755 index b9f389bb..00000000 --- a/CPP/7zip/Bundles/Alone7z/Alone.dsp +++ /dev/null @@ -1,1453 +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 "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "_NO_CRYPTO" /D "BREAK_HANDLER" /D "BENCH_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 /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "_NO_CRYPTO" /D "BREAK_HANDLER" /D "BENCH_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 "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "_NO_CRYPTO" /D "BREAK_HANDLER" /D "BENCH_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 "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "_NO_CRYPTO" /D "BREAK_HANDLER" /D "BENCH_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\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\Defs.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\DynamicBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\IntToString.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\IntToString.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\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\MyException.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\MyString.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyString.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyUnknown.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyVector.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyVector.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\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\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\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\System.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\System.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\Thread.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Windows\Time.h -# End Source File -# End Group -# Begin Group "7zip Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Common\CreateCoder.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\CreateCoder.h -# End Source File -# Begin Source File - -SOURCE=..\..\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\FilterCoder.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\FilterCoder.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\MethodId.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\MethodId.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\MethodProps.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\MethodProps.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\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\RegisterArc.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\RegisterCodec.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamBinder.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamBinder.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamObjects.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamObjects.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamUtils.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamUtils.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\VirtThread.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\VirtThread.h -# End Source File -# End Group -# Begin Group "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 -# Begin Source File - -SOURCE=..\..\Compress\Copy\CopyRegister.cpp -# End Source File -# End Group -# Begin Group "LZ" - -# PROP Default_Filter "" -# 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 -# Begin Source File - -SOURCE=..\..\Compress\LZMA\LZMARegister.cpp -# 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 "LZMA_Alone" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.h -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\LZMA_Alone\LzmaBenchCon.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\LZMA_Alone\LzmaBenchCon.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\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\7zRegister.cpp -# 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\DummyOutStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\DummyOutStream.h -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\HandlerOut.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\HandlerOut.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\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\LoadCodecs.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\UI\Common\LoadCodecs.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\Property.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 -# Begin Group "C" - -# PROP Default_Filter "" -# Begin Group "C Branch" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchARM.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchARM.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchARMThumb.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchARMThumb.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchIA64.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchIA64.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchPPC.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchPPC.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchSPARC.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchSPARC.h -# End Source File -# 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 -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\IStream.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\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\MatchFinder.h -# 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 -# 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/CPP/7zip/Bundles/Alone7z/Alone.dsw b/CPP/7zip/Bundles/Alone7z/Alone.dsw deleted file mode 100755 index 65eca43f..00000000 --- a/CPP/7zip/Bundles/Alone7z/Alone.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: "Alone"=.\Alone.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Bundles/Alone7z/makefile b/CPP/7zip/Bundles/Alone7z/makefile index 1feb1fbd..53b94c1d 100755 --- a/CPP/7zip/Bundles/Alone7z/makefile +++ b/CPP/7zip/Bundles/Alone7z/makefile @@ -120,16 +120,22 @@ AR_COMMON_OBJS = \ $O\7zSpecStream.obj \ $O\7zUpdate.obj \ +LZM_OBJS = \ + $O\LzmaArcRegister.obj \ + $O\LzmaFiltersDecode.obj \ + $O\LzmaHandler.obj \ + $O\LzmaIn.obj \ + +SPLIT_OBJS = \ + $O\SplitHandler.obj \ + $O\SplitHandlerOut.obj \ + $O\SplitRegister.obj \ BRANCH_OPT_OBJS = \ - $O\BranchCoder.obj \ $O\x86.obj \ $O\x86_2.obj \ - $O\ARM.obj \ - $O\ARMThumb.obj \ - $O\IA64.obj \ - $O\PPC.obj \ - $O\SPARC.obj \ + $O\BranchCoder.obj \ + $O\BranchMisc.obj \ $O\BranchRegister.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ @@ -142,9 +148,6 @@ COPY_OBJS = \ $O\CopyCoder.obj \ $O\CopyRegister.obj \ -LZ_OBJS = \ - $O\LZOutWindow.obj \ - LZMA_OPT_OBJS = \ $O\LZMADecoder.obj \ $O\LZMAEncoder.obj \ @@ -155,23 +158,17 @@ LZMA_BENCH_OBJS = \ $O\LzmaBenchCon.obj \ C_OBJS = \ - $O\Alloc.obj \ $O\7zCrc.obj \ - $O\Sort.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\Alloc.obj \ + $O\LzmaDec.obj \ + $O\LzmaEnc.obj \ + $O\LzFind.obj \ + $O\LzFindMt.obj \ $O\Threads.obj \ -C_LZ_OBJS = \ - $O\MatchFinder.obj \ - $O\MatchFinderMt.obj \ - -C_BRANCH_OBJS = \ - $O\BranchARM.obj \ - $O\BranchARMThumb.obj \ - $O\BranchIA64.obj \ - $O\BranchPPC.obj \ - $O\BranchSPARC.obj \ - $O\BranchX86.obj \ - OBJS = \ $O\StdAfx.obj \ $(CONSOLE_OBJS) \ @@ -181,16 +178,14 @@ OBJS = \ $(UI_COMMON_OBJS) \ $(AR_COMMON_OBJS) \ $(7Z_OBJS) \ + $(LZM_OBJS) \ + $(SPLIT_OBJS) \ $(BRANCH_OPT_OBJS) \ $(SWAP_OPT_OBJS) \ $(COPY_OBJS) \ - $(LZ_OBJS) \ $(LZMA_OPT_OBJS) \ $(LZMA_BENCH_OBJS) \ $(C_OBJS) \ - $(C_LZ_OBJS) \ - $(C_BRANCH_OBJS) \ - $O\RangeCoderBit.obj \ $(CRC_OBJS) \ $O\resource.res @@ -213,24 +208,19 @@ $(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp $(7Z_OBJS): ../../Archive/7z/$(*B).cpp $(COMPL) +$(LZM_OBJS): ../../Archive/Lzma/$(*B).cpp + $(COMPL) +$(SPLIT_OBJS): ../../Archive/Split/$(*B).cpp + $(COMPL) $(BRANCH_OPT_OBJS): ../../Compress/Branch/$(*B).cpp $(COMPL_O2) $(SWAP_OPT_OBJS): ../../Compress/ByteSwap/$(*B).cpp $(COMPL_O2) $(COPY_OBJS): ../../Compress/Copy/$(*B).cpp $(COMPL) -$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp - $(COMPL) $(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp $(COMPL_O2) $(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*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) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O2) diff --git a/CPP/7zip/Bundles/Format7z/makefile b/CPP/7zip/Bundles/Format7z/makefile index 04bad9fd..b839ebac 100755 --- a/CPP/7zip/Bundles/Format7z/makefile +++ b/CPP/7zip/Bundles/Format7z/makefile @@ -80,14 +80,10 @@ COMPRESS_OBJS = \ $O\CodecExports.obj \ BRANCH_OPT_OBJS = \ - $O\BranchCoder.obj \ $O\x86.obj \ $O\x86_2.obj \ - $O\ARM.obj \ - $O\ARMThumb.obj \ - $O\IA64.obj \ - $O\PPC.obj \ - $O\SPARC.obj \ + $O\BranchCoder.obj \ + $O\BranchMisc.obj \ $O\BranchRegister.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ @@ -135,26 +131,19 @@ AES_OPT_OBJS = \ CRYPTO_HASH_OBJS = \ $O\RandGen.obj \ $O\Sha1.obj \ - $O\Sha256.obj \ C_OBJS = \ $O\Alloc.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\LzmaDec.obj \ + $O\LzmaEnc.obj \ $O\Threads.obj \ - -C_LZ_OBJS = \ - $O\MatchFinder.obj \ - $O\MatchFinderMt.obj \ - -C_BRANCH_OBJS = \ - $O\BranchARM.obj \ - $O\BranchARMThumb.obj \ - $O\BranchIA64.obj \ - $O\BranchPPC.obj \ - $O\BranchSPARC.obj \ - $O\BranchX86.obj \ - -C_CRYPTO = \ + $O\LzFind.obj \ + $O\LzFindMt.obj \ $O\Aes.obj \ + $O\Sha256.obj \ !include "../../Crc2.mak" @@ -178,13 +167,9 @@ OBJS = \ $(LZMA_OPT_OBJS) \ $(PPMD_OPT_OBJS) \ $(C_OBJS) \ - $(C_LZ_OBJS) \ - $(C_BRANCH_OBJS) \ - $O\RangeCoderBit.obj \ $(7ZAES_OPT_OBJS) \ $(AES_OPT_OBJS) \ $(CRYPTO_HASH_OBJS) \ - $(C_CRYPTO) \ $(CRC_OBJS) \ $O\resource.res @@ -226,9 +211,6 @@ $(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp $(PPMD_OPT_OBJS): ../../Compress/PPMD/$(*B).cpp $(COMPL_O2) -$O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp - $(COMPL) - $(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp $(COMPL_O2) $(7ZAES_OPT_OBJS): ../../Crypto/7zAES/$(*B).cpp @@ -238,11 +220,5 @@ $(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp $(C_OBJS): ../../../../C/$(*B).c $(COMPL_O2) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O2) -$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c - $(COMPL_O2) -$(C_CRYPTO): ../../../../C/Crypto/$(*B).c - $(COMPL_O2) !include "../../Crc.mak" diff --git a/CPP/7zip/Bundles/Format7zExtract/makefile b/CPP/7zip/Bundles/Format7zExtract/makefile index 10bec119..55cad33e 100755 --- a/CPP/7zip/Bundles/Format7zExtract/makefile +++ b/CPP/7zip/Bundles/Format7zExtract/makefile @@ -68,14 +68,10 @@ COMPRESS_OBJS = \ $O\CodecExports.obj \ BRANCH_OPT_OBJS = \ - $O\BranchCoder.obj \ $O\x86.obj \ $O\x86_2.obj \ - $O\ARM.obj \ - $O\ARMThumb.obj \ - $O\IA64.obj \ - $O\PPC.obj \ - $O\SPARC.obj \ + $O\BranchCoder.obj \ + $O\BranchMisc.obj \ $O\BranchRegister.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ @@ -118,23 +114,15 @@ PPMD_OPT_OBJS = \ AES_OPT_OBJS = \ $O\MyAES.obj \ -CRYPTO_HASH_OBJS = \ - $O\Sha256.obj \ - C_OBJS = \ $O\Alloc.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\LzmaDec.obj \ $O\Threads.obj \ - -C_BRANCH_OBJS = \ - $O\BranchARM.obj \ - $O\BranchARMThumb.obj \ - $O\BranchIA64.obj \ - $O\BranchPPC.obj \ - $O\BranchSPARC.obj \ - $O\BranchX86.obj \ - -C_CRYPTO = \ $O\Aes.obj \ + $O\Sha256.obj \ !include "../../Crc2.mak" @@ -159,10 +147,7 @@ OBJS = \ $(PPMD_OPT_OBJS) \ $(7ZAES_OPT_OBJS) \ $(AES_OPT_OBJS) \ - $(CRYPTO_HASH_OBJS) \ $(C_OBJS) \ - $(C_BRANCH_OBJS) \ - $(C_CRYPTO) \ $(CRC_OBJS) \ $O\resource.res @@ -208,13 +193,7 @@ $(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp $(COMPL_O2) $(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_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O2) -$(C_CRYPTO): ../../../../C/Crypto/$(*B).c - $(COMPL_O2) !include "../../Crc.mak" diff --git a/CPP/7zip/Bundles/Format7zExtractR/makefile b/CPP/7zip/Bundles/Format7zExtractR/makefile index 0632e718..55069721 100755 --- a/CPP/7zip/Bundles/Format7zExtractR/makefile +++ b/CPP/7zip/Bundles/Format7zExtractR/makefile @@ -74,14 +74,10 @@ SWAP_OPT_OBJS = \ $O\ByteSwapRegister.obj \ BRANCH_OPT_OBJS = \ - $O\BranchCoder.obj \ $O\x86.obj \ $O\x86_2.obj \ - $O\ARM.obj \ - $O\ARMThumb.obj \ - $O\IA64.obj \ - $O\PPC.obj \ - $O\SPARC.obj \ + $O\BranchCoder.obj \ + $O\BranchMisc.obj \ $O\BranchRegister.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ @@ -90,26 +86,19 @@ COPY_OBJS = \ $O\CopyCoder.obj \ $O\CopyRegister.obj \ -LZ_OBJS = \ - $O\LZOutWindow.obj \ - LZMA_OPT_OBJS = \ $O\LZMADecoder.obj \ $O\LZMARegister.obj \ C_OBJS = \ - $O\Alloc.obj \ $O\7zCrc.obj \ + $O\Alloc.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\LzmaDec.obj \ $O\Threads.obj \ -C_BRANCH_OBJS = \ - $O\BranchARM.obj \ - $O\BranchARMThumb.obj \ - $O\BranchIA64.obj \ - $O\BranchPPC.obj \ - $O\BranchSPARC.obj \ - $O\BranchX86.obj \ - OBJS = \ $O\StdAfx.obj \ $(CONSOLE_OBJS) \ @@ -123,10 +112,8 @@ OBJS = \ $(BRANCH_OPT_OBJS) \ $(SWAP_OPT_OBJS) \ $(COPY_OBJS) \ - $(LZ_OBJS) \ $(LZMA_OPT_OBJS) \ $(C_OBJS) \ - $(C_BRANCH_OBJS) \ $O\resource.res @@ -154,12 +141,8 @@ $(SWAP_OPT_OBJS): ../../Compress/ByteSwap/$(*B).cpp $(COMPL_O2) $(COPY_OBJS): ../../Compress/Copy/$(*B).cpp $(COMPL) -$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp - $(COMPL) $(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp $(COMPL_O2) $(C_OBJS): ../../../../C/$(*B).c $(COMPL_O2) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O2) diff --git a/CPP/7zip/Bundles/Format7zF/Format7z.dsp b/CPP/7zip/Bundles/Format7zF/Format7z.dsp index 5b2f0098..7a41a82a 100755 --- a/CPP/7zip/Bundles/Format7zF/Format7z.dsp +++ b/CPP/7zip/Bundles/Format7zF/Format7z.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # 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 "NO_REGISTRY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /c +# ADD CPP /nologo /Gr /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "NO_REGISTRY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "_LZMA_PROB32_" /FAcs /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" @@ -70,7 +70,7 @@ LINK32=link.exe # 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 "NO_REGISTRY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /GZ /c +# ADD CPP /nologo /Gr /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\SDK" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "NO_REGISTRY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "_LZMA_PROB32" /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" @@ -105,176 +105,188 @@ SOURCE=..\..\Archive\ArchiveExports.cpp # End Source File # Begin Source File -SOURCE=..\..\Compress\CodecExports.cpp +SOURCE=..\..\Archive\Arj\arj.ico # End Source File # Begin Source File -SOURCE=..\..\Archive\DllExports2.cpp +SOURCE=..\..\Archive\BZip2\bz2.ico # End Source File # Begin Source File -SOURCE=.\resource.rc +SOURCE=..\..\Archive\Cab\cab.ico # End Source File # Begin Source File -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"StdAfx.h" +SOURCE=..\..\Compress\CodecExports.cpp # End Source File # Begin Source File -SOURCE=.\StdAfx.h +SOURCE=..\..\Archive\Cpio\cpio.ico # End Source File -# End Group -# Begin Group "Common" +# Begin Source File -# PROP Default_Filter "" +SOURCE=..\..\Archive\Deb\deb.ico +# End Source File # Begin Source File -SOURCE=..\..\..\Common\Buffer.h +SOURCE=..\..\Archive\DllExports2.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Common\CRC.cpp +SOURCE=..\..\Archive\GZip\gz.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\IntToString.cpp +SOURCE=..\..\Archive\Iso\Iso.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\IntToString.h +SOURCE=..\..\Archive\Lzh\lzh.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\MyCom.h +SOURCE=..\..\Archive\Lzma\lzma.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\MyException.h +SOURCE=..\..\Archive\Rar\rar.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\MyInitGuid.h +SOURCE=.\resource.rc # End Source File # Begin Source File -SOURCE=..\..\..\Common\MyString.cpp +SOURCE=..\..\Archive\RPM\rpm.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\MyString.h +SOURCE=..\..\Archive\Split\Split.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\MyUnknown.h +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"StdAfx.h" # End Source File # Begin Source File -SOURCE=..\..\..\Common\MyVector.cpp +SOURCE=.\StdAfx.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\MyVector.h +SOURCE=..\..\Archive\Tar\tar.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\MyWindows.h +SOURCE=..\..\Archive\Wim\wim.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\NewHandler.cpp +SOURCE=..\..\Archive\Z\Z.ico # End Source File # Begin Source File -SOURCE=..\..\..\Common\NewHandler.h +SOURCE=..\..\Archive\Zip\zip.ico # End Source File +# End Group +# Begin Group "Common" + +# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\Common\StringConvert.cpp +SOURCE=..\..\..\Common\Buffer.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\StringConvert.h +SOURCE=..\..\..\Common\CRC.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Common\StringToInt.cpp +SOURCE=..\..\..\Common\IntToString.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Common\StringToInt.h +SOURCE=..\..\..\Common\IntToString.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\UTFConvert.cpp +SOURCE=..\..\..\Common\MyCom.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\UTFConvert.h +SOURCE=..\..\..\Common\MyException.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\Wildcard.cpp +SOURCE=..\..\..\Common\MyInitGuid.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\Wildcard.h +SOURCE=..\..\..\Common\MyString.cpp # End Source File -# End Group -# Begin Group "Windows" +# Begin Source File -# PROP Default_Filter "" +SOURCE=..\..\..\Common\MyString.h +# End Source File # Begin Source File -SOURCE=..\..\..\Windows\FileDir.cpp +SOURCE=..\..\..\Common\MyUnknown.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\FileDir.h +SOURCE=..\..\..\Common\MyVector.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\FileFind.cpp +SOURCE=..\..\..\Common\MyVector.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\FileFind.h +SOURCE=..\..\..\Common\MyWindows.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\FileIO.cpp +SOURCE=..\..\..\Common\NewHandler.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\FileIO.h +SOURCE=..\..\..\Common\NewHandler.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\PropVariant.cpp +SOURCE=..\..\..\Common\StringConvert.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\PropVariant.h +SOURCE=..\..\..\Common\StringConvert.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Synchronization.cpp +SOURCE=..\..\..\Common\StringToInt.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Synchronization.h +SOURCE=..\..\..\Common\StringToInt.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\System.cpp +SOURCE=..\..\..\Common\Types.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\System.h +SOURCE=..\..\..\Common\UTFConvert.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Thread.h +SOURCE=..\..\..\Common\UTFConvert.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 "Compress" @@ -365,22 +377,6 @@ SOURCE=..\..\Compress\PPMD\PPMDType.h # PROP Default_Filter "" # Begin Source File -SOURCE=..\..\Compress\Branch\ARM.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\ARM.h -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\ARMThumb.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\ARMThumb.h -# End Source File -# Begin Source File - SOURCE=..\..\Compress\Branch\BCJ2Register.cpp # End Source File # Begin Source File @@ -397,31 +393,15 @@ SOURCE=..\..\Compress\Branch\BranchCoder.h # End Source File # Begin Source File -SOURCE=..\..\Compress\Branch\BranchRegister.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\IA64.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\IA64.h -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\PPC.cpp +SOURCE=..\..\Compress\Branch\BranchMisc.cpp # End Source File # Begin Source File -SOURCE=..\..\Compress\Branch\PPC.h +SOURCE=..\..\Compress\Branch\BranchMisc.h # End Source File # Begin Source File -SOURCE=..\..\Compress\Branch\SPARC.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\Branch\SPARC.h +SOURCE=..\..\Compress\Branch\BranchRegister.cpp # End Source File # Begin Source File @@ -588,6 +568,16 @@ SOURCE=..\..\Compress\Deflate\DeflateDecoder.h # Begin Source File SOURCE=..\..\Compress\Deflate\DeflateEncoder.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 @@ -638,6 +628,18 @@ SOURCE=..\..\Compress\BZip2\BZip2Decoder.h # Begin Source File SOURCE=..\..\Compress\BZip2\BZip2Encoder.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 @@ -693,14 +695,6 @@ SOURCE=..\..\Compress\Rar\RarCodecsRegister.cpp # PROP Default_Filter "" # Begin Source File -SOURCE=..\..\Compress\BWT\BlockSort.cpp -# 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 @@ -963,24 +957,6 @@ SOURCE=..\..\Crypto\Hash\Sha1.cpp SOURCE=..\..\Crypto\Hash\Sha1.h # End Source File -# Begin Source File - -SOURCE=..\..\Crypto\Hash\Sha256.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=..\..\Crypto\Hash\Sha256.h -# End Source File # End Group # Begin Group "RarAES" @@ -1020,6 +996,16 @@ SOURCE=..\..\Crypto\Rar20\Rar20Crypto.h # Begin Source File SOURCE=..\..\Crypto\WzAES\WzAES.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 @@ -1225,20 +1211,10 @@ SOURCE=..\..\Common\VirtThread.h # End Group # Begin Group "C" -# PROP Default_Filter "" -# Begin Group "Compress 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 +SOURCE=..\..\..\..\C\7zCrc.c !IF "$(CFG)" == "7z - Win32 Release" @@ -1254,11 +1230,11 @@ SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.h +SOURCE=..\..\..\..\C\7zCrc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.c +SOURCE=..\..\..\..\C\Aes.c !IF "$(CFG)" == "7z - Win32 Release" @@ -1274,28 +1250,20 @@ SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.h +SOURCE=..\..\..\..\C\Aes.h # End Source File -# End Group -# Begin Group "Huffman" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Compress\Huffman\HuffmanEncode.c +SOURCE=..\..\..\..\C\Alloc.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Huffman\HuffmanEncode.h +SOURCE=..\..\..\..\C\Alloc.h # End Source File -# End Group -# Begin Group "C Branch" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchARM.c +SOURCE=..\..\..\..\C\Bra.c !IF "$(CFG)" == "7z - Win32 Release" @@ -1311,11 +1279,11 @@ SOURCE=..\..\..\..\C\Compress\Branch\BranchARM.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchARM.h +SOURCE=..\..\..\..\C\Bra.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchARMThumb.c +SOURCE=..\..\..\..\C\Bra86.c !IF "$(CFG)" == "7z - Win32 Release" @@ -1331,11 +1299,23 @@ SOURCE=..\..\..\..\C\Compress\Branch\BranchARMThumb.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchARMThumb.h +SOURCE=..\..\..\..\C\BraIA64.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\Branch\BranchIA64.c +SOURCE=..\..\..\..\C\BwtSort.c !IF "$(CFG)" == "7z - Win32 Release" @@ -1351,11 +1331,15 @@ SOURCE=..\..\..\..\C\Compress\Branch\BranchIA64.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchIA64.h +SOURCE=..\..\..\..\C\BwtSort.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchPPC.c +SOURCE=..\..\..\..\C\CpuArch.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\HuffEnc.c !IF "$(CFG)" == "7z - Win32 Release" @@ -1371,11 +1355,11 @@ SOURCE=..\..\..\..\C\Compress\Branch\BranchPPC.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchPPC.h +SOURCE=..\..\..\..\C\HuffEnc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchSPARC.c +SOURCE=..\..\..\..\C\LzFind.c !IF "$(CFG)" == "7z - Win32 Release" @@ -1391,19 +1375,15 @@ SOURCE=..\..\..\..\C\Compress\Branch\BranchSPARC.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchSPARC.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchTypes.h +SOURCE=..\..\..\..\C\LzFind.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c +SOURCE=..\..\..\..\C\LzFindMt.c !IF "$(CFG)" == "7z - Win32 Release" -# ADD CPP /O2 /FAs +# ADD CPP /O2 # SUBTRACT CPP /YX /Yc /Yu !ELSEIF "$(CFG)" == "7z - Win32 Debug" @@ -1415,16 +1395,15 @@ SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.h +SOURCE=..\..\..\..\C\LzFindMt.h # End Source File -# End Group -# End Group -# Begin Group "Crypto-C" +# Begin Source File -# PROP Default_Filter "" +SOURCE=..\..\..\..\C\LzHash.h +# End Source File # Begin Source File -SOURCE=..\..\..\..\C\Crypto\Aes.c +SOURCE=..\..\..\..\C\LzmaDec.c !IF "$(CFG)" == "7z - Win32 Release" @@ -1440,12 +1419,11 @@ SOURCE=..\..\..\..\C\Crypto\Aes.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Crypto\Aes.h +SOURCE=..\..\..\..\C\LzmaDec.h # End Source File -# End Group # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.c +SOURCE=..\..\..\..\C\LzmaEnc.c !IF "$(CFG)" == "7z - Win32 Release" @@ -1461,24 +1439,31 @@ SOURCE=..\..\..\..\C\7zCrc.c # End Source File # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.h +SOURCE=..\..\..\..\C\LzmaEnc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=..\..\..\..\C\RotateDefs.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.h -# End Source File -# Begin Source File +SOURCE=..\..\..\..\C\Sha256.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 -SOURCE=..\..\..\..\C\CpuArch.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\IStream.h +SOURCE=..\..\..\..\C\Sha256.h # End Source File # Begin Source File @@ -2397,6 +2382,42 @@ SOURCE=..\..\Archive\Com\ComIn.h SOURCE=..\..\Archive\Com\ComRegister.cpp # End Source File # End Group +# Begin Group "Lzma Ar" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaArcRegister.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaFiltersDecode.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaFiltersDecode.h +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaHandler.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaHandler.h +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaIn.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaIn.h +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Lzma\LzmaItem.h +# End Source File +# End Group # Begin Source File SOURCE=..\..\Archive\IArchive.h @@ -2426,65 +2447,61 @@ SOURCE=..\..\IProgress.h SOURCE=..\..\IStream.h # End Source File # End Group -# Begin Source File - -SOURCE=..\..\Archive\Arj\arj.ico -# End Source File -# Begin Source File +# Begin Group "Windows" -SOURCE=..\..\Archive\BZip2\bz2.ico -# End Source File +# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\Archive\Cab\cab.ico +SOURCE=..\..\..\Windows\FileDir.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Cpio\cpio.ico +SOURCE=..\..\..\Windows\FileDir.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Deb\deb.ico +SOURCE=..\..\..\Windows\FileFind.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\GZip\gz.ico +SOURCE=..\..\..\Windows\FileFind.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Iso\Iso.ico +SOURCE=..\..\..\Windows\FileIO.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Lzh\lzh.ico +SOURCE=..\..\..\Windows\FileIO.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Rar\rar.ico +SOURCE=..\..\..\Windows\PropVariant.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\RPM\rpm.ico +SOURCE=..\..\..\Windows\PropVariant.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Split\Split.ico +SOURCE=..\..\..\Windows\Synchronization.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Tar\tar.ico +SOURCE=..\..\..\Windows\Synchronization.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Wim\wim.ico +SOURCE=..\..\..\Windows\System.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Z\Z.ico +SOURCE=..\..\..\Windows\System.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Zip\zip.ico +SOURCE=..\..\..\Windows\Thread.h # End Source File +# End Group # End Target # End Project diff --git a/CPP/7zip/Bundles/Format7zF/makefile b/CPP/7zip/Bundles/Format7zF/makefile index 887386ee..328f8ab6 100755 --- a/CPP/7zip/Bundles/Format7zF/makefile +++ b/CPP/7zip/Bundles/Format7zF/makefile @@ -147,6 +147,12 @@ LZH_OBJS = \ $O\LzhOutStreamWithCRC.obj \ $O\LzhRegister.obj \ +LZM_OBJS = \ + $O\LzmaArcRegister.obj \ + $O\LzmaFiltersDecode.obj \ + $O\LzmaHandler.obj \ + $O\LzmaIn.obj \ + NSIS_OBJS = \ $O\NsisDecode.obj \ $O\NsisHandler.obj \ @@ -204,17 +210,13 @@ COMPRESS_OBJS = \ $O\CodecExports.obj \ BRANCH_OPT_OBJS = \ + $O\x86.obj \ + $O\x86_2.obj \ $O\BranchCoder.obj \ + $O\BranchMisc.obj \ $O\BranchRegister.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ - $O\x86.obj \ - $O\x86_2.obj \ - $O\ARM.obj \ - $O\ARMThumb.obj \ - $O\IA64.obj \ - $O\PPC.obj \ - $O\SPARC.obj \ SWAP_OPT_OBJS = \ $O\ByteSwap.obj \ @@ -292,7 +294,6 @@ CRYPTO_HASH_OBJS = \ $O\Pbkdf2HmacSha1.obj \ $O\RandGen.obj \ $O\Sha1.obj \ - $O\Sha256.obj \ CRYPTO_WZAES_OBJS = \ $O\WzAES.obj \ @@ -311,23 +312,19 @@ CRYPTO_RARAES_OBJS = \ C_OBJS = \ $O\Alloc.obj \ - $O\Threads.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\BwtSort.obj \ + $O\HuffEnc.obj \ + $O\LzFind.obj \ + $O\LzFindMt.obj \ + $O\LzmaDec.obj \ + $O\LzmaEnc.obj \ $O\Sort.obj \ - -C_LZ_OBJS = \ - $O\MatchFinder.obj \ - $O\MatchFinderMt.obj \ - -C_BRANCH_OBJS = \ - $O\BranchARM.obj \ - $O\BranchARMThumb.obj \ - $O\BranchIA64.obj \ - $O\BranchPPC.obj \ - $O\BranchSPARC.obj \ - $O\BranchX86.obj \ - -C_CRYPTO = \ + $O\Threads.obj \ $O\Aes.obj \ + $O\Sha256.obj \ !include "../../Crc2.mak" @@ -350,6 +347,7 @@ OBJS = \ $(GZ_OBJS) \ $(ISO_OBJS) \ $(LZH_OBJS) \ + $(LZM_OBJS) \ $(NSIS_OBJS) \ $(RAR_OBJS) \ $(RPM_OBJS) \ @@ -377,11 +375,6 @@ OBJS = \ $(COMPRESS_Z_OBJS) \ $O\QuantumDecoder.obj \ $(C_OBJS) \ - $(C_LZ_OBJS) \ - $(C_BRANCH_OBJS) \ - $(C_CRYPTO) \ - $O\HuffmanEncode.obj \ - $O\BlockSort.obj \ $O\RangeCoderBit.obj \ $(7ZAES_OPT_OBJS) \ $(AES_OPT_OBJS) \ @@ -429,6 +422,8 @@ $(ISO_OBJS): ../../Archive/Iso/$(*B).cpp $(COMPL) $(LZH_OBJS): ../../Archive/Lzh/$(*B).cpp $(COMPL) +$(LZM_OBJS): ../../Archive/Lzma/$(*B).cpp + $(COMPL) $(NSIS_OBJS): ../../Archive/Nsis/$(*B).cpp $(COMPL) $(RAR_OBJS): ../../Archive/Rar/$(*B).cpp @@ -483,8 +478,6 @@ $(COMPRESS_Z_OBJS): ../../Compress/Z/$(*B).cpp $O\QuantumDecoder.obj: ../../Compress/Quantum/$(*B).cpp $(COMPL) -$O\BlockSort.obj: ../../Compress/BWT/$(*B).cpp - $(COMPL_O2) $O\RangeCoderBit.obj: ../../Compress/RangeCoder/$(*B).cpp $(COMPL) @@ -505,13 +498,5 @@ $(CRYPTO_RARAES_OBJS): ../../Crypto/RarAES/$(*B).cpp $(C_OBJS): ../../../../C/$(*B).c $(COMPL_O2) -$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c - $(COMPL_O2) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O2) -$O\HuffmanEncode.obj: ../../../../C/Compress/Huffman/$(*B).c - $(COMPL_O2) -$(C_CRYPTO): ../../../../C/Crypto/$(*B).c - $(COMPL_O2) !include "../../Crc.mak" diff --git a/CPP/7zip/Bundles/Format7zF/resource.rc b/CPP/7zip/Bundles/Format7zF/resource.rc index 365c0637..18ec9549 100755 --- a/CPP/7zip/Bundles/Format7zF/resource.rc +++ b/CPP/7zip/Bundles/Format7zF/resource.rc @@ -19,9 +19,10 @@ MY_VERSION_INFO_DLL("7z Standalone Plugin", "7za") 13 ICON "../../Archive/Tar/tar.ico" 14 ICON "../../Archive/GZip/gz.ico" 15 ICON "../../Archive/Wim/wim.ico" +16 ICON "../../Archive/Lzma/lzma.ico" STRINGTABLE BEGIN - 100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 split:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15" + 100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 split:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16" END diff --git a/CPP/7zip/Bundles/Format7zR/makefile b/CPP/7zip/Bundles/Format7zR/makefile index 6e96a8a2..7fd28ad5 100755 --- a/CPP/7zip/Bundles/Format7zR/makefile +++ b/CPP/7zip/Bundles/Format7zR/makefile @@ -77,14 +77,10 @@ COMPRESS_OBJS = \ $O\CodecExports.obj \ BRANCH_OPT_OBJS = \ - $O\BranchCoder.obj \ $O\x86.obj \ $O\x86_2.obj \ - $O\ARM.obj \ - $O\ARMThumb.obj \ - $O\IA64.obj \ - $O\PPC.obj \ - $O\SPARC.obj \ + $O\BranchCoder.obj \ + $O\BranchMisc.obj \ $O\BranchRegister.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ @@ -97,32 +93,23 @@ COPY_OBJS = \ $O\CopyCoder.obj \ $O\CopyRegister.obj \ -LZ_OBJS = \ - $O\LZOutWindow.obj \ - LZMA_OPT_OBJS = \ $O\LZMADecoder.obj \ $O\LZMAEncoder.obj \ $O\LZMARegister.obj \ C_OBJS = \ - $O\Alloc.obj \ $O\7zCrc.obj \ - $O\Sort.obj \ + $O\Alloc.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\LzFind.obj \ + $O\LzFindMt.obj \ + $O\LzmaDec.obj \ + $O\LzmaEnc.obj \ $O\Threads.obj \ -C_LZ_OBJS = \ - $O\MatchFinder.obj \ - $O\MatchFinderMt.obj \ - -C_BRANCH_OBJS = \ - $O\BranchARM.obj \ - $O\BranchARMThumb.obj \ - $O\BranchIA64.obj \ - $O\BranchPPC.obj \ - $O\BranchSPARC.obj \ - $O\BranchX86.obj \ - OBJS = \ $O\StdAfx.obj \ $(CONSOLE_OBJS) \ @@ -139,13 +126,9 @@ OBJS = \ $(SWAP_OPT_OBJS) \ $(COPY_OBJS) \ $(DEFLATE_OPT_OBJS) \ - $(LZ_OBJS) \ $(LZMA_OPT_OBJS) \ $(PPMD_OPT_OBJS) \ $(C_OBJS) \ - $(C_LZ_OBJS) \ - $(C_BRANCH_OBJS) \ - $O\RangeCoderBit.obj \ $O\resource.res @@ -173,16 +156,8 @@ $(SWAP_OPT_OBJS): ../../Compress/ByteSwap/$(*B).cpp $(COMPL_O2) $(COPY_OBJS): ../../Compress/Copy/$(*B).cpp $(COMPL) -$(LZ_OBJS): ../../Compress/LZ/$(*B).cpp - $(COMPL) $(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp $(COMPL_O2) -$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) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O2) diff --git a/CPP/7zip/Bundles/SFXCon/SFXCon.dsp b/CPP/7zip/Bundles/SFXCon/SFXCon.dsp index a0d21d0e..e272d88d 100755 --- a/CPP/7zip/Bundles/SFXCon/SFXCon.dsp +++ b/CPP/7zip/Bundles/SFXCon/SFXCon.dsp @@ -374,14 +374,6 @@ SOURCE=..\..\Crypto\AES\MyAES.h SOURCE=..\..\Crypto\Hash\RotateDefs.h # End Source File -# 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 "Windows" @@ -735,53 +727,59 @@ SOURCE=..\..\UI\Common\PropIDUtils.h # Begin Group "C" # PROP Default_Filter "" -# Begin Group "C Branch" +# Begin Source File -# PROP Default_Filter "" +SOURCE=..\..\..\..\C\7zCrc.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchTypes.h +SOURCE=..\..\..\..\C\7zCrc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c +SOURCE=..\..\..\..\C\Aes.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.h +SOURCE=..\..\..\..\C\Aes.h # End Source File -# End Group -# Begin Group "C Crypto" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Crypto\Aes.c +SOURCE=..\..\..\..\C\Alloc.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Crypto\Aes.h +SOURCE=..\..\..\..\C\Alloc.h # End Source File -# End Group # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.c +SOURCE=..\..\..\..\C\Bra.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Bra86.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.h +SOURCE=..\..\..\..\C\LzmaDec.c +# SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.c +SOURCE=..\..\..\..\C\LzmaDec.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Sha256.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.h +SOURCE=..\..\..\..\C\Sha256.h # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/SFXCon/makefile b/CPP/7zip/Bundles/SFXCon/makefile index dbe07baa..c32b11cd 100755 --- a/CPP/7zip/Bundles/SFXCon/makefile +++ b/CPP/7zip/Bundles/SFXCon/makefile @@ -81,9 +81,9 @@ AR_COMMON_OBJS = \ $O\7zRegister.obj \ BRANCH_OPT_OBJS = \ - $O\BranchCoder.obj \ $O\x86.obj \ $O\x86_2.obj \ + $O\BranchCoder.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ @@ -109,18 +109,13 @@ PPMD_OPT_OBJS = \ AES_OPT_OBJS = \ $O\MyAES.obj \ -CRYPTO_HASH_OBJS = \ - $O\Sha256.obj \ - C_OBJS = \ $O\Alloc.obj \ + $O\Bra86.obj \ + $O\LzmaDec.obj \ $O\Threads.obj \ - -C_BRANCH_OBJS = \ - $O\BranchX86.obj \ - -C_CRYPTO = \ $O\Aes.obj \ + $O\Sha256.obj \ !include "../../Crc2.mak" @@ -141,10 +136,7 @@ OBJS = \ $(PPMD_OPT_OBJS) \ $(7ZAES_OPT_OBJS) \ $(AES_OPT_OBJS) \ - $(CRYPTO_HASH_OBJS) \ $(C_OBJS) \ - $(C_BRANCH_OBJS) \ - $(C_CRYPTO) \ $(CRC_OBJS) \ $O\resource.res @@ -184,13 +176,7 @@ $(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp $(COMPL) $(7ZAES_OPT_OBJS): ../../Crypto/7zAES/$(*B).cpp $(COMPL) -$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp - $(COMPL) $(C_OBJS): ../../../../C/$(*B).c - $(COMPL_O1) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O1) -$(C_CRYPTO): ../../../../C/Crypto/$(*B).c - $(COMPL_O1) + $(COMPL_O2) !include "../../Crc.mak" diff --git a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp index 1fd348bc..3b0117a1 100755 --- a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp +++ b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp @@ -686,37 +686,42 @@ SOURCE=..\..\UI\FileManager\FormatUtils.h # End Group # Begin Group "C" -# PROP Default_Filter "" -# Begin Group "C Branch" - # PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c +SOURCE=..\..\..\..\C\7zCrc.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.h +SOURCE=..\..\..\..\C\7zCrc.h # End Source File -# End Group # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.c +SOURCE=..\..\..\..\C\Alloc.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.h +SOURCE=..\..\..\..\C\Alloc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.c +SOURCE=..\..\..\..\C\Bra.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Bra86.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.h +SOURCE=..\..\..\..\C\LzmaDec.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\LzmaDec.h # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/SFXSetup/makefile b/CPP/7zip/Bundles/SFXSetup/makefile index 10731a93..274730cd 100755 --- a/CPP/7zip/Bundles/SFXSetup/makefile +++ b/CPP/7zip/Bundles/SFXSetup/makefile @@ -83,9 +83,9 @@ AR_COMMON_OBJS = \ $O\7zRegister.obj \ BRANCH_OPT_OBJS = \ - $O\BranchCoder.obj \ $O\x86.obj \ $O\x86_2.obj \ + $O\BranchCoder.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ @@ -102,11 +102,10 @@ LZMA_OPT_OBJS = \ C_OBJS = \ $O\Alloc.obj \ + $O\Bra86.obj \ + $O\LzmaDec.obj \ $O\Threads.obj \ -C_BRANCH_OBJS = \ - $O\BranchX86.obj \ - !include "../../Crc2.mak" OBJS = \ @@ -127,7 +126,6 @@ OBJS = \ $(LZMA_OPT_OBJS) \ $O\MyMessages.obj \ $(C_OBJS) \ - $(C_BRANCH_OBJS) \ $(CRC_OBJS) \ $O\resource.res @@ -169,8 +167,6 @@ $O\MyMessages.obj: ../../UI/Explorer/MyMessages.cpp $(COMPL) $(C_OBJS): ../../../../C/$(*B).c - $(COMPL_O1) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O1) + $(COMPL_O2) !include "../../Crc.mak" diff --git a/CPP/7zip/Bundles/SFXWin/Main.cpp b/CPP/7zip/Bundles/SFXWin/Main.cpp index 39ca5306..44f37560 100755 --- a/CPP/7zip/Bundles/SFXWin/Main.cpp +++ b/CPP/7zip/Bundles/SFXWin/Main.cpp @@ -117,6 +117,8 @@ int APIENTRY WinMain2() */ if (result == S_OK) { + if (ecs->Messages.Size() > 0 || ecs->NumArchiveErrors != 0) + return NExitCode::kFatalError; return 0; } if (result == E_ABORT) diff --git a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp index 70de7602..0a78fe4d 100755 --- a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp +++ b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp @@ -374,14 +374,6 @@ SOURCE=..\..\Crypto\7zAES\MySHA256.h SOURCE=..\..\Crypto\Hash\RotateDefs.h # End Source File -# 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 "Dialogs" @@ -834,50 +826,56 @@ SOURCE=..\..\UI\Explorer\MyMessages.h # End Group # Begin Group "C" -# PROP Default_Filter "" -# Begin Group "C Branch" - # PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c +SOURCE=..\..\..\..\C\7zCrc.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.h +SOURCE=..\..\..\..\C\7zCrc.h # End Source File -# End Group -# Begin Group "C Crypto" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Crypto\Aes.c +SOURCE=..\..\..\..\C\Aes.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Crypto\Aes.h +SOURCE=..\..\..\..\C\Aes.h # End Source File -# End Group # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.c +SOURCE=..\..\..\..\C\Alloc.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.h +SOURCE=..\..\..\..\C\Alloc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.c +SOURCE=..\..\..\..\C\Bra.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Bra86.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.h +SOURCE=..\..\..\..\C\LzmaDec.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\LzmaDec.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Sha256.c +# SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/SFXWin/makefile b/CPP/7zip/Bundles/SFXWin/makefile index 55ebd8c6..a5f39559 100755 --- a/CPP/7zip/Bundles/SFXWin/makefile +++ b/CPP/7zip/Bundles/SFXWin/makefile @@ -90,9 +90,9 @@ AR_COMMON_OBJS = \ $O\7zRegister.obj \ BRANCH_OPT_OBJS = \ - $O\BranchCoder.obj \ $O\x86.obj \ $O\x86_2.obj \ + $O\BranchCoder.obj \ $O\BCJRegister.obj \ $O\BCJ2Register.obj \ @@ -118,18 +118,13 @@ PPMD_OPT_OBJS = \ AES_OPT_OBJS = \ $O\MyAES.obj \ -CRYPTO_HASH_OBJS = \ - $O\Sha256.obj \ - C_OBJS = \ $O\Alloc.obj \ + $O\Bra86.obj \ + $O\LzmaDec.obj \ $O\Threads.obj \ - -C_BRANCH_OBJS = \ - $O\BranchX86.obj \ - -C_CRYPTO = \ $O\Aes.obj \ + $O\Sha256.obj \ !include "../../Crc2.mak" @@ -150,14 +145,11 @@ OBJS = \ $(LZ_OBJS) \ $(LZMA_OPT_OBJS) \ $(PPMD_OPT_OBJS) \ - $(CRYPTO_HASH_OBJS) \ $(7ZAES_OPT_OBJS) \ $(AES_OPT_OBJS) \ $O\MyMessages.obj \ $(C_OBJS) \ - $(C_BRANCH_OBJS) \ $(CRC_OBJS) \ - $(C_CRYPTO) \ $O\resource.res @@ -196,8 +188,6 @@ $(LZMA_OPT_OBJS): ../../Compress/LZMA/$(*B).cpp $(PPMD_OPT_OBJS): ../../Compress/PPMD/$(*B).cpp $(COMPL) -$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp - $(COMPL) $(7ZAES_OPT_OBJS): ../../Crypto/7zAES/$(*B).cpp $(COMPL) $(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp @@ -206,10 +196,6 @@ $(AES_OPT_OBJS): ../../Crypto/AES/$(*B).cpp $O\MyMessages.obj: ../../UI/Explorer/MyMessages.cpp $(COMPL) $(C_OBJS): ../../../../C/$(*B).c - $(COMPL_O1) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O1) -$(C_CRYPTO): ../../../../C/Crypto/$(*B).c - $(COMPL_O1) + $(COMPL_O2) !include "../../Crc.mak" diff --git a/CPP/7zip/Common/FileStreams.cpp b/CPP/7zip/Common/FileStreams.cpp index bebcf14c..f1fa419f 100755 --- a/CPP/7zip/Common/FileStreams.cpp +++ b/CPP/7zip/Common/FileStreams.cpp @@ -18,7 +18,7 @@ static inline HRESULT ConvertBoolToHRESULT(bool result) DWORD lastError = ::GetLastError(); if (lastError == 0) return E_FAIL; - return lastError; + return HRESULT_FROM_WIN32(lastError); #else return result ? S_OK: E_FAIL; #endif diff --git a/CPP/7zip/Common/FilterCoder.cpp b/CPP/7zip/Common/FilterCoder.cpp index fd89d0e1..58690c3d 100755 --- a/CPP/7zip/Common/FilterCoder.cpp +++ b/CPP/7zip/Common/FilterCoder.cpp @@ -30,11 +30,8 @@ HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 siz if (size > remSize) size = (UInt32)remSize; } - UInt32 processedSize = 0; - RINOK(WriteStream(outStream, _buffer, size, &processedSize)); - if (size != processedSize) - return E_FAIL; - _nowPos64 += processedSize; + RINOK(WriteStream(outStream, _buffer, size)); + _nowPos64 += size; return S_OK; } @@ -51,12 +48,12 @@ STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream, while(NeedMore()) { - UInt32 processedSize; + size_t processedSize = kBufferSize - bufferPos; // Change it: It can be optimized using ReadPart - RINOK(ReadStream(inStream, _buffer + bufferPos, kBufferSize - bufferPos, &processedSize)); + RINOK(ReadStream(inStream, _buffer + bufferPos, &processedSize)); - UInt32 endPos = bufferPos + processedSize; + UInt32 endPos = bufferPos + (UInt32)processedSize; bufferPos = Filter->Filter(_buffer, endPos); if (bufferPos > endPos) @@ -149,10 +146,7 @@ STDMETHODIMP CFilterCoder::Flush() if (Filter->Filter(_buffer, endPos) != endPos) return E_FAIL; } - UInt32 processedSize; - RINOK(WriteStream(_outStream, _buffer, _bufferPos, &processedSize)); - if (_bufferPos != processedSize) - return E_FAIL; + RINOK(WriteStream(_outStream, _buffer, _bufferPos)); _bufferPos = 0; } CMyComPtr flush; @@ -196,11 +190,9 @@ STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize) _buffer[i] = _buffer[i + _convertedPosEnd]; _bufferPos = i; _convertedPosBegin = _convertedPosEnd = 0; - UInt32 processedSizeTemp; - UInt32 size0 = kBufferSize - _bufferPos; - // Optimize it: - RINOK(ReadStream(_inStream, _buffer + _bufferPos, size0, &processedSizeTemp)); - _bufferPos = _bufferPos + processedSizeTemp; + size_t processedSizeTemp = kBufferSize - _bufferPos; + RINOK(ReadStream(_inStream, _buffer + _bufferPos, &processedSizeTemp)); + _bufferPos = _bufferPos + (UInt32)processedSizeTemp; _convertedPosEnd = Filter->Filter(_buffer, _bufferPos); if (_convertedPosEnd == 0) { diff --git a/CPP/7zip/Common/InOutTempBuffer.cpp b/CPP/7zip/Common/InOutTempBuffer.cpp index ffaed32c..4cc0b2f2 100755 --- a/CPP/7zip/Common/InOutTempBuffer.cpp +++ b/CPP/7zip/Common/InOutTempBuffer.cpp @@ -92,7 +92,7 @@ HRESULT CInOutTempBuffer::WriteToStream(ISequentialOutStream *stream) if (_currentPositionInBuffer < _bufferPosition) { UInt32 sizeToWrite = _bufferPosition - _currentPositionInBuffer; - RINOK(WriteStream(stream, _buffer + _currentPositionInBuffer, sizeToWrite, NULL)); + RINOK(WriteStream(stream, _buffer + _currentPositionInBuffer, sizeToWrite)); _currentPositionInBuffer += sizeToWrite; } if (!_tmpFileCreated) @@ -104,7 +104,7 @@ HRESULT CInOutTempBuffer::WriteToStream(ISequentialOutStream *stream) return E_FAIL; if (localProcessedSize == 0) return S_OK; - RINOK(WriteStream(stream, _buffer, localProcessedSize, NULL)); + RINOK(WriteStream(stream, _buffer, localProcessedSize)); } } diff --git a/CPP/7zip/Common/MemBlocks.cpp b/CPP/7zip/Common/MemBlocks.cpp index 15702957..53f55242 100755 --- a/CPP/7zip/Common/MemBlocks.cpp +++ b/CPP/7zip/Common/MemBlocks.cpp @@ -125,13 +125,10 @@ HRESULT CMemBlocks::WriteToStream(size_t blockSize, ISequentialOutStream *outStr UInt32 curSize = (UInt32)blockSize; if (totalSize < curSize) curSize = (UInt32)totalSize; - UInt32 processedSize; if (blockIndex >= Blocks.Size()) return E_FAIL; - RINOK(WriteStream(outStream, Blocks[blockIndex], curSize, &processedSize)); - if (processedSize != curSize) - return E_FAIL; - totalSize -= processedSize; + RINOK(WriteStream(outStream, Blocks[blockIndex], curSize)); + totalSize -= curSize; } return S_OK; } diff --git a/CPP/7zip/Common/StreamObjects.cpp b/CPP/7zip/Common/StreamObjects.cpp index 32f8f306..95d1c878 100755 --- a/CPP/7zip/Common/StreamObjects.cpp +++ b/CPP/7zip/Common/StreamObjects.cpp @@ -8,11 +8,13 @@ STDMETHODIMP CSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize) { - UInt32 numBytesToRead = (UInt32)(MyMin(_pos + size, _size) - _pos); - memmove(data, _dataPointer + _pos, numBytesToRead); - _pos += numBytesToRead; - if(processedSize != NULL) - *processedSize = numBytesToRead; + size_t rem = _size - _pos; + if (size < rem) + rem = (size_t)size; + memcpy(data, _dataPointer + _pos, rem); + _pos += rem; + if (processedSize != NULL) + *processedSize = (UInt32)rem; return S_OK; } @@ -21,13 +23,13 @@ void CWriteBuffer::Write(const void *data, size_t size) { size_t newCapacity = _size + size; _buffer.EnsureCapacity(newCapacity); - memmove(_buffer + _size, data, size); + memcpy(_buffer + _size, data, size); _size += size; } STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UInt32 size, UInt32 *processedSize) { - _writeBuffer.Write(data, size); + _writeBuffer.Write(data, (size_t)size); if(processedSize != NULL) *processedSize = size; return S_OK; @@ -35,16 +37,14 @@ STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UInt32 size, UInt3 STDMETHODIMP CSequentialOutStreamImp2::Write(const void *data, UInt32 size, UInt32 *processedSize) { - UInt32 newSize = size; - if (_pos + size > _size) - newSize = (UInt32)(_size - _pos); - memmove(_buffer + _pos, data, newSize); - if(processedSize != NULL) - *processedSize = newSize; - _pos += newSize; - if (newSize != size) - return E_FAIL; - return S_OK; + size_t rem = _size - _pos; + if (size < rem) + rem = (size_t)size; + memcpy(_buffer + _pos, data, rem); + _pos += rem; + if (processedSize != NULL) + *processedSize = (UInt32)rem; + return (rem == size ? S_OK : E_FAIL); } STDMETHODIMP CSequentialInStreamSizeCount::Read(void *data, UInt32 size, UInt32 *processedSize) diff --git a/CPP/7zip/Common/StreamUtils.cpp b/CPP/7zip/Common/StreamUtils.cpp index 1d951271..9cde2c40 100755 --- a/CPP/7zip/Common/StreamUtils.cpp +++ b/CPP/7zip/Common/StreamUtils.cpp @@ -2,20 +2,21 @@ #include "StdAfx.h" -#include "../../Common/MyCom.h" #include "StreamUtils.h" -HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize) +static const UInt32 kBlockSize = ((UInt32)1 << 31); + +HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSize) { - if (processedSize != 0) - *processedSize = 0; - while(size != 0) + size_t size = *processedSize; + *processedSize = 0; + while (size != 0) { + UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize; UInt32 processedSizeLoc; - HRESULT res = stream->Read(data, size, &processedSizeLoc); - if (processedSize != 0) - *processedSize += processedSizeLoc; - data = (Byte *)((Byte *)data + processedSizeLoc); + HRESULT res = stream->Read(data, curSize, &processedSizeLoc); + *processedSize += processedSizeLoc; + data = (void *)((Byte *)data + processedSizeLoc); size -= processedSizeLoc; RINOK(res); if (processedSizeLoc == 0) @@ -24,16 +25,27 @@ HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 return S_OK; } -HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize) +HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size) +{ + size_t processedSize = size; + RINOK(ReadStream(stream, data, &processedSize)); + return (size == processedSize) ? S_OK : S_FALSE; +} + +HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size) +{ + size_t processedSize = size; + RINOK(ReadStream(stream, data, &processedSize)); + return (size == processedSize) ? S_OK : E_FAIL; +} + +HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size) { - if (processedSize != 0) - *processedSize = 0; - while(size != 0) + while (size != 0) { + UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize; UInt32 processedSizeLoc; - HRESULT res = stream->Write(data, size, &processedSizeLoc); - if (processedSize != 0) - *processedSize += processedSizeLoc; + HRESULT res = stream->Write(data, curSize, &processedSizeLoc); data = (const void *)((const Byte *)data + processedSizeLoc); size -= processedSizeLoc; RINOK(res); diff --git a/CPP/7zip/Common/StreamUtils.h b/CPP/7zip/Common/StreamUtils.h index 59f88733..f1cfd184 100755 --- a/CPP/7zip/Common/StreamUtils.h +++ b/CPP/7zip/Common/StreamUtils.h @@ -5,7 +5,9 @@ #include "../IStream.h" -HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize); -HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize); +HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *size); +HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size); +HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size); +HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size); #endif diff --git a/CPP/7zip/Common/VirtThread.cpp b/CPP/7zip/Common/VirtThread.cpp index 3567f98e..f12581ad 100755 --- a/CPP/7zip/Common/VirtThread.cpp +++ b/CPP/7zip/Common/VirtThread.cpp @@ -17,7 +17,7 @@ static THREAD_FUNC_DECL CoderThread(void *p) } } -HRes CVirtThread::Create() +WRes CVirtThread::Create() { RINOK(StartEvent.CreateIfNotCreated()); RINOK(FinishedEvent.CreateIfNotCreated()); diff --git a/CPP/7zip/Common/VirtThread.h b/CPP/7zip/Common/VirtThread.h index 62c055b6..604b090b 100755 --- a/CPP/7zip/Common/VirtThread.h +++ b/CPP/7zip/Common/VirtThread.h @@ -14,7 +14,7 @@ struct CVirtThread bool ExitEvent; ~CVirtThread(); - HRes Create(); + WRes Create(); void Start(); void WaitFinish() { FinishedEvent.Lock(); } virtual void Execute() = 0; diff --git a/CPP/7zip/Compress/Arj/ArjDecoder1.cpp b/CPP/7zip/Compress/Arj/ArjDecoder1.cpp index dda3721a..df859971 100755 --- a/CPP/7zip/Compress/Arj/ArjDecoder1.cpp +++ b/CPP/7zip/Compress/Arj/ArjDecoder1.cpp @@ -237,7 +237,7 @@ UInt32 CCoder::decode_p() } -STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream, +HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress) { @@ -297,7 +297,7 @@ STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream, UInt32 len = number - 256 + kMatchMinLen; UInt32 distance = decode_p(); if (distance >= pos) - throw "data error"; + return S_FALSE; m_OutWindowStream.CopyBlock(distance, len); pos += len; } diff --git a/CPP/7zip/Compress/Arj/ArjDecoder1.h b/CPP/7zip/Compress/Arj/ArjDecoder1.h index 434a0a41..b337ec72 100755 --- a/CPP/7zip/Compress/Arj/ArjDecoder1.h +++ b/CPP/7zip/Compress/Arj/ArjDecoder1.h @@ -86,13 +86,11 @@ class CCoder : UInt32 decode_c(); UInt32 decode_p(); -public: - - MY_UNKNOWN_IMP - - STDMETHOD(CodeReal)(ISequentialInStream *inStream, + HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); +public: + MY_UNKNOWN_IMP STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, diff --git a/CPP/7zip/Compress/Arj/ArjDecoder2.cpp b/CPP/7zip/Compress/Arj/ArjDecoder2.cpp index 24c101d1..a0eca445 100755 --- a/CPP/7zip/Compress/Arj/ArjDecoder2.cpp +++ b/CPP/7zip/Compress/Arj/ArjDecoder2.cpp @@ -12,7 +12,7 @@ static const UInt32 kHistorySize = 26624; // static const UInt32 kMatchMaxLen = 256; static const UInt32 kMatchMinLen = 3; -STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream, +HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo * /* progress */) { @@ -71,7 +71,7 @@ STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream, if (width != 0) distance += m_InBitStream.ReadBits(width); if (distance >= pos) - throw "data error"; + return S_FALSE; m_OutWindowStream.CopyBlock(distance, len); pos += len; } diff --git a/CPP/7zip/Compress/Arj/ArjDecoder2.h b/CPP/7zip/Compress/Arj/ArjDecoder2.h index 7a33f6bd..67a54eba 100755 --- a/CPP/7zip/Compress/Arj/ArjDecoder2.h +++ b/CPP/7zip/Compress/Arj/ArjDecoder2.h @@ -47,12 +47,11 @@ class CCoder : }; friend class CCoderReleaser; -public: - MY_UNKNOWN_IMP - - STDMETHOD(CodeReal)(ISequentialInStream *inStream, + HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); +public: + MY_UNKNOWN_IMP STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, diff --git a/CPP/7zip/Compress/BWT/BlockSort.cpp b/CPP/7zip/Compress/BWT/BlockSort.cpp deleted file mode 100755 index 283d8302..00000000 --- a/CPP/7zip/Compress/BWT/BlockSort.cpp +++ /dev/null @@ -1,486 +0,0 @@ -// 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 - -#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 deleted file mode 100755 index def48a96..00000000 --- a/CPP/7zip/Compress/BWT/BlockSort.h +++ /dev/null @@ -1,21 +0,0 @@ -// 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/BZip2/BZip2.dsp b/CPP/7zip/Compress/BZip2/BZip2.dsp deleted file mode 100755 index e26819a0..00000000 --- a/CPP/7zip/Compress/BZip2/BZip2.dsp +++ /dev/null @@ -1,316 +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=..\CodecExports.cpp -# End Source File -# Begin Source File - -SOURCE=..\DllExports.cpp -# End Source File -# Begin Source File - -SOURCE=.\resource.rc -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"StdAfx.h" -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Group "Common" - -# PROP Default_Filter "" -# 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 Group "Ñ" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.h -# End Source File -# 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 -# Begin Source File - -SOURCE=.\BZip2Register.cpp -# End Source File -# End Target -# End Project diff --git a/CPP/7zip/Compress/BZip2/BZip2.dsw b/CPP/7zip/Compress/BZip2/BZip2.dsw deleted file mode 100755 index 697e5095..00000000 --- a/CPP/7zip/Compress/BZip2/BZip2.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: "BZip2"=.\BZip2.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp b/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp index 3f7dbc58..47ffa7c8 100755 --- a/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp +++ b/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp @@ -432,10 +432,12 @@ CDecoder::~CDecoder() Free(); } -HRes CDecoder::Create() +#define RINOK_THREAD(x) { WRes __result_ = (x); if(__result_ != 0) return __result_; } + +HRESULT CDecoder::Create() { - RINOK(CanProcessEvent.CreateIfNotCreated()); - RINOK(CanStartWaitingEvent.CreateIfNotCreated()); + RINOK_THREAD(CanProcessEvent.CreateIfNotCreated()); + RINOK_THREAD(CanStartWaitingEvent.CreateIfNotCreated()); if (m_States != 0 && m_NumThreadsPrev == NumThreads) return S_OK; Free(); @@ -454,7 +456,7 @@ HRes CDecoder::Create() ti.Decoder = this; if (MtMode) { - HRes res = ti.Create(); + HRESULT res = ti.Create(); if (res != S_OK) { NumThreads = t; @@ -524,9 +526,12 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress) CState &s = m_States[t]; if (!s.Alloc()) return E_OUTOFMEMORY; - s.StreamWasFinishedEvent.Reset(); - s.WaitingWasStartedEvent.Reset(); - s.CanWriteEvent.Reset(); + if (MtMode) + { + RINOK(s.StreamWasFinishedEvent.Reset()); + RINOK(s.WaitingWasStartedEvent.Reset()); + RINOK(s.CanWriteEvent.Reset()); + } } #else if (!m_States[0].Alloc()) @@ -647,12 +652,13 @@ STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value) static THREAD_FUNC_DECL MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; } -HRes CState::Create() +HRESULT CState::Create() { - RINOK(StreamWasFinishedEvent.CreateIfNotCreated()); - RINOK(WaitingWasStartedEvent.CreateIfNotCreated()); - RINOK(CanWriteEvent.CreateIfNotCreated()); - return Thread.Create(MFThread, this); + RINOK_THREAD(StreamWasFinishedEvent.CreateIfNotCreated()); + RINOK_THREAD(WaitingWasStartedEvent.CreateIfNotCreated()); + RINOK_THREAD(CanWriteEvent.CreateIfNotCreated()); + RINOK_THREAD(Thread.Create(MFThread, this)); + return S_OK; } void CState::FinishStream() diff --git a/CPP/7zip/Compress/BZip2/BZip2Decoder.h b/CPP/7zip/Compress/BZip2/BZip2Decoder.h index 9c965b49..511302d5 100755 --- a/CPP/7zip/Compress/BZip2/BZip2Decoder.h +++ b/CPP/7zip/Compress/BZip2/BZip2Decoder.h @@ -17,13 +17,7 @@ #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 +#define NO_INLINE MY_FAST_CALL namespace NCompress { namespace NBZip2 { @@ -50,7 +44,7 @@ struct CState Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size. - HRes Create(); + HRESULT Create(); void FinishStream(); void ThreadFunc(); @@ -126,7 +120,7 @@ public: UInt32 BlockSizeMax; CDecoder(); ~CDecoder(); - HRes Create(); + HRESULT Create(); void Free(); #else diff --git a/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp b/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp index ac5f78e1..2491ef17 100755 --- a/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp +++ b/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp @@ -5,19 +5,15 @@ extern "C" { #include "../../../../C/Alloc.h" +#include "../../../../C/BwtSort.h" +#include "../../../../C/HuffEnc.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 { @@ -61,12 +57,15 @@ static THREAD_FUNC_DECL MFThread(void *threadCoderInfo) return ((CThreadInfo *)threadCoderInfo)->ThreadFunc(); } -HRes CThreadInfo::Create() +#define RINOK_THREAD(x) { WRes __result_ = (x); if(__result_ != 0) return __result_; } + +HRESULT CThreadInfo::Create() { - RINOK(StreamWasFinishedEvent.Create()); - RINOK(WaitingWasStartedEvent.Create()); - RINOK(CanWriteEvent.Create()); - return Thread.Create(MFThread, this); + RINOK_THREAD(StreamWasFinishedEvent.Create()); + RINOK_THREAD(WaitingWasStartedEvent.Create()); + RINOK_THREAD(CanWriteEvent.Create()); + RINOK_THREAD(Thread.Create(MFThread, this)); + return S_OK; } void CThreadInfo::FinishStream(bool needLeave) @@ -145,10 +144,10 @@ CEncoder::~CEncoder() Free(); } -HRes CEncoder::Create() +HRESULT CEncoder::Create() { - RINOK(CanProcessEvent.CreateIfNotCreated()); - RINOK(CanStartWaitingEvent.CreateIfNotCreated()); + RINOK_THREAD(CanProcessEvent.CreateIfNotCreated()); + RINOK_THREAD(CanStartWaitingEvent.CreateIfNotCreated()); if (ThreadsInfo != 0 && m_NumThreadsPrev == NumThreads) return S_OK; try @@ -167,7 +166,7 @@ HRes CEncoder::Create() ti.Encoder = this; if (MtMode) { - HRes res = ti.Create(); + HRESULT res = ti.Create(); if (res != S_OK) { NumThreads = t; @@ -733,9 +732,12 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, { #ifdef COMPRESS_BZIP2_MT CThreadInfo &ti = ThreadsInfo[t]; - ti.StreamWasFinishedEvent.Reset(); - ti.WaitingWasStartedEvent.Reset(); - ti.CanWriteEvent.Reset(); + if (MtMode) + { + RINOK(ti.StreamWasFinishedEvent.Reset()); + RINOK(ti.WaitingWasStartedEvent.Reset()); + RINOK(ti.CanWriteEvent.Reset()); + } #else CThreadInfo &ti = ThreadsInfo; ti.Encoder = this; diff --git a/CPP/7zip/Compress/BZip2/BZip2Encoder.h b/CPP/7zip/Compress/BZip2/BZip2Encoder.h index 02d4cde3..98cd20d6 100755 --- a/CPP/7zip/Compress/BZip2/BZip2Encoder.h +++ b/CPP/7zip/Compress/BZip2/BZip2Encoder.h @@ -70,9 +70,9 @@ public: void SetPos(UInt32 bitPos) { m_Pos = bitPos / 8; - m_BitPos = 8 - (bitPos & 7); + m_BitPos = 8 - ((int)bitPos & 7); } - void SetCurState(UInt32 bitPos, Byte curByte) + void SetCurState(int bitPos, Byte curByte) { m_BitPos = 8 - bitPos; m_CurByte = curByte; @@ -103,7 +103,7 @@ private: UInt32 m_CRCs[1 << kNumPassesMax]; UInt32 m_NumCrcs; - int m_BlockIndex; + UInt32 m_BlockIndex; void WriteBits2(UInt32 value, UInt32 numBits); void WriteByte2(Byte b); @@ -128,7 +128,7 @@ public: UInt64 m_PackSize; Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size. - HRes Create(); + HRESULT Create(); void FinishStream(bool needLeave); DWORD ThreadFunc(); #endif @@ -189,7 +189,7 @@ public: void WriteCRC(UInt32 v); #ifdef COMPRESS_BZIP2_MT - HRes Create(); + HRESULT Create(); void Free(); #endif diff --git a/CPP/7zip/Compress/BZip2/makefile b/CPP/7zip/Compress/BZip2/makefile deleted file mode 100755 index 6e467583..00000000 --- a/CPP/7zip/Compress/BZip2/makefile +++ /dev/null @@ -1,58 +0,0 @@ -PROG = BZip2.dll -DEF_FILE = ../Codec.def -CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_BZIP2_MT -D_7ZIP_LARGE_PAGES -LIBS = $(LIBS) oleaut32.lib - -COMPRESS_OBJS = \ - $O\CodecExports.obj \ - $O\DllExports.obj \ - -BZIP2_OBJS = \ - $O\BZip2CRC.obj \ - $O\BZip2Register.obj \ - -BZIP2_OPT_OBJS = \ - $O\BZip2Decoder.obj \ - $O\BZip2Encoder.obj \ - -WIN_OBJS = \ - $O\Synchronization.obj - -7ZIP_COMMON_OBJS = \ - $O\InBuffer.obj \ - $O\OutBuffer.obj \ - -C_OBJS = \ - $O\Alloc.obj \ - $O\Sort.obj \ - -OBJS = \ - $O\StdAfx.obj \ - $(COMPRESS_OBJS) \ - $(BZIP2_OBJS) \ - $(BZIP2_OPT_OBJS) \ - $(WIN_OBJS) \ - $(7ZIP_COMMON_OBJS) \ - $O\BlockSort.obj \ - $(C_OBJS) \ - $O\HuffmanEncode.obj \ - $O\resource.res - -!include "../../../Build.mak" - -$(COMPRESS_OBJS): ../$(*B).cpp - $(COMPL) -$(BZIP2_OBJS): $(*B).cpp - $(COMPL) -$(BZIP2_OPT_OBJS): $(*B).cpp - $(COMPL_O2) -$(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/CPP/7zip/Compress/BZip2/resource.rc b/CPP/7zip/Compress/BZip2/resource.rc deleted file mode 100755 index c5bea782..00000000 --- a/CPP/7zip/Compress/BZip2/resource.rc +++ /dev/null @@ -1,3 +0,0 @@ -#include "../../MyVersionInfo.rc" - -MY_VERSION_INFO_DLL("BZip2 Codec", "BZip2") diff --git a/CPP/7zip/Compress/Branch/ARM.cpp b/CPP/7zip/Compress/Branch/ARM.cpp deleted file mode 100755 index 5870bc03..00000000 --- a/CPP/7zip/Compress/Branch/ARM.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// ARM.cpp - -#include "StdAfx.h" -#include "ARM.h" - -extern "C" -{ -#include "../../../../C/Compress/Branch/BranchARM.h" -} - -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/CPP/7zip/Compress/Branch/ARM.h b/CPP/7zip/Compress/Branch/ARM.h deleted file mode 100755 index 5561299b..00000000 --- a/CPP/7zip/Compress/Branch/ARM.h +++ /dev/null @@ -1,10 +0,0 @@ -// ARM.h - -#ifndef __ARM_H -#define __ARM_H - -#include "BranchCoder.h" - -MyClassA(BC_ARM, 0x05, 1) - -#endif diff --git a/CPP/7zip/Compress/Branch/ARMThumb.cpp b/CPP/7zip/Compress/Branch/ARMThumb.cpp deleted file mode 100755 index 7df641ac..00000000 --- a/CPP/7zip/Compress/Branch/ARMThumb.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// ARMThumb.cpp - -#include "StdAfx.h" - -#include "ARMThumb.h" - -extern "C" -{ -#include "../../../../C/Compress/Branch/BranchARMThumb.h" -} - -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/CPP/7zip/Compress/Branch/ARMThumb.h b/CPP/7zip/Compress/Branch/ARMThumb.h deleted file mode 100755 index 601e40bf..00000000 --- a/CPP/7zip/Compress/Branch/ARMThumb.h +++ /dev/null @@ -1,10 +0,0 @@ -// ARMThumb.h - -#ifndef __ARMTHUMB_H -#define __ARMTHUMB_H - -#include "BranchCoder.h" - -MyClassA(BC_ARMThumb, 0x07, 1) - -#endif diff --git a/CPP/7zip/Compress/Branch/Branch.dsp b/CPP/7zip/Compress/Branch/Branch.dsp deleted file mode 100755 index 795a534a..00000000 --- a/CPP/7zip/Compress/Branch/Branch.dsp +++ /dev/null @@ -1,433 +0,0 @@ -# Microsoft Developer Studio Project File - Name="Branch" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=Branch - 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 "Branch.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 "Branch.mak" CFG="Branch - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "Branch - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "Branch - 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)" == "Branch - 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 "BRANCH_EXPORTS" /YX /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O2 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BRANCH_EXPORTS" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -# 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\Branch.dll" /opt:NOWIN98 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "Branch - 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 "BRANCH_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BRANCH_EXPORTS" /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\Branch.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "Branch - Win32 Release" -# Name "Branch - Win32 Debug" -# Begin Group "Spec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\Codec.def -# End Source File -# Begin Source File - -SOURCE=..\CodecExports.cpp -# End Source File -# Begin Source File - -SOURCE=..\DllExports.cpp -# End Source File -# Begin Source File - -SOURCE=.\resource.rc -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"StdAfx.h" -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Group "Methods" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\ARM.cpp - -!IF "$(CFG)" == "Branch - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\ARM.h -# End Source File -# Begin Source File - -SOURCE=.\ARMThumb.cpp - -!IF "$(CFG)" == "Branch - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\ARMThumb.h -# End Source File -# Begin Source File - -SOURCE=.\BCJ2Register.cpp -# End Source File -# Begin Source File - -SOURCE=.\BCJRegister.cpp -# End Source File -# Begin Source File - -SOURCE=.\BranchCoder.cpp -# End Source File -# Begin Source File - -SOURCE=.\BranchCoder.h -# End Source File -# Begin Source File - -SOURCE=.\BranchRegister.cpp -# End Source File -# Begin Source File - -SOURCE=.\BranchTypes.h -# End Source File -# Begin Source File - -SOURCE=.\BranchX86.h -# End Source File -# Begin Source File - -SOURCE=.\IA64.cpp - -!IF "$(CFG)" == "Branch - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\IA64.h -# End Source File -# Begin Source File - -SOURCE=.\PPC.cpp - -!IF "$(CFG)" == "Branch - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\PPC.h -# End Source File -# Begin Source File - -SOURCE=.\SPARC.cpp -# End Source File -# Begin Source File - -SOURCE=.\SPARC.h -# End Source File -# Begin Source File - -SOURCE=.\x86.cpp - -!IF "$(CFG)" == "Branch - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\x86.h -# End Source File -# Begin Source File - -SOURCE=.\x86_2.cpp - -!IF "$(CFG)" == "Branch - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\x86_2.h -# End Source File -# End Group -# Begin Group "Stream" - -# 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 -# End Group -# Begin Group "RangeCoder" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\RangeCoder\RangeCoder.h -# End Source File -# Begin Source File - -SOURCE=..\RangeCoder\RangeCoderBit.h -# End Source File -# End Group -# Begin Group "C" - -# PROP Default_Filter "" -# Begin Group "C Branch" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchARM.c - -!IF "$(CFG)" == "Branch - Win32 Release" - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchARM.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchARMThumb.c - -!IF "$(CFG)" == "Branch - Win32 Release" - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchARMThumb.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchIA64.c - -!IF "$(CFG)" == "Branch - Win32 Release" - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchIA64.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchPPC.c - -!IF "$(CFG)" == "Branch - Win32 Release" - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchPPC.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchSPARC.c - -!IF "$(CFG)" == "Branch - Win32 Release" - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchSPARC.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchTypes.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c - -!IF "$(CFG)" == "Branch - Win32 Release" - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.h -# End Source File -# End Group -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.c - -!IF "$(CFG)" == "Branch - Win32 Release" - -!ELSEIF "$(CFG)" == "Branch - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.h -# End Source File -# End Group -# End Target -# End Project diff --git a/CPP/7zip/Compress/Branch/Branch.dsw b/CPP/7zip/Compress/Branch/Branch.dsw deleted file mode 100755 index 841c85a3..00000000 --- a/CPP/7zip/Compress/Branch/Branch.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: "Branch"=.\Branch.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Compress/Branch/BranchMisc.cpp b/CPP/7zip/Compress/Branch/BranchMisc.cpp new file mode 100755 index 00000000..ff4eafbe --- /dev/null +++ b/CPP/7zip/Compress/Branch/BranchMisc.cpp @@ -0,0 +1,39 @@ +// BranchMisc.cpp + +#include "StdAfx.h" +#include "BranchMisc.h" + +extern "C" +{ +#include "../../../../C/Bra.h" +} + +UInt32 CBC_ARM_Encoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::ARM_Convert(data, size, _bufferPos, 1); } + +UInt32 CBC_ARM_Decoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::ARM_Convert(data, size, _bufferPos, 0); } + +UInt32 CBC_ARMT_Encoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::ARMT_Convert(data, size, _bufferPos, 1); } + +UInt32 CBC_ARMT_Decoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::ARMT_Convert(data, size, _bufferPos, 0); } + +UInt32 CBC_PPC_Encoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::PPC_Convert(data, size, _bufferPos, 1); } + +UInt32 CBC_PPC_Decoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::PPC_Convert(data, size, _bufferPos, 0); } + +UInt32 CBC_SPARC_Encoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::SPARC_Convert(data, size, _bufferPos, 1); } + +UInt32 CBC_SPARC_Decoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::SPARC_Convert(data, size, _bufferPos, 0); } + +UInt32 CBC_IA64_Encoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::IA64_Convert(data, size, _bufferPos, 1); } + +UInt32 CBC_IA64_Decoder::SubFilter(Byte *data, UInt32 size) + { return (UInt32)::IA64_Convert(data, size, _bufferPos, 0); } diff --git a/CPP/7zip/Compress/Branch/BranchMisc.h b/CPP/7zip/Compress/Branch/BranchMisc.h new file mode 100755 index 00000000..219eec1c --- /dev/null +++ b/CPP/7zip/Compress/Branch/BranchMisc.h @@ -0,0 +1,14 @@ +// BranchMisc.h + +#ifndef __BRANCHMISC_H +#define __BRANCHMISC_H + +#include "BranchCoder.h" + +MyClassA(BC_ARM, 0x05, 1) +MyClassA(BC_ARMT, 0x07, 1) +MyClassA(BC_PPC, 0x02, 5) +MyClassA(BC_SPARC, 0x08, 5) +MyClassA(BC_IA64, 0x04, 1) + +#endif diff --git a/CPP/7zip/Compress/Branch/BranchRegister.cpp b/CPP/7zip/Compress/Branch/BranchRegister.cpp index 2ccdcc64..69fbe5d3 100755 --- a/CPP/7zip/Compress/Branch/BranchRegister.cpp +++ b/CPP/7zip/Compress/Branch/BranchRegister.cpp @@ -4,31 +4,27 @@ #include "../../Common/RegisterCodec.h" -#include "PPC.h" -#include "IA64.h" -#include "ARM.h" -#include "ARMThumb.h" -#include "SPARC.h" +#include "BranchMisc.h" #define CREATE_CODEC(x) \ static void *CreateCodec ## x() { return (void *)(ICompressFilter *)(new C ## x ## _Decoder); } \ static void *CreateCodec ## x ## Out() { return (void *)(ICompressFilter *)(new C ## x ## _Encoder); } -CREATE_CODEC(BC_PPC_B) +CREATE_CODEC(BC_PPC) CREATE_CODEC(BC_IA64) CREATE_CODEC(BC_ARM) -CREATE_CODEC(BC_ARMThumb) +CREATE_CODEC(BC_ARMT) CREATE_CODEC(BC_SPARC) #define METHOD_ITEM(x, id1, id2, name) { CreateCodec ## x, CreateCodec ## x ## Out, 0x03030000 + (id1 * 256) + id2, name, 1, true } static CCodecInfo g_CodecsInfo[] = { - METHOD_ITEM(BC_PPC_B, 0x02, 0x05, L"BC_PPC_B"), - METHOD_ITEM(BC_IA64, 0x04, 1, L"BC_IA64"), - METHOD_ITEM(BC_ARM, 0x05, 1, L"BC_ARM"), - METHOD_ITEM(BC_ARMThumb,0x07, 1, L"BC_ARMThumb"), - METHOD_ITEM(BC_SPARC, 0x08, 0x05, L"BC_SPARC") + METHOD_ITEM(BC_PPC, 0x02, 0x05, L"PPC"), + METHOD_ITEM(BC_IA64, 0x04, 1, L"IA64"), + METHOD_ITEM(BC_ARM, 0x05, 1, L"ARM"), + METHOD_ITEM(BC_ARMT, 0x07, 1, L"ARMT"), + METHOD_ITEM(BC_SPARC, 0x08, 0x05, L"SPARC") }; REGISTER_CODECS(Branch) diff --git a/CPP/7zip/Compress/Branch/IA64.cpp b/CPP/7zip/Compress/Branch/IA64.cpp deleted file mode 100755 index ae4766a3..00000000 --- a/CPP/7zip/Compress/Branch/IA64.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// IA64.cpp - -#include "StdAfx.h" -#include "IA64.h" - -extern "C" -{ -#include "../../../../C/Compress/Branch/BranchIA64.h" -} - -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/CPP/7zip/Compress/Branch/IA64.h b/CPP/7zip/Compress/Branch/IA64.h deleted file mode 100755 index 7fe715ed..00000000 --- a/CPP/7zip/Compress/Branch/IA64.h +++ /dev/null @@ -1,10 +0,0 @@ -// IA64.h - -#ifndef __IA64_H -#define __IA64_H - -#include "BranchCoder.h" - -MyClassA(BC_IA64, 0x04, 1) - -#endif diff --git a/CPP/7zip/Compress/Branch/PPC.cpp b/CPP/7zip/Compress/Branch/PPC.cpp deleted file mode 100755 index ecd4b3d8..00000000 --- a/CPP/7zip/Compress/Branch/PPC.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// PPC.cpp - -#include "StdAfx.h" -#include "PPC.h" - -extern "C" -{ -#include "../../../../C/Compress/Branch/BranchPPC.h" -} - -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/CPP/7zip/Compress/Branch/PPC.h b/CPP/7zip/Compress/Branch/PPC.h deleted file mode 100755 index a0e33444..00000000 --- a/CPP/7zip/Compress/Branch/PPC.h +++ /dev/null @@ -1,10 +0,0 @@ -// PPC.h - -#ifndef __PPC_H -#define __PPC_H - -#include "BranchCoder.h" - -MyClassA(BC_PPC_B, 0x02, 5) - -#endif diff --git a/CPP/7zip/Compress/Branch/SPARC.cpp b/CPP/7zip/Compress/Branch/SPARC.cpp deleted file mode 100755 index 5678eb31..00000000 --- a/CPP/7zip/Compress/Branch/SPARC.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// SPARC.cpp - -#include "StdAfx.h" -#include "SPARC.h" - -extern "C" -{ -#include "../../../../C/Compress/Branch/BranchSPARC.h" -} - -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/CPP/7zip/Compress/Branch/SPARC.h b/CPP/7zip/Compress/Branch/SPARC.h deleted file mode 100755 index e0a682ef..00000000 --- a/CPP/7zip/Compress/Branch/SPARC.h +++ /dev/null @@ -1,10 +0,0 @@ -// SPARC.h - -#ifndef __SPARC_H -#define __SPARC_H - -#include "BranchCoder.h" - -MyClassA(BC_SPARC, 0x08, 5) - -#endif diff --git a/CPP/7zip/Compress/Branch/makefile b/CPP/7zip/Compress/Branch/makefile deleted file mode 100755 index 73ae75b2..00000000 --- a/CPP/7zip/Compress/Branch/makefile +++ /dev/null @@ -1,63 +0,0 @@ -PROG = Branch.dll -DEF_FILE = ../Codec.def -CFLAGS = $(CFLAGS) -I ../../../ -LIBS = $(LIBS) oleaut32.lib - -COMPRESS_OBJS = \ - $O\CodecExports.obj \ - $O\DllExports.obj \ - -BRANCH_OPT_OBJS = \ - $O\ARM.obj \ - $O\ARMThumb.obj \ - $O\BranchCoder.obj \ - $O\IA64.obj \ - $O\PPC.obj \ - $O\SPARC.obj \ - $O\x86.obj \ - $O\x86_2.obj \ - $O\BranchRegister.obj \ - $O\BCJRegister.obj \ - $O\BCJ2Register.obj \ - -C_OBJS = \ - $O\Alloc.obj \ - -C_BRANCH_OBJS = \ - $O\BranchARM.obj \ - $O\BranchARMThumb.obj \ - $O\BranchIA64.obj \ - $O\BranchPPC.obj \ - $O\BranchSPARC.obj \ - $O\BranchX86.obj \ - -7ZIP_COMMON_OBJS = \ - $O\InBuffer.obj \ - $O\OutBuffer.obj \ - - -OBJS = \ - $O\StdAfx.obj \ - $(COMPRESS_OBJS) \ - $(BRANCH_OPT_OBJS) \ - $(7ZIP_COMMON_OBJS) \ - $O\RangeCoderBit.obj \ - $(C_OBJS) \ - $(C_BRANCH_OBJS) \ - $O\resource.res - - -!include "../../../Build.mak" - -$(COMPRESS_OBJS): ../$(*B).cpp - $(COMPL) -$(BRANCH_OPT_OBJS): $(*B).cpp - $(COMPL_O2) -$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp - $(COMPL) -$O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp - $(COMPL) -$(C_OBJS): ../../../../C/$(*B).c - $(COMPL_O2) -$(C_BRANCH_OBJS): ../../../../C/Compress/Branch/$(*B).c - $(COMPL_O2) diff --git a/CPP/7zip/Compress/Branch/resource.rc b/CPP/7zip/Compress/Branch/resource.rc deleted file mode 100755 index 5476d4fa..00000000 --- a/CPP/7zip/Compress/Branch/resource.rc +++ /dev/null @@ -1,3 +0,0 @@ -#include "../../MyVersionInfo.rc" - -MY_VERSION_INFO_DLL("Branch Filter", "Branch") diff --git a/CPP/7zip/Compress/Branch/x86.h b/CPP/7zip/Compress/Branch/x86.h index 58176600..e898cb7e 100755 --- a/CPP/7zip/Compress/Branch/x86.h +++ b/CPP/7zip/Compress/Branch/x86.h @@ -6,7 +6,7 @@ #include "BranchCoder.h" extern "C" { -#include "../../../../C/Compress/Branch/BranchX86.h" +#include "../../../../C/Bra.h" } struct CBranch86 diff --git a/CPP/7zip/Compress/ByteSwap/ByteSwap.dsp b/CPP/7zip/Compress/ByteSwap/ByteSwap.dsp deleted file mode 100755 index 14c42981..00000000 --- a/CPP/7zip/Compress/ByteSwap/ByteSwap.dsp +++ /dev/null @@ -1,133 +0,0 @@ -# Microsoft Developer Studio Project File - Name="ByteSwap" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=ByteSwap - 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 "ByteSwap.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 "ByteSwap.mak" CFG="ByteSwap - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "ByteSwap - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "ByteSwap - 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)" == "ByteSwap - 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 "BYTESWAP_EXPORTS" /YX /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BYTESWAP_EXPORTS" /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\Swap.dll" /opt:NOWIN98 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "ByteSwap - 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 "BYTESWAP_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BYTESWAP_EXPORTS" /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\Swap.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "ByteSwap - Win32 Release" -# Name "ByteSwap - Win32 Debug" -# Begin Group "Spec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\Codec.def -# End Source File -# Begin Source File - -SOURCE=..\CodecExports.cpp -# End Source File -# Begin Source File - -SOURCE=..\DllExports.cpp -# End Source File -# Begin Source File - -SOURCE=.\resource.rc -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"StdAfx.h" -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\ByteSwap.cpp -# End Source File -# Begin Source File - -SOURCE=.\ByteSwap.h -# End Source File -# Begin Source File - -SOURCE=.\ByteSwapRegister.cpp -# End Source File -# End Target -# End Project diff --git a/CPP/7zip/Compress/ByteSwap/ByteSwap.dsw b/CPP/7zip/Compress/ByteSwap/ByteSwap.dsw deleted file mode 100755 index 413d7e6e..00000000 --- a/CPP/7zip/Compress/ByteSwap/ByteSwap.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: "ByteSwap"=.\ByteSwap.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Compress/ByteSwap/makefile b/CPP/7zip/Compress/ByteSwap/makefile deleted file mode 100755 index 80e8af78..00000000 --- a/CPP/7zip/Compress/ByteSwap/makefile +++ /dev/null @@ -1,25 +0,0 @@ -PROG = Swap.dll -DEF_FILE = ../Codec.def -CFLAGS = $(CFLAGS) -I ../../../ -LIBS = $(LIBS) oleaut32.lib - -COMPRESS_OBJS = \ - $O\CodecExports.obj \ - $O\DllExports.obj \ - -SWAP_OPT_OBJS = \ - $O\ByteSwap.obj \ - $O\ByteSwapRegister.obj \ - -OBJS = \ - $O\StdAfx.obj \ - $(COMPRESS_OBJS) \ - $(SWAP_OPT_OBJS) \ - $O\resource.res - -!include "../../../Build.mak" - -$(COMPRESS_OBJS): ../$(*B).cpp - $(COMPL) -$(SWAP_OPT_OBJS): $(*B).cpp - $(COMPL_O2) diff --git a/CPP/7zip/Compress/ByteSwap/resource.rc b/CPP/7zip/Compress/ByteSwap/resource.rc deleted file mode 100755 index 21c0c505..00000000 --- a/CPP/7zip/Compress/ByteSwap/resource.rc +++ /dev/null @@ -1,3 +0,0 @@ -#include "../../MyVersionInfo.rc" - -MY_VERSION_INFO_DLL("SWAP filter Codec", "SWAP") diff --git a/CPP/7zip/Compress/CodecExports.cpp b/CPP/7zip/Compress/CodecExports.cpp index a4a85b64..7500d923 100755 --- a/CPP/7zip/Compress/CodecExports.cpp +++ b/CPP/7zip/Compress/CodecExports.cpp @@ -48,7 +48,7 @@ static HRESULT FindCodecClassId(const GUID *clsID, UInt32 isCoder2, bool isFilte UInt64 id = 0; for (int j = 0; j < 8; j++) id |= ((UInt64)clsID->Data4[j]) << (8 * j); - for (UInt32 i = 0; i < g_NumCodecs; i++) + for (unsigned i = 0; i < g_NumCodecs; i++) { const CCodecInfo &codec = *g_Codecs[i]; if (id != codec.Id || encode && !codec.CreateEncoder || !encode && !codec.CreateDecoder) @@ -142,7 +142,7 @@ STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value) if (codec.NumInStreams != 1) { value->vt = VT_UI4; - value->ulVal = codec.NumInStreams; + value->ulVal = (ULONG)codec.NumInStreams; } break; } diff --git a/CPP/7zip/Compress/Copy/Copy.dsp b/CPP/7zip/Compress/Copy/Copy.dsp deleted file mode 100755 index efbc5e31..00000000 --- a/CPP/7zip/Compress/Copy/Copy.dsp +++ /dev/null @@ -1,158 +0,0 @@ -# Microsoft Developer Studio Project File - Name="Copy" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=Copy - 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 "Copy.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 "Copy.mak" CFG="Copy - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "Copy - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "Copy - 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)" == "Copy - 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 "COPY_EXPORTS" /YX /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COPY_EXPORTS" /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\Copy.dll" /opt:NOWIN98 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "Copy - 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 "COPY_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COPY_EXPORTS" /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\Copy.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "Copy - Win32 Release" -# Name "Copy - Win32 Debug" -# Begin Group "Spec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\Codec.def -# End Source File -# Begin Source File - -SOURCE=..\CodecExports.cpp -# End Source File -# Begin Source File - -SOURCE=..\DllExports.cpp -# End Source File -# Begin Source File - -SOURCE=.\resource.rc -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"StdAfx.h" -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Group "7-Zip Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Common\StreamUtils.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamUtils.h -# End Source File -# End Group -# Begin Group "Ñ" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\CopyCoder.cpp -# End Source File -# Begin Source File - -SOURCE=.\CopyCoder.h -# End Source File -# Begin Source File - -SOURCE=.\CopyRegister.cpp -# End Source File -# End Target -# End Project diff --git a/CPP/7zip/Compress/Copy/Copy.dsw b/CPP/7zip/Compress/Copy/Copy.dsw deleted file mode 100755 index 53ddf6cf..00000000 --- a/CPP/7zip/Compress/Copy/Copy.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: "Copy"=".\Copy.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Compress/Copy/CopyCoder.cpp b/CPP/7zip/Compress/Copy/CopyCoder.cpp index 8e18db2b..d5285185 100755 --- a/CPP/7zip/Compress/Copy/CopyCoder.cpp +++ b/CPP/7zip/Compress/Copy/CopyCoder.cpp @@ -42,7 +42,7 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream, RINOK(inStream->Read(_buffer, size, &realProcessedSize)); if (realProcessedSize == 0) break; - RINOK(WriteStream(outStream, _buffer, realProcessedSize, NULL)); + RINOK(WriteStream(outStream, _buffer, realProcessedSize)); TotalSize += realProcessedSize; if (progress != NULL) { diff --git a/CPP/7zip/Compress/Copy/makefile b/CPP/7zip/Compress/Copy/makefile deleted file mode 100755 index 4588a341..00000000 --- a/CPP/7zip/Compress/Copy/makefile +++ /dev/null @@ -1,37 +0,0 @@ -PROG = Copy.dll -DEF_FILE = ../Codec.def -CFLAGS = $(CFLAGS) -I ../../../ -LIBS = $(LIBS) oleaut32.lib - -COMPRESS_OBJS = \ - $O\CodecExports.obj \ - $O\DllExports.obj \ - -COPY_OBJS = \ - $O\CopyCoder.obj \ - $O\CopyRegister.obj \ - -7ZIP_COMMON_OBJS = \ - $O\StreamUtils.obj \ - -C_OBJS = \ - $O\Alloc.obj \ - -OBJS = \ - $O\StdAfx.obj \ - $(COMPRESS_OBJS) \ - $(COPY_OBJS) \ - $(7ZIP_COMMON_OBJS) \ - $(C_OBJS) \ - $O\resource.res - -!include "../../../Build.mak" - -$(COMPRESS_OBJS): ../$(*B).cpp - $(COMPL) -$(COPY_OBJS): $(*B).cpp - $(COMPL) -$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp - $(COMPL) -$(C_OBJS): ../../../../C/$(*B).c - $(COMPL_O2) diff --git a/CPP/7zip/Compress/Copy/resource.rc b/CPP/7zip/Compress/Copy/resource.rc deleted file mode 100755 index 234c85bf..00000000 --- a/CPP/7zip/Compress/Copy/resource.rc +++ /dev/null @@ -1,3 +0,0 @@ -#include "../../MyVersionInfo.rc" - -MY_VERSION_INFO_DLL("Copy Codec", "Copy") diff --git a/CPP/7zip/Compress/Deflate/Deflate.dsp b/CPP/7zip/Compress/Deflate/Deflate.dsp deleted file mode 100755 index 11854458..00000000 --- a/CPP/7zip/Compress/Deflate/Deflate.dsp +++ /dev/null @@ -1,350 +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=..\CodecExports.cpp -# End Source File -# Begin Source File - -SOURCE=..\DllExports.cpp -# End Source File -# Begin Source File - -SOURCE=.\resource.rc -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"StdAfx.h" -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Group "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\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\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\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=.\Deflate64Register.cpp -# End Source File -# 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 -# Begin Source File - -SOURCE=.\DeflateNsisRegister.cpp -# End Source File -# Begin Source File - -SOURCE=.\DeflateRegister.cpp -# End Source File -# End Target -# End Project diff --git a/CPP/7zip/Compress/Deflate/Deflate.dsw b/CPP/7zip/Compress/Deflate/Deflate.dsw deleted file mode 100755 index f17203ed..00000000 --- a/CPP/7zip/Compress/Deflate/Deflate.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: "Deflate"=.\Deflate.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp index 2c623750..44ff42b4 100755 --- a/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp +++ b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp @@ -2,6 +2,8 @@ #include "StdAfx.h" +#include + #include "DeflateEncoder.h" #include "Windows/Defs.h" @@ -9,8 +11,8 @@ extern "C" { #include "../../../../C/Alloc.h" +#include "../../../../C/HuffEnc.h" } -// #include "../LZ/BinTree/BinTree3Z.h" #if _MSC_VER >= 1300 #define NO_INLINE __declspec(noinline) @@ -18,11 +20,6 @@ extern "C" #define NO_INLINE #endif -extern "C" -{ - #include "../../../../C/Compress/Huffman/HuffmanEncode.h" -} - namespace NCompress { namespace NDeflate { namespace NEncoder { @@ -31,7 +28,7 @@ const int kNumDivPassesMax = 10; // [0, 16); ratio/speed/ram tradeoff; use big v 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 kDivideCodeBlockSizeMin = (1 << 7); // [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)) @@ -40,11 +37,11 @@ static const UInt32 kMatchArrayLimit = kMatchArraySize - kMatchMaxLen * 4 * size static const UInt32 kBlockUncompressedSizeThreshold = kMaxUncompressedBlockSize - kMatchMaxLen - kNumOpts; -static const int kMaxCodeBitLength = 12; +static const int kMaxCodeBitLength = 11; static const int kMaxLevelBitLength = 7; -static Byte kNoLiteralStatPrice = 12; -static Byte kNoLenStatPrice = 12; +static Byte kNoLiteralStatPrice = 11; +static Byte kNoLenStatPrice = 11; static Byte kNoPosStatPrice = 6; static Byte g_LenSlots[kNumLenSymbolsMax]; @@ -85,19 +82,9 @@ inline UInt32 GetPosSlot(UInt32 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 }; +static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } +static void SzFree(void *p, void *address) { p = p; MyFree(address); } +static ISzAlloc g_Alloc = { SzAlloc, SzFree }; CCoder::CCoder(bool deflate64Mode): m_Deflate64Mode(deflate64Mode), @@ -591,10 +578,10 @@ NO_INLINE void CCoder::LevelTableCode(const Byte *levels, int numLevels, const B } } -NO_INLINE void CCoder::MakeTables() +NO_INLINE void CCoder::MakeTables(unsigned maxHuffLen) { - Huffman_Generate(mainFreqs, mainCodes, m_NewLevels.litLenLevels, kFixedMainTableSize, kMaxCodeBitLength); - Huffman_Generate(distFreqs, distCodes, m_NewLevels.distLevels, kDistTableSize64, kMaxCodeBitLength); + Huffman_Generate(mainFreqs, mainCodes, m_NewLevels.litLenLevels, kFixedMainTableSize, maxHuffLen); + Huffman_Generate(distFreqs, distCodes, m_NewLevels.distLevels, kDistTableSize64, maxHuffLen); } NO_INLINE UInt32 Huffman_GetPrice(const UInt32 *freqs, const Byte *lens, UInt32 num) @@ -632,7 +619,7 @@ NO_INLINE void CCoder::TryBlock() if (m_OptimumCurrentIndex == m_OptimumEndIndex) { if (m_Pos >= kMatchArrayLimit || BlockSizeRes >= blockSize || !m_SecondPass && - ((Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) == 0) || m_ValueIndex >= m_ValueBlockSize)) + ((Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) == 0) || m_ValueIndex >= m_ValueBlockSize)) break; } UInt32 pos; @@ -773,7 +760,11 @@ NO_INLINE UInt32 CCoder::TryDynBlock(int tableIndex, UInt32 numPasses) { m_Pos = posTemp; TryBlock(); - MakeTables(); + unsigned numHuffBits = + (m_ValueIndex > 18000 ? 12 : + (m_ValueIndex > 7000 ? 11 : + (m_ValueIndex > 2000 ? 10 : 9))); + MakeTables(numHuffBits); SetPrices(m_NewLevels); } @@ -893,11 +884,12 @@ void CCoder::CodeBlock(int tableIndex, bool finalBlock) WriteBits(NBlockType::kFixedHuffman, kBlockTypeFieldSize); TryFixedBlock(tableIndex); int i; + const int kMaxStaticHuffLen = 9; for (i = 0; i < kFixedMainTableSize; i++) - mainFreqs[i] = (UInt32)1 << (kNumHuffmanBits - m_NewLevels.litLenLevels[i]); + mainFreqs[i] = (UInt32)1 << (kMaxStaticHuffLen - m_NewLevels.litLenLevels[i]); for (i = 0; i < kFixedDistTableSize; i++) - distFreqs[i] = (UInt32)1 << (kNumHuffmanBits - m_NewLevels.distLevels[i]); - MakeTables(); + distFreqs[i] = (UInt32)1 << (kMaxStaticHuffLen - m_NewLevels.distLevels[i]); + MakeTables(kMaxStaticHuffLen); } else { @@ -921,9 +913,13 @@ void CCoder::CodeBlock(int tableIndex, bool finalBlock) } } -HRes Read(void *object, void *data, UInt32 size, UInt32 *processedSize) +SRes Read(void *object, void *data, size_t *size) { - return (HRes)((CSeqInStream *)object)->RealStream->Read(data, size, processedSize); + const UInt32 kStepSize = (UInt32)1 << 31; + UInt32 curSize = ((*size < kStepSize) ? (UInt32)*size : kStepSize); + HRESULT res = ((CSeqInStream *)object)->RealStream->Read(data, curSize, &curSize); + *size = curSize; + return (SRes)res; } HRESULT CCoder::CodeReal(ISequentialInStream *inStream, @@ -935,7 +931,7 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream, RINOK(Create()); - m_ValueBlockSize = (1 << 13) + (1 << 12) * m_NumDivPasses; + m_ValueBlockSize = (7 << 10) + (1 << 12) * m_NumDivPasses; UInt64 nowPos = 0; diff --git a/CPP/7zip/Compress/Deflate/DeflateEncoder.h b/CPP/7zip/Compress/Deflate/DeflateEncoder.h index a7b2bb5b..4cdfa707 100755 --- a/CPP/7zip/Compress/Deflate/DeflateEncoder.h +++ b/CPP/7zip/Compress/Deflate/DeflateEncoder.h @@ -12,7 +12,7 @@ extern "C" { - #include "../../../../C/Compress/Lz/MatchFinder.h" + #include "../../../../C/LzFind.h" } namespace NCompress { @@ -132,7 +132,7 @@ public: void WriteBits(UInt32 value, int numBits); void LevelTableCode(const Byte *levels, int numLevels, const Byte *lens, const UInt32 *codes); - void MakeTables(); + void MakeTables(unsigned maxHuffLen); UInt32 GetLzBlockPrice() const; void TryBlock(); UInt32 TryDynBlock(int tableIndex, UInt32 numPasses); diff --git a/CPP/7zip/Compress/Deflate/makefile b/CPP/7zip/Compress/Deflate/makefile deleted file mode 100755 index 302d2888..00000000 --- a/CPP/7zip/Compress/Deflate/makefile +++ /dev/null @@ -1,63 +0,0 @@ -PROG = Deflate.dll -DEF_FILE = ../Codec.def -CFLAGS = $(CFLAGS) -I ../../../ -LIBS = $(LIBS) oleaut32.lib - -COMPRESS_OBJS = \ - $O\CodecExports.obj \ - $O\DllExports.obj \ - -DEFLATE_OPT_OBJS = \ - $O\DeflateDecoder.obj \ - $O\DeflateEncoder.obj \ - $O\DeflateRegister.obj \ - $O\Deflate64Register.obj \ - $O\DeflateNsisRegister.obj \ - -7ZIP_COMMON_OBJS = \ - $O\InBuffer.obj \ - $O\OutBuffer.obj \ - $O\LSBFDecoder.obj \ - $O\LSBFEncoder.obj \ - -LZ_OBJS = \ - $O\LZOutWindow.obj \ - -C_OBJS = \ - $O\Alloc.obj \ - $O\7zCrc.obj \ - $O\Sort.obj \ - -C_LZ_OBJS = \ - $O\MatchFinder.obj \ - -!include "../../Crc2.mak" - -OBJS = \ - $O\StdAfx.obj \ - $(COMPRESS_OBJS) \ - $(DEFLATE_OPT_OBJS) \ - $(7ZIP_COMMON_OBJS) \ - $(LZ_OBJS) \ - $(C_OBJS) \ - $(C_LZ_OBJS) \ - $O\HuffmanEncode.obj \ - $O\resource.res - -!include "../../../Build.mak" - -$(COMPRESS_OBJS): ../$(*B).cpp - $(COMPL) -$(DEFLATE_OPT_OBJS): $(*B).cpp - $(COMPL_O2) -$(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) -!include "../../Crc.mak" diff --git a/CPP/7zip/Compress/Deflate/resource.rc b/CPP/7zip/Compress/Deflate/resource.rc deleted file mode 100755 index 910bc281..00000000 --- a/CPP/7zip/Compress/Deflate/resource.rc +++ /dev/null @@ -1,3 +0,0 @@ -#include "../../MyVersionInfo.rc" - -MY_VERSION_INFO_DLL("Deflate Codec", "Deflate") diff --git a/CPP/7zip/Compress/Huffman/HuffmanDecoder.h b/CPP/7zip/Compress/Huffman/HuffmanDecoder.h index 57115197..df67e8c9 100755 --- a/CPP/7zip/Compress/Huffman/HuffmanDecoder.h +++ b/CPP/7zip/Compress/Huffman/HuffmanDecoder.h @@ -22,7 +22,8 @@ public: bool SetCodeLengths(const Byte *codeLengths) { - int lenCounts[kNumBitsMax + 1], tmpPositions[kNumBitsMax + 1]; + int lenCounts[kNumBitsMax + 1]; + UInt32 tmpPositions[kNumBitsMax + 1]; int i; for(i = 1; i <= kNumBitsMax; i++) lenCounts[i] = 0; diff --git a/CPP/7zip/Compress/LZMA/LZMA.dsp b/CPP/7zip/Compress/LZMA/LZMA.dsp deleted file mode 100755 index 2e699d43..00000000 --- a/CPP/7zip/Compress/LZMA/LZMA.dsp +++ /dev/null @@ -1,367 +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 "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "NDEBUG" -# ADD RSC /l 0x419 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-zip\Codecs\LZMA.dll" /opt:NOWIN98 -# SUBTRACT LINK32 /pdb:none /debug - -!ELSEIF "$(CFG)" == "LZMA - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "_DEBUG" -# ADD RSC /l 0x419 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-zip\Codecs\LZMA.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "LZMA - Win32 Release" -# Name "LZMA - Win32 Debug" -# Begin Group "Spec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\Codec.def -# End Source File -# Begin Source File - -SOURCE=..\CodecExports.cpp -# End Source File -# Begin Source File - -SOURCE=..\DllExports.cpp -# End Source File -# Begin Source File - -SOURCE=.\resource.rc -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"StdAfx.h" -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Group "7-zip Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Common\InBuffer.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\InBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\OutBuffer.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\OutBuffer.h -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamUtils.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Common\StreamUtils.h -# End Source File -# End Group -# Begin Group "RangeCoder" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\RangeCoder\RangeCoder.h -# End Source File -# Begin Source File - -SOURCE=..\RangeCoder\RangeCoderBit.cpp -# End Source File -# Begin Source File - -SOURCE=..\RangeCoder\RangeCoderBit.h -# End Source File -# Begin Source File - -SOURCE=..\RangeCoder\RangeCoderBitTree.h -# End Source File -# Begin Source File - -SOURCE=..\RangeCoder\RangeCoderOpt.h -# End Source File -# End Group -# Begin Group "Interface" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\ICoder.h -# End Source File -# Begin Source File - -SOURCE=..\..\IStream.h -# End Source File -# End Group -# Begin Group "LZ" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\LZ\LZOutWindow.cpp -# End Source File -# Begin Source File - -SOURCE=..\LZ\LZOutWindow.h -# End Source File -# End Group -# Begin Group "Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\Common\ComTry.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\Defs.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\Exception.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyCom.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyUnknown.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\MyWindows.h -# End Source File -# End Group -# Begin Group "C" - -# PROP Default_Filter "" -# Begin 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\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\IStream.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Threads.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Threads.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Types.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\LZMA.h -# End Source File -# Begin Source File - -SOURCE=.\LZMADecoder.cpp - -!IF "$(CFG)" == "LZMA - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "LZMA - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\LZMADecoder.h -# End Source File -# Begin Source File - -SOURCE=.\LZMAEncoder.cpp - -!IF "$(CFG)" == "LZMA - Win32 Release" - -# ADD CPP /O2 /FAs -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "LZMA - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\LZMAEncoder.h -# End Source File -# Begin Source File - -SOURCE=.\LZMARegister.cpp -# End Source File -# End Target -# End Project diff --git a/CPP/7zip/Compress/LZMA/LZMA.dsw b/CPP/7zip/Compress/LZMA/LZMA.dsw deleted file mode 100755 index f750e453..00000000 --- a/CPP/7zip/Compress/LZMA/LZMA.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: "LZMA"=".\LZMA.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Compress/LZMA/LZMA.h b/CPP/7zip/Compress/LZMA/LZMA.h deleted file mode 100755 index 7bc4c438..00000000 --- a/CPP/7zip/Compress/LZMA/LZMA.h +++ /dev/null @@ -1,82 +0,0 @@ -// LZMA.h - -#ifndef __LZMA_H -#define __LZMA_H - -namespace NCompress { -namespace NLZMA { - -const UInt32 kNumRepDistances = 4; - -const int kNumStates = 12; - -const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; -const Byte kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; -const Byte kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; -const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; - -class CState -{ -public: - Byte Index; - void Init() { Index = 0; } - void UpdateChar() { Index = kLiteralNextStates[Index]; } - void UpdateMatch() { Index = kMatchNextStates[Index]; } - void UpdateRep() { Index = kRepNextStates[Index]; } - void UpdateShortRep() { Index = kShortRepNextStates[Index]; } - bool IsCharState() const { return Index < 7; } -}; - -const int kNumPosSlotBits = 6; -const int kDicLogSizeMin = 0; -const int kDicLogSizeMax = 32; -const int kDistTableSizeMax = kDicLogSizeMax * 2; - -const UInt32 kNumLenToPosStates = 4; - -inline UInt32 GetLenToPosState(UInt32 len) -{ - len -= 2; - if (len < kNumLenToPosStates) - return len; - return kNumLenToPosStates - 1; -} - -namespace NLength { - -const int kNumPosStatesBitsMax = 4; -const UInt32 kNumPosStatesMax = (1 << kNumPosStatesBitsMax); - -const int kNumPosStatesBitsEncodingMax = 4; -const UInt32 kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax); - -const int kNumLowBits = 3; -const int kNumMidBits = 3; -const int kNumHighBits = 8; -const UInt32 kNumLowSymbols = 1 << kNumLowBits; -const UInt32 kNumMidSymbols = 1 << kNumMidBits; -const UInt32 kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits); - -} - -const UInt32 kMatchMinLen = 2; -const UInt32 kMatchMaxLen = kMatchMinLen + NLength::kNumSymbolsTotal - 1; - -const int kNumAlignBits = 4; -const UInt32 kAlignTableSize = 1 << kNumAlignBits; -const UInt32 kAlignMask = (kAlignTableSize - 1); - -const UInt32 kStartPosModelIndex = 4; -const UInt32 kEndPosModelIndex = 14; -const UInt32 kNumPosModels = kEndPosModelIndex - kStartPosModelIndex; - -const UInt32 kNumFullDistances = 1 << (kEndPosModelIndex / 2); - -const int kNumLitPosStatesBitsEncodingMax = 4; -const int kNumLitContextBitsMax = 8; - -const int kNumMoveBits = 5; - -}} - -#endif diff --git a/CPP/7zip/Compress/LZMA/LZMADecoder.cpp b/CPP/7zip/Compress/LZMA/LZMADecoder.cpp index 1b73855c..1df7fe6c 100755 --- a/CPP/7zip/Compress/LZMA/LZMADecoder.cpp +++ b/CPP/7zip/Compress/LZMA/LZMADecoder.cpp @@ -4,333 +4,187 @@ #include "LZMADecoder.h" #include "../../../Common/Defs.h" +#include "../../Common/StreamUtils.h" + +extern "C" +{ + #include "../../../../C/Alloc.h" +} + +static HRESULT SResToHRESULT(SRes res) +{ + switch(res) + { + case SZ_OK: return S_OK; + case SZ_ERROR_MEM: return E_OUTOFMEMORY; + case SZ_ERROR_PARAM: return E_INVALIDARG; + // case SZ_ERROR_PROGRESS: return E_ABORT; + case SZ_ERROR_DATA: return S_FALSE; + } + return E_FAIL; +} namespace NCompress { namespace NLZMA { -const int kLenIdFinished = -1; -const int kLenIdNeedInit = -2; +static const UInt32 kInBufSize = 1 << 20; -void CDecoder::Init() +CDecoder::CDecoder(): _inBuf(0), _outSizeDefined(false) { - { - 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(); - } - } - { - for (UInt32 i = 0; i < kNumLenToPosStates; i++) - _posSlotDecoder[i].Init(); - } - { - for(UInt32 i = 0; i < kNumFullDistances - kEndPosModelIndex; i++) - _posDecoders[i].Init(); - } - _posAlignDecoder.Init(); - _lenDecoder.Init(_posStateMask + 1); - _repMatchLenDecoder.Init(_posStateMask + 1); - _literalDecoder.Init(); - - _state.Init(); - _reps[0] = _reps[1] = _reps[2] = _reps[3] = 0; + LzmaDec_Construct(&_state); } -HRESULT CDecoder::CodeSpec(UInt32 curSize) -{ - if (_outSizeDefined) - { - const UInt64 rem = _outSize - _outWindowStream.GetProcessedSize(); - if (curSize > rem) - curSize = (UInt32)rem; - } +static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } +static void SzFree(void *p, void *address) { p = p; MyFree(address); } +static ISzAlloc g_Alloc = { SzAlloc, SzFree }; - if (_remainLen == kLenIdFinished) - return S_OK; - if (_remainLen == kLenIdNeedInit) - { - _rangeDecoder.Init(); - Init(); - _remainLen = 0; - } - if (curSize == 0) - return S_OK; +CDecoder::~CDecoder() +{ + LzmaDec_Free(&_state, &g_Alloc); + MyFree(_inBuf); +} - UInt32 rep0 = _reps[0]; - UInt32 rep1 = _reps[1]; - UInt32 rep2 = _reps[2]; - UInt32 rep3 = _reps[3]; - CState state = _state; - Byte previousByte; +STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *prop, UInt32 size) +{ + RINOK(SResToHRESULT(LzmaDec_Allocate(&_state, prop, size, &g_Alloc))); - while(_remainLen > 0 && curSize > 0) + if (_inBuf == 0) { - previousByte = _outWindowStream.GetByte(rep0); - _outWindowStream.PutByte(previousByte); - _remainLen--; - curSize--; + _inBuf = (Byte *)MyAlloc(kInBufSize); + if (_inBuf == 0) + return E_OUTOFMEMORY; } - UInt64 nowPos64 = _outWindowStream.GetProcessedSize(); - if (nowPos64 == 0) - previousByte = 0; - else - previousByte = _outWindowStream.GetByte(0); - while(curSize > 0) - { - { - #ifdef _NO_EXCEPTIONS - if (_rangeDecoder.Stream.ErrorCode != S_OK) - return _rangeDecoder.Stream.ErrorCode; - #endif - if (_rangeDecoder.Stream.WasFinished()) - return S_FALSE; - UInt32 posState = UInt32(nowPos64) & _posStateMask; - if (_isMatch[state.Index][posState].Decode(&_rangeDecoder) == 0) - { - if(!state.IsCharState()) - previousByte = _literalDecoder.DecodeWithMatchByte(&_rangeDecoder, - (UInt32)nowPos64, previousByte, _outWindowStream.GetByte(rep0)); - else - previousByte = _literalDecoder.DecodeNormal(&_rangeDecoder, - (UInt32)nowPos64, previousByte); - _outWindowStream.PutByte(previousByte); - state.UpdateChar(); - curSize--; - nowPos64++; - } - else - { - UInt32 len; - if(_isRep[state.Index].Decode(&_rangeDecoder) == 1) - { - len = 0; - if(_isRepG0[state.Index].Decode(&_rangeDecoder) == 0) - { - if(_isRep0Long[state.Index][posState].Decode(&_rangeDecoder) == 0) - { - state.UpdateShortRep(); - len = 1; - } - } - else - { - UInt32 distance; - if(_isRepG1[state.Index].Decode(&_rangeDecoder) == 0) - distance = rep1; - else - { - if (_isRepG2[state.Index].Decode(&_rangeDecoder) == 0) - distance = rep2; - else - { - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - if (len == 0) - { - len = _repMatchLenDecoder.Decode(&_rangeDecoder, posState) + kMatchMinLen; - state.UpdateRep(); - } - } - else - { - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - len = kMatchMinLen + _lenDecoder.Decode(&_rangeDecoder, posState); - state.UpdateMatch(); - UInt32 posSlot = _posSlotDecoder[GetLenToPosState(len)].Decode(&_rangeDecoder); - if (posSlot >= kStartPosModelIndex) - { - UInt32 numDirectBits = (posSlot >> 1) - 1; - rep0 = ((2 | (posSlot & 1)) << numDirectBits); + return S_OK; +} - if (posSlot < kEndPosModelIndex) - rep0 += NRangeCoder::ReverseBitTreeDecode(_posDecoders + - rep0 - posSlot - 1, &_rangeDecoder, numDirectBits); - else - { - rep0 += (_rangeDecoder.DecodeDirectBits( - numDirectBits - kNumAlignBits) << kNumAlignBits); - rep0 += _posAlignDecoder.ReverseDecode(&_rangeDecoder); - if (rep0 == 0xFFFFFFFF) - { - _remainLen = kLenIdFinished; - return S_OK; - } - } - } - else - rep0 = posSlot; - } - UInt32 locLen = len; - if (len > curSize) - locLen = (UInt32)curSize; - if (!_outWindowStream.CopyBlock(rep0, locLen)) - return S_FALSE; - previousByte = _outWindowStream.GetByte(0); - curSize -= locLen; - nowPos64 += locLen; - len -= locLen; - if (len != 0) - { - _remainLen = (Int32)len; - break; - } +STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value) { *value = _inSizeProcessed; return S_OK; } +STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { _inStream = inStream; return S_OK; } +STDMETHODIMP CDecoder::ReleaseInStream() { _inStream.Release(); return S_OK; } - #ifdef _NO_EXCEPTIONS - if (_outWindowStream.ErrorCode != S_OK) - return _outWindowStream.ErrorCode; - #endif - } - } - } - if (_rangeDecoder.Stream.WasFinished()) - return S_FALSE; - _reps[0] = rep0; - _reps[1] = rep1; - _reps[2] = rep2; - _reps[3] = rep3; - _state = state; +STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize) +{ + _outSizeDefined = (outSize != NULL); + if (_outSizeDefined) + _outSize = *outSize; + LzmaDec_Init(&_state); + + _inPos = _inSize = 0; + _inSizeProcessed = _outSizeProcessed = 0; return S_OK; } -STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream, - ISequentialOutStream *outStream, - const UInt64 *, const UInt64 *outSize, - ICompressProgressInfo *progress) +STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, + ISequentialOutStream *outStream, const UInt64 * /* inSize */, + const UInt64 *outSize, ICompressProgressInfo *progress) { - SetInStream(inStream); - _outWindowStream.SetStream(outStream); + if (_inBuf == 0) + return S_FALSE; SetOutStreamSize(outSize); - CDecoderFlusher flusher(this); for (;;) { - UInt32 curSize = 1 << 18; - RINOK(CodeSpec(curSize)); - if (_remainLen == kLenIdFinished) - break; - if (progress != NULL) + if (_inPos == _inSize) { - UInt64 inSize = _rangeDecoder.GetProcessedSize(); - UInt64 nowPos64 = _outWindowStream.GetProcessedSize(); - RINOK(progress->SetRatioInfo(&inSize, &nowPos64)); + _inPos = _inSize = 0; + RINOK(inStream->Read(_inBuf, kInBufSize, &_inSize)); } - if (_outSizeDefined) - if (_outWindowStream.GetProcessedSize() >= _outSize) - break; - } - flusher.NeedFlush = false; - return Flush(); -} - - -#ifdef _NO_EXCEPTIONS - -#define LZMA_TRY_BEGIN -#define LZMA_TRY_END - -#else -#define LZMA_TRY_BEGIN try { -#define LZMA_TRY_END } \ - catch(const CInBufferException &e) { return e.ErrorCode; } \ - catch(const CLZOutWindowException &e) { return e.ErrorCode; } \ - catch(...) { return S_FALSE; } + SizeT dicPos = _state.dicPos; + SizeT curSize = _state.dicBufSize - dicPos; + const UInt32 kStepSize = ((UInt32)1 << 22); + if (curSize > kStepSize) + curSize = (SizeT)kStepSize; + + ELzmaFinishMode finishMode = LZMA_FINISH_ANY; + if (_outSizeDefined) + { + const UInt64 rem = _outSize - _outSizeProcessed; + if (rem < curSize) + { + curSize = (SizeT)rem; + /* + // finishMode = LZMA_FINISH_END; + we can't use LZMA_FINISH_END here to allow partial decoding + */ + } + } -#endif + SizeT inSizeProcessed = _inSize - _inPos; + ELzmaStatus status; + SRes res = LzmaDec_DecodeToDic(&_state, dicPos + curSize, _inBuf + _inPos, &inSizeProcessed, finishMode, &status); + _inPos += (UInt32)inSizeProcessed; + _inSizeProcessed += inSizeProcessed; + SizeT outSizeProcessed = _state.dicPos - dicPos; + _outSizeProcessed += outSizeProcessed; -STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, - ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, - ICompressProgressInfo *progress) -{ - LZMA_TRY_BEGIN - return CodeReal(inStream, outStream, inSize, outSize, progress); - LZMA_TRY_END -} - -STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *properties, UInt32 size) -{ - if (size < 5) - return E_INVALIDARG; - int lc = properties[0] % 9; - Byte remainder = (Byte)(properties[0] / 9); - int lp = remainder % 5; - int pb = remainder / 5; - if (pb > NLength::kNumPosStatesBitsMax) - return E_INVALIDARG; - _posStateMask = (1 << pb) - 1; - UInt32 dictionarySize = 0; - for (int i = 0; i < 4; i++) - dictionarySize += ((UInt32)(properties[1 + i])) << (i * 8); - if (!_outWindowStream.Create(dictionarySize)) - return E_OUTOFMEMORY; - if (!_literalDecoder.Create(lp, lc)) - return E_OUTOFMEMORY; - if (!_rangeDecoder.Create(1 << 20)) - return E_OUTOFMEMORY; - return S_OK; -} + bool finished = (inSizeProcessed == 0 && outSizeProcessed == 0); + bool stopDecoding = (_outSizeDefined && _outSizeProcessed >= _outSize); -STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value) -{ - *value = _rangeDecoder.GetProcessedSize(); - return S_OK; -} - -STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) -{ - _rangeDecoder.SetStream(inStream); - return S_OK; -} - -STDMETHODIMP CDecoder::ReleaseInStream() -{ - _rangeDecoder.ReleaseStream(); - return S_OK; -} + if (res != 0 || _state.dicPos == _state.dicBufSize || finished || stopDecoding) + { + HRESULT res2 = WriteStream(outStream, _state.dic, _state.dicPos); + if (res != 0) + return S_FALSE; + RINOK(res2); + if (stopDecoding) + return S_OK; + if (finished) + return (status == LZMA_STATUS_FINISHED_WITH_MARK ? S_OK : S_FALSE); + } + if (_state.dicPos == _state.dicBufSize) + _state.dicPos = 0; -STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize) -{ - _outSizeDefined = (outSize != NULL); - if (_outSizeDefined) - _outSize = *outSize; - _remainLen = kLenIdNeedInit; - _outWindowStream.Init(); - return S_OK; + if (progress != NULL) + { + RINOK(progress->SetRatioInfo(&_inSizeProcessed, &_outSizeProcessed)); + } + } } #ifndef NO_READ_FROM_CODER STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize) { - LZMA_TRY_BEGIN if (processedSize) *processedSize = 0; - const UInt64 startPos = _outWindowStream.GetProcessedSize(); - _outWindowStream.SetMemStream((Byte *)data); - RINOK(CodeSpec(size)); - if (processedSize) - *processedSize = (UInt32)(_outWindowStream.GetProcessedSize() - startPos); - return Flush(); - LZMA_TRY_END + do + { + if (_inPos == _inSize) + { + _inPos = _inSize = 0; + RINOK(_inStream->Read(_inBuf, kInBufSize, &_inSize)); + } + { + SizeT inProcessed = _inSize - _inPos; + + if (_outSizeDefined) + { + const UInt64 rem = _outSize - _outSizeProcessed; + if (rem < size) + size = (UInt32)rem; + } + + SizeT outProcessed = size; + ELzmaStatus status; + SRes res = LzmaDec_DecodeToBuf(&_state, (Byte *)data, &outProcessed, + _inBuf + _inPos, &inProcessed, LZMA_FINISH_ANY, &status); + _inPos += (UInt32)inProcessed; + _inSizeProcessed += inProcessed; + _outSizeProcessed += outProcessed; + size -= (UInt32)outProcessed; + data = (Byte *)data + outProcessed; + if (processedSize) + *processedSize += (UInt32)outProcessed; + RINOK(SResToHRESULT(res)); + if (inProcessed == 0 && outProcessed == 0) + return S_OK; + } + } + while (size != 0); + return S_OK; } #endif diff --git a/CPP/7zip/Compress/LZMA/LZMADecoder.h b/CPP/7zip/Compress/LZMA/LZMADecoder.h index bc44a5a9..be5df30d 100755 --- a/CPP/7zip/Compress/LZMA/LZMADecoder.h +++ b/CPP/7zip/Compress/LZMA/LZMADecoder.h @@ -1,151 +1,19 @@ -// LZMA/Decoder.h +// LZMADecoder.h #ifndef __LZMA_DECODER_H #define __LZMA_DECODER_H #include "../../../Common/MyCom.h" #include "../../ICoder.h" -#include "../LZ/LZOutWindow.h" -#include "../RangeCoder/RangeCoderBitTree.h" extern "C" { - #include "../../../../C/Alloc.h" + #include "../../../../C/LzmaDec.h" } -#include "LZMA.h" - namespace NCompress { namespace NLZMA { -typedef NRangeCoder::CBitDecoder CMyBitDecoder; - -class CLiteralDecoder2 -{ - CMyBitDecoder _decoders[0x300]; -public: - void Init() - { - for (int i = 0; i < 0x300; i++) - _decoders[i].Init(); - } - Byte DecodeNormal(NRangeCoder::CDecoder *rangeDecoder) - { - UInt32 symbol = 1; - RC_INIT_VAR - do - { - // symbol = (symbol << 1) | _decoders[0][symbol].Decode(rangeDecoder); - RC_GETBIT(kNumMoveBits, _decoders[symbol].Prob, symbol) - } - while (symbol < 0x100); - RC_FLUSH_VAR - return (Byte)symbol; - } - Byte DecodeWithMatchByte(NRangeCoder::CDecoder *rangeDecoder, Byte matchByte) - { - UInt32 symbol = 1; - RC_INIT_VAR - do - { - UInt32 matchBit = (matchByte >> 7) & 1; - matchByte <<= 1; - // UInt32 bit = _decoders[1 + matchBit][symbol].Decode(rangeDecoder); - // symbol = (symbol << 1) | bit; - UInt32 bit; - RC_GETBIT2(kNumMoveBits, _decoders[0x100 + (matchBit << 8) + symbol].Prob, symbol, - bit = 0, bit = 1) - if (matchBit != bit) - { - while (symbol < 0x100) - { - // symbol = (symbol << 1) | _decoders[0][symbol].Decode(rangeDecoder); - RC_GETBIT(kNumMoveBits, _decoders[symbol].Prob, symbol) - } - break; - } - } - while (symbol < 0x100); - RC_FLUSH_VAR - return (Byte)symbol; - } -}; - -class CLiteralDecoder -{ - CLiteralDecoder2 *_coders; - int _numPrevBits; - int _numPosBits; - UInt32 _posMask; -public: - CLiteralDecoder(): _coders(0) {} - ~CLiteralDecoder() { 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 = (CLiteralDecoder2 *)MyAlloc(numStates * sizeof(CLiteralDecoder2)); - } - _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(); - } - UInt32 GetState(UInt32 pos, Byte prevByte) const - { return ((pos & _posMask) << _numPrevBits) + (prevByte >> (8 - _numPrevBits)); } - Byte DecodeNormal(NRangeCoder::CDecoder *rangeDecoder, UInt32 pos, Byte prevByte) - { return _coders[GetState(pos, prevByte)].DecodeNormal(rangeDecoder); } - Byte DecodeWithMatchByte(NRangeCoder::CDecoder *rangeDecoder, UInt32 pos, Byte prevByte, Byte matchByte) - { return _coders[GetState(pos, prevByte)].DecodeWithMatchByte(rangeDecoder, matchByte); } -}; - -namespace NLength { - -class CDecoder -{ - CMyBitDecoder _choice; - CMyBitDecoder _choice2; - NRangeCoder::CBitTreeDecoder _lowCoder[kNumPosStatesMax]; - NRangeCoder::CBitTreeDecoder _midCoder[kNumPosStatesMax]; - NRangeCoder::CBitTreeDecoder _highCoder; -public: - void Init(UInt32 numPosStates) - { - _choice.Init(); - _choice2.Init(); - for (UInt32 posState = 0; posState < numPosStates; posState++) - { - _lowCoder[posState].Init(); - _midCoder[posState].Init(); - } - _highCoder.Init(); - } - UInt32 Decode(NRangeCoder::CDecoder *rangeDecoder, UInt32 posState) - { - if(_choice.Decode(rangeDecoder) == 0) - return _lowCoder[posState].Decode(rangeDecoder); - if(_choice2.Decode(rangeDecoder) == 0) - return kNumLowSymbols + _midCoder[posState].Decode(rangeDecoder); - return kNumLowSymbols + kNumMidSymbols + _highCoder.Decode(rangeDecoder); - } -}; - -} - class CDecoder: public ICompressCoder, public ICompressSetDecoderProperties2, @@ -157,38 +25,15 @@ class CDecoder: #endif public CMyUnknownImp { - CLZOutWindow _outWindowStream; - NRangeCoder::CDecoder _rangeDecoder; - - CMyBitDecoder _isMatch[kNumStates][NLength::kNumPosStatesMax]; - CMyBitDecoder _isRep[kNumStates]; - CMyBitDecoder _isRepG0[kNumStates]; - CMyBitDecoder _isRepG1[kNumStates]; - CMyBitDecoder _isRepG2[kNumStates]; - CMyBitDecoder _isRep0Long[kNumStates][NLength::kNumPosStatesMax]; - - NRangeCoder::CBitTreeDecoder _posSlotDecoder[kNumLenToPosStates]; - - CMyBitDecoder _posDecoders[kNumFullDistances - kEndPosModelIndex]; - NRangeCoder::CBitTreeDecoder _posAlignDecoder; - - NLength::CDecoder _lenDecoder; - NLength::CDecoder _repMatchLenDecoder; - - CLiteralDecoder _literalDecoder; - - UInt32 _posStateMask; - - /////////////////// - // State - UInt32 _reps[4]; - CState _state; - Int32 _remainLen; // -1 means end of stream. // -2 means need Init - UInt64 _outSize; + CMyComPtr _inStream; + Byte *_inBuf; + UInt32 _inPos; + UInt32 _inSize; + CLzmaDec _state; bool _outSizeDefined; - - void Init(); - HRESULT CodeSpec(UInt32 size); + UInt64 _outSize; + UInt64 _inSizeProcessed; + UInt64 _outSizeProcessed; public: #ifndef NO_READ_FROM_CODER @@ -204,34 +49,8 @@ public: ICompressGetInStreamProcessedSize) #endif - void ReleaseStreams() - { - _outWindowStream.ReleaseStream(); - ReleaseInStream(); - } - - class CDecoderFlusher - { - CDecoder *_decoder; - public: - bool NeedFlush; - CDecoderFlusher(CDecoder *decoder): _decoder(decoder), NeedFlush(true) {} - ~CDecoderFlusher() - { - if (NeedFlush) - _decoder->Flush(); - _decoder->ReleaseStreams(); - } - }; - - HRESULT Flush() { return _outWindowStream.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, + ISequentialOutStream *outStream, const UInt64 *_inSize, const UInt64 *outSize, ICompressProgressInfo *progress); STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); @@ -246,8 +65,9 @@ public: STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); #endif - CDecoder(): _outSizeDefined(false) {} - virtual ~CDecoder() {} + CDecoder(); + virtual ~CDecoder(); + }; }} diff --git a/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp index 021099d8..25faa730 100755 --- a/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp +++ b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp @@ -16,255 +16,71 @@ #endif #endif -#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; - -#ifndef LZMA_LOG_BSR -Byte g_FastPos[1 << kNumLogBits]; - -class CFastPosInit -{ -public: - CFastPosInit() { Init(); } - void Init() - { - const Byte kFastSlots = kNumLogBits * 2; - 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; -#endif +#include "../../Common/StreamUtils.h" -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); +extern "C" +{ +#include "../../../../C/Alloc.h" } -void CLiteralEncoder2::EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, - Byte matchByte, Byte symbol) +static HRESULT SResToHRESULT(SRes res) { - UInt32 context = 1; - int i = 8; - do + switch(res) { - 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; - } + case SZ_OK: return S_OK; + case SZ_ERROR_MEM: return E_OUTOFMEMORY; + case SZ_ERROR_PARAM: return E_INVALIDARG; + // case SZ_ERROR_THREAD: return E_FAIL; } - while(i != 0); + return E_FAIL; } -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 NCompress { +namespace NLZMA { -namespace NLength { +static const UInt32 kStreamStepSize = (UInt32)1 << 31; -void CEncoder::Init(UInt32 numPosStates) +static SRes MyRead(void *object, void *data, size_t *size) { - _choice.Init(); - _choice2.Init(); - for (UInt32 posState = 0; posState < numPosStates; posState++) - { - _lowCoder[posState].Init(); - _midCoder[posState].Init(); - } - _highCoder.Init(); + UInt32 curSize = ((*size < kStreamStepSize) ? (UInt32)*size : kStreamStepSize); + HRESULT res = ((CSeqInStream *)object)->RealStream->Read(data, curSize, &curSize); + *size = curSize; + return (SRes)res; } -void CEncoder::Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState) +static size_t MyWrite(void *object, const void *data, size_t size) { - 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); - } - } + CSeqOutStream *p = (CSeqOutStream *)object; + p->Res = WriteStream(p->RealStream, data, size); + if (p->Res != 0) + return 0; + return size; } -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); -} +static void *SzBigAlloc(void *, size_t size) { return BigAlloc(size); } +static void SzBigFree(void *, void *address) { BigFree(address); } +static ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree }; -} +static void *SzAlloc(void *, size_t size) { return MyAlloc(size); } +static void SzFree(void *, void *address) { MyFree(address); } +static ISzAlloc g_Alloc = { SzAlloc, SzFree }; -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) +CEncoder::CEncoder() { - MatchFinder_Construct(&_matchFinderBase); - // _maxMode = false; - _fastMode = false; - #ifdef COMPRESS_MF_MT - MatchFinderMt_Construct(&_matchFinderMt); - _matchFinderMt.MatchFinder = &_matchFinderBase; - #endif + _seqInStream.SeqInStream.Read = MyRead; + _seqOutStream.SeqOutStream.Write = MyWrite; + _encoder = 0; + _encoder = LzmaEnc_Create(&g_Alloc); + if (_encoder == 0) + throw 1; } - -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; + if (_encoder != 0) + LzmaEnc_Destroy(_encoder, &g_Alloc, &g_BigAlloc); } inline wchar_t GetUpperChar(wchar_t c) @@ -274,7 +90,7 @@ inline wchar_t GetUpperChar(wchar_t c) return c; } -static int ParseMatchFinder(const wchar_t *s, int *btMode, UInt32 *numHashBytes /* , int *skipModeBits */) +static int ParseMatchFinder(const wchar_t *s, int *btMode, int *numHashBytes) { wchar_t c = GetUpperChar(*s++); if (c == L'H') @@ -299,1249 +115,113 @@ static int ParseMatchFinder(const wchar_t *s, int *btMode, UInt32 *numHashBytes 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) { + CLzmaEncProps props; + LzmaEncProps_Init(&props); + for (UInt32 i = 0; i < numProperties; i++) { const PROPVARIANT &prop = properties[i]; - switch(propIDs[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; - } + if (prop.vt != VT_UI4) return E_INVALIDARG; props.fb = prop.ulVal; break; case NCoderPropID::kMatchFinderCycles: - { - if (prop.vt != VT_UI4) - return E_INVALIDARG; - _matchFinderCycles = prop.ulVal; - break; - } + if (prop.vt != VT_UI4) return E_INVALIDARG; props.mc = 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; - } - case NCoderPropID::kMultiThread: - { - if (prop.vt != VT_BOOL) - return E_INVALIDARG; - #ifdef COMPRESS_MF_MT - Bool newMultiThread = (prop.boolVal == VARIANT_TRUE); - if (newMultiThread != _multiThread) - { - ReleaseMatchFinder(); - _multiThread = newMultiThread; - } - #endif - break; - } - case NCoderPropID::kNumThreads: - { - if (prop.vt != VT_UI4) - return E_INVALIDARG; - #ifdef COMPRESS_MF_MT - Bool newMultiThread = (prop.ulVal > 1) ? True : False; - if (newMultiThread != _multiThread) - { - ReleaseMatchFinder(); - _multiThread = newMultiThread; - } - #endif - break; - } + if (prop.vt != VT_UI4) return E_INVALIDARG; props.algo = prop.ulVal; break; case NCoderPropID::kDictionarySize: - { - const int kDicLogSizeMaxCompress = 30; // must be <= ((kNumLogBits - 1) * 2) + 7 = 31; - 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; - } + if (prop.vt != VT_UI4) return E_INVALIDARG; props.dictSize = prop.ulVal; 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; - } + if (prop.vt != VT_UI4) return E_INVALIDARG; props.pb = prop.ulVal; 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; - } + if (prop.vt != VT_UI4) return E_INVALIDARG; props.lp = prop.ulVal; 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; - } + if (prop.vt != VT_UI4) return E_INVALIDARG; props.lc = prop.ulVal; break; + case NCoderPropID::kNumThreads: + if (prop.vt != VT_UI4) return E_INVALIDARG; props.numThreads = prop.ulVal; break; + case NCoderPropID::kMultiThread: + if (prop.vt != VT_BOOL) return E_INVALIDARG; props.numThreads = ((prop.boolVal == VARIANT_TRUE) ? 2 : 1); break; case NCoderPropID::kEndMarker: - { - if (prop.vt != VT_BOOL) - return E_INVALIDARG; - SetWriteEndMarkerMode(prop.boolVal == VARIANT_TRUE); - break; - } + if (prop.vt != VT_BOOL) return E_INVALIDARG; props.writeEndMark = (prop.boolVal == VARIANT_TRUE); break; + case NCoderPropID::kMatchFinder: + if (prop.vt != VT_BSTR) return E_INVALIDARG; + if (!ParseMatchFinder(prop.bstrVal, &props.btMode, &props.numHashBytes /* , &_matchFinderBase.skipModeBits */)) + return E_INVALIDARG; break; default: return E_INVALIDARG; } } - return S_OK; + return SResToHRESULT(LzmaEnc_SetProps(_encoder, &props)); } 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); + Byte props[LZMA_PROPS_SIZE]; + size_t size = LZMA_PROPS_SIZE; + RINOK(LzmaEnc_WriteProperties(_encoder, props, &size)); + return WriteStream(outStream, props, size); } STDMETHODIMP CEncoder::SetOutStream(ISequentialOutStream *outStream) { - _rangeEncoder.SetStream(outStream); + _seqOutStream.RealStream = outStream; + _seqOutStream.Res = S_OK; return S_OK; } STDMETHODIMP CEncoder::ReleaseOutStream() { - _rangeEncoder.ReleaseStream(); + _seqOutStream.RealStream.Release(); return S_OK; } -HRESULT CEncoder::Init() +typedef struct _CCompressProgressImp { - CBaseState::Init(); - - _rangeEncoder.Init(); + ICompressProgress p; + ICompressProgressInfo *Progress; + HRESULT Res; +} CCompressProgressImp; - 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(); - } +#define PROGRESS_UNKNOWN_VALUE ((UInt64)(Int64)-1) - _lenEncoder.Init(1 << _posStateBits); - _repMatchLenEncoder.Init(1 << _posStateBits); +#define CONVERT_PR_VAL(x) (x == PROGRESS_UNKNOWN_VALUE ? NULL : &x) - _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) +SRes CompressProgress(void *pp, UInt64 inSize, UInt64 outSize) { - #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]; - const Byte *data2 = data - (reps[i] + 1); - if (data[0] != data2[0] || data[1] != data2[1]) - { - repLens[i] = 0; - continue; - } - UInt32 lenTest; - for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; 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 - (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 - (reps[0] + 1)); - - UInt32 posState = (position & _posStateMask); - - UInt32 curAnd1Price = curPrice + - _isMatch[state.Index][posState].GetPrice0() + - _literalEncoder.GetSubCoder(position, *(data - 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 - const Byte *data2 = data - (reps[0] + 1); - UInt32 limit = MyMin(numAvailableBytesFull, _numFastBytes + 1); - UInt32 temp; - for (temp = 1; temp < limit && data[temp] == data2[temp]; 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; - const Byte *data2 = data - (reps[repIndex] + 1); - if (data[0] != data2[0] || data[1] != data2[1]) - continue; - UInt32 lenTest; - for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; 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] == data2[lenTest2]; 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[lenTest - 1])->GetPrice( - true, data2[lenTest], 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 - const Byte *data2 = data - (curBack + 1); - UInt32 lenTest2 = lenTest + 1; - UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes); - for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; 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[lenTest - 1])->GetPrice( - true, data2[lenTest], 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; - - const Byte *pby2 = pby - distance; - for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; 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++) - { - const Byte *data2 = data - (_repDistances[i] + 1); - if (data[0] != data2[0] || data[1] != data2[1]) - { - repLens[i] = 0; - continue; - } - UInt32 len; - for (len = 2; len < numAvailableBytes && data[len] == data2[len]; 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++) - { - const Byte *data2 = data - (_repDistances[i] + 1); - if (data[1] != data2[1] || data[2] != data2[2]) - { - repLens[i] = 0; - continue; - } - UInt32 len; - for (len = 2; len < numAvailableBytes && data[len] == data2[len]; 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; - #ifdef COMPRESS_MF_MT - #ifdef USE_ALLOCA - alloca(0x300); - #endif - #endif - 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; - } - } - } + CCompressProgressImp *p = (CCompressProgressImp *)pp; + p->Res = p->Progress->SetRatioInfo(CONVERT_PR_VAL(inSize), CONVERT_PR_VAL(outSize)); + return (SRes)p->Res; } STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, - ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, + 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 + CCompressProgressImp progressImp; + progressImp.p.Progress = CompressProgress; + progressImp.Progress = progress; + progressImp.Res = SZ_OK; + + _seqInStream.RealStream = inStream; + SetOutStream(outStream); + SRes res = LzmaEnc_Encode(_encoder, &_seqOutStream.SeqOutStream, &_seqInStream.SeqInStream, progress ? &progressImp.p : NULL, &g_Alloc, &g_BigAlloc); + ReleaseOutStream(); + if (res == SZ_ERROR_WRITE && _seqOutStream.Res != S_OK) + return _seqOutStream.Res; + if (res == SZ_ERROR_PROGRESS && progressImp.Res != S_OK) + return progressImp.Res; + return SResToHRESULT(res); } -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 &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 index da159795..711ac0b4 100755 --- a/CPP/7zip/Compress/LZMA/LZMAEncoder.h +++ b/CPP/7zip/Compress/LZMA/LZMAEncoder.h @@ -8,419 +8,39 @@ extern "C" { - #include "../../../../C/Alloc.h" - #include "../../../../C/Compress/Lz/MatchFinder.h" - #ifdef COMPRESS_MF_MT - #include "../../../../C/Compress/Lz/MatchFinderMt.h" - #endif + #include "../../../../C/LzmaEnc.h" } -#include "../RangeCoder/RangeCoderBitTree.h" - -#include "LZMA.h" - namespace NCompress { namespace NLZMA { -typedef NRangeCoder::CBitEncoder 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); } -}; - - -// #define LZMA_LOG_BRANCH - -#if _MSC_VER >= 1400 -// Must give gain in core 2. but slower ~2% on k8. -// #define LZMA_LOG_BSR -#endif - -#ifndef LZMA_LOG_BSR -static const int kNumLogBits = 13; // don't change it ! -extern Byte g_FastPos[]; -#endif -inline UInt32 GetPosSlot(UInt32 pos) +struct CSeqInStream { - #ifdef LZMA_LOG_BSR - if (pos < 2) - return pos; - unsigned long index; - _BitScanReverse(&index, pos); - return (index + index) + ((pos >> (index - 1)) & 1); - #else - if (pos < (1 << kNumLogBits)) - return g_FastPos[pos]; - if (pos < (1 << (kNumLogBits * 2 - 1))) - return g_FastPos[pos >> (kNumLogBits - 1)] + (kNumLogBits - 1) * 2; - return g_FastPos[pos >> (kNumLogBits - 1) * 2] + (kNumLogBits - 1) * 4; - #endif -} - -inline UInt32 GetPosSlot2(UInt32 pos) -{ - #ifdef LZMA_LOG_BSR - unsigned long index; - _BitScanReverse(&index, pos); - return (index + index) + ((pos >> (index - 1)) & 1); - #else - #ifdef LZMA_LOG_BRANCH - if (pos < (1 << (kNumLogBits + 6))) - return g_FastPos[pos >> 6] + 12; - if (pos < (1 << (kNumLogBits * 2 + 5))) - return g_FastPos[pos >> (kNumLogBits + 5)] + (kNumLogBits + 5) * 2; - return g_FastPos[pos >> (kNumLogBits * 2 + 4)] + (kNumLogBits * 2 + 4) * 2; - #else - // it's faster with VC6-32bit. - UInt32 s = 6 + ((kNumLogBits - 1) & (UInt32)((Int32)(((1 << (kNumLogBits + 6)) - 1) - pos) >> 31)); - return g_FastPos[pos >> s] + (s * 2); - #endif - #endif -} - -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 _lowCoder[kNumPosStatesEncodingMax]; - NRangeCoder::CBitTreeEncoder _midCoder[kNumPosStatesEncodingMax]; - NRangeCoder::CBitTreeEncoder _highCoder; -public: - void Init(UInt32 numPosStates); - void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState); - void SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const; + ISeqInStream SeqInStream; + ISequentialInStream *RealStream; }; -const UInt32 kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols; - -class CPriceTableEncoder: public CEncoder +struct CSeqOutStream { - 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); - } + ISeqOutStream SeqOutStream; + CMyComPtr RealStream; + HRESULT Res; }; -} - -typedef struct _CSeqInStream -{ - ISeqInStream SeqInStream; - CMyComPtr 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 _posSlotEncoder[kNumLenToPosStates]; - - CMyBitEncoder _posEncoders[kNumFullDistances - kEndPosModelIndex]; - NRangeCoder::CBitTreeEncoder _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]; + CLzmaEncHandle _encoder; - 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); + CSeqOutStream _seqOutStream; public: CEncoder(); - void SetWriteEndMarkerMode(bool writeEndMarker) - { _writeEndMark= writeEndMarker; } - - HRESULT Create(); MY_UNKNOWN_IMP3( ICompressSetOutStream, @@ -428,20 +48,7 @@ public: 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, diff --git a/CPP/7zip/Compress/LZMA/makefile b/CPP/7zip/Compress/LZMA/makefile deleted file mode 100755 index 4a108b42..00000000 --- a/CPP/7zip/Compress/LZMA/makefile +++ /dev/null @@ -1,70 +0,0 @@ -PROG = LZMA.dll -DEF_FILE = ../Codec.def -CFLAGS = $(CFLAGS) -I ../../../ \ - -DCOMPRESS_MF_MT \ - -D_7ZIP_LARGE_PAGES \ - -LIBS = $(LIBS) oleaut32.lib - -COMPRESS_OBJS = \ - $O\CodecExports.obj \ - $O\DllExports.obj \ - -COMMON_OBJS = \ - $O\CRC.obj \ - -LZMA_OPT_OBJS = \ - $O\LZMADecoder.obj \ - $O\LZMAEncoder.obj \ - $O\LZMARegister.obj \ - -7ZIP_COMMON_OBJS = \ - $O\InBuffer.obj \ - $O\OutBuffer.obj \ - $O\StreamUtils.obj \ - -LZ_OBJS = \ - $O\LZOutWindow.obj \ - -C_OBJS = \ - $O\Threads.obj \ - $O\Alloc.obj \ - -C_LZ_OBJS = \ - $O\MatchFinder.obj \ - $O\MatchFinderMt.obj \ - -!include "../../Crc2.mak" - -OBJS = \ - $O\StdAfx.obj \ - $(COMPRESS_OBJS) \ - $(COMMON_OBJS) \ - $(LZMA_OPT_OBJS) \ - $(7ZIP_COMMON_OBJS) \ - $(LZ_OBJS) \ - $(C_OBJS) \ - $(C_LZ_OBJS) \ - $(CRC_OBJS) \ - $O\RangeCoderBit.obj \ - $O\resource.res - -!include "../../../Build.mak" - -$(COMPRESS_OBJS): ../$(*B).cpp - $(COMPL) -$(COMMON_OBJS): ../../../Common/$(*B).cpp - $(COMPL) -$(LZMA_OPT_OBJS): $(*B).cpp - $(COMPL_O2) -$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp - $(COMPL) -$(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) -!include "../../Crc.mak" diff --git a/CPP/7zip/Compress/LZMA/resource.rc b/CPP/7zip/Compress/LZMA/resource.rc deleted file mode 100755 index 1b2b6abb..00000000 --- a/CPP/7zip/Compress/LZMA/resource.rc +++ /dev/null @@ -1,3 +0,0 @@ -#include "../../MyVersionInfo.rc" - -MY_VERSION_INFO_DLL("LZMA Codec", "LZMA") diff --git a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp index 39fee934..a09c3069 100755 --- a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp +++ b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp @@ -371,134 +371,132 @@ SOURCE=..\..\Common\StreamUtils.h # Begin Group "C" # PROP Default_Filter "" -# Begin Group "C-Lz" +# Begin Group "LzmaUtil" # PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.c +SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Dec.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.h +SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Dec.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.c +SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Enc.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.h +SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Enc.h # End Source File +# End Group # Begin Source File -SOURCE=..\..\..\..\C\Threads.c +SOURCE=..\..\..\..\C\7zCrc.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Threads.h +SOURCE=..\..\..\..\C\7zCrc.h # End Source File -# End Group -# Begin Group "LZMA_C" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lzma\LzmaDecode.c +SOURCE=..\..\..\..\C\Alloc.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lzma\LzmaDecode.h +SOURCE=..\..\..\..\C\Alloc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Lzma\LzmaTypes.h +SOURCE=..\..\..\..\C\Bra.h # End Source File -# End Group -# Begin Group "Branch" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchTypes.h +SOURCE=..\..\..\..\C\Bra86.c +# SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c +SOURCE=..\..\..\..\C\LzFind.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.h +SOURCE=..\..\..\..\C\LzFind.h # End Source File -# End Group # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.c +SOURCE=..\..\..\..\C\LzFindMt.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.h +SOURCE=..\..\..\..\C\LzFindMt.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.c +SOURCE=..\..\..\..\C\LzHash.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\LzmaDec.c # SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.h +SOURCE=..\..\..\..\C\LzmaDec.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Types.h +SOURCE=..\..\..\..\C\LzmaEnc.c +# SUBTRACT CPP /YX /Yc /Yu # End Source File -# End Group # Begin Source File -SOURCE=..\..\ICoder.h +SOURCE=..\..\..\..\C\LzmaEnc.h # End Source File # Begin Source File -SOURCE=.\LzmaAlone.cpp +SOURCE=..\..\..\..\C\Threads.c +# SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=.\LzmaBench.cpp +SOURCE=..\..\..\..\C\Threads.h # End Source File # Begin Source File -SOURCE=.\LzmaBench.h +SOURCE=..\..\..\..\C\Types.h # End Source File +# End Group # Begin Source File -SOURCE=.\LzmaBenchCon.cpp +SOURCE=..\..\ICoder.h # End Source File # Begin Source File -SOURCE=.\LzmaBenchCon.h +SOURCE=.\LzmaAlone.cpp # End Source File # Begin Source File -SOURCE=.\LzmaRam.cpp +SOURCE=.\LzmaBench.cpp # End Source File # Begin Source File -SOURCE=.\LzmaRam.h +SOURCE=.\LzmaBench.h # End Source File # Begin Source File -SOURCE=.\LzmaRamDecode.c -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=.\LzmaBenchCon.cpp # End Source File # Begin Source File -SOURCE=.\LzmaRamDecode.h +SOURCE=.\LzmaBenchCon.h # End Source File # End Target # End Project diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp index 0e83f576..0d2800bd 100755 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp +++ b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp @@ -26,15 +26,19 @@ #include "../LZMA/LZMAEncoder.h" #include "LzmaBenchCon.h" -#include "LzmaRam.h" #ifdef COMPRESS_MF_MT #include "../../../Windows/System.h" #endif +#include "../../MyVersion.h" + + extern "C" { -#include "LzmaRamDecode.h" + #include "../../../../C/Alloc.h" + #include "../../../../C/LzmaUtil/Lzma86Dec.h" + #include "../../../../C/LzmaUtil/Lzma86Enc.h" } using namespace NCommandLineParser; @@ -105,7 +109,7 @@ static void PrintHelp() " b: Benchmark\n" "\n" " -a{N}: set compression mode - [0, 1], default: 1 (max)\n" - " -d{N}: set dictionary - [0,30], default: 23 (8MB)\n" + " -d{N}: set dictionary - [12, 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" @@ -159,7 +163,7 @@ int main2(int n, const char *args[]) g_IsNT = IsItWindowsNT(); #endif - fprintf(stderr, "\nLZMA 4.56 Copyright (c) 1999-2007 Igor Pavlov 2007-10-19\n"); + fprintf(stderr, "\nLZMA " MY_VERSION_COPYRIGHT_DATE "\n"); if (n == 1) { @@ -306,7 +310,7 @@ int main2(int n, const char *args[]) inStreamSpec->File.GetLength(fileSize); if (fileSize > 0xF0000000) throw "File is too big"; - UInt32 inSize = (UInt32)fileSize; + size_t inSize = (size_t)fileSize; Byte *inBuffer = 0; if (inSize != 0) { @@ -315,18 +319,15 @@ int main2(int n, const char *args[]) throw kCantAllocate; } - UInt32 processedSize; - if (ReadStream(inStream, inBuffer, (UInt32)inSize, &processedSize) != S_OK) + if (ReadStream_FAIL(inStream, inBuffer, inSize) != S_OK) throw "Can not read"; - if ((UInt32)inSize != processedSize) - throw "Read size error"; Byte *outBuffer = 0; - size_t outSizeProcessed; + size_t outSize; if (encodeMode) { // we allocate 105% of original size for output buffer - size_t outSize = (size_t)fileSize / 20 * 21 + (1 << 16); + outSize = (size_t)fileSize / 20 * 21 + (1 << 16); if (outSize != 0) { outBuffer = (Byte *)MyAlloc((size_t)outSize); @@ -335,8 +336,8 @@ int main2(int n, const char *args[]) } if (!dictionaryIsDefined) dictionary = 1 << 23; - int res = LzmaRamEncode(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed, - dictionary, parser[NKey::kFilter86].PostCharIndex == 0 ? SZ_FILTER_YES : SZ_FILTER_AUTO); + int res = Lzma86_Encode(outBuffer, &outSize, inBuffer, inSize, + 5, dictionary, parser[NKey::kFilter86].PostCharIndex == 0 ? SZ_FILTER_YES : SZ_FILTER_AUTO); if (res != 0) { fprintf(stderr, "\nEncoder error = %d\n", (int)res); @@ -345,20 +346,25 @@ int main2(int n, const char *args[]) } else { - size_t outSize; - if (LzmaRamGetUncompressedSize(inBuffer, inSize, &outSize) != 0) + UInt64 outSize64; + if (Lzma86_GetUnpackSize(inBuffer, inSize, &outSize64) != 0) throw "data error"; + outSize = (size_t)outSize64; + if (outSize != outSize64) + throw "too big"; if (outSize != 0) { outBuffer = (Byte *)MyAlloc(outSize); if (outBuffer == 0) throw kCantAllocate; } - int res = LzmaRamDecompress(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed, malloc, free); + int res = Lzma86_Decode(outBuffer, &outSize, inBuffer, &inSize); + if (inSize != (size_t)fileSize) + throw "incorrect processed size"; if (res != 0) throw "LzmaDecoder error"; } - if (WriteStream(outStream, outBuffer, (UInt32)outSizeProcessed, &processedSize) != S_OK) + if (WriteStream(outStream, outBuffer, outSize) != S_OK) throw kWriteError; MyFree(outBuffer); MyFree(inBuffer); @@ -486,40 +492,22 @@ int main2(int n, const char *args[]) NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder; CMyComPtr 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) + Byte header[kPropertiesSize + 8]; + if (ReadStream_FALSE(inStream, header, kPropertiesSize + 8) != S_OK) { fprintf(stderr, kReadError); return 1; } - if (decoderSpec->SetDecoderProperties2(properties, kPropertiesSize) != S_OK) + if (decoderSpec->SetDecoderProperties2(header, 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) + fileSize |= ((UInt64)header[kPropertiesSize + i]) << (8 * i); + + if (decoder->Code(inStream, outStream, 0, (fileSize == (UInt64)(Int64)-1) ? 0 : &fileSize, 0) != S_OK) { fprintf(stderr, "Decoder error"); return 1; @@ -536,7 +524,7 @@ int main2(int n, const char *args[]) return 0; } -int main(int n, const char *args[]) +int MY_CDECL main(int n, const char *args[]) { try { return main2(n, args); } catch(const char *s) diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp index 4cd2d63e..cbb0aa86 100755 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp +++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp @@ -438,17 +438,14 @@ static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq) UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 size) { UInt64 t = GetLogSize(dictionarySize) - (kBenchMinDicLogSize << kSubBits); - // UInt64 numCommandsForOne = 1000 + ((t * t * 7) >> (2 * kSubBits)); // AMD K8 - UInt64 numCommandsForOne = 870 + ((t * t * 5) >> (2 * kSubBits)); // Intel Core2 - + UInt64 numCommandsForOne = 870 + ((t * t * 5) >> (2 * kSubBits)); UInt64 numCommands = (UInt64)(size) * numCommandsForOne; return MyMultDiv64(numCommands, elapsedTime, freq); } UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations) { - // UInt64 numCommands = (inSize * 216 + outSize * 14) * numIterations; // AMD K8 - UInt64 numCommands = (inSize * 220 + outSize * 8) * numIterations; // Intel Core2 + UInt64 numCommands = (inSize * 200 + outSize * 4) * numIterations; return MyMultDiv64(numCommands, elapsedTime, freq); } @@ -796,10 +793,9 @@ HRESULT LzmaBench( { for (UInt32 j = 0; j < numSubDecoderThreads; j++) { - size_t allocaSize = ((i * numSubDecoderThreads + j) * 16 * 21) & 0x7FF; HRESULT res = encoder.CreateDecoderThread(j, (i == 0 && j == 0) #ifdef USE_ALLOCA - , allocaSize + , ((i * numSubDecoderThreads + j) * 16 * 21) & 0x7FF #endif ); RINOK(res); diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaRam.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaRam.cpp deleted file mode 100755 index b86d1ea9..00000000 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaRam.cpp +++ /dev/null @@ -1,226 +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 "../../../../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 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 outStream = outStreamSpec; - CInStreamRam *inStreamSpec = new CInStreamRam; - if (inStreamSpec == 0) - return SZ_RAM_E_OUTOFMEMORY; - CMyComPtr 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 x86State; - x86_Convert_Init(x86State); - x86_Convert(filteredStream, (SizeT)inSize, 0, &x86State, 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/CPP/7zip/Compress/LZMA_Alone/LzmaRam.h b/CPP/7zip/Compress/LZMA_Alone/LzmaRam.h deleted file mode 100755 index 1244dc86..00000000 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaRam.h +++ /dev/null @@ -1,46 +0,0 @@ -// LzmaRam.h - -#ifndef __LzmaRam_h -#define __LzmaRam_h - -#include -#include "../../../Common/Types.h" - -/* -LzmaRamEncode: BCJ + LZMA RAM->RAM compressing. -It uses .lzma format, but it writes one additional byte to .lzma file: - 0: - no filter - 1: - x86(BCJ) filter. - -To provide best compression ratio dictionarySize mustbe >= inSize - -LzmaRamEncode allocates Data with MyAlloc/BigAlloc functions. -RAM Requirements: - RamSize = dictionarySize * 9.5 + 6MB + FilterBlockSize - FilterBlockSize = 0, if useFilter == false - FilterBlockSize = inSize, if useFilter == true - - Return code: - 0 - OK - 1 - Unspecified Error - 2 - Memory allocating error - 3 - Output buffer OVERFLOW - -If you use SZ_FILTER_AUTO mode, then encoder will use 2 or 3 passes: - 2 passes when FILTER_NO provides better compression. - 3 passes when FILTER_YES provides better compression. -*/ - -enum ESzFilterMode -{ - SZ_FILTER_NO, - SZ_FILTER_YES, - SZ_FILTER_AUTO -}; - -int LzmaRamEncode( - const Byte *inBuffer, size_t inSize, - Byte *outBuffer, size_t outSize, size_t *outSizeProcessed, - UInt32 dictionarySize, ESzFilterMode filterMode); - -#endif diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.c b/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.c deleted file mode 100755 index 29f798be..00000000 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.c +++ /dev/null @@ -1,78 +0,0 @@ -/* 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 x86State; - x86_Convert_Init(x86State); - x86_Convert(outBuffer, (SizeT)outSizeProcessedLoc, 0, &x86State, 0); - } - return 0; -} diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.h b/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.h deleted file mode 100755 index 7e641c55..00000000 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaRamDecode.h +++ /dev/null @@ -1,55 +0,0 @@ -/* LzmaRamDecode.h */ - -#ifndef __LzmaRamDecode_h -#define __LzmaRamDecode_h - -#include - -/* -LzmaRamGetUncompressedSize: - In: - inBuffer - input data - inSize - input data size - Out: - outSize - uncompressed size - Return code: - 0 - OK - 1 - Error in headers -*/ - -int LzmaRamGetUncompressedSize( - const unsigned char *inBuffer, - size_t inSize, - size_t *outSize); - - -/* -LzmaRamDecompress: - In: - inBuffer - input data - inSize - input data size - outBuffer - output data - outSize - output size - allocFunc - alloc function (can be malloc) - freeFunc - free function (can be free) - Out: - outSizeProcessed - processed size - Return code: - 0 - OK - 1 - Error in headers / data stream - 2 - Memory allocating error - -Memory requirements depend from properties of LZMA stream. -With default lzma settings it's about 16 KB. -*/ - -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 *)); - -#endif diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile b/CPP/7zip/Compress/LZMA_Alone/makefile index 16e76376..69196871 100755 --- a/CPP/7zip/Compress/LZMA_Alone/makefile +++ b/CPP/7zip/Compress/LZMA_Alone/makefile @@ -1,49 +1,13 @@ PROG = lzma.exe +LIBS = $(LIBS) user32.lib CFLAGS = $(CFLAGS) \ -DCOMPRESS_MF_MT \ -DBENCH_MT \ -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/ -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\LzmaBenchCon.obj \ - $O\LzmaRam.obj \ LZMA_OPT_OBJS = \ $O\LZMADecoder.obj \ @@ -66,44 +30,33 @@ WIN_OBJS = \ $O\OutBuffer.obj \ $O\StreamUtils.obj \ -LZ_OBJS = \ - $O\LZOutWindow.obj \ - C_OBJS = \ - $O\Alloc.obj \ $O\7zCrc.obj \ + $O\Alloc.obj \ + $O\Bra86.obj \ + $O\LzFind.obj \ + $O\LzFindMt.obj \ + $O\LzmaDec.obj \ + $O\LzmaEnc.obj \ $O\Threads.obj \ -C_LZ_OBJS = \ - $O\MatchFinder.obj \ - $O\MatchFinderMt.obj \ +C_LZMAUTIL_OBJS = \ + $O\Lzma86Dec.obj \ + $O\Lzma86Enc.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\LzmaRamDecode.obj \ - $O\LzmaDecode.obj \ + $(C_LZMAUTIL_OBJS) \ $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) +!include "../../../Build.mak" $(LZMA_OBJS): $(*B).cpp @@ -116,21 +69,11 @@ $(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) -$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 +$(C_LZMAUTIL_OBJS): ../../../../C/LzmaUtil/$(*B).c $(COMPL_O2) diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc index 4fed05e6..b5a5f1d1 100755 --- a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc +++ b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc @@ -22,11 +22,8 @@ OBJS = \ LzmaAlone.o \ LzmaBench.o \ LzmaBenchCon.o \ - LzmaRam.o \ LZMADecoder.o \ LZMAEncoder.o \ - LZOutWindow.o \ - RangeCoderBit.o \ InBuffer.o \ OutBuffer.o \ FileStreams.o \ @@ -41,10 +38,12 @@ OBJS = \ MyVector.o \ 7zCrc.o \ Alloc.o \ - BranchX86.o \ - MatchFinder.o \ - LzmaDecode.o \ - LzmaRamDecode.o \ + Bra86.o \ + LzFind.o \ + LzmaDec.o \ + LzmaEnc.o \ + Lzma86Dec.o \ + Lzma86Enc.o \ all: $(PROG) @@ -61,21 +60,12 @@ LzmaBench.o: LzmaBench.cpp LzmaBenchCon.o: LzmaBenchCon.cpp $(CXX) $(CFLAGS) LzmaBenchCon.cpp -LzmaRam.o: LzmaRam.cpp - $(CXX) $(CFLAGS) LzmaRam.cpp - LZMADecoder.o: ../LZMA/LZMADecoder.cpp $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.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 @@ -122,17 +112,23 @@ MyVector.o: ../../../Common/MyVector.cpp Alloc.o: ../../../../C/Alloc.c $(CXX_C) $(CFLAGS) ../../../../C/Alloc.c -BranchX86.o: ../../../../C/Compress/Branch/BranchX86.c - $(CXX_C) $(CFLAGS) ../../../../C/Compress/Branch/BranchX86.c +Bra86.o: ../../../../C/Bra86.c + $(CXX_C) $(CFLAGS) ../../../../C/Bra86.c + +LzFind.o: ../../../../C/LzFind.c + $(CXX_C) $(CFLAGS) ../../../../C/LzFind.c + +LzmaDec.o: ../../../../C/LzmaDec.c + $(CXX_C) $(CFLAGS) ../../../../C/LzmaDec.c -MatchFinder.o: ../../../../C/Compress/Lz/MatchFinder.c - $(CXX_C) $(CFLAGS) ../../../../C/Compress/Lz/MatchFinder.c +LzmaEnc.o: ../../../../C/LzmaEnc.c + $(CXX_C) $(CFLAGS) ../../../../C/LzmaEnc.c -LzmaDecode.o: ../../../../C/Compress/Lzma/LzmaDecode.c - $(CXX_C) $(CFLAGS) ../../../../C/Compress/Lzma/LzmaDecode.c +Lzma86Dec.o: ../../../../C/LzmaUtil/Lzma86Dec.c + $(CXX_C) $(CFLAGS) ../../../../C/LzmaUtil/Lzma86Dec.c -LzmaRamDecode.o: LzmaRamDecode.c - $(CXX_C) $(CFLAGS) LzmaRamDecode.c +Lzma86Enc.o: ../../../../C/LzmaUtil/Lzma86Enc.c + $(CXX_C) $(CFLAGS) ../../../../C/LzmaUtil/Lzma86Enc.c clean: -$(RM) $(PROG) $(OBJS) diff --git a/CPP/7zip/Compress/Lzx/LzxDecoder.cpp b/CPP/7zip/Compress/Lzx/LzxDecoder.cpp index 5ed05b53..94ce6fc9 100755 --- a/CPP/7zip/Compress/Lzx/LzxDecoder.cpp +++ b/CPP/7zip/Compress/Lzx/LzxDecoder.cpp @@ -38,7 +38,7 @@ STDMETHODIMP CDecoder::Flush() return m_x86ConvertOutStreamSpec->Flush(); } -UInt32 CDecoder::ReadBits(UInt32 numBits) { return m_InBitStream.ReadBits(numBits); } +UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); } #define RIF(x) { if (!(x)) return false; } @@ -63,12 +63,12 @@ bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols) UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream); if (number == kLevelSymbolZeros) { - num = kLevelSymbolZerosStartValue + ReadBits(kLevelSymbolZerosNumBits); + num = kLevelSymbolZerosStartValue + (int)ReadBits(kLevelSymbolZerosNumBits); symbol = 0; } else if (number == kLevelSymbolZerosBig) { - num = kLevelSymbolZerosBigStartValue + ReadBits(kLevelSymbolZerosBigNumBits); + num = kLevelSymbolZerosBigStartValue + (int)ReadBits(kLevelSymbolZerosBigNumBits); symbol = 0; } else if (number == kLevelSymbolSame || number <= kNumHuffmanBits) @@ -77,7 +77,7 @@ bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols) num = 1; else { - num = kLevelSymbolSameStartValue + ReadBits(kLevelSymbolSameNumBits); + num = kLevelSymbolSameStartValue + (int)ReadBits(kLevelSymbolSameNumBits); number = m_LevelDecoder.DecodeSymbol(&m_InBitStream); if (number > kNumHuffmanBits) return false; @@ -262,7 +262,7 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize) int numDirectBits; if (posSlot < kNumPowerPosSlots) { - numDirectBits = (posSlot >> 1) - 1; + numDirectBits = (int)(posSlot >> 1) - 1; distance = ((2 | (posSlot & 1)) << numDirectBits); } else @@ -297,7 +297,7 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize) next -= locLen; if (len != 0) { - _remainLen = len; + _remainLen = (int)len; return S_OK; } } diff --git a/CPP/7zip/Compress/Lzx/LzxDecoder.h b/CPP/7zip/Compress/Lzx/LzxDecoder.h index 777067e0..4a577d38 100755 --- a/CPP/7zip/Compress/Lzx/LzxDecoder.h +++ b/CPP/7zip/Compress/Lzx/LzxDecoder.h @@ -63,7 +63,7 @@ public: void MovePos(UInt32 numBits) { - m_BitPos += numBits; + m_BitPos += (int)numBits; Normalize(); } @@ -76,8 +76,8 @@ public: UInt32 ReadBitsBig(int numBits) { - UInt32 numBits0 = numBits / 2; - UInt32 numBits1 = numBits - numBits0; + int numBits0 = numBits / 2; + int numBits1 = numBits - numBits0; UInt32 res = ReadBits(numBits0) << numBits1; return res + ReadBits(numBits1); } @@ -128,7 +128,7 @@ class CDecoder : bool _wimMode; - UInt32 ReadBits(UInt32 numBits); + UInt32 ReadBits(int numBits); bool ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols); bool ReadTables(); void ClearPrevLevels(); diff --git a/CPP/7zip/Compress/PPMD/PPMD.dsp b/CPP/7zip/Compress/PPMD/PPMD.dsp deleted file mode 100755 index c98d809d..00000000 --- a/CPP/7zip/Compress/PPMD/PPMD.dsp +++ /dev/null @@ -1,242 +0,0 @@ -# Microsoft Developer Studio Project File - Name="PPMD" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=PPMD - 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 "PPMD.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 "PPMD.mak" CFG="PPMD - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "PPMD - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "PPMD - 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)" == "PPMD - 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 "PPMD_EXPORTS" /YX /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PPMD_EXPORTS" /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\PPMd.dll" /opt:NOWIN98 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "PPMD - 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 "PPMD_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PPMD_EXPORTS" /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\PPMd.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "PPMD - Win32 Release" -# Name "PPMD - Win32 Debug" -# Begin Group "Spec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\Codec.def -# End Source File -# Begin Source File - -SOURCE=..\CodecExports.cpp -# End Source File -# Begin Source File - -SOURCE=..\DllExports.cpp -# End Source File -# Begin Source File - -SOURCE=.\resource.rc -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Group "PPMD" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\PPMDContext.h -# End Source File -# Begin Source File - -SOURCE=.\PPMDDecode.h -# End Source File -# Begin Source File - -SOURCE=.\PPMDDecoder.cpp - -!IF "$(CFG)" == "PPMD - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "PPMD - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\PPMDDecoder.h -# End Source File -# Begin Source File - -SOURCE=.\PPMDEncode.h -# End Source File -# Begin Source File - -SOURCE=.\PPMDEncoder.cpp - -!IF "$(CFG)" == "PPMD - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "PPMD - Win32 Debug" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\PPMDEncoder.h -# End Source File -# Begin Source File - -SOURCE=.\PPMDRegister.cpp -# End Source File -# Begin Source File - -SOURCE=.\PPMDSubAlloc.h -# End Source File -# Begin Source File - -SOURCE=.\PPMDType.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\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 -# End Group -# Begin Group "Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\Common\Types.h -# End Source File -# End Group -# Begin Group "Ñ" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\Alloc.h -# End Source File -# End Group -# End Target -# End Project diff --git a/CPP/7zip/Compress/PPMD/PPMD.dsw b/CPP/7zip/Compress/PPMD/PPMD.dsw deleted file mode 100755 index 8032f3db..00000000 --- a/CPP/7zip/Compress/PPMD/PPMD.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: "PPMD"=.\PPMD.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp b/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp index fe99ea5a..cefd2478 100755 --- a/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp +++ b/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp @@ -81,7 +81,7 @@ STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream) properties[0] = _order; for (int i = 0; i < 4; i++) properties[1 + i] = Byte(_usedMemorySize >> (8 * i)); - return WriteStream(outStream, properties, kPropSize, NULL); + return WriteStream(outStream, properties, kPropSize); } const UInt32 kUsedMemorySizeDefault = (1 << 24); diff --git a/CPP/7zip/Compress/PPMD/makefile b/CPP/7zip/Compress/PPMD/makefile deleted file mode 100755 index f146edb0..00000000 --- a/CPP/7zip/Compress/PPMD/makefile +++ /dev/null @@ -1,43 +0,0 @@ -PROG = PPMd.dll -DEF_FILE = ../Codec.def -CFLAGS = $(CFLAGS) -I ../../../ -D_7ZIP_LARGE_PAGES -LIBS = $(LIBS) oleaut32.lib - -COMPRESS_OBJS = \ - $O\CodecExports.obj \ - $O\DllExports.obj \ - -PPMD_OPT_OBJS = \ - $O\PPMDDecoder.obj \ - $O\PPMDEncoder.obj \ - $O\PPMDRegister.obj \ - -7ZIP_COMMON_OBJS = \ - $O\InBuffer.obj \ - $O\OutBuffer.obj \ - $O\StreamUtils.obj \ - -C_OBJS = \ - $O\Alloc.obj \ - -OBJS = \ - $O\StdAfx.obj \ - $(COMPRESS_OBJS) \ - $(PPMD_OPT_OBJS) \ - $(7ZIP_COMMON_OBJS) \ - $(C_OBJS) \ - $O\resource.res - - -!include "../../../Build.mak" - -$(COMPRESS_OBJS): ../$(*B).cpp - $(COMPL) -$(PPMD_OPT_OBJS): $(*B).cpp - $(COMPL_O2) -$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp - $(COMPL) -$(C_OBJS): ../../../../C/$(*B).c - $(COMPL_O2) - - diff --git a/CPP/7zip/Compress/PPMD/resource.rc b/CPP/7zip/Compress/PPMD/resource.rc deleted file mode 100755 index fed98e19..00000000 --- a/CPP/7zip/Compress/PPMD/resource.rc +++ /dev/null @@ -1,3 +0,0 @@ -#include "../../MyVersionInfo.rc" - -MY_VERSION_INFO_DLL("PPMd Codec", "PPMd") diff --git a/CPP/7zip/Compress/RangeCoder/RangeCoder.h b/CPP/7zip/Compress/RangeCoder/RangeCoder.h index bbb2ba82..0a6b4064 100755 --- a/CPP/7zip/Compress/RangeCoder/RangeCoder.h +++ b/CPP/7zip/Compress/RangeCoder/RangeCoder.h @@ -71,13 +71,12 @@ public: Low = (UInt32)Low << 8; } - void EncodeDirectBits(UInt32 value, int numTotalBits) + void EncodeDirectBits(UInt32 value, int numBits) { - for (int i = numTotalBits - 1; i >= 0; i--) + for (numBits--; numBits >= 0; numBits--) { Range >>= 1; - if (((value >> i) & 1) == 1) - Low += Range; + Low += Range & (0 - ((value >> numBits) & 1)); if (Range < kTopValue) { Range <<= 8; diff --git a/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp index 8e4c4d3a..9a7c0a05 100755 --- a/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp +++ b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp @@ -7,74 +7,30 @@ namespace NCompress { namespace NRangeCoder { -UInt32 CPriceTables::ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; -static CPriceTables g_PriceTables; - -CPriceTables::CPriceTables() { Init(); } +UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; -void CPriceTables::Init() +struct CPriceTables { CPriceTables() { - const int kNumBits = (kNumBitModelTotalBits - kNumMoveReducingBits); - for(int i = kNumBits - 1; i >= 0; i--) - { - UInt32 start = 1 << (kNumBits - i - 1); - UInt32 end = 1 << (kNumBits - i); - for (UInt32 j = start; j < end; j++) - ProbPrices[j] = (i << kNumBitPriceShiftBits) + - (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1)); - } - - /* - // simplest: bad solution - for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++) - ProbPrices[i] = kBitPrice; - */ - - /* - const double kDummyMultMid = (1.0 / kBitPrice) / 2; - const double kDummyMultMid = 0; - // float solution - double ln2 = log(double(2)); - double lnAll = log(double(kBitModelTotal >> kNumMoveReducingBits)); - for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++) - ProbPrices[i] = UInt32((fabs(lnAll - log(double(i))) / ln2 + kDummyMultMid) * kBitPrice); - */ - - /* - // experimental, slow, solution: - for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++) + for (UInt32 i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits)) { - const int kCyclesBits = 5; - const UInt32 kCycles = (1 << kCyclesBits); - - UInt32 range = UInt32(-1); + const int kCyclesBits = kNumBitPriceShiftBits; + UInt32 w = i; UInt32 bitCount = 0; - for (UInt32 j = 0; j < kCycles; j++) + for (int j = 0; j < kCyclesBits; j++) { - range >>= (kNumBitModelTotalBits - kNumMoveReducingBits); - range *= i; - while(range < (1 << 31)) + w = w * w; + bitCount <<= 1; + while (w >= ((UInt32)1 << 16)) { - range <<= 1; + w >>= 1; bitCount++; } } - bitCount <<= kNumBitPriceShiftBits; - range -= (1 << 31); - for (int k = kNumBitPriceShiftBits - 1; k >= 0; k--) - { - range <<= 1; - if (range > (1 << 31)) - { - bitCount += (1 << k); - range -= (1 << 31); - } - } - ProbPrices[i] = (bitCount - // + (1 << (kCyclesBits - 1)) - ) >> kCyclesBits; + ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount); } - */ } +}; + +static CPriceTables g_PriceTables; }} diff --git a/CPP/7zip/Compress/RangeCoder/RangeCoderBit.h b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.h index 624f887c..0ac50dfe 100755 --- a/CPP/7zip/Compress/RangeCoder/RangeCoderBit.h +++ b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.h @@ -11,18 +11,12 @@ namespace NRangeCoder { const int kNumBitModelTotalBits = 11; const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits); -const int kNumMoveReducingBits = 2; +const int kNumMoveReducingBits = 4; -const int kNumBitPriceShiftBits = 6; +const int kNumBitPriceShiftBits = 4; const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits; -class CPriceTables -{ -public: - static UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; - static void Init(); - CPriceTables(); -}; +extern UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; template class CBitModel @@ -74,11 +68,10 @@ public: } UInt32 GetPrice(UInt32 symbol) const { - return CPriceTables::ProbPrices[ - (((this->Prob - symbol) ^ ((-(int)symbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits]; + return ProbPrices[(this->Prob ^ ((-(int)symbol)) & (kBitModelTotal - 1)) >> kNumMoveReducingBits]; } - UInt32 GetPrice0() const { return CPriceTables::ProbPrices[this->Prob >> kNumMoveReducingBits]; } - UInt32 GetPrice1() const { return CPriceTables::ProbPrices[(kBitModelTotal - this->Prob) >> kNumMoveReducingBits]; } + UInt32 GetPrice0() const { return ProbPrices[this->Prob >> kNumMoveReducingBits]; } + UInt32 GetPrice1() const { return ProbPrices[(this->Prob ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]; } }; diff --git a/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h b/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h index 4f0c78b4..97dd9b38 100755 --- a/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h +++ b/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h @@ -16,7 +16,7 @@ class CBitTreeEncoder public: void Init() { - for(UInt32 i = 1; i < (1 << NumBitLevels); i++) + for(UInt32 i = 0; i < (1 << NumBitLevels); i++) Models[i].Init(); } void Encode(CEncoder *rangeEncoder, UInt32 symbol) @@ -74,7 +74,7 @@ class CBitTreeDecoder public: void Init() { - for(UInt32 i = 1; i < (1 << NumBitLevels); i++) + for(UInt32 i = 0; i < (1 << NumBitLevels); i++) Models[i].Init(); } UInt32 Decode(CDecoder *rangeDecoder) diff --git a/CPP/7zip/Compress/Rar/Rar29.dsp b/CPP/7zip/Compress/Rar/Rar29.dsp index c5ee2228..9eb36ac3 100755 --- a/CPP/7zip/Compress/Rar/Rar29.dsp +++ b/CPP/7zip/Compress/Rar/Rar29.dsp @@ -182,19 +182,19 @@ SOURCE=..\..\..\Common\CRC.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Common\NewHandler.cpp +SOURCE=..\..\..\Common\MyVector.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Common\NewHandler.h +SOURCE=..\..\..\Common\MyVector.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\Vector.cpp +SOURCE=..\..\..\Common\NewHandler.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Common\Vector.h +SOURCE=..\..\..\Common\NewHandler.h # End Source File # End Group # Begin Group "Rar3" diff --git a/CPP/7zip/Compress/Rar/Rar2Decoder.cpp b/CPP/7zip/Compress/Rar/Rar2Decoder.cpp index 057a1a60..28d50213 100755 --- a/CPP/7zip/Compress/Rar/Rar2Decoder.cpp +++ b/CPP/7zip/Compress/Rar/Rar2Decoder.cpp @@ -69,16 +69,6 @@ Byte CFilter::Decode(int &channelDelta, Byte deltaByte) } } -class CException -{ -public: - enum ECauseType - { - kData - } Cause; - CException(ECauseType cause): Cause(cause) {} -}; - static const char *kNumberErrorMessage = "Number error"; static const UInt32 kHistorySize = 1 << 20; @@ -307,7 +297,7 @@ bool CDecoder::DecodeLz(Int32 pos) return true; } -STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream, +HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress) { @@ -373,7 +363,7 @@ STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream, } } if (pos > unPackSize) - throw CException(CException::kData); + return S_FALSE; if (!ReadLastTables()) return S_FALSE; diff --git a/CPP/7zip/Compress/Rar/Rar2Decoder.h b/CPP/7zip/Compress/Rar/Rar2Decoder.h index 9567de0a..7906b1fc 100755 --- a/CPP/7zip/Compress/Rar/Rar2Decoder.h +++ b/CPP/7zip/Compress/Rar/Rar2Decoder.h @@ -147,6 +147,10 @@ class CDecoder : bool DecodeMm(UInt32 pos); bool DecodeLz(Int32 pos); + HRESULT CodeReal(ISequentialInStream *inStream, + ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, + ICompressProgressInfo *progress); + public: CDecoder(); @@ -158,10 +162,6 @@ public: 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); diff --git a/CPP/7zip/Compress/Rar/Rar3Decoder.cpp b/CPP/7zip/Compress/Rar/Rar3Decoder.cpp index e629f4df..5ba13646 100755 --- a/CPP/7zip/Compress/Rar/Rar3Decoder.cpp +++ b/CPP/7zip/Compress/Rar/Rar3Decoder.cpp @@ -58,11 +58,7 @@ CDecoder::~CDecoder() 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; + return WriteStream(_outStream, data, size); } HRESULT CDecoder::WriteData(const Byte *data, UInt32 size) diff --git a/CPP/7zip/Compress/Rar/Rar3Vm.h b/CPP/7zip/Compress/Rar/Rar3Vm.h index d31fcd0a..8b2e01f1 100755 --- a/CPP/7zip/Compress/Rar/Rar3Vm.h +++ b/CPP/7zip/Compress/Rar/Rar3Vm.h @@ -11,9 +11,6 @@ #include "../../../../C/CpuArch.h" #define RARVM_STANDARD_FILTERS -#ifdef LITTLE_ENDIAN_UNALIGN -#define RARVM_LITTLE_ENDIAN_UNALIGN -#endif namespace NCompress { namespace NRar3 { @@ -37,27 +34,8 @@ public: 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 -} +inline UInt32 GetValue32(const void *addr) { return GetUi32(addr); } +inline void SetValue32(void *addr, UInt32 value) { SetUi32(addr, value); } UInt32 ReadEncodedUInt32(CMemBitDecoder &inp); @@ -147,14 +125,7 @@ class CVm 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 - } + return GetUi32(addr); } static void SetValue(bool byteMode, void *addr, UInt32 value) @@ -162,16 +133,7 @@ class CVm 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 - } + SetUi32(addr, value); } UInt32 GetFixedGlobalValue32(UInt32 globalOffset) { return GetValue(false, &Mem[kGlobalOffset + globalOffset]); } diff --git a/CPP/7zip/Compress/Rar/makefile b/CPP/7zip/Compress/Rar/makefile index f55bf17e..27cedbd9 100755 --- a/CPP/7zip/Compress/Rar/makefile +++ b/CPP/7zip/Compress/Rar/makefile @@ -16,7 +16,7 @@ RAR29_OPT_OBJS = \ COMMON_OBJS = \ $O\CRC.obj \ - $O\Vector.obj \ + $O\MyVector.obj \ 7ZIP_COMMON_OBJS = \ $O\InBuffer.obj \ diff --git a/CPP/7zip/Crypto/7zAES/7zAES.cpp b/CPP/7zip/Crypto/7zAES/7zAES.cpp index 97332b44..ce6b7aef 100755 --- a/CPP/7zip/Crypto/7zAES/7zAES.cpp +++ b/CPP/7zip/Crypto/7zAES/7zAES.cpp @@ -7,9 +7,13 @@ #include "../../Common/StreamObjects.h" #include "../../Common/StreamUtils.h" #include "../AES/MyAES.h" -#include "../Hash/Sha256.h" #include "7zAES.h" +extern "C" +{ +#include "../../../../C/Sha256.h" +} + #ifndef EXTRACT_ONLY #include "../Hash/RandGen.h" #endif @@ -43,19 +47,20 @@ void CKeyInfo::CalculateDigest() } else { - NCrypto::NSha256::CContext sha; + CSha256 sha; + Sha256_Init(&sha); const UInt64 numRounds = UInt64(1) << (NumCyclesPower); Byte temp[8] = { 0,0,0,0,0,0,0,0 }; for (UInt64 round = 0; round < numRounds; round++) { - sha.Update(Salt, SaltSize); - sha.Update(Password, Password.GetCapacity()); - sha.Update(temp, 8); + Sha256_Update(&sha, Salt, (size_t)SaltSize); + Sha256_Update(&sha, Password, Password.GetCapacity()); + Sha256_Update(&sha, temp, 8); for (int i = 0; i < 8; i++) if (++(temp[i]) != 0) break; } - sha.Final(Key); + Sha256_Final(&sha, Key); } } @@ -129,7 +134,7 @@ STDMETHODIMP CEncoder::ResetSalt() STDMETHODIMP CEncoder::ResetInitVector() { _ivSize = 8; - g_RandomGenerator.Generate(_iv, _ivSize); + g_RandomGenerator.Generate(_iv, (unsigned)_ivSize); return S_OK; } @@ -142,7 +147,7 @@ STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream) UInt32 ivSize = _ivSize; // _key.NumCyclesPower = 0x3F; - _key.NumCyclesPower = 18; + _key.NumCyclesPower = 19; Byte firstByte = (Byte)(_key.NumCyclesPower | (((_key.SaltSize == 0) ? 0 : 1) << 7) | @@ -156,11 +161,11 @@ STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream) RINOK(outStream->Write(&secondByte, 1, NULL)); if (_key.SaltSize > 0) { - RINOK(WriteStream(outStream, _key.Salt, _key.SaltSize, NULL)); + RINOK(WriteStream(outStream, _key.Salt, _key.SaltSize)); } if (ivSize > 0) { - RINOK(WriteStream(outStream, _iv, ivSize, NULL)); + RINOK(WriteStream(outStream, _iv, ivSize)); } return S_OK; } @@ -208,8 +213,8 @@ STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size) STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size) { - _key.Password.SetCapacity(size); - memcpy(_key.Password, data, size); + _key.Password.SetCapacity((size_t)size); + memcpy(_key.Password, data, (size_t)size); return S_OK; } diff --git a/CPP/7zip/Crypto/AES/MyAES.cpp b/CPP/7zip/Crypto/AES/MyAES.cpp index 926e8969..842a634e 100755 --- a/CPP/7zip/Crypto/AES/MyAES.cpp +++ b/CPP/7zip/Crypto/AES/MyAES.cpp @@ -12,14 +12,14 @@ STDMETHODIMP CAesCbcEncoder::Init() { return S_OK; } STDMETHODIMP_(UInt32) CAesCbcEncoder::Filter(Byte *data, UInt32 size) { - return AesCbcEncode(&Aes, data, size); + return (UInt32)AesCbc_Encode(&Aes, data, size); } STDMETHODIMP CAesCbcEncoder::SetKey(const Byte *data, UInt32 size) { if ((size & 0x7) != 0 || size < 16 || size > 32) return E_INVALIDARG; - AesSetKeyEncode(&Aes.aes, data, size); + Aes_SetKeyEncode(&Aes.aes, data, size); return S_OK; } @@ -27,7 +27,7 @@ STDMETHODIMP CAesCbcEncoder::SetInitVector(const Byte *data, UInt32 size) { if (size != AES_BLOCK_SIZE) return E_INVALIDARG; - AesCbcInit(&Aes, data); + AesCbc_Init(&Aes, data); return S_OK; } @@ -35,14 +35,14 @@ STDMETHODIMP CAesCbcDecoder::Init() { return S_OK; } STDMETHODIMP_(UInt32) CAesCbcDecoder::Filter(Byte *data, UInt32 size) { - return AesCbcDecode(&Aes, data, size); + return (UInt32)AesCbc_Decode(&Aes, data, size); } STDMETHODIMP CAesCbcDecoder::SetKey(const Byte *data, UInt32 size) { if ((size & 0x7) != 0 || size < 16 || size > 32) return E_INVALIDARG; - AesSetKeyDecode(&Aes.aes, data, size); + Aes_SetKeyDecode(&Aes.aes, data, size); return S_OK; } @@ -50,7 +50,7 @@ STDMETHODIMP CAesCbcDecoder::SetInitVector(const Byte *data, UInt32 size) { if (size != AES_BLOCK_SIZE) return E_INVALIDARG; - AesCbcInit(&Aes, data); + AesCbc_Init(&Aes, data); return S_OK; } diff --git a/CPP/7zip/Crypto/AES/MyAES.h b/CPP/7zip/Crypto/AES/MyAES.h index 29bd83c6..ee1d2828 100755 --- a/CPP/7zip/Crypto/AES/MyAES.h +++ b/CPP/7zip/Crypto/AES/MyAES.h @@ -10,7 +10,7 @@ extern "C" { -#include "../../../../C/Crypto/Aes.h" +#include "../../../../C/Aes.h" } namespace NCrypto { diff --git a/CPP/7zip/Crypto/Hash/RotateDefs.h b/CPP/7zip/Crypto/Hash/RotateDefs.h deleted file mode 100755 index 832e7357..00000000 --- a/CPP/7zip/Crypto/Hash/RotateDefs.h +++ /dev/null @@ -1,19 +0,0 @@ -// RotateDefs.h - -#ifndef __ROTATEDEFS_H -#define __ROTATEDEFS_H - -#ifdef _MSC_VER - -#include -#define rotlFixed(x, n) _rotl((x), (n)) -#define rotrFixed(x, n) _rotr((x), (n)) - -#else - -#define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) -#define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) - -#endif - -#endif diff --git a/CPP/7zip/Crypto/Hash/Sha1.cpp b/CPP/7zip/Crypto/Hash/Sha1.cpp index 0e1d2ecf..8d56b3dc 100755 --- a/CPP/7zip/Crypto/Hash/Sha1.cpp +++ b/CPP/7zip/Crypto/Hash/Sha1.cpp @@ -5,7 +5,10 @@ #include "StdAfx.h" #include "Sha1.h" -#include "RotateDefs.h" +extern "C" +{ +#include "../../../../C/RotateDefs.h" +} namespace NCrypto { namespace NSha1 { diff --git a/CPP/7zip/Crypto/Hash/Sha256.cpp b/CPP/7zip/Crypto/Hash/Sha256.cpp deleted file mode 100755 index db236058..00000000 --- a/CPP/7zip/Crypto/Hash/Sha256.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// Crypto/Sha256.cpp -// This code is based on code from Wei Dai's Crypto++ library. - -#include "StdAfx.h" - -#include "Sha256.h" -#include "RotateDefs.h" - -namespace NCrypto { -namespace NSha256 { - -// define it for speed optimization -// #define _SHA256_UNROLL -// #define _SHA256_UNROLL2 - -void CContext::Init() -{ - _state[0] = 0x6a09e667; - _state[1] = 0xbb67ae85; - _state[2] = 0x3c6ef372; - _state[3] = 0xa54ff53a; - _state[4] = 0x510e527f; - _state[5] = 0x9b05688c; - _state[6] = 0x1f83d9ab; - _state[7] = 0x5be0cd19; - - _count = 0; -} - -#define S0(x) (rotrFixed(x, 2) ^ rotrFixed(x,13) ^ rotrFixed(x, 22)) -#define S1(x) (rotrFixed(x, 6) ^ rotrFixed(x,11) ^ rotrFixed(x, 25)) -#define s0(x) (rotrFixed(x, 7) ^ rotrFixed(x,18) ^ (x >> 3)) -#define s1(x) (rotrFixed(x,17) ^ rotrFixed(x,19) ^ (x >> 10)) - -#define blk0(i) (W[i] = data[i]) -#define blk2(i) (W[i&15] += s1(W[(i-2)&15]) + W[(i-7)&15] + s0(W[(i-15)&15])) - -#define Ch(x,y,z) (z^(x&(y^z))) -#define Maj(x,y,z) ((x&y)|(z&(x|y))) - -#define a(i) T[(0-(i))&7] -#define b(i) T[(1-(i))&7] -#define c(i) T[(2-(i))&7] -#define d(i) T[(3-(i))&7] -#define e(i) T[(4-(i))&7] -#define f(i) T[(5-(i))&7] -#define g(i) T[(6-(i))&7] -#define h(i) T[(7-(i))&7] - - -#ifdef _SHA256_UNROLL2 - -#define R(a,b,c,d,e,f,g,h, i) h += S1(e) + Ch(e,f,g) + K[i+j] + (j?blk2(i):blk0(i));\ - d += h; h += S0(a) + Maj(a, b, c) - -#define RX_8(i) \ - R(a,b,c,d,e,f,g,h, i); \ - R(h,a,b,c,d,e,f,g, i+1); \ - R(g,h,a,b,c,d,e,f, i+2); \ - R(f,g,h,a,b,c,d,e, i+3); \ - R(e,f,g,h,a,b,c,d, i+4); \ - R(d,e,f,g,h,a,b,c, i+5); \ - R(c,d,e,f,g,h,a,b, i+6); \ - R(b,c,d,e,f,g,h,a, i+7) - -#else - -#define R(i) h(i) += S1(e(i)) + Ch(e(i),f(i),g(i)) + K[i+j] + (j?blk2(i):blk0(i));\ - d(i) += h(i); h(i) += S0(a(i)) + Maj(a(i), b(i), c(i)) - -#ifdef _SHA256_UNROLL - -#define RX_8(i) R(i+0); R(i+1); R(i+2); R(i+3); R(i+4); R(i+5); R(i+6); R(i+7); - -#endif - -#endif - - -void CContext::Transform(UInt32 *state, const UInt32 *data) -{ - UInt32 W[16]; - - #ifdef _SHA256_UNROLL2 - UInt32 a,b,c,d,e,f,g,h; - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - e = state[4]; - f = state[5]; - g = state[6]; - h = state[7]; - #else - UInt32 T[8]; - for (int s = 0; s < 8; s++) - T[s] = state[s]; - #endif - - for (unsigned int j = 0; j < 64; j += 16) - { - #if defined(_SHA256_UNROLL) || defined(_SHA256_UNROLL2) - RX_8(0); RX_8(8); - #else - for (unsigned int i = 0; i < 16; i++) { R(i); } - #endif - } - - #ifdef _SHA256_UNROLL2 - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - state[4] += e; - state[5] += f; - state[6] += g; - state[7] += h; - #else - for (int i = 0; i < 8; i++) - state[i] += T[i]; - #endif - - // Wipe variables - // memset(W, 0, sizeof(W)); - // memset(T, 0, sizeof(T)); -} - -const UInt32 CContext::K[64] = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, - 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, - 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, - 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, - 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 -}; - -#undef S0 -#undef S1 -#undef s0 -#undef s1 - -void CContext::WriteByteBlock() -{ - UInt32 data32[16]; - for (int i = 0; i < 16; i++) - { - data32[i] = (UInt32(_buffer[i * 4]) << 24) + - (UInt32(_buffer[i * 4 + 1]) << 16) + - (UInt32(_buffer[i * 4 + 2]) << 8) + - UInt32(_buffer[i * 4 + 3]); - } - Transform(_state, data32); -} - -void CContext::Update(const Byte *data, size_t size) -{ - UInt32 curBufferPos = (UInt32)_count & 0x3F; - while (size > 0) - { - _buffer[curBufferPos++] = *data++; - _count++; - size--; - if (curBufferPos == 64) - { - curBufferPos = 0; - WriteByteBlock(); - } - } -} - -void CContext::Final(Byte *digest) -{ - UInt64 lenInBits = (_count << 3); - UInt32 curBufferPos = (UInt32)_count & 0x3F; - _buffer[curBufferPos++] = 0x80; - while (curBufferPos != (64 - 8)) - { - curBufferPos &= 0x3F; - if (curBufferPos == 0) - WriteByteBlock(); - _buffer[curBufferPos++] = 0; - } - for (int i = 0; i < 8; i++) - { - _buffer[curBufferPos++] = (Byte)(lenInBits >> 56); - lenInBits <<= 8; - } - WriteByteBlock(); - - for (int j = 0; j < 8; j++) - { - *digest++ = (Byte)(_state[j] >> 24); - *digest++ = (Byte)(_state[j] >> 16); - *digest++ = (Byte)(_state[j] >> 8); - *digest++ = (Byte)(_state[j]); - } - Init(); -} - -}} diff --git a/CPP/7zip/Crypto/Hash/Sha256.h b/CPP/7zip/Crypto/Hash/Sha256.h deleted file mode 100755 index e4788f41..00000000 --- a/CPP/7zip/Crypto/Hash/Sha256.h +++ /dev/null @@ -1,30 +0,0 @@ -// Crypto/Sha256.h - -#ifndef __CRYPTO_SHA256_H -#define __CRYPTO_SHA256_H - -#include "Common/Types.h" - -namespace NCrypto { -namespace NSha256 { - -class CContext -{ - static const UInt32 K[64]; - - UInt32 _state[8]; - UInt64 _count; - Byte _buffer[64]; - static void Transform(UInt32 *digest, const UInt32 *data); - void WriteByteBlock(); -public: - enum {DIGESTSIZE = 32}; - CContext() { Init(); } ; - void Init(); - void Update(const Byte *data, size_t size); - void Final(Byte *digest); -}; - -}} - -#endif diff --git a/CPP/7zip/Crypto/RarAES/RarAES.cpp b/CPP/7zip/Crypto/RarAES/RarAES.cpp index f978e275..cb907ec2 100755 --- a/CPP/7zip/Crypto/RarAES/RarAES.cpp +++ b/CPP/7zip/Crypto/RarAES/RarAES.cpp @@ -76,14 +76,14 @@ STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size) STDMETHODIMP CDecoder::Init() { Calculate(); - AesSetKeyDecode(&Aes.aes, aesKey, kRarAesKeySize); - AesCbcInit(&Aes, aesInit); + Aes_SetKeyDecode(&Aes.aes, aesKey, kRarAesKeySize); + AesCbc_Init(&Aes, aesInit); return S_OK; } STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size) { - return AesCbcDecode(&Aes, data, size); + return (UInt32)AesCbc_Decode(&Aes, data, size); } void CDecoder::Calculate() diff --git a/CPP/7zip/Crypto/RarAES/RarAES.h b/CPP/7zip/Crypto/RarAES/RarAES.h index aea948d8..a99ad531 100755 --- a/CPP/7zip/Crypto/RarAES/RarAES.h +++ b/CPP/7zip/Crypto/RarAES/RarAES.h @@ -12,7 +12,7 @@ extern "C" { -#include "../../../../C/Crypto/Aes.h" +#include "../../../../C/Aes.h" } namespace NCrypto { diff --git a/CPP/7zip/Crypto/WzAES/WzAES.cpp b/CPP/7zip/Crypto/WzAES/WzAES.cpp index 106f2d94..704ea9fc 100755 --- a/CPP/7zip/Crypto/WzAES/WzAES.cpp +++ b/CPP/7zip/Crypto/WzAES/WzAES.cpp @@ -47,12 +47,12 @@ void CBaseCoder::EncryptData(Byte *data, UInt32 size) { if (++_counter[0] == 0) _counter[1]++; - UInt32 outBuf[4]; - AesEncode32(_counter, outBuf, Aes.rkey, Aes.numRounds2); - SetUi32(_buffer, outBuf[0]); - SetUi32(_buffer + 4, outBuf[1]); - SetUi32(_buffer + 8, outBuf[2]); - SetUi32(_buffer + 12, outBuf[3]); + UInt32 temp[4]; + Aes_Encode32(&Aes, temp, _counter); + SetUi32(_buffer, temp[0]); + SetUi32(_buffer + 4, temp[1]); + SetUi32(_buffer + 8, temp[2]); + SetUi32(_buffer + 12, temp[3]); pos = 0; } *data++ ^= _buffer[pos++]; @@ -115,17 +115,10 @@ STDMETHODIMP CBaseCoder::Init() for (int i = 0; i < 4; i++) _counter[i] = 0; - AesSetKeyEncode(&Aes, buf, keySize); + Aes_SetKeyEncode(&Aes, buf, keySize); return S_OK; } -static HRESULT SafeWrite(ISequentialOutStream *outStream, const Byte *data, UInt32 size) -{ - UInt32 processedSize; - RINOK(WriteStream(outStream, data, size, &processedSize)); - return ((processedSize == size) ? S_OK : E_FAIL); -} - /* STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream) { @@ -139,15 +132,15 @@ HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream) UInt32 saltSize = _key.GetSaltSize(); g_RandomGenerator.Generate(_key.Salt, saltSize); Init(); - RINOK(SafeWrite(outStream, _key.Salt, saltSize)); - return SafeWrite(outStream, _key.PwdVerifComputed, kPwdVerifCodeSize); + RINOK(WriteStream(outStream, _key.Salt, saltSize)); + return WriteStream(outStream, _key.PwdVerifComputed, kPwdVerifCodeSize); } HRESULT CEncoder::WriteFooter(ISequentialOutStream *outStream) { Byte mac[kMacSize]; _hmac.Final(mac, kMacSize); - return SafeWrite(outStream, mac, kMacSize); + return WriteStream(outStream, mac, kMacSize); } STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size) @@ -167,10 +160,7 @@ HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream) UInt32 saltSize = _key.GetSaltSize(); UInt32 extraSize = saltSize + kPwdVerifCodeSize; Byte temp[kSaltSizeMax + kPwdVerifCodeSize]; - UInt32 processedSize; - RINOK(ReadStream(inStream, temp, extraSize, &processedSize)); - if (processedSize != extraSize) - return E_FAIL; + RINOK(ReadStream_FAIL(inStream, temp, extraSize)); UInt32 i; for (i = 0; i < saltSize; i++) _key.Salt[i] = temp[i]; @@ -195,11 +185,8 @@ bool CDecoder::CheckPasswordVerifyCode() HRESULT CDecoder::CheckMac(ISequentialInStream *inStream, bool &isOK) { isOK = false; - UInt32 processedSize; Byte mac1[kMacSize]; - RINOK(ReadStream(inStream, mac1, kMacSize, &processedSize)); - if (processedSize != kMacSize) - return E_FAIL; + RINOK(ReadStream_FAIL(inStream, mac1, kMacSize)); Byte mac2[kMacSize]; _hmac.Final(mac2, kMacSize); isOK = CompareArrays(mac1, mac2, kMacSize); diff --git a/CPP/7zip/Crypto/WzAES/WzAES.h b/CPP/7zip/Crypto/WzAES/WzAES.h index 72a493a1..fa14410a 100755 --- a/CPP/7zip/Crypto/WzAES/WzAES.h +++ b/CPP/7zip/Crypto/WzAES/WzAES.h @@ -23,7 +23,7 @@ specified in password Based File Encryption Utility: extern "C" { -#include "../../../../C/Crypto/Aes.h" +#include "../../../../C/Aes.h" } namespace NCrypto { diff --git a/CPP/7zip/Crypto/Zip/ZipCipher.cpp b/CPP/7zip/Crypto/Zip/ZipCipher.cpp index 639776ce..b466f8a7 100755 --- a/CPP/7zip/Crypto/Zip/ZipCipher.cpp +++ b/CPP/7zip/Crypto/Zip/ZipCipher.cpp @@ -36,12 +36,8 @@ HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream) header[kHeaderSize - 1] = Byte(_crc >> 24); header[kHeaderSize - 2] = Byte(_crc >> 16); - UInt32 processedSize; _cipher.EncryptHeader(header); - RINOK(WriteStream(outStream, header, kHeaderSize, &processedSize)); - if (processedSize != kHeaderSize) - return E_FAIL; - return S_OK; + return WriteStream(outStream, header, kHeaderSize); } STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size) @@ -61,10 +57,7 @@ STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size) HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream) { Byte header[kHeaderSize]; - UInt32 processedSize; - RINOK(ReadStream(inStream, header, kHeaderSize, &processedSize)); - if (processedSize != kHeaderSize) - return E_FAIL; + RINOK(ReadStream_FAIL(inStream, header, kHeaderSize)); _cipher.DecryptHeader(header); return S_OK; } diff --git a/CPP/7zip/ICoder.h b/CPP/7zip/ICoder.h index a4976534..7b0ace12 100755 --- a/CPP/7zip/ICoder.h +++ b/CPP/7zip/ICoder.h @@ -39,6 +39,7 @@ namespace NCoderPropID kDictionarySize = 0x400, kUsedMemorySize, kOrder, + kBlockSize, kPosStateBits = 0x440, kLitContextBits, kLitPosBits, diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h index af5c7d31..6e57dea3 100755 --- a/CPP/7zip/MyVersion.h +++ b/CPP/7zip/MyVersion.h @@ -1,8 +1,8 @@ #define MY_VER_MAJOR 4 -#define MY_VER_MINOR 57 -#define MY_VER_BUILD 0 -#define MY_VERSION "4.57" -#define MY_7ZIP_VERSION "7-Zip 4.57" -#define MY_DATE "2007-12-06" -#define MY_COPYRIGHT "Copyright (c) 1999-2007 Igor Pavlov" +#define MY_VER_MINOR 58 +#define MY_VER_BUILD 10 +#define MY_VERSION " 4.58 beta" +#define MY_7ZIP_VERSION "7-Zip 4.58 beta" +#define MY_DATE "2008-05-05" +#define MY_COPYRIGHT "Copyright (c) 1999-2008 Igor Pavlov" #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE diff --git a/CPP/7zip/PropID.h b/CPP/7zip/PropID.h index a13fe27f..40450ee1 100755 --- a/CPP/7zip/PropID.h +++ b/CPP/7zip/PropID.h @@ -45,6 +45,7 @@ enum kpidLinks, kpidNumBlocks, kpidNumVolumes, + kpidTimeType, kpidTotalSize = 0x1100, kpidFreeSpace, diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp index 4c6ba1a1..7976e1a2 100755 --- a/CPP/7zip/UI/Agent/AgentOut.cpp +++ b/CPP/7zip/UI/Agent/AgentOut.cpp @@ -250,7 +250,7 @@ STDMETHODIMP CAgent::DoOperation( UString resultPath; int pos; if(!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos)) - throw 141716; + return E_FAIL; NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos)); } if (!outStreamSpec->Create(archiveName, true)) @@ -282,7 +282,7 @@ STDMETHODIMP CAgent::DoOperation( catch(...) { delete []propValues; - throw; + return E_FAIL; } delete []propValues; } @@ -295,7 +295,8 @@ STDMETHODIMP CAgent::DoOperation( CInFileStream *sfxStreamSpec = new CInFileStream; CMyComPtr sfxStream(sfxStreamSpec); if (!sfxStreamSpec->Open(sfxModule)) - throw "Can't open sfx module"; + return E_FAIL; + // throw "Can't open sfx module"; RINOK(CopyBlock(sfxStream, outStream)); } diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp index bb0d0530..a50a26c7 100755 --- a/CPP/7zip/UI/Agent/AgentProxy.cpp +++ b/CPP/7zip/UI/Agent/AgentProxy.cpp @@ -228,7 +228,20 @@ HRESULT CProxyArchive::ReadObjects(IInArchive *archive, IProgress *progress) CProxyFolder *currentItem = &RootFolder; UString fileName; if(propVariantPath.vt == VT_EMPTY) + { fileName = DefaultName; + + NCOM::CPropVariant prop; + RINOK(archive->GetProperty(i, kpidExtension, &prop)); + if (prop.vt == VT_BSTR) + { + fileName += L'.'; + fileName += prop.bstrVal; + } + else if (prop.vt != VT_EMPTY) + return E_FAIL; + + } else { if(propVariantPath.vt != VT_BSTR) diff --git a/CPP/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp index fce1c4f6..e059d3ac 100755 --- a/CPP/7zip/UI/Client7z/Client7z.cpp +++ b/CPP/7zip/UI/Client7z/Client7z.cpp @@ -275,7 +275,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, else { if (propVariant.vt != VT_UI4) - throw "incorrect item"; + return E_FAIL; _processedFileInfo.Attributes = propVariant.ulVal; _processedFileInfo.AttributesAreDefined = true; } @@ -684,11 +684,7 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef ////////////////////////////////////////////////////////////////////////// // Main function -int -#ifdef _MSC_VER -__cdecl -#endif -main(int argc, char* argv[]) +int MY_CDECL main(int argc, char* argv[]) { #ifdef _WIN32 #ifndef _UNICODE diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.h b/CPP/7zip/UI/Common/ArchiveExtractCallback.h index fd30d64d..756dfb08 100755 --- a/CPP/7zip/UI/Common/ArchiveExtractCallback.h +++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.h @@ -95,7 +95,7 @@ private: public: CArchiveExtractCallback(): WriteModified(true), - WriteCreated(false), + WriteCreated(true), WriteAccessed(false), _multiArchives(false) { diff --git a/CPP/7zip/UI/Common/DirItem.h b/CPP/7zip/UI/Common/DirItem.h index 89bd4cd3..d2f2ab43 100755 --- a/CPP/7zip/UI/Common/DirItem.h +++ b/CPP/7zip/UI/Common/DirItem.h @@ -5,30 +5,31 @@ #include "Common/MyString.h" #include "Common/Types.h" +#include "../../Archive/IArchive.h" struct CDirItem { - UInt32 Attributes; FILETIME CreationTime; FILETIME LastAccessTime; FILETIME LastWriteTime; UInt64 Size; UString Name; UString FullPath; + UInt32 Attributes; bool IsDirectory() const { return (Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0 ; } }; struct CArchiveItem { - bool IsDirectory; - // DWORD Attributes; - // NWindows::NCOM::CPropVariant LastWriteTime; FILETIME LastWriteTime; - bool SizeIsDefined; UInt64 Size; UString Name; + bool IsDirectory; + bool SizeIsDefined; bool Censored; - int IndexInServer; + UInt32 IndexInServer; + int FileTimeType; + CArchiveItem(): IsDirectory(false), SizeIsDefined(false), Censored(false), FileTimeType(-1) {} }; #endif diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp index 087340a1..52b2ebe8 100755 --- a/CPP/7zip/UI/Common/LoadCodecs.cpp +++ b/CPP/7zip/UI/Common/LoadCodecs.cpp @@ -482,10 +482,10 @@ int CCodecs::FindFormatForArchiveType(const UString &arcType) const extern unsigned int g_NumCodecs; STDAPI CreateCoder2(bool encode, UInt32 index, const GUID *iid, void **outObject); STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value); -// STDAPI GetNumberOfMethods(UINT32 *numCodecs); +// STDAPI GetNumberOfMethods(UInt32 *numCodecs); #endif -STDMETHODIMP CCodecs::GetNumberOfMethods(UINT32 *numMethods) +STDMETHODIMP CCodecs::GetNumberOfMethods(UInt32 *numMethods) { *numMethods = #ifdef EXPORT_CODECS @@ -495,7 +495,7 @@ STDMETHODIMP CCodecs::GetNumberOfMethods(UINT32 *numMethods) return S_OK; } -STDMETHODIMP CCodecs::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *value) +STDMETHODIMP CCodecs::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) { #ifdef EXPORT_CODECS if (index < g_NumCodecs) @@ -525,7 +525,7 @@ STDMETHODIMP CCodecs::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *valu return Libs[ci.LibIndex].GetMethodProperty(ci.CodecIndex, propID, value); } -STDMETHODIMP CCodecs::CreateDecoder(UINT32 index, const GUID *iid, void **coder) +STDMETHODIMP CCodecs::CreateDecoder(UInt32 index, const GUID *iid, void **coder) { #ifdef EXPORT_CODECS if (index < g_NumCodecs) @@ -541,7 +541,7 @@ STDMETHODIMP CCodecs::CreateDecoder(UINT32 index, const GUID *iid, void **coder) return S_OK; } -STDMETHODIMP CCodecs::CreateEncoder(UINT32 index, const GUID *iid, void **coder) +STDMETHODIMP CCodecs::CreateEncoder(UInt32 index, const GUID *iid, void **coder) { #ifdef EXPORT_CODECS if (index < g_NumCodecs) diff --git a/CPP/7zip/UI/Common/LoadCodecs.h b/CPP/7zip/UI/Common/LoadCodecs.h index 231680b5..dadcf7c2 100755 --- a/CPP/7zip/UI/Common/LoadCodecs.h +++ b/CPP/7zip/UI/Common/LoadCodecs.h @@ -154,10 +154,10 @@ public: MY_UNKNOWN_IMP #ifdef EXTERNAL_CODECS - STDMETHOD(GetNumberOfMethods)(UINT32 *numMethods); - STDMETHOD(GetProperty)(UINT32 index, PROPID propID, PROPVARIANT *value); - STDMETHOD(CreateDecoder)(UINT32 index, const GUID *interfaceID, void **coder); - STDMETHOD(CreateEncoder)(UINT32 index, const GUID *interfaceID, void **coder); + STDMETHOD(GetNumberOfMethods)(UInt32 *numMethods); + STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value); + STDMETHOD(CreateDecoder)(UInt32 index, const GUID *interfaceID, void **coder); + STDMETHOD(CreateEncoder)(UInt32 index, const GUID *interfaceID, void **coder); #endif int GetCodecLibIndex(UInt32 index); diff --git a/CPP/7zip/UI/Common/OpenArchive.cpp b/CPP/7zip/UI/Common/OpenArchive.cpp index 2874f6a7..4bd93455 100755 --- a/CPP/7zip/UI/Common/OpenArchive.cpp +++ b/CPP/7zip/UI/Common/OpenArchive.cpp @@ -37,7 +37,18 @@ HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, const UString &def { RINOK(GetArchiveItemPath(archive, index, result)); if (result.IsEmpty()) + { result = defaultName; + NCOM::CPropVariant prop; + RINOK(archive->GetProperty(index, kpidExtension, &prop)); + if (prop.vt == VT_BSTR) + { + result += L'.'; + result += prop.bstrVal; + } + else if (prop.vt != VT_EMPTY) + return E_FAIL; + } return S_OK; } @@ -129,12 +140,12 @@ HRESULT OpenArchive( { CIntVector orderIndices2; CByteBuffer byteBuffer; - const UInt32 kBufferSize = (200 << 10); + const size_t 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)); + size_t processedSize = kBufferSize; + RINOK(ReadStream(inStream, buffer, &processedSize)); for (UInt32 pos = 0; pos < processedSize; pos++) { for (int i = 0; i < orderIndices.Size(); i++) @@ -159,16 +170,16 @@ HRESULT OpenArchive( else if (extension == L"000" || extension == L"001") { CByteBuffer byteBuffer; - const UInt32 kBufferSize = (1 << 10); + const size_t kBufferSize = (1 << 10); byteBuffer.SetCapacity(kBufferSize); Byte *buffer = byteBuffer; RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL)); - UInt32 processedSize; - RINOK(ReadStream(inStream, buffer, kBufferSize, &processedSize)); + size_t processedSize = kBufferSize; + RINOK(ReadStream(inStream, buffer, &processedSize)); if (processedSize >= 16) { Byte kRarHeader[] = {0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}; - if (TestSignature(buffer, kRarHeader, 7) && buffer[9] == 0x73 && (buffer[10] && 1) != 0) + if (TestSignature(buffer, kRarHeader, 7) && buffer[9] == 0x73 && (buffer[10] & 1) != 0) { for (int i = 0; i < orderIndices.Size(); i++) { diff --git a/CPP/7zip/UI/Common/SetProperties.cpp b/CPP/7zip/UI/Common/SetProperties.cpp index b1434ace..201e95b5 100755 --- a/CPP/7zip/UI/Common/SetProperties.cpp +++ b/CPP/7zip/UI/Common/SetProperties.cpp @@ -44,9 +44,23 @@ HRESULT SetProperties(IUnknown *unknown, const CObjectVector &propert { const CProperty &property = properties[i]; NCOM::CPropVariant propVariant; - if (!property.Value.IsEmpty()) + UString name = property.Name; + if (property.Value.IsEmpty()) + { + if (!name.IsEmpty()) + { + wchar_t c = name[name.Length() - 1]; + if (c == L'-') + propVariant = false; + else if (c == L'+') + propVariant = true; + if (propVariant.vt != VT_EMPTY) + name = name.Left(name.Length() - 1); + } + } + else ParseNumberString(property.Value, propVariant); - realNames.Add(property.Name); + realNames.Add(name); values[i] = propVariant; } CRecordVector names; diff --git a/CPP/7zip/UI/Common/Update.cpp b/CPP/7zip/UI/Common/Update.cpp index ec5ebc80..8e879246 100755 --- a/CPP/7zip/UI/Common/Update.cpp +++ b/CPP/7zip/UI/Common/Update.cpp @@ -2,10 +2,6 @@ #include "StdAfx.h" -#ifdef _WIN32 -#include -#endif - #include "Update.h" #include "Common/IntToString.h" @@ -338,9 +334,9 @@ static HRESULT Compress( switch(value) { case NFileTimeType::kWindows: - case NFileTimeType::kDOS: case NFileTimeType::kUnix: - fileTimeType = NFileTimeType::EEnum(value); + case NFileTimeType::kDOS: + fileTimeType = (NFileTimeType::EEnum)value; break; default: return E_FAIL; @@ -516,11 +512,31 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor, RINOK(GetArchiveItemFileTime(archive, i, archiveFileInfo.LastWriteTime, ai.LastWriteTime)); - CPropVariant propertySize; - RINOK(archive->GetProperty(i, kpidSize, &propertySize)); - ai.SizeIsDefined = (propertySize.vt != VT_EMPTY); - if (ai.SizeIsDefined) - ai.Size = ConvertPropVariantToUInt64(propertySize); + { + CPropVariant prop; + RINOK(archive->GetProperty(i, kpidSize, &prop)); + ai.SizeIsDefined = (prop.vt != VT_EMPTY); + if (ai.SizeIsDefined) + ai.Size = ConvertPropVariantToUInt64(prop); + } + + { + CPropVariant prop; + RINOK(archive->GetProperty(i, kpidTimeType, &prop)); + if (prop.vt == VT_UI4) + { + ai.FileTimeType = (int)(NFileTimeType::EEnum)prop.ulVal; + switch(ai.FileTimeType) + { + case NFileTimeType::kWindows: + case NFileTimeType::kUnix: + case NFileTimeType::kDOS: + break; + default: + return E_FAIL; + } + } + } ai.IndexInServer = i; archiveItems.Add(ai); @@ -593,6 +609,17 @@ struct CEnumDirItemUpdateCallback: public IEnumDirItemCallback HRESULT CheckBreak() { return Callback->CheckBreak(); } }; +#ifdef _WIN32 +typedef ULONG (FAR PASCAL MY_MAPISENDDOCUMENTS)( + ULONG_PTR ulUIParam, + LPSTR lpszDelimChar, + LPSTR lpszFilePaths, + LPSTR lpszFileNames, + ULONG ulReserved +); +typedef MY_MAPISENDDOCUMENTS FAR *MY_LPMAPISENDDOCUMENTS; +#endif + HRESULT UpdateArchive( CCodecs *codecs, const NWildcard::CCensor &censor, @@ -814,7 +841,7 @@ HRESULT UpdateArchive( errorInfo.Message = L"can not load Mapi32.dll"; return E_FAIL; } - LPMAPISENDDOCUMENTS fnSend = (LPMAPISENDDOCUMENTS) + MY_LPMAPISENDDOCUMENTS fnSend = (MY_LPMAPISENDDOCUMENTS) mapiLib.GetProcAddress("MAPISendDocuments"); if (fnSend == 0) { diff --git a/CPP/7zip/UI/Common/UpdatePair.cpp b/CPP/7zip/UI/Common/UpdatePair.cpp index b4fb2a15..2ee0f167 100755 --- a/CPP/7zip/UI/Common/UpdatePair.cpp +++ b/CPP/7zip/UI/Common/UpdatePair.cpp @@ -14,8 +14,7 @@ using namespace NWindows; using namespace NTime; -static int MyCompareTime(NFileTimeType::EEnum fileTimeType, - const FILETIME &time1, const FILETIME &time2) +static int MyCompareTime(NFileTimeType::EEnum fileTimeType, const FILETIME &time1, const FILETIME &time2) { switch(fileTimeType) { @@ -24,16 +23,8 @@ static int MyCompareTime(NFileTimeType::EEnum fileTimeType, case NFileTimeType::kUnix: { UInt32 unixTime1, unixTime2; - if (!FileTimeToUnixTime(time1, unixTime1)) - { - unixTime1 = 0; - // throw 4191614; - } - if (!FileTimeToUnixTime(time2, unixTime2)) - { - unixTime2 = 0; - // throw 4191615; - } + FileTimeToUnixTime(time1, unixTime1); + FileTimeToUnixTime(time2, unixTime2); return MyCompare(unixTime1, unixTime2); } case NFileTimeType::kDOS: @@ -41,12 +32,6 @@ static int MyCompareTime(NFileTimeType::EEnum fileTimeType, UInt32 dosTime1, dosTime2; FileTimeToDosTime(time1, dosTime1); FileTimeToDosTime(time2, dosTime2); - /* - if (!FileTimeToDosTime(time1, dosTime1)) - throw 4191616; - if (!FileTimeToDosTime(time2, dosTime2)) - throw 4191617; - */ return MyCompare(dosTime1, dosTime2); } } @@ -125,7 +110,8 @@ void GetUpdatePairInfoList( throw 1082022;; // TTString(kNotCensoredCollisionMessaged + dirItem.Name); pair.DirItemIndex = dirItemIndex2; pair.ArchiveItemIndex = archiveItemIndex2; - switch (MyCompareTime(fileTimeType, dirItem.LastWriteTime, archiveItem.LastWriteTime)) + switch (MyCompareTime(archiveItem.FileTimeType != - 1 ? + (NFileTimeType::EEnum)archiveItem.FileTimeType : fileTimeType, dirItem.LastWriteTime, archiveItem.LastWriteTime)) { case -1: pair.State = NUpdateArchive::NPairState::kNewInArchive; diff --git a/CPP/7zip/UI/Console/List.cpp b/CPP/7zip/UI/Console/List.cpp index 7a2b9628..6ba2830e 100755 --- a/CPP/7zip/UI/Console/List.cpp +++ b/CPP/7zip/UI/Console/List.cpp @@ -295,7 +295,16 @@ HRESULT CFieldPrinter::PrintItemInfo(IInArchive *archive, PrintSpaces(fieldInfo.PrefixSpacesWidth); NCOM::CPropVariant propVariant; - RINOK(archive->GetProperty(index, fieldInfo.PropID, &propVariant)); + if (fieldInfo.PropID == kpidPath) + { + UString s; + RINOK(GetArchiveItemPath(archive, index, defaultItemName, s)); + propVariant = s; + } + else + { + RINOK(archive->GetProperty(index, fieldInfo.PropID, &propVariant)); + } if (techMode) { g_StdOut << fieldInfo.Name << " = "; diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp index de496530..265d2212 100755 --- a/CPP/7zip/UI/Console/Main.cpp +++ b/CPP/7zip/UI/Console/Main.cpp @@ -1,4 +1,4 @@ -/ Main.cpp +// Main.cpp #include "StdAfx.h" @@ -298,7 +298,7 @@ int Main2( stdStream << endl << "Codecs:" << endl; #ifdef EXTERNAL_CODECS - UINT32 numMethods; + UInt32 numMethods; if (codecs->GetNumberOfMethods(&numMethods) == S_OK) for (UInt32 j = 0; j < numMethods; j++) { diff --git a/CPP/7zip/UI/Console/MainAr.cpp b/CPP/7zip/UI/Console/MainAr.cpp index fd42e4f6..6cc5cf9d 100755 --- a/CPP/7zip/UI/Console/MainAr.cpp +++ b/CPP/7zip/UI/Console/MainAr.cpp @@ -48,11 +48,7 @@ static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n"; static const char *kInternalExceptionMessage = "\n\nInternal Error #"; -int -#ifdef _MSC_VER -__cdecl -#endif -main +int MY_CDECL main ( #ifndef _WIN32 int numArguments, const char *arguments[] diff --git a/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp index 1d4420da..dd4e2b9e 100755 --- a/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp +++ b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp @@ -144,10 +144,8 @@ HRESULT CUpdateCallbackConsole::SetCompleted(const UInt64 *completeValue) HRESULT CUpdateCallbackConsole::SetRatioInfo(const UInt64 * /* inSize */, const UInt64 * /* outSize */) { - /* if (NConsoleClose::TestBreakSignal()) return E_ABORT; - */ return S_OK; } diff --git a/CPP/7zip/UI/Explorer/ContextMenu.cpp b/CPP/7zip/UI/Explorer/ContextMenu.cpp index 06210412..5a736eb1 100755 --- a/CPP/7zip/UI/Explorer/ContextMenu.cpp +++ b/CPP/7zip/UI/Explorer/ContextMenu.cpp @@ -352,7 +352,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, { CCommandMapItem commandMapItem; if(!popupMenu.CreatePopup()) - throw 210503; + return E_FAIL; menuDestroyer.Attach(popupMenu); commandMapItem.CommandInternalID = kCommandNULL; commandMapItem.Verb = kMainVerb; diff --git a/CPP/7zip/UI/Far/ExtractEngine.cpp b/CPP/7zip/UI/Far/ExtractEngine.cpp index c6583aae..2ffb14c1 100755 --- a/CPP/7zip/UI/Far/ExtractEngine.cpp +++ b/CPP/7zip/UI/Far/ExtractEngine.cpp @@ -101,13 +101,15 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite( *answer = NOverwriteAnswer::kAutoRename; break; default: - throw 20413; + return E_FAIL; } return S_OK; } STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, bool /* isFolder */, INT32 /* askExtractMode */, const UINT64 * /* position */) { + if(WasEscPressed()) + return E_ABORT; m_CurrentFilePath = name; return S_OK; } diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp index c176ac92..40851c0c 100755 --- a/CPP/7zip/UI/Far/Plugin.cpp +++ b/CPP/7zip/UI/Far/Plugin.cpp @@ -68,6 +68,9 @@ static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex, fileTime = propVariant.filetime; } } + +#define kDotsReplaceString "[[..]]" +#define kDotsReplaceStringU L"[[..]]" void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) { @@ -83,6 +86,9 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) if (oemString.Length() > kFileNameSizeMax) oemString = oemString.Left(kFileNameSizeMax); + if (oemString == "..") + oemString = kDotsReplaceString; + MyStringCopy(panelItem.FindData.cFileName, (const char *)oemString); panelItem.FindData.cAlternateFileName[0] = 0; @@ -194,12 +200,15 @@ void CPlugin::FreeFindData(struct PluginPanelItem *panelItems, } -void CPlugin::EnterToDirectory(const UString &aDirName) +void CPlugin::EnterToDirectory(const UString &dirName) { CMyComPtr newFolder; - _folder->BindToFolder(aDirName, &newFolder); + UString s = dirName; + if (dirName == kDotsReplaceStringU) + s = L".."; + _folder->BindToFolder(s, &newFolder); if (newFolder == NULL) - if (aDirName.IsEmpty()) + if (dirName.IsEmpty()) return; else throw 40325; diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp index 86479f04..4a4dcc96 100755 --- a/CPP/7zip/UI/FileManager/App.cpp +++ b/CPP/7zip/UI/FileManager/App.cpp @@ -443,6 +443,12 @@ static void ReducePathToRealFileSystemPath(UString &path) path = path.Left(pos + 1); if (path.Length() == 3 && path[1] == L':') break; + if (path.Length() > 2 && path[0] == '\\' && path[1] == '\\') + { + int nextPos = path.Find('\\', 2); // pos after \\COMPNAME + if (nextPos > 0 && path.Find('\\', nextPos + 1) == pos) + break; + } path = path.Left(pos); } } @@ -524,6 +530,12 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) destPath = copyDialog.Value; + if (destPath.IsEmpty()) + { + srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + return; + } + if (!IsPathAbsolute(destPath)) { if (!srcPanel.IsFSFolder()) @@ -534,6 +546,13 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) destPath = srcPanel._currentFolderPrefix + destPath; } + if (destPath.Length() > 0 && destPath[0] == '\\') + if (destPath.Length() == 1 || destPath[1] != '\\') + { + srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + return; + } + if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) || IsThereFolderOfPath(destPath)) { diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp index 8b27b217..7998d5cc 100755 --- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp +++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp @@ -162,7 +162,7 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite( *answer = NOverwriteAnswer::kYes; break; default: - throw 20413; + return E_FAIL; } return S_OK; } @@ -408,7 +408,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( OverwriteMode = NExtract::NOverwriteMode::kAutoRename; break; default: - throw 20413; + return E_FAIL; } } } diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp index b9a51193..66e5a086 100755 --- a/CPP/7zip/UI/FileManager/FM.cpp +++ b/CPP/7zip/UI/FileManager/FM.cpp @@ -766,38 +766,40 @@ void OnSize(HWND hWnd) MoveSubWindows(hWnd); } +int Window_GetRealHeight(NWindows::CWindow &w) +{ + RECT rect; + WINDOWPLACEMENT placement; + w.GetWindowRect(&rect); + int res = rect.bottom - rect.top; + if (w.GetPlacement(&placement)) + res += placement.rcNormalPosition.top; + return res; +} + void MoveSubWindows(HWND hWnd) { RECT rect; ::GetClientRect(hWnd, &rect); int xSize = rect.right; - int kHeaderSize = 0; - int ySize = MyMax(int(rect.bottom - kHeaderSize), 0); + int headerSize = 0; if (g_App._rebar) - { - RECT barRect; - g_App._rebar.GetWindowRect(&barRect); - kHeaderSize = barRect.bottom - barRect.top; - ySize = MyMax(int(rect.bottom - kHeaderSize), 0); - } + headerSize = Window_GetRealHeight(g_App._rebar); + int ySize = MyMax((int)(rect.bottom - headerSize), 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); + g_App.Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize); int xWidth1 = g_Splitter.GetPos() + kSplitterWidth; - g_App.Panels[1].Move(xWidth1, kHeaderSize, xSize - xWidth1, ySize); + g_App.Panels[1].Move(xWidth1, headerSize, 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[otherPanel].Move(0, headerSize, 0, ySize); */ - g_App.Panels[g_App.LastFocusedPanel].Move(0, kHeaderSize, xSize, ySize); + g_App.Panels[g_App.LastFocusedPanel].Move(0, headerSize, xSize, ySize); } } diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp index ac6e7d4b..9807b958 100755 --- a/CPP/7zip/UI/FileManager/Panel.cpp +++ b/CPP/7zip/UI/FileManager/Panel.cpp @@ -515,7 +515,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) _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}; + int sizes[] = {150, 250, 350, -1}; _statusBar.SetParts(4, sizes); // _statusBar2.SetParts(5, sizes); diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp index 7a42b2d0..bf746282 100755 --- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp +++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp @@ -145,8 +145,13 @@ static const wchar_t *kStartExtensions[] = { L"exe", L"bat", L"com", L"chm", - L"msi", L"doc", L"xls", L"ppt", L"wps", L"wpt", L"wks", L"xlr", L"wdb", + L"msi", L"doc", L"xls", L"ppt", L"pps", L"wps", L"wpt", L"wks", L"xlr", L"wdb", + + L"docx", L"docm", L"dotx", L"dotm", L"xlsx", L"xlsm", L"xltx", L"xltm", L"xlsb", + L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn", + L"odt", L"ods", + L"wb3", L"pdf" }; diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp index 69b06119..572118d0 100755 --- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp +++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp @@ -9,7 +9,6 @@ #include "Windows/PropVariant.h" #include "Windows/PropVariantConversions.h" -// #include "Windows/COM.h" #include "../Common/PropIDUtils.h" #include "../../PropID.h" @@ -19,26 +18,56 @@ using namespace NWindows; -static UString ConvertSizeToString(UINT64 value) +static UString ConvertSizeToStringShort(UInt64 value) { - wchar_t s[64]; - if (value < (UINT64(10000) << 0) /*&& ((value & 0x3FF) != 0 || value == 0)*/) + wchar_t s[32]; + wchar_t c, c2 = L'B'; + if (value < (UInt64)10000) { - ConvertUInt64ToString(value, s); - return UString(s) + L" B"; + c = L'B'; + c2 = L'\0'; } - if (value < (UINT64(10000) << 10)) + else if (value < ((UInt64)10000 << 10)) { - ConvertUInt64ToString((value >> 10), s); - return UString(s) + L" K"; + value >>= 10; + c = L'K'; } - if (value < (UINT64(10000) << 20)) + else if (value < ((UInt64)10000 << 20)) { - ConvertUInt64ToString((value >> 20), s); - return UString(s) + L" M"; + value >>= 20; + c = L'M'; } - ConvertUInt64ToString((value >> 30), s); - return UString(s) + L" G"; + else + { + value >>= 30; + c = L'G'; + } + ConvertUInt64ToString(value, s); + int p = MyStringLen(s); + s[p++] = L' '; + s[p++] = c; + s[p++] = c2; + s[p++] = L'\0'; + return s; +} + +static UString ConvertSizeToString(UInt64 value) +{ + wchar_t s[32]; + ConvertUInt64ToString(value, s); + int i = MyStringLen(s); + int pos = sizeof(s) / sizeof(s[0]); + s[--pos] = L'\0'; + while (i > 3) + { + s[--pos] = s[--i]; + s[--pos] = s[--i]; + s[--pos] = s[--i]; + s[--pos] = L' '; + } + while (i > 0) + s[--pos] = s[--i]; + return s + pos; } LRESULT CPanel::SetItemText(LVITEMW &item) @@ -60,11 +89,11 @@ LRESULT CPanel::SetItemText(LVITEMW &item) } if (!defined) { - NCOM::CPropVariant propVariant; - _folder->GetProperty(index, kpidAttributes, &propVariant); + NCOM::CPropVariant prop; + _folder->GetProperty(index, kpidAttributes, &prop); UINT32 attributes = 0; - if (propVariant.vt == VT_UI4) - attributes = propVariant.ulVal; + if (prop.vt == VT_UI4) + attributes = prop.ulVal; else { if (IsItemFolder(index)) @@ -109,7 +138,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item) */ // const NFind::CFileInfo &aFileInfo = m_Files[index]; - NCOM::CPropVariant propVariant; + NCOM::CPropVariant prop; /* bool needRead = true; if (propID == kpidSize) @@ -117,26 +146,26 @@ LRESULT CPanel::SetItemText(LVITEMW &item) CComPtr getItemFullSize; if (_folder.QueryInterface(&getItemFullSize) == S_OK) { - if (getItemFullSize->GetItemFullSize(index, &propVariant) == S_OK) + if (getItemFullSize->GetItemFullSize(index, &prop) == S_OK) needRead = false; } } if (needRead) */ - if (_folder->GetProperty(realIndex, propID, &propVariant) != S_OK) + if (_folder->GetProperty(realIndex, propID, &prop) != S_OK) throw 2723407; - if ((propID == kpidSize || propID == kpidPackedSize || - propID == kpidTotalSize || propID == kpidFreeSpace || - propID == kpidClusterSize) - && - (propVariant.vt == VT_UI8 || propVariant.vt == VT_UI4)) - s = ConvertSizeToString(ConvertPropVariantToUInt64(propVariant)); + if ((propID == kpidSize || propID == kpidPackedSize || propID == kpidClusterSize || + propID == kpidNumSubFolders || propID == kpidNumSubFiles) && + (prop.vt == VT_UI8 || prop.vt == VT_UI4)) + s = ConvertSizeToString(ConvertPropVariantToUInt64(prop)); + else if ((propID == kpidTotalSize || propID == kpidFreeSpace) && + (prop.vt == VT_UI8 || prop.vt == VT_UI4)) + s = ConvertSizeToStringShort(ConvertPropVariantToUInt64(prop)); else - s = ConvertPropertyToString(propVariant, propID, false); - { + s = ConvertPropertyToString(prop, propID, false); s.Replace(wchar_t(0xA), L' '); s.Replace(wchar_t(0xD), L' '); } @@ -364,7 +393,7 @@ void CPanel::OnRefreshStatusBar() if (indices.Size() > 0) { - UINT64 totalSize = 0; + UInt64 totalSize = 0; for (int i = 0; i < indices.Size(); i++) totalSize += GetItemSize(indices[i]); selectSizeString = ConvertSizeToString(totalSize); @@ -380,9 +409,9 @@ void CPanel::OnRefreshStatusBar() if (realIndex != kParentIndex) { sizeString = ConvertSizeToString(GetItemSize(realIndex)); - NCOM::CPropVariant propVariant; - if (_folder->GetProperty(realIndex, kpidLastWriteTime, &propVariant) == S_OK) - dateString = ConvertPropertyToString(propVariant, kpidLastWriteTime, false); + NCOM::CPropVariant prop; + if (_folder->GetProperty(realIndex, kpidLastWriteTime, &prop) == S_OK) + dateString = ConvertPropertyToString(prop, kpidLastWriteTime, false); } } _statusBar.SetText(2, sizeString); diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.rc b/CPP/7zip/UI/FileManager/ProgressDialog2.rc index d505033f..58cdec36 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.rc +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.rc @@ -10,7 +10,7 @@ #define bYPos (ySize - marg - bYSize) #undef bXSize -#define bXSize 72 +#define bXSize 80 #define bXPos1 (xSize - marg - bXSize) #define bXPos2 (bXPos1 - 10 - bXSize) diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp index 6836f724..51d215bc 100755 --- a/CPP/7zip/UI/GUI/CompressDialog.cpp +++ b/CPP/7zip/UI/GUI/CompressDialog.cpp @@ -409,6 +409,8 @@ void CCompressDialog::CheckControlsEnable() 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); + + ShowItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames); } bool CCompressDialog::IsSFX() @@ -1022,13 +1024,16 @@ void CCompressDialog::SetDictionary() } case kBZip2: { - UInt32 defaultDictionary; - if (level >= 5) - defaultDictionary = (900 << 10); - else if (level >= 3) - defaultDictionary = (500 << 10); - else - defaultDictionary = (100 << 10); + // UInt32 defaultDictionary; + if (defaultDictionary == UInt32(-1)) + { + 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; diff --git a/CPP/Build.mak b/CPP/Build.mak index d2595560..fd411aba 100755 --- a/CPP/Build.mak +++ b/CPP/Build.mak @@ -1,7 +1,9 @@ !IFDEF CPU +!IFNDEF NO_BUFFEROVERFLOWU LIBS = $(LIBS) bufferoverflowU.lib -CFLAGS = $(CFLAGS) -GS- -Zc:forScope !ENDIF +!ENDIF + !IFNDEF O !IFDEF CPU @@ -21,7 +23,7 @@ MY_ML = ml64 COMPL_ASM = $(MY_ML) -c -Fo$O/ $** -CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -EHsc -Gz -WX -Gy +CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -WX -EHsc -Gr -Gy -GR- !IFDEF MY_STATIC_LINK !IFNDEF MY_SINGLE_THREAD @@ -32,14 +34,15 @@ CFLAGS = $(CFLAGS) -MD !ENDIF !IFDEF NEW_COMPILER -CFLAGS_O1 = $(CFLAGS) -O1 -W4 -Wp64 -CFLAGS_O2 = $(CFLAGS) -O2 -W4 -Wp64 +CFLAGS = $(CFLAGS) -W4 -GS- -Zc:forScope !ELSE -CFLAGS_O1 = $(CFLAGS) -O1 -W3 -CFLAGS_O2 = $(CFLAGS) -O2 -W3 +CFLAGS = $(CFLAGS) -W3 !ENDIF -LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98 -OPT:REF +CFLAGS_O1 = $(CFLAGS) -O1 +CFLAGS_O2 = $(CFLAGS) -O2 + +LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98 -OPT:REF -OPT:ICF !IFDEF DEF_FILE LFLAGS = $(LFLAGS) -DLL -DEF:$(DEF_FILE) diff --git a/CPP/Common/CRC.cpp b/CPP/Common/CRC.cpp index b768128c..f151471b 100755 --- a/CPP/Common/CRC.cpp +++ b/CPP/Common/CRC.cpp @@ -7,8 +7,4 @@ extern "C" #include "../../C/7zCrc.h" } -class CCRCTableInit -{ -public: - CCRCTableInit() { CrcGenerateTable(); } -} g_CRCTableInit; +struct CCRCTableInit { CCRCTableInit() { CrcGenerateTable(); } } g_CRCTableInit; diff --git a/CPP/Common/ListFileUtils.cpp b/CPP/Common/ListFileUtils.cpp index 4f8a9e59..cf03d324 100755 --- a/CPP/Common/ListFileUtils.cpp +++ b/CPP/Common/ListFileUtils.cpp @@ -2,6 +2,7 @@ #include "StdAfx.h" +#include "MyWindows.h" #include "../Windows/FileIO.h" #include "ListFileUtils.h" diff --git a/CPP/Common/StringConvert.cpp b/CPP/Common/StringConvert.cpp index c0b19e16..762efd8d 100755 --- a/CPP/Common/StringConvert.cpp +++ b/CPP/Common/StringConvert.cpp @@ -26,23 +26,31 @@ UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) return resultString; } -AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage) +AString UnicodeStringToMultiByte(const UString &s, UINT codePage, char defaultChar, bool &defaultCharWasUsed) { - AString resultString; - if(!srcString.IsEmpty()) + AString dest; + defaultCharWasUsed = false; + if (!s.IsEmpty()) { - int numRequiredBytes = srcString.Length() * 2; - char defaultChar = '_'; - int numChars = WideCharToMultiByte(codePage, 0, srcString, - srcString.Length(), resultString.GetBuffer(numRequiredBytes), - numRequiredBytes + 1, &defaultChar, NULL); + int numRequiredBytes = s.Length() * 2; + BOOL defUsed; + int numChars = WideCharToMultiByte(codePage, 0, s, s.Length(), + dest.GetBuffer(numRequiredBytes), numRequiredBytes + 1, + &defaultChar, &defUsed); + defaultCharWasUsed = (defUsed != FALSE); #ifndef _WIN32_WCE if(numChars == 0) throw 282229; #endif - resultString.ReleaseBuffer(numChars); + dest.ReleaseBuffer(numChars); } - return resultString; + return dest; +} + +AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage) +{ + bool defaultCharWasUsed; + return UnicodeStringToMultiByte(srcString, codePage, '_', defaultCharWasUsed); } #ifndef _WIN32_WCE diff --git a/CPP/Common/StringConvert.h b/CPP/Common/StringConvert.h index 32d8a3a1..0c37eb07 100755 --- a/CPP/Common/StringConvert.h +++ b/CPP/Common/StringConvert.h @@ -8,8 +8,10 @@ #include "Types.h" UString MultiByteToUnicodeString(const AString &srcString, UINT codePage = CP_ACP); +AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage, char defaultChar, bool &defaultCharWasUsed); AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage = CP_ACP); + inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString) { return unicodeString; } inline const UString& GetUnicodeString(const UString &unicodeString) diff --git a/CPP/Common/Types.h b/CPP/Common/Types.h index 41d785e9..9365b327 100755 --- a/CPP/Common/Types.h +++ b/CPP/Common/Types.h @@ -3,55 +3,9 @@ #ifndef __COMMON_TYPES_H #define __COMMON_TYPES_H -#ifndef _7ZIP_BYTE_DEFINED -#define _7ZIP_BYTE_DEFINED -typedef unsigned char Byte; -#endif +#include "../../C/Types.h" -#ifndef _7ZIP_INT16_DEFINED -#define _7ZIP_INT16_DEFINED -typedef short Int16; -#endif - -#ifndef _7ZIP_UINT16_DEFINED -#define _7ZIP_UINT16_DEFINED -typedef unsigned short UInt16; -#endif - -#ifndef _7ZIP_INT32_DEFINED -#define _7ZIP_INT32_DEFINED -typedef int Int32; -#endif - -#ifndef _7ZIP_UINT32_DEFINED -#define _7ZIP_UINT32_DEFINED -typedef unsigned int UInt32; -#endif - -#ifdef _MSC_VER - -#ifndef _7ZIP_INT64_DEFINED -#define _7ZIP_INT64_DEFINED -typedef __int64 Int64; -#endif - -#ifndef _7ZIP_UINT64_DEFINED -#define _7ZIP_UINT64_DEFINED -typedef unsigned __int64 UInt64; -#endif - -#else - -#ifndef _7ZIP_INT64_DEFINED -#define _7ZIP_INT64_DEFINED -typedef long long int Int64; -#endif - -#ifndef _7ZIP_UINT64_DEFINED -#define _7ZIP_UINT64_DEFINED -typedef unsigned long long int UInt64; -#endif +typedef int HRes; #endif -#endif diff --git a/CPP/Windows/PropVariantConversions.cpp b/CPP/Windows/PropVariantConversions.cpp index 993dac76..0596d723 100755 --- a/CPP/Windows/PropVariantConversions.cpp +++ b/CPP/Windows/PropVariantConversions.cpp @@ -66,6 +66,11 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool { *s++ = ':'; UIntToStringSpec(st.wSecond, s, 2); + /* + s += 2; + *s++ = '.'; + UIntToStringSpec(st.wMilliseconds, s, 3); + */ } } /* diff --git a/CPP/Windows/Synchronization.h b/CPP/Windows/Synchronization.h index c16f7b4d..e9668de8 100755 --- a/CPP/Windows/Synchronization.h +++ b/CPP/Windows/Synchronization.h @@ -26,9 +26,9 @@ public: operator HANDLE() { return _object.handle; } CBaseEvent() { Event_Construct(&_object); } ~CBaseEvent() { Close(); } - HRes Close() { return Event_Close(&_object); } + WRes Close() { return Event_Close(&_object); } #ifdef _WIN32 - HRes Create(bool manualReset, bool initiallyOwn, LPCTSTR name = NULL, + WRes Create(bool manualReset, bool initiallyOwn, LPCTSTR name = NULL, LPSECURITY_ATTRIBUTES securityAttributes = NULL) { _object.handle = ::CreateEvent(securityAttributes, BoolToBOOL(manualReset), @@ -37,7 +37,7 @@ public: return 0; return ::GetLastError(); } - HRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name) + WRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name) { _object.handle = ::OpenEvent(desiredAccess, BoolToBOOL(inheritHandle), name); if (_object.handle != 0) @@ -46,27 +46,27 @@ public: } #endif - HRes Set() { return Event_Set(&_object); } + WRes Set() { return Event_Set(&_object); } // bool Pulse() { return BOOLToBool(::PulseEvent(_handle)); } - HRes Reset() { return Event_Reset(&_object); } - HRes Lock() { return Event_Wait(&_object); } + WRes Reset() { return Event_Reset(&_object); } + WRes Lock() { return Event_Wait(&_object); } }; class CManualResetEvent: public CBaseEvent { public: - HRes Create(bool initiallyOwn = false) + WRes Create(bool initiallyOwn = false) { return ManualResetEvent_Create(&_object, initiallyOwn ? 1: 0); } - HRes CreateIfNotCreated() + WRes CreateIfNotCreated() { if (IsCreated()) return 0; return ManualResetEvent_CreateNotSignaled(&_object); } #ifdef _WIN32 - HRes CreateWithName(bool initiallyOwn, LPCTSTR name) + WRes CreateWithName(bool initiallyOwn, LPCTSTR name) { return CBaseEvent::Create(true, initiallyOwn, name); } @@ -76,11 +76,11 @@ public: class CAutoResetEvent: public CBaseEvent { public: - HRes Create() + WRes Create() { return AutoResetEvent_CreateNotSignaled(&_object); } - HRes CreateIfNotCreated() + WRes CreateIfNotCreated() { if (IsCreated()) return 0; @@ -92,13 +92,13 @@ public: class CObject: public CHandle { public: - HRes Lock(DWORD timeoutInterval = INFINITE) + WRes Lock(DWORD timeoutInterval = INFINITE) { return (::WaitForSingleObject(_handle, timeoutInterval) == WAIT_OBJECT_0 ? 0 : ::GetLastError()); } }; class CMutex: public CObject { public: - HRes Create(bool initiallyOwn, LPCTSTR name = NULL, + WRes Create(bool initiallyOwn, LPCTSTR name = NULL, LPSECURITY_ATTRIBUTES securityAttributes = NULL) { _handle = ::CreateMutex(securityAttributes, BoolToBOOL(initiallyOwn), name); @@ -106,14 +106,14 @@ public: return 0; return ::GetLastError(); } - HRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name) + WRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name) { _handle = ::OpenMutex(desiredAccess, BoolToBOOL(inheritHandle), name); if (_handle != 0) return 0; return ::GetLastError(); } - HRes Release() + WRes Release() { return ::ReleaseMutex(_handle) ? 0 : ::GetLastError(); } @@ -133,15 +133,15 @@ class CSemaphore public: CSemaphore() { Semaphore_Construct(&_object); } ~CSemaphore() { Close(); } - HRes Close() { return Semaphore_Close(&_object); } + WRes Close() { return Semaphore_Close(&_object); } operator HANDLE() { return _object.handle; } - HRes Create(UInt32 initiallyCount, UInt32 maxCount) + WRes Create(UInt32 initiallyCount, UInt32 maxCount) { return Semaphore_Create(&_object, initiallyCount, maxCount); } - HRes Release() { return Semaphore_Release1(&_object); } - HRes Release(UInt32 releaseCount) { return Semaphore_ReleaseN(&_object, releaseCount); } - HRes Lock() { return Semaphore_Wait(&_object); } + WRes Release() { return Semaphore_Release1(&_object); } + WRes Release(UInt32 releaseCount) { return Semaphore_ReleaseN(&_object, releaseCount); } + WRes Lock() { return Semaphore_Wait(&_object); } }; class CCriticalSection diff --git a/CPP/Windows/Thread.h b/CPP/Windows/Thread.h index a46a5688..59760d4d 100755 --- a/CPP/Windows/Thread.h +++ b/CPP/Windows/Thread.h @@ -19,10 +19,10 @@ public: CThread() { Thread_Construct(&thread); } ~CThread() { Close(); } bool IsCreated() { return Thread_WasCreated(&thread) != 0; } - HRes Close() { return Thread_Close(&thread); } - HRes Create(THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter) + WRes Close() { return Thread_Close(&thread); } + WRes Create(THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter) { return Thread_Create(&thread, startAddress, parameter); } - HRes Wait() { return Thread_Wait(&thread); } + WRes Wait() { return Thread_Wait(&thread); } #ifdef _WIN32 DWORD Resume() { return ::ResumeThread(thread.handle); } -- cgit v1.2.3