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

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/CPP
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2010-11-18 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:05 +0300
commitde4f8c22fe4b9e59b60495b84db2e81de50999a9 (patch)
tree496da451ff6616360219f42db53fb36cad7d447f /CPP
parentb75af1bba61529be6787dc470f9db60906a182e5 (diff)
9.209.20
Diffstat (limited to 'CPP')
-rwxr-xr-xCPP/7zip/Archive/SquashfsHandler.cpp208
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.cpp2
-rwxr-xr-xCPP/7zip/Compress/LzmaDecoder.cpp2
-rwxr-xr-xCPP/7zip/MyVersion.h8
-rwxr-xr-xCPP/7zip/UI/Console/UserInputUtils.cpp2
-rwxr-xr-xCPP/7zip/UI/Far/PluginDelete.cpp2
-rwxr-xr-xCPP/7zip/UI/Far/PluginWrite.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelItemOpen.cpp2
8 files changed, 214 insertions, 16 deletions
diff --git a/CPP/7zip/Archive/SquashfsHandler.cpp b/CPP/7zip/Archive/SquashfsHandler.cpp
index e09c09de..2cc1219a 100755
--- a/CPP/7zip/Archive/SquashfsHandler.cpp
+++ b/CPP/7zip/Archive/SquashfsHandler.cpp
@@ -859,6 +859,8 @@ class CHandler:
NCompress::NZlib::CDecoder *_zlibDecoderSpec;
CMyComPtr<ICompressCoder> _zlibDecoder;
+
+ CByteBuffer _inputBuffer;
CDynBufSeqOutStream *_dynOutStreamSpec;
CMyComPtr<ISequentialOutStream> _dynOutStream;
@@ -870,7 +872,8 @@ class CHandler:
_cachedUnpackBlockSize = 0;
}
- HRESULT Decompress(ISequentialOutStream *outStream, UInt32 inSize, UInt32 outSizeMax);
+ HRESULT Decompress(ISequentialOutStream *outStream, Byte *outBuf, bool *outBufWasWritten, UInt32 *outBufWasWrittenSize,
+ UInt32 inSize, UInt32 outSizeMax);
HRESULT ReadMetadataBlock(UInt32 &packSize);
HRESULT ReadData(CData &data, UInt64 start, UInt64 end);
@@ -932,8 +935,166 @@ static const STATPROPSTG kArcProps[] =
IMP_IInArchive_Props
IMP_IInArchive_ArcProps
-HRESULT CHandler::Decompress(ISequentialOutStream *outStream, UInt32 inSize, UInt32 outSizeMax)
+static HRESULT LzoDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
+{
+ SizeT destRem = *destLen;
+ SizeT srcRem = *srcLen;
+ *destLen = 0;
+ *srcLen = 0;
+ const Byte *destStart = dest;
+ const Byte *srcStart = src;
+ unsigned mode = 2;
+
+ {
+ if (srcRem == 0)
+ return S_FALSE;
+ UInt32 b = *src;
+ if (b > 17)
+ {
+ src++;
+ srcRem--;
+ b -= 17;
+ mode = (b < 4 ? 0 : 1);
+ if (b > srcRem || b > destRem)
+ return S_FALSE;
+ srcRem -= b;
+ destRem -= b;
+ do
+ *dest++ = *src++;
+ while (--b);
+ }
+ }
+
+ for (;;)
+ {
+ if (srcRem < 3)
+ return S_FALSE;
+ UInt32 b = *src++;
+ srcRem--;
+ UInt32 len, back;
+ if (b >= 64)
+ {
+ srcRem--;
+ back = ((b >> 2) & 7) + ((UInt32)*src++ << 3);
+ len = (b >> 5) + 1;
+ }
+ else if (b < 16)
+ {
+ if (mode == 2)
+ {
+ if (b == 0)
+ {
+ for (b = 15;; b += 255)
+ {
+ if (srcRem == 0)
+ return S_FALSE;
+ UInt32 b2 = *src++;
+ srcRem--;
+ if (b2 != 0)
+ {
+ b += b2;
+ break;
+ }
+ }
+ }
+ b += 3;
+ if (b > srcRem || b > destRem)
+ return S_FALSE;
+ srcRem -= b;
+ destRem -= b;
+ mode = 1;
+ do
+ *dest++ = *src++;
+ while (--b);
+ continue;
+ }
+ srcRem--;
+ back = (b >> 2) + (*src++ << 2);
+ len = 2;
+ if (mode == 1)
+ {
+ back += (1 << 11);
+ len = 3;
+ }
+ }
+ else
+ {
+ UInt32 bOld = b;
+ b = (b < 32 ? 7 : 31);
+ len = bOld & b;
+ if (len == 0)
+ {
+ for (len = b;; len += 255)
+ {
+ if (srcRem == 0)
+ return S_FALSE;
+ UInt32 b2 = *src++;
+ srcRem--;
+ if (b2 != 0)
+ {
+ len += b2;
+ break;
+ }
+ }
+ }
+ len += 2;
+ if (srcRem < 2)
+ return S_FALSE;
+ b = *src;
+ back = (b >> 2) + ((UInt32)src[1] << 6);
+ src += 2;
+ srcRem -= 2;
+ if (bOld < 32)
+ {
+ if (back == 0)
+ {
+ *destLen = dest - destStart;
+ *srcLen = src - srcStart;
+ return S_OK;
+ }
+ back += ((bOld & 8) << 11) + (1 << 14) - 1;
+ }
+ }
+ back++;
+ if (len > destRem || (size_t)(dest - destStart) < back)
+ return S_FALSE;
+ destRem -= len;
+ Byte *destTemp = dest - back;
+ dest += len;
+ do
+ {
+ *(destTemp + back) = *destTemp;
+ destTemp++;
+ }
+ while (--len);
+ b &= 3;
+ if (b == 0)
+ {
+ mode = 2;
+ continue;
+ }
+ if (b > srcRem || b > destRem)
+ return S_FALSE;
+ srcRem -= b;
+ destRem -= b;
+ mode = 0;
+ *dest++ = *src++;
+ if (b > 1)
+ {
+ *dest++ = *src++;
+ if (b > 2)
+ *dest++ = *src++;
+ }
+ }
+}
+
+HRESULT CHandler::Decompress(ISequentialOutStream *outStream, Byte *outBuf, bool *outBufWasWritten, UInt32 *outBufWasWrittenSize, UInt32 inSize, UInt32 outSizeMax)
{
+ if (outBuf)
+ {
+ *outBufWasWritten = false;
+ *outBufWasWrittenSize = 0;
+ }
UInt32 method = _h.Method;
if (_h.SeveralMethods)
{
@@ -943,11 +1104,40 @@ HRESULT CHandler::Decompress(ISequentialOutStream *outStream, UInt32 inSize, UIn
RINOK(_stream->Seek(-1, STREAM_SEEK_CUR, NULL));
}
- if (method == kMethod_LZMA)
+ if (method == kMethod_LZO)
+ {
+ if (_inputBuffer.GetCapacity() < inSize)
+ {
+ _inputBuffer.Free();
+ _inputBuffer.SetCapacity(inSize);
+ }
+ RINOK(ReadStream_FALSE(_stream, _inputBuffer, inSize));
+
+ Byte *dest = outBuf;
+ if (!outBuf)
+ {
+ dest = _dynOutStreamSpec->GetBufPtrForWriting(outSizeMax);
+ if (!dest)
+ return E_OUTOFMEMORY;
+ }
+ SizeT destLen = outSizeMax, srcLen = inSize;
+ RINOK(LzoDecode(dest, &destLen, _inputBuffer, &srcLen));
+ if (inSize != srcLen)
+ return S_FALSE;
+ if (outBuf)
+ {
+ *outBufWasWritten = true;
+ *outBufWasWrittenSize = (UInt32)destLen;
+ }
+ else
+ _dynOutStreamSpec->UpdateSize(destLen);
+ }
+ else if (method == kMethod_LZMA)
{
if (!_lzmaDecoder)
{
_lzmaDecoderSpec = new NCompress::NLzma::CDecoder();
+ _lzmaDecoderSpec->FinishStream = true;
_lzmaDecoder = _lzmaDecoderSpec;
}
const UInt32 kPropsSize = 5 + 8;
@@ -995,7 +1185,7 @@ HRESULT CHandler::ReadMetadataBlock(UInt32 &packSize)
if (isCompressed)
{
_limitedInStreamSpec->Init(size);
- RINOK(Decompress(_dynOutStream, size, kMetadataBlockSize));
+ RINOK(Decompress(_dynOutStream, NULL, NULL, NULL, size, kMetadataBlockSize));
}
else
{
@@ -1227,6 +1417,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
{
case kMethod_ZLIB:
case kMethod_LZMA:
+ case kMethod_LZO:
break;
default:
return E_NOTIMPL;
@@ -1779,8 +1970,13 @@ HRESULT CHandler::ReadBlock(UInt64 blockIndex, Byte *dest, size_t blockSize)
if (compressed)
{
_outStreamSpec->Init((Byte *)_cachedBlock, _h.BlockSize);
- HRESULT res = Decompress(_outStream, packBlockSize, _h.BlockSize);
- _cachedUnpackBlockSize = (UInt32)_outStreamSpec->GetPos();
+ bool outBufWasWritten;
+ UInt32 outBufWasWrittenSize;
+ HRESULT res = Decompress(_outStream, _cachedBlock, &outBufWasWritten, &outBufWasWrittenSize, packBlockSize, _h.BlockSize);
+ if (outBufWasWritten)
+ _cachedUnpackBlockSize = outBufWasWrittenSize;
+ else
+ _cachedUnpackBlockSize = (UInt32)_outStreamSpec->GetPos();
RINOK(res);
}
else
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp
index e54b15ba..bd156322 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp
@@ -70,8 +70,8 @@ static const char *kMethods[] =
"Shrink",
"Reduced1",
"Reduced2",
- "Reduced2",
"Reduced3",
+ "Reduced4",
"Implode",
"Tokenizing",
"Deflate",
diff --git a/CPP/7zip/Compress/LzmaDecoder.cpp b/CPP/7zip/Compress/LzmaDecoder.cpp
index dadd3aba..b7c260bd 100755
--- a/CPP/7zip/Compress/LzmaDecoder.cpp
+++ b/CPP/7zip/Compress/LzmaDecoder.cpp
@@ -108,7 +108,7 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
if (_outSizeDefined)
{
const UInt64 rem = _outSize - _outSizeProcessed;
- if (rem < curSize)
+ if (rem <= curSize)
{
curSize = (SizeT)rem;
if (FinishStream)
diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h
index f3c49653..eda88db0 100755
--- a/CPP/7zip/MyVersion.h
+++ b/CPP/7zip/MyVersion.h
@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 9
-#define MY_VER_MINOR 19
+#define MY_VER_MINOR 20
#define MY_VER_BUILD 0
-#define MY_VERSION "9.19 beta"
-#define MY_7ZIP_VERSION "7-Zip 9.19 beta"
-#define MY_DATE "2010-11-11"
+#define MY_VERSION "9.20"
+#define MY_7ZIP_VERSION "7-Zip 9.20"
+#define MY_DATE "2010-11-18"
#define MY_COPYRIGHT "Copyright (c) 1999-2010 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE
diff --git a/CPP/7zip/UI/Console/UserInputUtils.cpp b/CPP/7zip/UI/Console/UserInputUtils.cpp
index 30ed5f99..75468009 100755
--- a/CPP/7zip/UI/Console/UserInputUtils.cpp
+++ b/CPP/7zip/UI/Console/UserInputUtils.cpp
@@ -78,6 +78,8 @@ UString GetPassword(CStdOutStream *outStream)
UString res = g_StdIn.ScanUStringUntilNewLine();
if (wasChanged)
SetConsoleMode(console, mode);
+ (*outStream) << "\n";
+ outStream->Flush();
return res;
#else
return g_StdIn.ScanUStringUntilNewLine();
diff --git a/CPP/7zip/UI/Far/PluginDelete.cpp b/CPP/7zip/UI/Far/PluginDelete.cpp
index 182fbfb0..c8d784c3 100755
--- a/CPP/7zip/UI/Far/PluginDelete.cpp
+++ b/CPP/7zip/UI/Far/PluginDelete.cpp
@@ -103,7 +103,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
- updateCallbackSpec->Init(/* m_ArchiveHandler, */ &progressBox);
+ updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
result = outArchive->DeleteItems(
diff --git a/CPP/7zip/UI/Far/PluginWrite.cpp b/CPP/7zip/UI/Far/PluginWrite.cpp
index ca515c42..be9616a4 100755
--- a/CPP/7zip/UI/Far/PluginWrite.cpp
+++ b/CPP/7zip/UI/Far/PluginWrite.cpp
@@ -234,7 +234,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
- updateCallbackSpec->Init(/* m_ArchiveHandler, */ &progressBox);
+ updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
return NFileOperationReturnCode::kError;
@@ -742,7 +742,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
- updateCallbackSpec->Init(/* archiveHandler, */ &progressBox);
+ updateCallbackSpec->Init(/* archiveHandler, */ progressBoxPointer);
RINOK(SetOutProperties(outArchive, compressionInfo.Level));
diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
index 10a8b73c..934e98d3 100755
--- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
@@ -212,7 +212,7 @@ static const char *kStartExtensions =
" chm"
" msi doc xls ppt pps wps wpt wks xlr wdb vsd pub"
- " docx docm dotx dotm xlsx xlsm xltx xltm xlsb"
+ " docx docm dotx dotm xlsx xlsm xltx xltm xlsb xps"
" xlam pptx pptm potx potm ppam ppsx ppsm xsn"
" mpp"
" msg"