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

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2010-03-15 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:02 +0300
commit993daef9cbed7febf494217f07e40e0a26b3bc06 (patch)
tree41db24cb11222422aa3c4d61b80646344e3efefc /CPP/7zip/Archive/Zip
parentdb5eb6d638f5a5ec10517ed4a994b849a6cc7d29 (diff)
9.119.11
Diffstat (limited to 'CPP/7zip/Archive/Zip')
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.cpp28
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipCompressionMode.h3
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.cpp3
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.h5
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandlerOut.cpp50
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHeader.h1
6 files changed, 85 insertions, 5 deletions
diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
index 0a74a3d1..7fed3cab 100755
--- a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
@@ -15,6 +15,7 @@
#include "../../Common/StreamUtils.h"
#include "../../Compress/LzmaEncoder.h"
+#include "../../Compress/PpmdZip.h"
#include "../Common/InStreamWithCRC.h"
@@ -169,13 +170,14 @@ HRESULT CAddCommon::Compress(
else
{
if (!_cryptoStreamSpec->Filter)
+ {
_cryptoStreamSpec->Filter = _filterSpec = new NCrypto::NZip::CEncoder;
- RINOK(_filterSpec->CryptoSetPassword((const Byte *)(const char *)_options.Password, _options.Password.Length()));
+ _filterSpec->CryptoSetPassword((const Byte *)(const char *)_options.Password, _options.Password.Length());
+ }
UInt32 crc = 0;
RINOK(GetStreamCRC(inStream, crc));
RINOK(inCrcStreamSpec->Seek(0, STREAM_SEEK_SET, NULL));
- RINOK(_filterSpec->CryptoSetCRC(crc));
- RINOK(_filterSpec->WriteHeader(outStream));
+ RINOK(_filterSpec->WriteHeader(outStream, crc));
}
RINOK(_cryptoStreamSpec->SetOutStream(outStream));
outStreamReleaser.FilterCoder = _cryptoStreamSpec;
@@ -235,6 +237,26 @@ HRESULT CAddCommon::Compress(
numProps--;
RINOK(_lzmaEncoder->SetCoderProperties(propIDs, props, numProps));
}
+ else if (method == NFileHeader::NCompressionMethod::kPPMd)
+ {
+ _compressExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_PPMd;
+ NCompress::NPpmdZip::CEncoder *encoder = new NCompress::NPpmdZip::CEncoder();
+ _compressEncoder = encoder;
+ NWindows::NCOM::CPropVariant props[] =
+ {
+ // _options.Algo,
+ _options.MemSize,
+ _options.Order
+
+ };
+ PROPID propIDs[] =
+ {
+ // NCoderPropID::kAlgorithm,
+ NCoderPropID::kUsedMemorySize,
+ NCoderPropID::kOrder
+ };
+ RINOK(encoder->SetCoderProperties(propIDs, props, sizeof(propIDs) / sizeof(propIDs[0])));
+ }
else
{
CMethodId methodId;
diff --git a/CPP/7zip/Archive/Zip/ZipCompressionMode.h b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
index e5acfa6b..7ef7cfb2 100755
--- a/CPP/7zip/Archive/Zip/ZipCompressionMode.h
+++ b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
@@ -18,6 +18,9 @@ struct CCompressionMethodMode
bool NumMatchFinderCyclesDefined;
UInt32 NumMatchFinderCycles;
UInt32 DicSize;
+ UInt32 MemSize;
+ UInt32 Order;
+
#ifndef _7ZIP_ST
UInt32 NumThreads;
#endif
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp
index df1ca20b..64477766 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp
@@ -18,6 +18,7 @@
#include "../../Compress/CopyCoder.h"
#include "../../Compress/LzmaDecoder.h"
#include "../../Compress/ImplodeDecoder.h"
+#include "../../Compress/PpmdZip.h"
#include "../../Compress/ShrinkDecoder.h"
#include "../../Crypto/WzAes.h"
@@ -595,6 +596,8 @@ HRESULT CZipDecoder::Decode(
mi.Coder = new NCompress::NImplode::NDecoder::CCoder;
else if (methodId == NFileHeader::NCompressionMethod::kLZMA)
mi.Coder = new CLzmaDecoder;
+ else if (methodId == NFileHeader::NCompressionMethod::kPPMd)
+ mi.Coder = new NCompress::NPpmdZip::CDecoder(true);
else
{
CMethodId szMethodID;
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h
index 6236b20c..55ebff25 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.h
+++ b/CPP/7zip/Archive/Zip/ZipHandler.h
@@ -53,6 +53,9 @@ private:
UInt32 m_NumPasses;
UInt32 m_NumFastBytes;
UInt32 m_NumMatchFinderCycles;
+ UInt32 m_MemSize;
+ UInt32 m_Order;
+
bool m_NumMatchFinderCyclesDefined;
bool m_ForceAesMode;
@@ -77,6 +80,8 @@ private:
m_DicSize =
m_NumPasses =
m_NumFastBytes =
+ m_Order =
+ m_MemSize =
m_NumMatchFinderCycles = 0xFFFFFFFF;
m_NumMatchFinderCyclesDefined = false;
m_ForceAesMode = false;
diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
index 3571fdeb..b190dd2f 100755
--- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -51,6 +51,18 @@ static const UInt32 kLzmaDicSizeX5 = 1 << 24;
static const UInt32 kLzmaDicSizeX7 = 1 << 25;
static const UInt32 kLzmaDicSizeX9 = 1 << 26;
+static const UInt32 kPpmdMemSizeX1 = (1 << 20);
+static const UInt32 kPpmdMemSizeX3 = (1 << 22);
+static const UInt32 kPpmdMemSizeX5 = (1 << 24);
+static const UInt32 kPpmdMemSizeX7 = (1 << 26);
+static const UInt32 kPpmdMemSizeX9 = (1 << 27);
+
+static const UInt32 kPpmdOrderX1 = 4;
+static const UInt32 kPpmdOrderX3 = 6;
+static const UInt32 kPpmdOrderX5 = 8;
+static const UInt32 kPpmdOrderX7 = 10;
+static const UInt32 kPpmdOrderX9 = 16;
+
static const UInt32 kBZip2NumPassesX1 = 1;
static const UInt32 kBZip2NumPassesX7 = 2;
static const UInt32 kBZip2NumPassesX9 = 7;
@@ -290,13 +302,14 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
(mainMethod == NFileHeader::NCompressionMethod::kDeflated64);
bool isLZMA = (mainMethod == NFileHeader::NCompressionMethod::kLZMA);
bool isLz = (isLZMA || isDeflate);
- bool isBZip2 = (mainMethod == NFileHeader::NCompressionMethod::kBZip2);
options.NumPasses = m_NumPasses;
options.DicSize = m_DicSize;
options.NumFastBytes = m_NumFastBytes;
options.NumMatchFinderCycles = m_NumMatchFinderCycles;
options.NumMatchFinderCyclesDefined = m_NumMatchFinderCyclesDefined;
options.Algo = m_Algo;
+ options.MemSize = m_MemSize;
+ options.Order = m_Order;
#ifndef _7ZIP_ST
options.NumThreads = _numThreads;
#endif
@@ -336,7 +349,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
options.Algo = (level >= 5 ? kLzAlgoX5 :
kLzAlgoX1);
}
- if (isBZip2)
+ if (mainMethod == NFileHeader::NCompressionMethod::kBZip2)
{
if (options.NumPasses == 0xFFFFFFFF)
options.NumPasses = (level >= 9 ? kBZip2NumPassesX9 :
@@ -347,6 +360,26 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
(level >= 3 ? kBZip2DicSizeX3 :
kBZip2DicSizeX1));
}
+ if (mainMethod == NFileHeader::NCompressionMethod::kPPMd)
+ {
+ if (options.MemSize == 0xFFFFFFFF)
+ options.MemSize =
+ (level >= 9 ? kPpmdMemSizeX9 :
+ (level >= 7 ? kPpmdMemSizeX7 :
+ (level >= 5 ? kPpmdMemSizeX5 :
+ (level >= 3 ? kPpmdMemSizeX3 :
+ kPpmdMemSizeX1))));
+
+ if (options.Order == 0xFFFFFFFF)
+ options.Order =
+ (level >= 9 ? kPpmdOrderX9 :
+ (level >= 7 ? kPpmdOrderX7 :
+ (level >= 5 ? kPpmdOrderX5 :
+ (level >= 3 ? kPpmdOrderX3 :
+ kPpmdOrderX1))));
+
+ options.Algo = 0;
+ }
return Update(
EXTERNAL_CODECS_VARS
@@ -389,6 +422,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
else if (m == L"DEFLATE64") m_MainMethod = NFileHeader::NCompressionMethod::kDeflated64;
else if (m == L"BZIP2") m_MainMethod = NFileHeader::NCompressionMethod::kBZip2;
else if (m == L"LZMA") m_MainMethod = NFileHeader::NCompressionMethod::kLZMA;
+ else if (m == L"PPMD") m_MainMethod = NFileHeader::NCompressionMethod::kPPMd;
else return E_INVALIDARG;
}
else if (prop.vt == VT_UI4)
@@ -446,6 +480,18 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
RINOK(ParsePropDictionaryValue(name.Mid(1), prop, dicSize));
m_DicSize = dicSize;
}
+ else if (name.Left(3) == L"MEM")
+ {
+ UInt32 memSize = kPpmdMemSizeX5;
+ RINOK(ParsePropDictionaryValue(name.Mid(3), prop, memSize));
+ m_MemSize = memSize;
+ }
+ else if (name[0] == L'O')
+ {
+ UInt32 order = kPpmdOrderX5;
+ RINOK(ParsePropValue(name.Mid(1), prop, order));
+ m_Order = order;
+ }
else if (name.Left(4) == L"PASS")
{
UInt32 num = kDeflateNumPassesX9;
diff --git a/CPP/7zip/Archive/Zip/ZipHeader.h b/CPP/7zip/Archive/Zip/ZipHeader.h
index 1233af6c..eeff5980 100755
--- a/CPP/7zip/Archive/Zip/ZipHeader.h
+++ b/CPP/7zip/Archive/Zip/ZipHeader.h
@@ -89,6 +89,7 @@ namespace NFileHeader
const Byte kExtractVersion_BZip2 = 46;
const Byte kExtractVersion_Aes = 51;
const Byte kExtractVersion_LZMA = 63;
+ const Byte kExtractVersion_PPMd = 63;
// const Byte kSupportedVersion = 20;
}