summaryrefslogtreecommitdiffstats
path: root/other-licenses/7zstub/src/7zip/Archive/7z
diff options
context:
space:
mode:
Diffstat (limited to 'other-licenses/7zstub/src/7zip/Archive/7z')
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zCompressionMode.cpp3
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zCompressionMode.h64
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zDecode.cpp443
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zDecode.h71
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zExtract.cpp265
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zFolderOutStream.cpp161
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zFolderOutStream.h57
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zHandler.cpp757
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zHandler.h234
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zHeader.cpp19
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zHeader.h96
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zIn.cpp1294
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zIn.h288
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zItem.h181
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zMethodID.cpp76
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zMethodID.h29
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zMethods.cpp174
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zMethods.h36
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zProperties.cpp166
-rw-r--r--other-licenses/7zstub/src/7zip/Archive/7z/7zProperties.h22
20 files changed, 0 insertions, 4436 deletions
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zCompressionMode.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zCompressionMode.cpp
deleted file mode 100644
index 232c63820..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zCompressionMode.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// CompressionMethod.cpp
-
-#include "StdAfx.h"
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zCompressionMode.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zCompressionMode.h
deleted file mode 100644
index 215d5cbfb..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zCompressionMode.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// 7zCompressionMode.h
-
-#ifndef __7Z_COMPRESSION_MODE_H
-#define __7Z_COMPRESSION_MODE_H
-
-#include "../../../Windows/PropVariant.h"
-
-#include "7zMethodID.h"
-
-namespace NArchive {
-namespace N7z {
-
-struct CProperty
-{
- PROPID PropID;
- NWindows::NCOM::CPropVariant Value;
-};
-
-struct CMethodFull
-{
- CMethodID MethodID;
- UInt32 NumInStreams;
- UInt32 NumOutStreams;
- bool IsSimpleCoder() const
- { return (NumInStreams == 1) && (NumOutStreams == 1); }
-
- #ifdef EXCLUDE_COM
- #else
- CLSID EncoderClassID;
- CSysString FilePath;
- #endif
-
- CObjectVector<CProperty> CoderProperties;
-};
-
-struct CBind
-{
- UInt32 InCoder;
- UInt32 InStream;
- UInt32 OutCoder;
- UInt32 OutStream;
-};
-
-struct CCompressionMethodMode
-{
- CObjectVector<CMethodFull> Methods;
- CRecordVector<CBind> Binds;
- #ifdef COMPRESS_MT
- UInt32 NumThreads;
- #endif
- bool PasswordIsDefined;
- UString Password;
-
- bool IsEmpty() const { return (Methods.IsEmpty() && !PasswordIsDefined); }
- CCompressionMethodMode(): PasswordIsDefined(false)
- #ifdef COMPRESS_MT
- , NumThreads(1)
- #endif
- {}
-};
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zDecode.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zDecode.cpp
deleted file mode 100644
index 7f8f14965..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zDecode.cpp
+++ /dev/null
@@ -1,443 +0,0 @@
-// 7zDecode.cpp
-
-#include "StdAfx.h"
-
-#include "7zDecode.h"
-
-#include "../../IPassword.h"
-#include "../../Common/LockedStream.h"
-#include "../../Common/StreamObjects.h"
-#include "../../Common/ProgressUtils.h"
-#include "../../Common/LimitedStreams.h"
-#include "../Common/FilterCoder.h"
-
-#include "7zMethods.h"
-
-#ifdef COMPRESS_LZMA
-#include "../../Compress/LZMA/LZMADecoder.h"
-static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
-#endif
-
-#ifdef COMPRESS_PPMD
-#include "../../Compress/PPMD/PPMDDecoder.h"
-static NArchive::N7z::CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
-#endif
-
-#ifdef COMPRESS_BCJ_X86
-#include "../../Compress/Branch/x86.h"
-static NArchive::N7z::CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
-#endif
-
-#ifdef COMPRESS_BCJ2
-#include "../../Compress/Branch/x86_2.h"
-static NArchive::N7z::CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
-#endif
-
-#ifdef COMPRESS_DEFLATE
-#ifndef COMPRESS_DEFLATE_DECODER
-#define COMPRESS_DEFLATE_DECODER
-#endif
-#endif
-
-#ifdef COMPRESS_DEFLATE_DECODER
-#include "../../Compress/Deflate/DeflateDecoder.h"
-static NArchive::N7z::CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
-#endif
-
-#ifdef COMPRESS_BZIP2
-#ifndef COMPRESS_BZIP2_DECODER
-#define COMPRESS_BZIP2_DECODER
-#endif
-#endif
-
-#ifdef COMPRESS_BZIP2_DECODER
-#include "../../Compress/BZip2/BZip2Decoder.h"
-static NArchive::N7z::CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
-#endif
-
-#ifdef COMPRESS_COPY
-#include "../../Compress/Copy/CopyCoder.h"
-static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
-#endif
-
-#ifdef CRYPTO_7ZAES
-#include "../../Crypto/7zAES/7zAES.h"
-static NArchive::N7z::CMethodID k_7zAES = { { 0x6, 0xF1, 0x07, 0x01 }, 4 };
-#endif
-
-namespace NArchive {
-namespace N7z {
-
-static void ConvertFolderItemInfoToBindInfo(const CFolder &folder,
- CBindInfoEx &bindInfo)
-{
- bindInfo.Clear();
- int i;
- for (i = 0; i < folder.BindPairs.Size(); i++)
- {
- NCoderMixer2::CBindPair bindPair;
- bindPair.InIndex = (UInt32)folder.BindPairs[i].InIndex;
- bindPair.OutIndex = (UInt32)folder.BindPairs[i].OutIndex;
- bindInfo.BindPairs.Add(bindPair);
- }
- UInt32 outStreamIndex = 0;
- for (i = 0; i < folder.Coders.Size(); i++)
- {
- NCoderMixer2::CCoderStreamsInfo coderStreamsInfo;
- const CCoderInfo &coderInfo = folder.Coders[i];
- coderStreamsInfo.NumInStreams = (UInt32)coderInfo.NumInStreams;
- coderStreamsInfo.NumOutStreams = (UInt32)coderInfo.NumOutStreams;
- bindInfo.Coders.Add(coderStreamsInfo);
- const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
- bindInfo.CoderMethodIDs.Add(altCoderInfo.MethodID);
- for (UInt32 j = 0; j < coderStreamsInfo.NumOutStreams; j++, outStreamIndex++)
- if (folder.FindBindPairForOutStream(outStreamIndex) < 0)
- bindInfo.OutStreams.Add(outStreamIndex);
- }
- for (i = 0; i < folder.PackStreams.Size(); i++)
- bindInfo.InStreams.Add((UInt32)folder.PackStreams[i]);
-}
-
-static bool AreCodersEqual(const NCoderMixer2::CCoderStreamsInfo &a1,
- const NCoderMixer2::CCoderStreamsInfo &a2)
-{
- return (a1.NumInStreams == a2.NumInStreams) &&
- (a1.NumOutStreams == a2.NumOutStreams);
-}
-
-static bool AreBindPairsEqual(const NCoderMixer2::CBindPair &a1, const NCoderMixer2::CBindPair &a2)
-{
- return (a1.InIndex == a2.InIndex) &&
- (a1.OutIndex == a2.OutIndex);
-}
-
-static bool AreBindInfoExEqual(const CBindInfoEx &a1, const CBindInfoEx &a2)
-{
- if (a1.Coders.Size() != a2.Coders.Size())
- return false;
- int i;
- for (i = 0; i < a1.Coders.Size(); i++)
- if (!AreCodersEqual(a1.Coders[i], a2.Coders[i]))
- return false;
- if (a1.BindPairs.Size() != a2.BindPairs.Size())
- return false;
- for (i = 0; i < a1.BindPairs.Size(); i++)
- if (!AreBindPairsEqual(a1.BindPairs[i], a2.BindPairs[i]))
- return false;
- for (i = 0; i < a1.CoderMethodIDs.Size(); i++)
- if (a1.CoderMethodIDs[i] != a2.CoderMethodIDs[i])
- return false;
- if (a1.InStreams.Size() != a2.InStreams.Size())
- return false;
- if (a1.OutStreams.Size() != a2.OutStreams.Size())
- return false;
- return true;
-}
-
-CDecoder::CDecoder(bool multiThread)
-{
- #ifndef _ST_MODE
- multiThread = true;
- #endif
- _multiThread = multiThread;
- _bindInfoExPrevIsDefinded = false;
- #ifndef EXCLUDE_COM
- LoadMethodMap();
- #endif
-}
-
-HRESULT CDecoder::Decode(IInStream *inStream,
- UInt64 startPos,
- const UInt64 *packSizes,
- const CFolder &folderInfo,
- ISequentialOutStream *outStream,
- ICompressProgressInfo *compressProgress
- #ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
- #endif
- #ifdef COMPRESS_MT
- , bool mtMode, UInt32 numThreads
- #endif
- )
-{
- CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;
-
- CLockedInStream lockedInStream;
- lockedInStream.Init(inStream);
-
- for (int j = 0; j < folderInfo.PackStreams.Size(); j++)
- {
- CLockedSequentialInStreamImp *lockedStreamImpSpec = new
- CLockedSequentialInStreamImp;
- CMyComPtr<ISequentialInStream> lockedStreamImp = lockedStreamImpSpec;
- lockedStreamImpSpec->Init(&lockedInStream, startPos);
- startPos += packSizes[j];
-
- CLimitedSequentialInStream *streamSpec = new
- CLimitedSequentialInStream;
- CMyComPtr<ISequentialInStream> inStream = streamSpec;
- streamSpec->Init(lockedStreamImp, packSizes[j]);
- inStreams.Add(inStream);
- }
-
- int numCoders = folderInfo.Coders.Size();
-
- CBindInfoEx bindInfo;
- ConvertFolderItemInfoToBindInfo(folderInfo, bindInfo);
- bool createNewCoders;
- if (!_bindInfoExPrevIsDefinded)
- createNewCoders = true;
- else
- createNewCoders = !AreBindInfoExEqual(bindInfo, _bindInfoExPrev);
- if (createNewCoders)
- {
- int i;
- _decoders.Clear();
- // _decoders2.Clear();
-
- _mixerCoder.Release();
-
- if (_multiThread)
- {
- _mixerCoderMTSpec = new NCoderMixer2::CCoderMixer2MT;
- _mixerCoder = _mixerCoderMTSpec;
- _mixerCoderCommon = _mixerCoderMTSpec;
- }
- else
- {
- #ifdef _ST_MODE
- _mixerCoderSTSpec = new NCoderMixer2::CCoderMixer2ST;
- _mixerCoder = _mixerCoderSTSpec;
- _mixerCoderCommon = _mixerCoderSTSpec;
- #endif
- }
- _mixerCoderCommon->SetBindInfo(bindInfo);
-
- for (i = 0; i < numCoders; i++)
- {
- const CCoderInfo &coderInfo = folderInfo.Coders[i];
- const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
- #ifndef EXCLUDE_COM
- CMethodInfo methodInfo;
- if (!GetMethodInfo(altCoderInfo.MethodID, methodInfo))
- return E_NOTIMPL;
- #endif
-
- if (coderInfo.IsSimpleCoder())
- {
- CMyComPtr<ICompressCoder> decoder;
- CMyComPtr<ICompressFilter> filter;
-
- #ifdef COMPRESS_LZMA
- if (altCoderInfo.MethodID == k_LZMA)
- decoder = new NCompress::NLZMA::CDecoder;
- #endif
-
- #ifdef COMPRESS_PPMD
- if (altCoderInfo.MethodID == k_PPMD)
- decoder = new NCompress::NPPMD::CDecoder;
- #endif
-
- #ifdef COMPRESS_BCJ_X86
- if (altCoderInfo.MethodID == k_BCJ_X86)
- filter = new CBCJ_x86_Decoder;
- #endif
-
- #ifdef COMPRESS_DEFLATE_DECODER
- if (altCoderInfo.MethodID == k_Deflate)
- decoder = new NCompress::NDeflate::NDecoder::CCOMCoder;
- #endif
-
- #ifdef COMPRESS_BZIP2_DECODER
- if (altCoderInfo.MethodID == k_BZip2)
- decoder = new NCompress::NBZip2::CDecoder;
- #endif
-
- #ifdef COMPRESS_COPY
- if (altCoderInfo.MethodID == k_Copy)
- decoder = new NCompress::CCopyCoder;
- #endif
-
- #ifdef CRYPTO_7ZAES
- if (altCoderInfo.MethodID == k_7zAES)
- filter = new NCrypto::NSevenZ::CDecoder;
- #endif
-
- if (filter)
- {
- CFilterCoder *coderSpec = new CFilterCoder;
- decoder = coderSpec;
- coderSpec->Filter = filter;
- }
- #ifndef EXCLUDE_COM
- if (decoder == 0)
- {
- RINOK(_libraries.CreateCoderSpec(methodInfo.FilePath,
- methodInfo.Decoder, &decoder));
- }
- #endif
-
- if (decoder == 0)
- return E_NOTIMPL;
-
- _decoders.Add((IUnknown *)decoder);
-
- if (_multiThread)
- _mixerCoderMTSpec->AddCoder(decoder);
- #ifdef _ST_MODE
- else
- _mixerCoderSTSpec->AddCoder(decoder, false);
- #endif
- }
- else
- {
- CMyComPtr<ICompressCoder2> decoder;
-
- #ifdef COMPRESS_BCJ2
- if (altCoderInfo.MethodID == k_BCJ2)
- decoder = new CBCJ2_x86_Decoder;
- #endif
-
- #ifndef EXCLUDE_COM
- if (decoder == 0)
- {
- RINOK(_libraries.CreateCoder2(methodInfo.FilePath,
- methodInfo.Decoder, &decoder));
- }
- #endif
-
- if (decoder == 0)
- return E_NOTIMPL;
-
- _decoders.Add((IUnknown *)decoder);
- if (_multiThread)
- _mixerCoderMTSpec->AddCoder2(decoder);
- #ifdef _ST_MODE
- else
- _mixerCoderSTSpec->AddCoder2(decoder, false);
- #endif
- }
- }
- _bindInfoExPrev = bindInfo;
- _bindInfoExPrevIsDefinded = true;
- }
- int i;
- _mixerCoderCommon->ReInit();
-
- UInt32 packStreamIndex = 0, unPackStreamIndex = 0;
- UInt32 coderIndex = 0;
- // UInt32 coder2Index = 0;
-
- for (i = 0; i < numCoders; i++)
- {
- const CCoderInfo &coderInfo = folderInfo.Coders[i];
- const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
- CMyComPtr<IUnknown> &decoder = _decoders[coderIndex];
-
- {
- CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
- HRESULT result = decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
- if (setDecoderProperties)
- {
- const CByteBuffer &properties = altCoderInfo.Properties;
- size_t size = properties.GetCapacity();
- if (size > 0xFFFFFFFF)
- return E_NOTIMPL;
- if (size > 0)
- {
- RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)properties, (UInt32)size));
- }
- }
- }
-
- #ifdef COMPRESS_MT
- if (mtMode)
- {
- CMyComPtr<ICompressSetCoderMt> setCoderMt;
- decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
- if (setCoderMt)
- {
- RINOK(setCoderMt->SetNumberOfThreads(numThreads));
- }
- }
- #endif
-
- #ifndef _NO_CRYPTO
- {
- CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
- HRESULT result = decoder.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
- if (cryptoSetPassword)
- {
- if (getTextPassword == 0)
- return E_FAIL;
- CMyComBSTR password;
- RINOK(getTextPassword->CryptoGetTextPassword(&password));
- CByteBuffer buffer;
- UString unicodePassword(password);
- const UInt32 sizeInBytes = unicodePassword.Length() * 2;
- buffer.SetCapacity(sizeInBytes);
- for (int i = 0; i < unicodePassword.Length(); i++)
- {
- wchar_t c = unicodePassword[i];
- ((Byte *)buffer)[i * 2] = (Byte)c;
- ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
- }
- RINOK(cryptoSetPassword->CryptoSetPassword(
- (const Byte *)buffer, sizeInBytes));
- }
- }
- #endif
-
- coderIndex++;
-
- UInt32 numInStreams = (UInt32)coderInfo.NumInStreams;
- UInt32 numOutStreams = (UInt32)coderInfo.NumOutStreams;
- CRecordVector<const UInt64 *> packSizesPointers;
- CRecordVector<const UInt64 *> unPackSizesPointers;
- packSizesPointers.Reserve(numInStreams);
- unPackSizesPointers.Reserve(numOutStreams);
- UInt32 j;
- for (j = 0; j < numOutStreams; j++, unPackStreamIndex++)
- unPackSizesPointers.Add(&folderInfo.UnPackSizes[unPackStreamIndex]);
-
- for (j = 0; j < numInStreams; j++, packStreamIndex++)
- {
- int bindPairIndex = folderInfo.FindBindPairForInStream(packStreamIndex);
- if (bindPairIndex >= 0)
- packSizesPointers.Add(
- &folderInfo.UnPackSizes[(UInt32)folderInfo.BindPairs[bindPairIndex].OutIndex]);
- else
- {
- int index = folderInfo.FindPackStreamArrayIndex(packStreamIndex);
- if (index < 0)
- return E_FAIL;
- packSizesPointers.Add(&packSizes[index]);
- }
- }
-
- _mixerCoderCommon->SetCoderInfo(i,
- &packSizesPointers.Front(),
- &unPackSizesPointers.Front());
- }
- UInt32 mainCoder, temp;
- bindInfo.FindOutStream(bindInfo.OutStreams[0], mainCoder, temp);
-
- if (_multiThread)
- _mixerCoderMTSpec->SetProgressCoderIndex(mainCoder);
- /*
- else
- _mixerCoderSTSpec->SetProgressCoderIndex(mainCoder);;
- */
-
- if (numCoders == 0)
- return 0;
- CRecordVector<ISequentialInStream *> inStreamPointers;
- inStreamPointers.Reserve(inStreams.Size());
- for (i = 0; i < inStreams.Size(); i++)
- inStreamPointers.Add(inStreams[i]);
- ISequentialOutStream *outStreamPointer = outStream;
- return _mixerCoder->Code(&inStreamPointers.Front(), NULL,
- inStreams.Size(), &outStreamPointer, NULL, 1, compressProgress);
-}
-
-}}
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zDecode.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zDecode.h
deleted file mode 100644
index 6620c2ed8..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zDecode.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// 7zDecode.h
-
-#ifndef __7Z_DECODE_H
-#define __7Z_DECODE_H
-
-#include "../../IStream.h"
-#include "../../IPassword.h"
-
-#include "../Common/CoderMixer2.h"
-#include "../Common/CoderMixer2MT.h"
-#ifdef _ST_MODE
-#include "../Common/CoderMixer2ST.h"
-#endif
-#ifndef EXCLUDE_COM
-#include "../Common/CoderLoader.h"
-#endif
-
-#include "7zItem.h"
-
-namespace NArchive {
-namespace N7z {
-
-struct CBindInfoEx: public NCoderMixer2::CBindInfo
-{
- CRecordVector<CMethodID> CoderMethodIDs;
- void Clear()
- {
- CBindInfo::Clear();
- CoderMethodIDs.Clear();
- }
-};
-
-class CDecoder
-{
- #ifndef EXCLUDE_COM
- CCoderLibraries _libraries;
- #endif
-
- bool _bindInfoExPrevIsDefinded;
- CBindInfoEx _bindInfoExPrev;
-
- bool _multiThread;
- #ifdef _ST_MODE
- NCoderMixer2::CCoderMixer2ST *_mixerCoderSTSpec;
- #endif
- NCoderMixer2::CCoderMixer2MT *_mixerCoderMTSpec;
- NCoderMixer2::CCoderMixer2 *_mixerCoderCommon;
-
- CMyComPtr<ICompressCoder2> _mixerCoder;
- CObjectVector<CMyComPtr<IUnknown> > _decoders;
- // CObjectVector<CMyComPtr<ICompressCoder2> > _decoders2;
-public:
- CDecoder(bool multiThread);
- HRESULT Decode(IInStream *inStream,
- UInt64 startPos,
- const UInt64 *packSizes,
- const CFolder &folder,
- ISequentialOutStream *outStream,
- ICompressProgressInfo *compressProgress
- #ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPasswordSpec
- #endif
- #ifdef COMPRESS_MT
- , bool mtMode, UInt32 numThreads
- #endif
- );
-};
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zExtract.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zExtract.cpp
deleted file mode 100644
index cc892bc9d..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zExtract.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-// 7zExtract.cpp
-
-#include "StdAfx.h"
-
-#include "7zHandler.h"
-#include "7zFolderOutStream.h"
-#include "7zMethods.h"
-#include "7zDecode.h"
-// #include "7z1Decode.h"
-
-#include "../../../Common/ComTry.h"
-#include "../../Common/StreamObjects.h"
-#include "../../Common/ProgressUtils.h"
-#include "../../Common/LimitedStreams.h"
-
-namespace NArchive {
-namespace N7z {
-
-struct CExtractFolderInfo
-{
- #ifdef _7Z_VOL
- int VolumeIndex;
- #endif
- CNum FileIndex;
- CNum FolderIndex;
- CBoolVector ExtractStatuses;
- UInt64 UnPackSize;
- CExtractFolderInfo(
- #ifdef _7Z_VOL
- int volumeIndex,
- #endif
- CNum fileIndex, CNum folderIndex):
- #ifdef _7Z_VOL
- VolumeIndex(volumeIndex),
- #endif
- FileIndex(fileIndex),
- FolderIndex(folderIndex),
- UnPackSize(0)
- {
- if (fileIndex != kNumNoIndex)
- {
- ExtractStatuses.Reserve(1);
- ExtractStatuses.Add(true);
- }
- };
-};
-
-STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
- Int32 testModeSpec, IArchiveExtractCallback *extractCallbackSpec)
-{
- COM_TRY_BEGIN
- bool testMode = (testModeSpec != 0);
- CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
- UInt64 importantTotalUnPacked = 0;
-
- bool allFilesMode = (numItems == UInt32(-1));
- if (allFilesMode)
- numItems =
- #ifdef _7Z_VOL
- _refs.Size();
- #else
- _database.Files.Size();
- #endif
-
- if(numItems == 0)
- return S_OK;
-
- /*
- if(_volumes.Size() != 1)
- return E_FAIL;
- const CVolume &volume = _volumes.Front();
- const CArchiveDatabaseEx &_database = volume.Database;
- IInStream *_inStream = volume.Stream;
- */
-
- CObjectVector<CExtractFolderInfo> extractFolderInfoVector;
- for(UInt32 ii = 0; ii < numItems; ii++)
- {
- // UInt32 fileIndex = allFilesMode ? indexIndex : indices[indexIndex];
- UInt32 ref2Index = allFilesMode ? ii : indices[ii];
- // const CRef2 &ref2 = _refs[ref2Index];
-
- // for(UInt32 ri = 0; ri < ref2.Refs.Size(); ri++)
- {
- #ifdef _7Z_VOL
- // const CRef &ref = ref2.Refs[ri];
- const CRef &ref = _refs[ref2Index];
-
- int volumeIndex = ref.VolumeIndex;
- const CVolume &volume = _volumes[volumeIndex];
- const CArchiveDatabaseEx &database = volume.Database;
- UInt32 fileIndex = ref.ItemIndex;
- #else
- const CArchiveDatabaseEx &database = _database;
- UInt32 fileIndex = ref2Index;
- #endif
-
- CNum folderIndex = database.FileIndexToFolderIndexMap[fileIndex];
- if (folderIndex == kNumNoIndex)
- {
- extractFolderInfoVector.Add(CExtractFolderInfo(
- #ifdef _7Z_VOL
- volumeIndex,
- #endif
- fileIndex, kNumNoIndex));
- continue;
- }
- if (extractFolderInfoVector.IsEmpty() ||
- folderIndex != extractFolderInfoVector.Back().FolderIndex
- #ifdef _7Z_VOL
- || volumeIndex != extractFolderInfoVector.Back().VolumeIndex
- #endif
- )
- {
- extractFolderInfoVector.Add(CExtractFolderInfo(
- #ifdef _7Z_VOL
- volumeIndex,
- #endif
- kNumNoIndex, folderIndex));
- const CFolder &folderInfo = database.Folders[folderIndex];
- UInt64 unPackSize = folderInfo.GetUnPackSize();
- importantTotalUnPacked += unPackSize;
- extractFolderInfoVector.Back().UnPackSize = unPackSize;
- }
-
- CExtractFolderInfo &efi = extractFolderInfoVector.Back();
-
- // const CFolderInfo &folderInfo = m_dam_Folders[folderIndex];
- CNum startIndex = database.FolderStartFileIndex[folderIndex];
- for (CNum index = efi.ExtractStatuses.Size();
- index <= fileIndex - startIndex; index++)
- {
- // UInt64 unPackSize = _database.Files[startIndex + index].UnPackSize;
- // Count partial_folder_size
- // efi.UnPackSize += unPackSize;
- // importantTotalUnPacked += unPackSize;
- efi.ExtractStatuses.Add(index == fileIndex - startIndex);
- }
- }
- }
-
- extractCallback->SetTotal(importantTotalUnPacked);
-
- CDecoder decoder(
- #ifdef _ST_MODE
- false
- #else
- true
- #endif
- );
- // CDecoder1 decoder;
-
- UInt64 currentImportantTotalUnPacked = 0;
- UInt64 totalFolderUnPacked;
-
- for(int i = 0; i < extractFolderInfoVector.Size(); i++,
- currentImportantTotalUnPacked += totalFolderUnPacked)
- {
- const CExtractFolderInfo &efi = extractFolderInfoVector[i];
- totalFolderUnPacked = efi.UnPackSize;
-
- RINOK(extractCallback->SetCompleted(&currentImportantTotalUnPacked));
-
- CFolderOutStream *folderOutStream = new CFolderOutStream;
- CMyComPtr<ISequentialOutStream> outStream(folderOutStream);
-
- #ifdef _7Z_VOL
- const CVolume &volume = _volumes[efi.VolumeIndex];
- const CArchiveDatabaseEx &database = volume.Database;
- #else
- const CArchiveDatabaseEx &database = _database;
- #endif
-
- CNum startIndex;
- if (efi.FileIndex != kNumNoIndex)
- startIndex = efi.FileIndex;
- else
- startIndex = database.FolderStartFileIndex[efi.FolderIndex];
-
-
- HRESULT result = folderOutStream->Init(&database,
- #ifdef _7Z_VOL
- volume.StartRef2Index,
- #else
- 0,
- #endif
- startIndex,
- &efi.ExtractStatuses, extractCallback, testMode);
-
- RINOK(result);
-
- if (efi.FileIndex != kNumNoIndex)
- continue;
-
- CNum folderIndex = efi.FolderIndex;
- const CFolder &folderInfo = database.Folders[folderIndex];
-
- CLocalProgress *localProgressSpec = new CLocalProgress;
- CMyComPtr<ICompressProgressInfo> progress = localProgressSpec;
- localProgressSpec->Init(extractCallback, false);
-
- CLocalCompressProgressInfo *localCompressProgressSpec =
- new CLocalCompressProgressInfo;
- CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
- localCompressProgressSpec->Init(progress, NULL, &currentImportantTotalUnPacked);
-
- CNum packStreamIndex = database.FolderStartPackStreamIndex[folderIndex];
- UInt64 folderStartPackPos = database.GetFolderStreamPos(folderIndex, 0);
-
- #ifndef _NO_CRYPTO
- CMyComPtr<ICryptoGetTextPassword> getTextPassword;
- if (extractCallback)
- extractCallback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
- #endif
-
- try
- {
- HRESULT result = decoder.Decode(
- #ifdef _7Z_VOL
- volume.Stream,
- #else
- _inStream,
- #endif
- folderStartPackPos,
- &database.PackSizes[packStreamIndex],
- folderInfo,
- outStream,
- compressProgress
- #ifndef _NO_CRYPTO
- , getTextPassword
- #endif
- #ifdef COMPRESS_MT
- , true, _numThreads
- #endif
- );
-
- if (result == S_FALSE)
- {
- RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError));
- continue;
- }
- if (result == E_NOTIMPL)
- {
- RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
- continue;
- }
- if (result != S_OK)
- return result;
- if (folderOutStream->WasWritingFinished() != S_OK)
- {
- RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError));
- continue;
- }
- }
- catch(...)
- {
- RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError));
- continue;
- }
- }
- return S_OK;
- COM_TRY_END
-}
-
-}}
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zFolderOutStream.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zFolderOutStream.cpp
deleted file mode 100644
index 94afc6905..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zFolderOutStream.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-// 7zFolderOutStream.cpp
-
-#include "StdAfx.h"
-
-#include "7zFolderOutStream.h"
-
-namespace NArchive {
-namespace N7z {
-
-CFolderOutStream::CFolderOutStream()
-{
- _outStreamWithHashSpec = new COutStreamWithCRC;
- _outStreamWithHash = _outStreamWithHashSpec;
-}
-
-HRESULT CFolderOutStream::Init(
- const CArchiveDatabaseEx *archiveDatabase,
- UInt32 ref2Offset,
- UInt32 startIndex,
- const CBoolVector *extractStatuses,
- IArchiveExtractCallback *extractCallback,
- bool testMode)
-{
- _archiveDatabase = archiveDatabase;
- _ref2Offset = ref2Offset;
- _startIndex = startIndex;
-
- _extractStatuses = extractStatuses;
- _extractCallback = extractCallback;
- _testMode = testMode;
-
- _currentIndex = 0;
- _fileIsOpen = false;
- return WriteEmptyFiles();
-}
-
-HRESULT CFolderOutStream::OpenFile()
-{
- Int32 askMode;
- if((*_extractStatuses)[_currentIndex])
- askMode = _testMode ?
- NArchive::NExtract::NAskMode::kTest :
- NArchive::NExtract::NAskMode::kExtract;
- else
- askMode = NArchive::NExtract::NAskMode::kSkip;
- CMyComPtr<ISequentialOutStream> realOutStream;
-
- UInt32 index = _startIndex + _currentIndex;
- RINOK(_extractCallback->GetStream(_ref2Offset + index, &realOutStream, askMode));
-
- _outStreamWithHashSpec->Init(realOutStream);
- if (askMode == NArchive::NExtract::NAskMode::kExtract &&
- (!realOutStream))
- {
- const CFileItem &fileInfo = _archiveDatabase->Files[index];
- if (!fileInfo.IsAnti && !fileInfo.IsDirectory)
- askMode = NArchive::NExtract::NAskMode::kSkip;
- }
- return _extractCallback->PrepareOperation(askMode);
-}
-
-HRESULT CFolderOutStream::WriteEmptyFiles()
-{
- for(;_currentIndex < _extractStatuses->Size(); _currentIndex++)
- {
- UInt32 index = _startIndex + _currentIndex;
- const CFileItem &fileInfo = _archiveDatabase->Files[index];
- if (!fileInfo.IsAnti && !fileInfo.IsDirectory && fileInfo.UnPackSize != 0)
- return S_OK;
- RINOK(OpenFile());
- RINOK(_extractCallback->SetOperationResult(
- NArchive::NExtract::NOperationResult::kOK));
- _outStreamWithHashSpec->ReleaseStream();
- }
- return S_OK;
-}
-
-STDMETHODIMP CFolderOutStream::Write(const void *data,
- UInt32 size, UInt32 *processedSize)
-{
- UInt32 realProcessedSize = 0;
- while(_currentIndex < _extractStatuses->Size())
- {
- if (_fileIsOpen)
- {
- UInt32 index = _startIndex + _currentIndex;
- const CFileItem &fileInfo = _archiveDatabase->Files[index];
- UInt64 fileSize = fileInfo.UnPackSize;
-
- UInt32 numBytesToWrite = (UInt32)MyMin(fileSize - _filePos,
- UInt64(size - realProcessedSize));
-
- UInt32 processedSizeLocal;
- RINOK(_outStreamWithHash->Write((const Byte *)data + realProcessedSize,
- numBytesToWrite, &processedSizeLocal));
-
- _filePos += processedSizeLocal;
- realProcessedSize += processedSizeLocal;
- if (_filePos == fileSize)
- {
- bool digestsAreEqual;
- if (fileInfo.IsFileCRCDefined)
- digestsAreEqual = fileInfo.FileCRC == _outStreamWithHashSpec->GetCRC();
- else
- digestsAreEqual = true;
-
- RINOK(_extractCallback->SetOperationResult(
- digestsAreEqual ?
- NArchive::NExtract::NOperationResult::kOK :
- NArchive::NExtract::NOperationResult::kCRCError));
- _outStreamWithHashSpec->ReleaseStream();
- _fileIsOpen = false;
- _currentIndex++;
- }
- if (realProcessedSize == size)
- {
- if (processedSize != NULL)
- *processedSize = realProcessedSize;
- return WriteEmptyFiles();
- }
- }
- else
- {
- RINOK(OpenFile());
- _fileIsOpen = true;
- _filePos = 0;
- }
- }
- if (processedSize != NULL)
- *processedSize = size;
- return S_OK;
-}
-
-HRESULT CFolderOutStream::FlushCorrupted(Int32 resultEOperationResult)
-{
- while(_currentIndex < _extractStatuses->Size())
- {
- if (_fileIsOpen)
- {
- RINOK(_extractCallback->SetOperationResult(resultEOperationResult));
- _outStreamWithHashSpec->ReleaseStream();
- _fileIsOpen = false;
- _currentIndex++;
- }
- else
- {
- RINOK(OpenFile());
- _fileIsOpen = true;
- }
- }
- return S_OK;
-}
-
-HRESULT CFolderOutStream::WasWritingFinished()
-{
- if (_currentIndex == _extractStatuses->Size())
- return S_OK;
- return E_FAIL;
-}
-
-}}
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zFolderOutStream.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zFolderOutStream.h
deleted file mode 100644
index 05a6358c7..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zFolderOutStream.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// 7zFolderOutStream.h
-
-#ifndef __7Z_FOLDEROUTSTREAM_H
-#define __7Z_FOLDEROUTSTREAM_H
-
-#include "7zIn.h"
-
-#include "../../IStream.h"
-#include "../IArchive.h"
-#include "../Common/OutStreamWithCRC.h"
-
-namespace NArchive {
-namespace N7z {
-
-class CFolderOutStream:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
-public:
- MY_UNKNOWN_IMP
-
- CFolderOutStream();
-
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
-private:
-
- COutStreamWithCRC *_outStreamWithHashSpec;
- CMyComPtr<ISequentialOutStream> _outStreamWithHash;
- const CArchiveDatabaseEx *_archiveDatabase;
- const CBoolVector *_extractStatuses;
- UInt32 _startIndex;
- UInt32 _ref2Offset;
- int _currentIndex;
- // UInt64 _currentDataPos;
- CMyComPtr<IArchiveExtractCallback> _extractCallback;
- bool _testMode;
-
- bool _fileIsOpen;
- UInt64 _filePos;
-
- HRESULT OpenFile();
- HRESULT WriteEmptyFiles();
-public:
- HRESULT Init(
- const CArchiveDatabaseEx *archiveDatabase,
- UInt32 ref2Offset,
- UInt32 startIndex,
- const CBoolVector *extractStatuses,
- IArchiveExtractCallback *extractCallback,
- bool testMode);
- HRESULT FlushCorrupted(Int32 resultEOperationResult);
- HRESULT WasWritingFinished();
-};
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zHandler.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zHandler.cpp
deleted file mode 100644
index b6f492aea..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zHandler.cpp
+++ /dev/null
@@ -1,757 +0,0 @@
-// 7zHandler.cpp
-
-#include "StdAfx.h"
-
-#include "7zHandler.h"
-#include "7zProperties.h"
-
-#include "../../../Common/IntToString.h"
-#include "../../../Common/ComTry.h"
-#include "../../../Windows/Defs.h"
-
-#include "../Common/ItemNameUtils.h"
-#ifdef _7Z_VOL
-#include "../Common/MultiStream.h"
-#endif
-
-#ifdef __7Z_SET_PROPERTIES
-#ifdef EXTRACT_ONLY
-#include "../Common/ParseProperties.h"
-#endif
-#endif
-
-using namespace NWindows;
-
-namespace NArchive {
-namespace N7z {
-
-CHandler::CHandler()
-{
- #ifdef COMPRESS_MT
- _numThreads = NWindows::NSystem::GetNumberOfProcessors();
- #endif
- #ifndef EXTRACT_ONLY
- Init();
- #endif
- #ifndef EXCLUDE_COM
- LoadMethodMap();
- #endif
-}
-
-STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
-{
- COM_TRY_BEGIN
- *numItems =
- #ifdef _7Z_VOL
- _refs.Size();
- #else
- *numItems = _database.Files.Size();
- #endif
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
-{
- value->vt = VT_EMPTY;
- return S_OK;
-}
-
-#ifdef _SFX
-
-STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- return E_NOTIMPL;
-}
-
-#endif
-
-
-STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
-{
- *numProperties = 0;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- return E_NOTIMPL;
-}
-
-
-static void MySetFileTime(bool timeDefined, FILETIME unixTime,
- NWindows::NCOM::CPropVariant &propVariant)
-{
- if (timeDefined)
- propVariant = unixTime;
-}
-
-/*
-inline static wchar_t GetHex(Byte value)
-{
- return (value < 10) ? ('0' + value) : ('A' + (value - 10));
-}
-
-static UString ConvertBytesToHexString(const Byte *data, UInt32 size)
-{
- UString result;
- for (UInt32 i = 0; i < size; i++)
- {
- Byte b = data[i];
- result += GetHex(b >> 4);
- result += GetHex(b & 0xF);
- }
- return result;
-}
-*/
-
-
-#ifndef _SFX
-
-static UString ConvertUInt32ToString(UInt32 value)
-{
- wchar_t buffer[32];
- ConvertUInt64ToString(value, buffer);
- return buffer;
-}
-
-static UString GetStringForSizeValue(UInt32 value)
-{
- for (int i = 31; i >= 0; i--)
- if ((UInt32(1) << i) == value)
- return ConvertUInt32ToString(i);
- UString result;
- if (value % (1 << 20) == 0)
- {
- result += ConvertUInt32ToString(value >> 20);
- result += L"m";
- }
- else if (value % (1 << 10) == 0)
- {
- result += ConvertUInt32ToString(value >> 10);
- result += L"k";
- }
- else
- {
- result += ConvertUInt32ToString(value);
- result += L"b";
- }
- return result;
-}
-
-static CMethodID k_Copy = { { 0x0 }, 1 };
-static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
-static CMethodID k_BCJ = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
-static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
-static CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
-static CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
-static CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
-
-static inline char GetHex(Byte value)
-{
- return (value < 10) ? ('0' + value) : ('A' + (value - 10));
-}
-static inline UString GetHex2(Byte value)
-{
- UString result;
- result += GetHex(value >> 4);
- result += GetHex(value & 0xF);
- return result;
-}
-
-#endif
-
-static inline UInt32 GetUInt32FromMemLE(const Byte *p)
-{
- return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
-}
-
-STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
-{
- COM_TRY_BEGIN
- NWindows::NCOM::CPropVariant propVariant;
-
- /*
- const CRef2 &ref2 = _refs[index];
- if (ref2.Refs.IsEmpty())
- return E_FAIL;
- const CRef &ref = ref2.Refs.Front();
- */
-
- #ifdef _7Z_VOL
- const CRef &ref = _refs[index];
- const CVolume &volume = _volumes[ref.VolumeIndex];
- const CArchiveDatabaseEx &_database = volume.Database;
- UInt32 index2 = ref.ItemIndex;
- const CFileItem &item = _database.Files[index2];
- #else
- const CFileItem &item = _database.Files[index];
- UInt32 index2 = index;
- #endif
-
- switch(propID)
- {
- case kpidPath:
- {
- if (!item.Name.IsEmpty())
- propVariant = NItemName::GetOSName(item.Name);
- break;
- }
- case kpidIsFolder:
- propVariant = item.IsDirectory;
- break;
- case kpidSize:
- {
- propVariant = item.UnPackSize;
- // propVariant = ref2.UnPackSize;
- break;
- }
- case kpidPosition:
- {
- /*
- if (ref2.Refs.Size() > 1)
- propVariant = ref2.StartPos;
- else
- */
- if (item.IsStartPosDefined)
- propVariant = item.StartPos;
- break;
- }
- case kpidPackedSize:
- {
- // propVariant = ref2.PackSize;
- {
- CNum folderIndex = _database.FileIndexToFolderIndexMap[index2];
- if (folderIndex != kNumNoIndex)
- {
- if (_database.FolderStartFileIndex[folderIndex] == (CNum)index2)
- propVariant = _database.GetFolderFullPackSize(folderIndex);
- /*
- else
- propVariant = UInt64(0);
- */
- }
- else
- propVariant = UInt64(0);
- }
- break;
- }
- case kpidLastAccessTime:
- MySetFileTime(item.IsLastAccessTimeDefined, item.LastAccessTime, propVariant);
- break;
- case kpidCreationTime:
- MySetFileTime(item.IsCreationTimeDefined, item.CreationTime, propVariant);
- break;
- case kpidLastWriteTime:
- MySetFileTime(item.IsLastWriteTimeDefined, item.LastWriteTime, propVariant);
- break;
- case kpidAttributes:
- if (item.AreAttributesDefined)
- propVariant = item.Attributes;
- break;
- case kpidCRC:
- if (item.IsFileCRCDefined)
- propVariant = item.FileCRC;
- break;
- #ifndef _SFX
- case kpidMethod:
- {
- CNum folderIndex = _database.FileIndexToFolderIndexMap[index2];
- if (folderIndex != kNumNoIndex)
- {
- const CFolder &folderInfo = _database.Folders[folderIndex];
- UString methodsString;
- for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
- {
- const CCoderInfo &coderInfo = folderInfo.Coders[i];
- if (!methodsString.IsEmpty())
- methodsString += L' ';
- CMethodInfo methodInfo;
-
- bool methodIsKnown;
-
- for (int j = 0; j < coderInfo.AltCoders.Size(); j++)
- {
- if (j > 0)
- methodsString += L"|";
- const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders[j];
-
- UString methodName;
- #ifdef NO_REGISTRY
-
- methodIsKnown = true;
- if (altCoderInfo.MethodID == k_Copy)
- methodName = L"Copy";
- else if (altCoderInfo.MethodID == k_LZMA)
- methodName = L"LZMA";
- else if (altCoderInfo.MethodID == k_BCJ)
- methodName = L"BCJ";
- else if (altCoderInfo.MethodID == k_BCJ2)
- methodName = L"BCJ2";
- else if (altCoderInfo.MethodID == k_PPMD)
- methodName = L"PPMD";
- else if (altCoderInfo.MethodID == k_Deflate)
- methodName = L"Deflate";
- else if (altCoderInfo.MethodID == k_BZip2)
- methodName = L"BZip2";
- else
- methodIsKnown = false;
-
- #else
-
- methodIsKnown = GetMethodInfo(
- altCoderInfo.MethodID, methodInfo);
- methodName = methodInfo.Name;
-
- #endif
-
- if (methodIsKnown)
- {
- methodsString += methodName;
- if (altCoderInfo.MethodID == k_LZMA)
- {
- if (altCoderInfo.Properties.GetCapacity() >= 5)
- {
- methodsString += L":";
- UInt32 dicSize = GetUInt32FromMemLE(
- ((const Byte *)altCoderInfo.Properties + 1));
- methodsString += GetStringForSizeValue(dicSize);
- }
- }
- else if (altCoderInfo.MethodID == k_PPMD)
- {
- if (altCoderInfo.Properties.GetCapacity() >= 5)
- {
- Byte order = *(const Byte *)altCoderInfo.Properties;
- methodsString += L":o";
- methodsString += ConvertUInt32ToString(order);
- methodsString += L":mem";
- UInt32 dicSize = GetUInt32FromMemLE(
- ((const Byte *)altCoderInfo.Properties + 1));
- methodsString += GetStringForSizeValue(dicSize);
- }
- }
- else
- {
- if (altCoderInfo.Properties.GetCapacity() > 0)
- {
- methodsString += L":[";
- for (size_t bi = 0; bi < altCoderInfo.Properties.GetCapacity(); bi++)
- {
- if (bi > 2 && bi + 1 < altCoderInfo.Properties.GetCapacity())
- {
- methodsString += L"..";
- break;
- }
- else
- methodsString += GetHex2(altCoderInfo.Properties[bi]);
- }
- methodsString += L"]";
- }
- }
- }
- else
- {
- methodsString += altCoderInfo.MethodID.ConvertToString();
- }
- }
- }
- propVariant = methodsString;
- }
- }
- break;
- case kpidBlock:
- {
- CNum folderIndex = _database.FileIndexToFolderIndexMap[index2];
- if (folderIndex != kNumNoIndex)
- propVariant = (UInt32)folderIndex;
- }
- break;
- case kpidPackedSize0:
- case kpidPackedSize1:
- case kpidPackedSize2:
- case kpidPackedSize3:
- case kpidPackedSize4:
- {
- CNum folderIndex = _database.FileIndexToFolderIndexMap[index2];
- if (folderIndex != kNumNoIndex)
- {
- const CFolder &folderInfo = _database.Folders[folderIndex];
- if (_database.FolderStartFileIndex[folderIndex] == (CNum)index2 &&
- folderInfo.PackStreams.Size() > (int)(propID - kpidPackedSize0))
- {
- propVariant = _database.GetFolderPackStreamSize(folderIndex, propID - kpidPackedSize0);
- }
- else
- propVariant = UInt64(0);
- }
- else
- propVariant = UInt64(0);
- }
- break;
- #endif
- case kpidIsAnti:
- propVariant = item.IsAnti;
- break;
- }
- propVariant.Detach(value);
- return S_OK;
- COM_TRY_END
-}
-
-static const wchar_t *kExt = L"7z";
-static const wchar_t *kAfterPart = L".7z";
-
-#ifdef _7Z_VOL
-
-class CVolumeName
-{
- bool _first;
- UString _unchangedPart;
- UString _changedPart;
- UString _afterPart;
-public:
- bool InitName(const UString &name)
- {
- _first = true;
- int dotPos = name.ReverseFind('.');
- UString basePart = name;
- if (dotPos >= 0)
- {
- UString ext = name.Mid(dotPos + 1);
- if (ext.CompareNoCase(kExt)==0 ||
- ext.CompareNoCase(L"EXE") == 0)
- {
- _afterPart = kAfterPart;
- basePart = name.Left(dotPos);
- }
- }
-
- int numLetters = 1;
- bool splitStyle = false;
- if (basePart.Right(numLetters) == L"1")
- {
- while (numLetters < basePart.Length())
- {
- if (basePart[basePart.Length() - numLetters - 1] != '0')
- break;
- numLetters++;
- }
- }
- else
- return false;
- _unchangedPart = basePart.Left(basePart.Length() - numLetters);
- _changedPart = basePart.Right(numLetters);
- return true;
- }
-
- UString GetNextName()
- {
- UString newName;
- // if (_newStyle || !_first)
- {
- int i;
- int numLetters = _changedPart.Length();
- for (i = numLetters - 1; i >= 0; i--)
- {
- wchar_t c = _changedPart[i];
- if (c == L'9')
- {
- c = L'0';
- newName = c + newName;
- if (i == 0)
- newName = UString(L'1') + newName;
- continue;
- }
- c++;
- newName = UString(c) + newName;
- i--;
- for (; i >= 0; i--)
- newName = _changedPart[i] + newName;
- break;
- }
- _changedPart = newName;
- }
- _first = false;
- return _unchangedPart + _changedPart + _afterPart;
- }
-};
-
-#endif
-
-STDMETHODIMP CHandler::Open(IInStream *stream,
- const UInt64 *maxCheckStartPosition,
- IArchiveOpenCallback *openArchiveCallback)
-{
- COM_TRY_BEGIN
- Close();
- #ifndef _SFX
- _fileInfoPopIDs.Clear();
- #endif
- try
- {
- CMyComPtr<IArchiveOpenCallback> openArchiveCallbackTemp = openArchiveCallback;
- #ifdef _7Z_VOL
- CVolumeName seqName;
-
- CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
- #endif
-
- #ifndef _NO_CRYPTO
- CMyComPtr<ICryptoGetTextPassword> getTextPassword;
- if (openArchiveCallback)
- {
- openArchiveCallbackTemp.QueryInterface(
- IID_ICryptoGetTextPassword, &getTextPassword);
- }
- #endif
- #ifdef _7Z_VOL
- if (openArchiveCallback)
- {
- openArchiveCallbackTemp.QueryInterface(IID_IArchiveOpenVolumeCallback, &openVolumeCallback);
- }
- while(true)
- {
- CMyComPtr<IInStream> inStream;
- if (!_volumes.IsEmpty())
- {
- if (!openVolumeCallback)
- break;
- if(_volumes.Size() == 1)
- {
- UString baseName;
- {
- NCOM::CPropVariant propVariant;
- RINOK(openVolumeCallback->GetProperty(kpidName, &propVariant));
- if (propVariant.vt != VT_BSTR)
- break;
- baseName = propVariant.bstrVal;
- }
- seqName.InitName(baseName);
- }
-
- UString fullName = seqName.GetNextName();
- HRESULT result = openVolumeCallback->GetStream(fullName, &inStream);
- if (result == S_FALSE)
- break;
- if (result != S_OK)
- return result;
- if (!stream)
- break;
- }
- else
- inStream = stream;
-
- CInArchive archive;
- RINOK(archive.Open(inStream, maxCheckStartPosition));
-
- _volumes.Add(CVolume());
- CVolume &volume = _volumes.Back();
- CArchiveDatabaseEx &database = volume.Database;
- volume.Stream = inStream;
- volume.StartRef2Index = _refs.Size();
-
- HRESULT result = archive.ReadDatabase(database
- #ifndef _NO_CRYPTO
- , getTextPassword
- #endif
- );
- if (result != S_OK)
- {
- _volumes.Clear();
- return result;
- }
- database.Fill();
- for(int i = 0; i < database.Files.Size(); i++)
- {
- CRef refNew;
- refNew.VolumeIndex = _volumes.Size() - 1;
- refNew.ItemIndex = i;
- _refs.Add(refNew);
- /*
- const CFileItem &file = database.Files[i];
- int j;
- */
- /*
- for (j = _refs.Size() - 1; j >= 0; j--)
- {
- CRef2 &ref2 = _refs[j];
- const CRef &ref = ref2.Refs.Back();
- const CVolume &volume2 = _volumes[ref.VolumeIndex];
- const CArchiveDatabaseEx &database2 = volume2.Database;
- const CFileItem &file2 = database2.Files[ref.ItemIndex];
- if (file2.Name.CompareNoCase(file.Name) == 0)
- {
- if (!file.IsStartPosDefined)
- continue;
- if (file.StartPos != ref2.StartPos + ref2.UnPackSize)
- continue;
- ref2.Refs.Add(refNew);
- break;
- }
- }
- */
- /*
- j = -1;
- if (j < 0)
- {
- CRef2 ref2New;
- ref2New.Refs.Add(refNew);
- j = _refs.Add(ref2New);
- }
- CRef2 &ref2 = _refs[j];
- ref2.UnPackSize += file.UnPackSize;
- ref2.PackSize += database.GetFilePackSize(i);
- if (ref2.Refs.Size() == 1 && file.IsStartPosDefined)
- ref2.StartPos = file.StartPos;
- */
- }
- if (database.Files.Size() != 1)
- break;
- const CFileItem &file = database.Files.Front();
- if (!file.IsStartPosDefined)
- break;
- }
- #else
- CInArchive archive;
- RINOK(archive.Open(stream, maxCheckStartPosition));
- HRESULT result = archive.ReadDatabase(_database
- #ifndef _NO_CRYPTO
- , getTextPassword
- #endif
- );
- RINOK(result);
- _database.Fill();
- _inStream = stream;
- #endif
- }
- catch(...)
- {
- Close();
- return S_FALSE;
- }
- // _inStream = stream;
- #ifndef _SFX
- FillPopIDs();
- #endif
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CHandler::Close()
-{
- COM_TRY_BEGIN
- #ifdef _7Z_VOL
- _volumes.Clear();
- _refs.Clear();
- #else
- _inStream.Release();
- _database.Clear();
- #endif
- return S_OK;
- COM_TRY_END
-}
-
-#ifdef _7Z_VOL
-STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
-{
- if (index != 0)
- return E_INVALIDARG;
- *stream = 0;
- CMultiStream *streamSpec = new CMultiStream;
- CMyComPtr<ISequentialInStream> streamTemp = streamSpec;
-
- UInt64 pos = 0;
- const UString *fileName;
- for (int i = 0; i < _refs.Size(); i++)
- {
- const CRef &ref = _refs[i];
- const CVolume &volume = _volumes[ref.VolumeIndex];
- const CArchiveDatabaseEx &database = volume.Database;
- const CFileItem &file = database.Files[ref.ItemIndex];
- if (i == 0)
- fileName = &file.Name;
- else
- if (fileName->Compare(file.Name) != 0)
- return S_FALSE;
- if (!file.IsStartPosDefined)
- return S_FALSE;
- if (file.StartPos != pos)
- return S_FALSE;
- CNum folderIndex = database.FileIndexToFolderIndexMap[ref.ItemIndex];
- if (folderIndex == kNumNoIndex)
- {
- if (file.UnPackSize != 0)
- return E_FAIL;
- continue;
- }
- if (database.NumUnPackStreamsVector[folderIndex] != 1)
- return S_FALSE;
- const CFolder &folder = database.Folders[folderIndex];
- if (folder.Coders.Size() != 1)
- return S_FALSE;
- const CCoderInfo &coder = folder.Coders.Front();
- if (coder.NumInStreams != 1 || coder.NumOutStreams != 1)
- return S_FALSE;
- const CAltCoderInfo &altCoder = coder.AltCoders.Front();
- if (altCoder.MethodID.IDSize != 1 || altCoder.MethodID.ID[0] != 0)
- return S_FALSE;
-
- pos += file.UnPackSize;
- CMultiStream::CSubStreamInfo subStreamInfo;
- subStreamInfo.Stream = volume.Stream;
- subStreamInfo.Pos = database.GetFolderStreamPos(folderIndex, 0);
- subStreamInfo.Size = file.UnPackSize;
- streamSpec->Streams.Add(subStreamInfo);
- }
- streamSpec->Init();
- *stream = streamTemp.Detach();
- return S_OK;
-}
-#endif
-
-
-#ifdef __7Z_SET_PROPERTIES
-#ifdef EXTRACT_ONLY
-
-STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
-{
- COM_TRY_BEGIN
- const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
- _numThreads = numProcessors;
-
- for (int i = 0; i < numProperties; i++)
- {
- UString name = names[i];
- name.MakeUpper();
- if (name.IsEmpty())
- return E_INVALIDARG;
- const PROPVARIANT &value = values[i];
- UInt32 number;
- int index = ParseStringToUInt32(name, number);
- if (index == 0)
- {
- if(name.Left(2).CompareNoCase(L"MT") == 0)
- {
- RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
- continue;
- }
- else
- return E_INVALIDARG;
- }
- }
- return S_OK;
- COM_TRY_END
-}
-
-#endif
-#endif
-
-}}
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zHandler.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zHandler.h
deleted file mode 100644
index 3da9b8859..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zHandler.h
+++ /dev/null
@@ -1,234 +0,0 @@
-// 7z/Handler.h
-
-#ifndef __7Z_HANDLER_H
-#define __7Z_HANDLER_H
-
-#include "../IArchive.h"
-#include "7zIn.h"
-
-#include "7zCompressionMode.h"
-
-#ifndef _SFX
-#include "7zMethods.h"
-#endif
-
-#ifdef COMPRESS_MT
-#include "../../../Windows/System.h"
-#endif
-
-namespace NArchive {
-namespace N7z {
-
-#ifdef _7Z_VOL
-struct CRef
-{
- int VolumeIndex;
- int ItemIndex;
-};
-
-/*
-struct CRef2
-{
- CRecordVector<CRef> Refs;
- UInt64 UnPackSize;
- UInt64 PackSize;
- UInt64 StartPos;
- CRef2(): UnPackSize(0), PackSize(0), StartPos(0) {}
-};
-*/
-
-struct CVolume
-{
- int StartRef2Index;
- CMyComPtr<IInStream> Stream;
- CArchiveDatabaseEx Database;
-};
-#endif
-
-#ifndef EXTRACT_ONLY
-
-struct COneMethodInfo
-{
- CObjectVector<CProperty> CoderProperties;
- UString MethodName;
-};
-#endif
-
-// {23170F69-40C1-278A-1000-000110070000}
-DEFINE_GUID(CLSID_CFormat7z,
- 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
-
-#ifndef __7Z_SET_PROPERTIES
-
-#ifdef EXTRACT_ONLY
-#ifdef COMPRESS_MT
-#define __7Z_SET_PROPERTIES
-#endif
-#else
-#define __7Z_SET_PROPERTIES
-#endif
-
-#endif
-
-
-class CHandler:
- public IInArchive,
- #ifdef _7Z_VOL
- public IInArchiveGetStream,
- #endif
- #ifdef __7Z_SET_PROPERTIES
- public ISetProperties,
- #endif
- #ifndef EXTRACT_ONLY
- public IOutArchive,
- #endif
- public CMyUnknownImp
-{
-public:
- MY_QUERYINTERFACE_BEGIN
- #ifdef _7Z_VOL
- MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
- #endif
- #ifdef __7Z_SET_PROPERTIES
- MY_QUERYINTERFACE_ENTRY(ISetProperties)
- #endif
- #ifndef EXTRACT_ONLY
- MY_QUERYINTERFACE_ENTRY(IOutArchive)
- #endif
- MY_QUERYINTERFACE_END
- MY_ADDREF_RELEASE
-
- STDMETHOD(Open)(IInStream *stream,
- 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);
-
- #ifdef _7Z_VOL
- STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
- #endif
-
- #ifdef __7Z_SET_PROPERTIES
- STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
- #endif
-
- #ifndef EXTRACT_ONLY
- // IOutArchiveHandler
- STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
- IArchiveUpdateCallback *updateCallback);
-
- STDMETHOD(GetFileTimeType)(UInt32 *type);
-
- // ISetProperties
-
- HRESULT SetSolidSettings(const UString &s);
- HRESULT SetSolidSettings(const PROPVARIANT &value);
- #endif
-
- CHandler();
-
-private:
- #ifdef _7Z_VOL
- CObjectVector<CVolume> _volumes;
- CObjectVector<CRef> _refs;
- #else
- CMyComPtr<IInStream> _inStream;
- NArchive::N7z::CArchiveDatabaseEx _database;
- #endif
-
- #ifdef COMPRESS_MT
- UInt32 _numThreads;
- #endif
-
- #ifndef EXTRACT_ONLY
- CObjectVector<COneMethodInfo> _methods;
- CRecordVector<CBind> _binds;
- bool _removeSfxBlock;
- UInt64 _numSolidFiles;
- UInt64 _numSolidBytes;
- bool _numSolidBytesDefined;
- bool _solidExtension;
-
- bool _compressHeaders;
- bool _compressHeadersFull;
- bool _encryptHeaders;
-
- bool _autoFilter;
- UInt32 _level;
-
- bool _volumeMode;
-
-
- HRESULT SetParam(COneMethodInfo &oneMethodInfo, const UString &name, const UString &value);
- HRESULT SetParams(COneMethodInfo &oneMethodInfo, const UString &srcString);
-
- HRESULT SetPassword(CCompressionMethodMode &methodMode,
- IArchiveUpdateCallback *updateCallback);
-
- HRESULT SetCompressionMethod(CCompressionMethodMode &method,
- CObjectVector<COneMethodInfo> &methodsInfo
- #ifdef COMPRESS_MT
- , UInt32 numThreads
- #endif
- );
-
- HRESULT SetCompressionMethod(
- CCompressionMethodMode &method,
- CCompressionMethodMode &headerMethod);
-
- #endif
-
- #ifndef _SFX
-
- CRecordVector<UInt64> _fileInfoPopIDs;
- void FillPopIDs();
-
- #endif
-
- #ifndef EXTRACT_ONLY
-
- void InitSolidFiles() { _numSolidFiles = UInt64(Int64(-1)); }
- void InitSolidSize() { _numSolidBytes = UInt64(Int64(-1)); }
- void InitSolid()
- {
- InitSolidFiles();
- InitSolidSize();
- _solidExtension = false;
- _numSolidBytesDefined = false;
- }
-
- void Init()
- {
- _removeSfxBlock = false;
- _compressHeaders = true;
- _compressHeadersFull = true;
- _encryptHeaders = false;
- #ifdef COMPRESS_MT
- _numThreads = NWindows::NSystem::GetNumberOfProcessors();
- #endif
-
- _level = 5;
- _autoFilter = true;
- _volumeMode = false;
- InitSolid();
- }
- #endif
-};
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zHeader.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zHeader.cpp
deleted file mode 100644
index 7aff58fa4..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zHeader.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// 7z/Header.cpp
-
-#include "StdAfx.h"
-#include "7zHeader.h"
-
-namespace NArchive {
-namespace N7z {
-
-Byte kSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C};
-Byte kFinishSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C + 1};
-
-class SignatureInitializer
-{
-public:
- SignatureInitializer() { kSignature[0]--; kFinishSignature[0]--;};
-} g_SignatureInitializer;
-
-}}
-
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zHeader.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zHeader.h
deleted file mode 100644
index f30167726..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zHeader.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// 7z/7zHeader.h
-
-#ifndef __7Z_HEADER_H
-#define __7Z_HEADER_H
-
-#include "7zMethodID.h"
-
-namespace NArchive {
-namespace N7z {
-
-const int kSignatureSize = 6;
-extern Byte kSignature[kSignatureSize];
-
-// #define _7Z_VOL
-// 7z-MultiVolume is not finished yet.
-// It can work already, but I still do not like some
-// things of that new multivolume format.
-// So please keep it commented.
-
-#ifdef _7Z_VOL
-extern Byte kFinishSignature[kSignatureSize];
-#endif
-
-struct CArchiveVersion
-{
- Byte Major;
- Byte Minor;
-};
-
-const Byte kMajorVersion = 0;
-
-struct CStartHeader
-{
- UInt64 NextHeaderOffset;
- UInt64 NextHeaderSize;
- UInt32 NextHeaderCRC;
-};
-
-const UInt32 kStartHeaderSize = 20;
-
-#ifdef _7Z_VOL
-struct CFinishHeader: public CStartHeader
-{
- UInt64 ArchiveStartOffset; // data offset from end if that struct
- UInt64 AdditionalStartBlockSize; // start signature & start header size
-};
-
-const UInt32 kFinishHeaderSize = kStartHeaderSize + 16;
-#endif
-
-namespace NID
-{
- enum EEnum
- {
- kEnd,
-
- kHeader,
-
- kArchiveProperties,
-
- kAdditionalStreamsInfo,
- kMainStreamsInfo,
- kFilesInfo,
-
- kPackInfo,
- kUnPackInfo,
- kSubStreamsInfo,
-
- kSize,
- kCRC,
-
- kFolder,
-
- kCodersUnPackSize,
- kNumUnPackStream,
-
- kEmptyStream,
- kEmptyFile,
- kAnti,
-
- kName,
- kCreationTime,
- kLastAccessTime,
- kLastWriteTime,
- kWinAttributes,
- kComment,
-
- kEncodedHeader,
-
- kStartPos
- };
-}
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zIn.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zIn.cpp
deleted file mode 100644
index 86709d36d..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zIn.cpp
+++ /dev/null
@@ -1,1294 +0,0 @@
-// 7zIn.cpp
-
-#include "StdAfx.h"
-
-#include "7zIn.h"
-#include "7zMethods.h"
-#include "7zDecode.h"
-#include "../../Common/StreamObjects.h"
-#include "../../Common/StreamUtils.h"
-#include "../../../Common/CRC.h"
-
-namespace NArchive {
-namespace N7z {
-
-class CStreamSwitch
-{
- CInArchive *_archive;
- bool _needRemove;
-public:
- CStreamSwitch(): _needRemove(false) {}
- ~CStreamSwitch() { Remove(); }
- void Remove();
- void Set(CInArchive *archive, const Byte *data, size_t size);
- void Set(CInArchive *archive, const CByteBuffer &byteBuffer);
- HRESULT Set(CInArchive *archive, const CObjectVector<CByteBuffer> *dataVector);
-};
-
-void CStreamSwitch::Remove()
-{
- if (_needRemove)
- {
- _archive->DeleteByteStream();
- _needRemove = false;
- }
-}
-
-void CStreamSwitch::Set(CInArchive *archive, const Byte *data, size_t size)
-{
- Remove();
- _archive = archive;
- _archive->AddByteStream(data, size);
- _needRemove = true;
-}
-
-void CStreamSwitch::Set(CInArchive *archive, const CByteBuffer &byteBuffer)
-{
- Set(archive, byteBuffer, byteBuffer.GetCapacity());
-}
-
-HRESULT CStreamSwitch::Set(CInArchive *archive, const CObjectVector<CByteBuffer> *dataVector)
-{
- Remove();
- Byte external;
- RINOK(archive->ReadByte(external));
- if (external != 0)
- {
- CNum dataIndex;
- RINOK(archive->ReadNum(dataIndex));
- Set(archive, (*dataVector)[dataIndex]);
- }
- return S_OK;
-}
-
-
-CInArchiveException::CInArchiveException(CCauseType cause):
- Cause(cause)
-{}
-
-HRESULT CInArchive::ReadDirect(IInStream *stream, void *data, UInt32 size,
- UInt32 *processedSize)
-{
- UInt32 realProcessedSize;
- HRESULT result = ReadStream(stream, data, size, &realProcessedSize);
- if(processedSize != NULL)
- *processedSize = realProcessedSize;
- _position += realProcessedSize;
- return result;
-}
-
-HRESULT CInArchive::ReadDirect(void *data, UInt32 size, UInt32 *processedSize)
-{
- return ReadDirect(_stream, data, size, processedSize);
-}
-
-HRESULT CInArchive::SafeReadDirect(void *data, UInt32 size)
-{
- UInt32 realProcessedSize;
- RINOK(ReadDirect(data, size, &realProcessedSize));
- if (realProcessedSize != size)
- throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
- return S_OK;
-}
-
-HRESULT CInArchive::SafeReadDirectByte(Byte &b)
-{
- return SafeReadDirect(&b, 1);
-}
-
-HRESULT CInArchive::SafeReadDirectUInt32(UInt32 &value)
-{
- value = 0;
- for (int i = 0; i < 4; i++)
- {
- Byte b;
- RINOK(SafeReadDirectByte(b));
- value |= (UInt32(b) << (8 * i));
- }
- return S_OK;
-}
-
-HRESULT CInArchive::SafeReadDirectUInt64(UInt64 &value)
-{
- value = 0;
- for (int i = 0; i < 8; i++)
- {
- Byte b;
- RINOK(SafeReadDirectByte(b));
- value |= (UInt64(b) << (8 * i));
- }
- return S_OK;
-}
-
-HRESULT CInArchive::ReadNumber(UInt64 &value)
-{
- Byte firstByte;
- RINOK(ReadByte(firstByte));
- Byte mask = 0x80;
- value = 0;
- for (int i = 0; i < 8; i++)
- {
- if ((firstByte & mask) == 0)
- {
- UInt64 highPart = firstByte & (mask - 1);
- value += (highPart << (i * 8));
- return S_OK;
- }
- Byte b;
- RINOK(ReadByte(b));
- value |= (UInt64(b) << (8 * i));
- mask >>= 1;
- }
- return S_OK;
-}
-
-HRESULT CInArchive::ReadNum(CNum &value)
-{
- UInt64 value64;
- RINOK(ReadNumber(value64));
- if (value64 > kNumMax)
- return E_FAIL;
- value = (CNum)value64;
- return S_OK;
-}
-
-HRESULT CInArchive::ReadUInt32(UInt32 &value)
-{
- value = 0;
- for (int i = 0; i < 4; i++)
- {
- Byte b;
- RINOK(ReadByte(b));
- value |= (UInt32(b) << (8 * i));
- }
- return S_OK;
-}
-
-HRESULT CInArchive::ReadUInt64(UInt64 &value)
-{
- value = 0;
- for (int i = 0; i < 8; i++)
- {
- Byte b;
- RINOK(ReadByte(b));
- value |= (UInt64(b) << (8 * i));
- }
- return S_OK;
-}
-
-static inline bool TestSignatureCandidate(const void *testBytes)
-{
- for (int i = 0; i < kSignatureSize; i++)
- if (((const Byte *)testBytes)[i] != kSignature[i])
- return false;
- return true;
-}
-
-#ifdef _7Z_VOL
-static inline bool TestFinishSignatureCandidate(const void *testBytes)
-{
- for (int i = 0; i < kSignatureSize; i++)
- if (((const Byte *)testBytes)[i] != kFinishSignature[i])
- return false;
- return true;
-}
-#endif
-
-HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
-{
- _position = _arhiveBeginStreamPosition;
- RINOK(stream->Seek(_arhiveBeginStreamPosition, STREAM_SEEK_SET, NULL));
-
- Byte signature[kSignatureSize];
- UInt32 processedSize;
- RINOK(ReadDirect(stream, signature, kSignatureSize, &processedSize));
- if(processedSize != kSignatureSize)
- return S_FALSE;
- if (TestSignatureCandidate(signature))
- return S_OK;
-
- CByteBuffer byteBuffer;
- const UInt32 kBufferSize = (1 << 16);
- byteBuffer.SetCapacity(kBufferSize);
- Byte *buffer = byteBuffer;
- UInt32 numPrevBytes = kSignatureSize - 1;
- memmove(buffer, signature + 1, numPrevBytes);
- UInt64 curTestPos = _arhiveBeginStreamPosition + 1;
- while(true)
- {
- if (searchHeaderSizeLimit != NULL)
- if (curTestPos - _arhiveBeginStreamPosition > *searchHeaderSizeLimit)
- return S_FALSE;
- UInt32 numReadBytes = kBufferSize - numPrevBytes;
- RINOK(ReadDirect(stream, buffer + numPrevBytes, numReadBytes, &processedSize));
- UInt32 numBytesInBuffer = numPrevBytes + processedSize;
- if (numBytesInBuffer < kSignatureSize)
- return S_FALSE;
- UInt32 numTests = numBytesInBuffer - kSignatureSize + 1;
- for(UInt32 pos = 0; pos < numTests; pos++, curTestPos++)
- {
- if (TestSignatureCandidate(buffer + pos))
- {
- _arhiveBeginStreamPosition = curTestPos;
- _position = curTestPos + kSignatureSize;
- return stream->Seek(_position, STREAM_SEEK_SET, NULL);
- }
- }
- numPrevBytes = numBytesInBuffer - numTests;
- memmove(buffer, buffer + numTests, numPrevBytes);
- }
-}
-
-// Out: _position must point to end of signature
-
-#ifdef _7Z_VOL
-HRESULT CInArchive::FindFinishSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
-{
- RINOK(stream->Seek(0, STREAM_SEEK_END, &_position));
- if (_position < kSignatureSize)
- return S_FALSE;
-
- CByteBuffer byteBuffer;
- const UInt32 kBufferSize = (1 << 18);
- byteBuffer.SetCapacity(kBufferSize);
- Byte *buffer = byteBuffer;
- UInt32 numPrevBytes = 0;
- UInt64 limitPos = 0;
- if (searchHeaderSizeLimit != NULL)
- if (*searchHeaderSizeLimit < _position)
- limitPos = _position - *searchHeaderSizeLimit;
-
- while(_position >= limitPos)
- {
- UInt32 numReadBytes = kBufferSize - numPrevBytes;
- if (numReadBytes > _position)
- numReadBytes = (UInt32)_position;
- UInt32 numBytesInBuffer = numPrevBytes + numReadBytes;
- if (numBytesInBuffer < kSignatureSize)
- return S_FALSE;
- _position -= numReadBytes;
- RINOK(stream->Seek(_position, STREAM_SEEK_SET, &_position));
- UInt32 startPos = kBufferSize - numBytesInBuffer;
- UInt32 processedSize;
- RINOK(ReadDirect(stream, buffer + startPos, numReadBytes, &processedSize));
- if (processedSize != numReadBytes)
- return S_FALSE;
- _position -= processedSize;
- for(UInt32 pos = kBufferSize; pos >= startPos + kSignatureSize; pos--)
- {
- if (TestFinishSignatureCandidate(buffer + pos - kSignatureSize))
- {
- _position += pos - startPos;
- return stream->Seek(_position, STREAM_SEEK_SET, NULL);
- }
- }
- numPrevBytes = kSignatureSize - 1;
- memmove(buffer + kBufferSize - numPrevBytes, buffer + startPos + 1, numPrevBytes);
- }
- return S_FALSE;
-}
-#endif
-
-// S_FALSE means that file is not archive
-HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
-{
- Close();
- RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_arhiveBeginStreamPosition))
- _position = _arhiveBeginStreamPosition;
- #ifdef _7Z_VOL
- HRESULT result = FindFinishSignature(stream, searchHeaderSizeLimit);
- if (result == S_OK)
- _finishSignature = true;
- else
- {
- if (result != S_FALSE)
- return result;
- _finishSignature = false;
- RINOK(FindAndReadSignature(stream, searchHeaderSizeLimit));
- }
- #else
- RINOK(FindAndReadSignature(stream, searchHeaderSizeLimit));
- #endif
- _stream = stream;
- return S_OK;
-}
-
-void CInArchive::Close()
-{
- _stream.Release();
-}
-
-HRESULT CInArchive::SkeepData(UInt64 size)
-{
- for (UInt64 i = 0; i < size; i++)
- {
- Byte temp;
- RINOK(ReadByte(temp));
- }
- return S_OK;
-}
-
-HRESULT CInArchive::SkeepData()
-{
- UInt64 size;
- RINOK(ReadNumber(size));
- return SkeepData(size);
-}
-
-HRESULT CInArchive::ReadArchiveProperties(CInArchiveInfo &archiveInfo)
-{
- while(true)
- {
- UInt64 type;
- RINOK(ReadID(type));
- if (type == NID::kEnd)
- break;
- SkeepData();
- }
- return S_OK;
-}
-
-HRESULT CInArchive::GetNextFolderItem(CFolder &folder)
-{
- CNum numCoders;
- RINOK(ReadNum(numCoders));
-
- folder.Coders.Clear();
- folder.Coders.Reserve((int)numCoders);
- CNum numInStreams = 0;
- CNum numOutStreams = 0;
- CNum i;
- for (i = 0; i < numCoders; i++)
- {
- folder.Coders.Add(CCoderInfo());
- CCoderInfo &coder = folder.Coders.Back();
-
- while (true)
- {
- coder.AltCoders.Add(CAltCoderInfo());
- CAltCoderInfo &altCoder = coder.AltCoders.Back();
- Byte mainByte;
- RINOK(ReadByte(mainByte));
- altCoder.MethodID.IDSize = mainByte & 0xF;
- RINOK(ReadBytes(altCoder.MethodID.ID, altCoder.MethodID.IDSize));
- if ((mainByte & 0x10) != 0)
- {
- RINOK(ReadNum(coder.NumInStreams));
- RINOK(ReadNum(coder.NumOutStreams));
- }
- else
- {
- coder.NumInStreams = 1;
- coder.NumOutStreams = 1;
- }
- if ((mainByte & 0x20) != 0)
- {
- CNum propertiesSize = 0;
- RINOK(ReadNum(propertiesSize));
- altCoder.Properties.SetCapacity((size_t)propertiesSize);
- RINOK(ReadBytes((Byte *)altCoder.Properties, (size_t)propertiesSize));
- }
- if ((mainByte & 0x80) == 0)
- break;
- }
- numInStreams += coder.NumInStreams;
- numOutStreams += coder.NumOutStreams;
- }
-
- CNum numBindPairs;
- // RINOK(ReadNumber(numBindPairs));
- numBindPairs = numOutStreams - 1;
- folder.BindPairs.Clear();
- folder.BindPairs.Reserve(numBindPairs);
- for (i = 0; i < numBindPairs; i++)
- {
- CBindPair bindPair;
- RINOK(ReadNum(bindPair.InIndex));
- RINOK(ReadNum(bindPair.OutIndex));
- folder.BindPairs.Add(bindPair);
- }
-
- CNum numPackedStreams = numInStreams - numBindPairs;
- folder.PackStreams.Reserve(numPackedStreams);
- if (numPackedStreams == 1)
- {
- for (CNum j = 0; j < numInStreams; j++)
- if (folder.FindBindPairForInStream(j) < 0)
- {
- folder.PackStreams.Add(j);
- break;
- }
- }
- else
- for(i = 0; i < numPackedStreams; i++)
- {
- CNum packStreamInfo;
- RINOK(ReadNum(packStreamInfo));
- folder.PackStreams.Add(packStreamInfo);
- }
-
- return S_OK;
-}
-
-HRESULT CInArchive::WaitAttribute(UInt64 attribute)
-{
- while(true)
- {
- UInt64 type;
- RINOK(ReadID(type));
- if (type == attribute)
- return S_OK;
- if (type == NID::kEnd)
- return S_FALSE;
- RINOK(SkeepData());
- }
-}
-
-HRESULT CInArchive::ReadHashDigests(int numItems,
- CRecordVector<bool> &digestsDefined,
- CRecordVector<UInt32> &digests)
-{
- RINOK(ReadBoolVector2(numItems, digestsDefined));
- digests.Clear();
- digests.Reserve(numItems);
- for(int i = 0; i < numItems; i++)
- {
- UInt32 crc;
- if (digestsDefined[i])
- RINOK(ReadUInt32(crc));
- digests.Add(crc);
- }
- return S_OK;
-}
-
-HRESULT CInArchive::ReadPackInfo(
- UInt64 &dataOffset,
- CRecordVector<UInt64> &packSizes,
- CRecordVector<bool> &packCRCsDefined,
- CRecordVector<UInt32> &packCRCs)
-{
- RINOK(ReadNumber(dataOffset));
- CNum numPackStreams;
- RINOK(ReadNum(numPackStreams));
-
- RINOK(WaitAttribute(NID::kSize));
- packSizes.Clear();
- packSizes.Reserve(numPackStreams);
- for(CNum i = 0; i < numPackStreams; i++)
- {
- UInt64 size;
- RINOK(ReadNumber(size));
- packSizes.Add(size);
- }
-
- UInt64 type;
- while(true)
- {
- RINOK(ReadID(type));
- if (type == NID::kEnd)
- break;
- if (type == NID::kCRC)
- {
- RINOK(ReadHashDigests(numPackStreams, packCRCsDefined, packCRCs));
- continue;
- }
- RINOK(SkeepData());
- }
- if (packCRCsDefined.IsEmpty())
- {
- packCRCsDefined.Reserve(numPackStreams);
- packCRCsDefined.Clear();
- packCRCs.Reserve(numPackStreams);
- packCRCs.Clear();
- for(CNum i = 0; i < numPackStreams; i++)
- {
- packCRCsDefined.Add(false);
- packCRCs.Add(0);
- }
- }
- return S_OK;
-}
-
-HRESULT CInArchive::ReadUnPackInfo(
- const CObjectVector<CByteBuffer> *dataVector,
- CObjectVector<CFolder> &folders)
-{
- RINOK(WaitAttribute(NID::kFolder));
- CNum numFolders;
- RINOK(ReadNum(numFolders));
-
- {
- CStreamSwitch streamSwitch;
- RINOK(streamSwitch.Set(this, dataVector));
- folders.Clear();
- folders.Reserve((UInt32)numFolders);
- for(CNum i = 0; i < numFolders; i++)
- {
- folders.Add(CFolder());
- RINOK(GetNextFolderItem(folders.Back()));
- }
- }
-
- RINOK(WaitAttribute(NID::kCodersUnPackSize));
-
- CNum i;
- for(i = 0; i < numFolders; i++)
- {
- CFolder &folder = folders[i];
- CNum numOutStreams = folder.GetNumOutStreams();
- folder.UnPackSizes.Reserve(numOutStreams);
- for(CNum j = 0; j < numOutStreams; j++)
- {
- UInt64 unPackSize;
- RINOK(ReadNumber(unPackSize));
- folder.UnPackSizes.Add(unPackSize);
- }
- }
-
- while(true)
- {
- UInt64 type;
- RINOK(ReadID(type));
- if (type == NID::kEnd)
- return S_OK;
- if (type == NID::kCRC)
- {
- CRecordVector<bool> crcsDefined;
- CRecordVector<UInt32> crcs;
- RINOK(ReadHashDigests(numFolders, crcsDefined, crcs));
- for(i = 0; i < numFolders; i++)
- {
- CFolder &folder = folders[i];
- folder.UnPackCRCDefined = crcsDefined[i];
- folder.UnPackCRC = crcs[i];
- }
- continue;
- }
- RINOK(SkeepData());
- }
-}
-
-HRESULT CInArchive::ReadSubStreamsInfo(
- const CObjectVector<CFolder> &folders,
- CRecordVector<CNum> &numUnPackStreamsInFolders,
- CRecordVector<UInt64> &unPackSizes,
- CRecordVector<bool> &digestsDefined,
- CRecordVector<UInt32> &digests)
-{
- numUnPackStreamsInFolders.Clear();
- numUnPackStreamsInFolders.Reserve(folders.Size());
- UInt64 type;
- while(true)
- {
- RINOK(ReadID(type));
- if (type == NID::kNumUnPackStream)
- {
- for(int i = 0; i < folders.Size(); i++)
- {
- CNum value;
- RINOK(ReadNum(value));
- numUnPackStreamsInFolders.Add(value);
- }
- continue;
- }
- if (type == NID::kCRC || type == NID::kSize)
- break;
- if (type == NID::kEnd)
- break;
- RINOK(SkeepData());
- }
-
- if (numUnPackStreamsInFolders.IsEmpty())
- for(int i = 0; i < folders.Size(); i++)
- numUnPackStreamsInFolders.Add(1);
-
- int i;
- for(i = 0; i < numUnPackStreamsInFolders.Size(); i++)
- {
- // v3.13 incorrectly worked with empty folders
- // v4.07: we check that folder is empty
- CNum numSubstreams = numUnPackStreamsInFolders[i];
- if (numSubstreams == 0)
- continue;
- UInt64 sum = 0;
- for (CNum j = 1; j < numSubstreams; j++)
- {
- UInt64 size;
- if (type == NID::kSize)
- {
- RINOK(ReadNumber(size));
- unPackSizes.Add(size);
- sum += size;
- }
- }
- unPackSizes.Add(folders[i].GetUnPackSize() - sum);
- }
- if (type == NID::kSize)
- {
- RINOK(ReadID(type));
- }
-
- int numDigests = 0;
- int numDigestsTotal = 0;
- for(i = 0; i < folders.Size(); i++)
- {
- CNum numSubstreams = numUnPackStreamsInFolders[i];
- if (numSubstreams != 1 || !folders[i].UnPackCRCDefined)
- numDigests += numSubstreams;
- numDigestsTotal += numSubstreams;
- }
-
- while(true)
- {
- if (type == NID::kCRC)
- {
- CRecordVector<bool> digestsDefined2;
- CRecordVector<UInt32> digests2;
- RINOK(ReadHashDigests(numDigests, digestsDefined2, digests2));
- int digestIndex = 0;
- for (i = 0; i < folders.Size(); i++)
- {
- CNum numSubstreams = numUnPackStreamsInFolders[i];
- const CFolder &folder = folders[i];
- if (numSubstreams == 1 && folder.UnPackCRCDefined)
- {
- digestsDefined.Add(true);
- digests.Add(folder.UnPackCRC);
- }
- else
- for (CNum j = 0; j < numSubstreams; j++, digestIndex++)
- {
- digestsDefined.Add(digestsDefined2[digestIndex]);
- digests.Add(digests2[digestIndex]);
- }
- }
- }
- else if (type == NID::kEnd)
- {
- if (digestsDefined.IsEmpty())
- {
- digestsDefined.Clear();
- digests.Clear();
- for (int i = 0; i < numDigestsTotal; i++)
- {
- digestsDefined.Add(false);
- digests.Add(0);
- }
- }
- return S_OK;
- }
- else
- {
- RINOK(SkeepData());
- }
- RINOK(ReadID(type));
- }
-}
-
-HRESULT CInArchive::ReadStreamsInfo(
- const CObjectVector<CByteBuffer> *dataVector,
- UInt64 &dataOffset,
- CRecordVector<UInt64> &packSizes,
- CRecordVector<bool> &packCRCsDefined,
- CRecordVector<UInt32> &packCRCs,
- CObjectVector<CFolder> &folders,
- CRecordVector<CNum> &numUnPackStreamsInFolders,
- CRecordVector<UInt64> &unPackSizes,
- CRecordVector<bool> &digestsDefined,
- CRecordVector<UInt32> &digests)
-{
- while(true)
- {
- UInt64 type;
- RINOK(ReadID(type));
- switch(type)
- {
- case NID::kEnd:
- return S_OK;
- case NID::kPackInfo:
- {
- RINOK(ReadPackInfo(dataOffset, packSizes,
- packCRCsDefined, packCRCs));
- break;
- }
- case NID::kUnPackInfo:
- {
- RINOK(ReadUnPackInfo(dataVector, folders));
- break;
- }
- case NID::kSubStreamsInfo:
- {
- RINOK(ReadSubStreamsInfo(folders, numUnPackStreamsInFolders,
- unPackSizes, digestsDefined, digests));
- break;
- }
- }
- }
-}
-
-HRESULT CInArchive::ReadFileNames(CObjectVector<CFileItem> &files)
-{
- for(int i = 0; i < files.Size(); i++)
- {
- UString &name = files[i].Name;
- name.Empty();
- while (true)
- {
- wchar_t c;
- RINOK(ReadWideCharLE(c));
- if (c == L'\0')
- break;
- name += c;
- }
- }
- return S_OK;
-}
-
-HRESULT CInArchive::ReadBoolVector(int numItems, CBoolVector &v)
-{
- v.Clear();
- v.Reserve(numItems);
- Byte b;
- Byte mask = 0;
- for(int i = 0; i < numItems; i++)
- {
- if (mask == 0)
- {
- RINOK(ReadByte(b));
- mask = 0x80;
- }
- v.Add((b & mask) != 0);
- mask >>= 1;
- }
- return S_OK;
-}
-
-HRESULT CInArchive::ReadBoolVector2(int numItems, CBoolVector &v)
-{
- Byte allAreDefined;
- RINOK(ReadByte(allAreDefined));
- if (allAreDefined == 0)
- return ReadBoolVector(numItems, v);
- v.Clear();
- v.Reserve(numItems);
- for (int i = 0; i < numItems; i++)
- v.Add(true);
- return S_OK;
-}
-
-HRESULT CInArchive::ReadTime(const CObjectVector<CByteBuffer> &dataVector,
- CObjectVector<CFileItem> &files, UInt64 type)
-{
- CBoolVector boolVector;
- RINOK(ReadBoolVector2(files.Size(), boolVector))
-
- CStreamSwitch streamSwitch;
- RINOK(streamSwitch.Set(this, &dataVector));
-
- for(int i = 0; i < files.Size(); i++)
- {
- CFileItem &file = files[i];
- CArchiveFileTime fileTime;
- bool defined = boolVector[i];
- if (defined)
- {
- UInt32 low, high;
- RINOK(ReadUInt32(low));
- RINOK(ReadUInt32(high));
- fileTime.dwLowDateTime = low;
- fileTime.dwHighDateTime = high;
- }
- switch(type)
- {
- case NID::kCreationTime:
- file.IsCreationTimeDefined = defined;
- if (defined)
- file.CreationTime = fileTime;
- break;
- case NID::kLastWriteTime:
- file.IsLastWriteTimeDefined = defined;
- if (defined)
- file.LastWriteTime = fileTime;
- break;
- case NID::kLastAccessTime:
- file.IsLastAccessTimeDefined = defined;
- if (defined)
- file.LastAccessTime = fileTime;
- break;
- }
- }
- return S_OK;
-}
-
-HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
- UInt64 &dataOffset, CObjectVector<CByteBuffer> &dataVector
- #ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
- #endif
- )
-{
- CRecordVector<UInt64> packSizes;
- CRecordVector<bool> packCRCsDefined;
- CRecordVector<UInt32> packCRCs;
- CObjectVector<CFolder> folders;
-
- CRecordVector<CNum> numUnPackStreamsInFolders;
- CRecordVector<UInt64> unPackSizes;
- CRecordVector<bool> digestsDefined;
- CRecordVector<UInt32> digests;
-
- RINOK(ReadStreamsInfo(NULL,
- dataOffset,
- packSizes,
- packCRCsDefined,
- packCRCs,
- folders,
- numUnPackStreamsInFolders,
- unPackSizes,
- digestsDefined,
- digests));
-
- // database.ArchiveInfo.DataStartPosition2 += database.ArchiveInfo.StartPositionAfterHeader;
-
- CNum packIndex = 0;
- CDecoder decoder(
- #ifdef _ST_MODE
- false
- #else
- true
- #endif
- );
- UInt64 dataStartPos = baseOffset + dataOffset;
- for(int i = 0; i < folders.Size(); i++)
- {
- const CFolder &folder = folders[i];
- dataVector.Add(CByteBuffer());
- CByteBuffer &data = dataVector.Back();
- UInt64 unPackSize = folder.GetUnPackSize();
- if (unPackSize > kNumMax)
- return E_FAIL;
- if (unPackSize > 0xFFFFFFFF)
- return E_FAIL;
- data.SetCapacity((size_t)unPackSize);
-
- CSequentialOutStreamImp2 *outStreamSpec = new CSequentialOutStreamImp2;
- CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
- outStreamSpec->Init(data, (size_t)unPackSize);
-
- HRESULT result = decoder.Decode(_stream, dataStartPos,
- &packSizes[packIndex], folder, outStream, NULL
- #ifndef _NO_CRYPTO
- , getTextPassword
- #endif
- #ifdef COMPRESS_MT
- , false, 1
- #endif
- );
- RINOK(result);
-
- if (folder.UnPackCRCDefined)
- if (!CCRC::VerifyDigest(folder.UnPackCRC, data, (UInt32)unPackSize))
- throw CInArchiveException(CInArchiveException::kIncorrectHeader);
- for (int j = 0; j < folder.PackStreams.Size(); j++)
- dataStartPos += packSizes[packIndex++];
- }
- return S_OK;
-}
-
-HRESULT CInArchive::ReadHeader(CArchiveDatabaseEx &database
- #ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
- #endif
- )
-{
- UInt64 type;
- RINOK(ReadID(type));
-
- if (type == NID::kArchiveProperties)
- {
- RINOK(ReadArchiveProperties(database.ArchiveInfo));
- RINOK(ReadID(type));
- }
-
- CObjectVector<CByteBuffer> dataVector;
-
- if (type == NID::kAdditionalStreamsInfo)
- {
- HRESULT result = ReadAndDecodePackedStreams(
- database.ArchiveInfo.StartPositionAfterHeader,
- database.ArchiveInfo.DataStartPosition2,
- dataVector
- #ifndef _NO_CRYPTO
- , getTextPassword
- #endif
- );
- RINOK(result);
- database.ArchiveInfo.DataStartPosition2 += database.ArchiveInfo.StartPositionAfterHeader;
- RINOK(ReadID(type));
- }
-
- CRecordVector<UInt64> unPackSizes;
- CRecordVector<bool> digestsDefined;
- CRecordVector<UInt32> digests;
-
- if (type == NID::kMainStreamsInfo)
- {
- RINOK(ReadStreamsInfo(&dataVector,
- database.ArchiveInfo.DataStartPosition,
- database.PackSizes,
- database.PackCRCsDefined,
- database.PackCRCs,
- database.Folders,
- database.NumUnPackStreamsVector,
- unPackSizes,
- digestsDefined,
- digests));
- database.ArchiveInfo.DataStartPosition += database.ArchiveInfo.StartPositionAfterHeader;
- RINOK(ReadID(type));
- }
- else
- {
- for(int i = 0; i < database.Folders.Size(); i++)
- {
- database.NumUnPackStreamsVector.Add(1);
- CFolder &folder = database.Folders[i];
- unPackSizes.Add(folder.GetUnPackSize());
- digestsDefined.Add(folder.UnPackCRCDefined);
- digests.Add(folder.UnPackCRC);
- }
- }
-
- database.Files.Clear();
-
- if (type == NID::kEnd)
- return S_OK;
- if (type != NID::kFilesInfo)
- throw CInArchiveException(CInArchiveException::kIncorrectHeader);
-
- CNum numFiles;
- RINOK(ReadNum(numFiles));
- database.Files.Reserve(numFiles);
- CNum i;
- for(i = 0; i < numFiles; i++)
- database.Files.Add(CFileItem());
-
- database.ArchiveInfo.FileInfoPopIDs.Add(NID::kSize);
- if (!database.PackSizes.IsEmpty())
- database.ArchiveInfo.FileInfoPopIDs.Add(NID::kPackInfo);
- if (numFiles > 0 && !digests.IsEmpty())
- database.ArchiveInfo.FileInfoPopIDs.Add(NID::kCRC);
-
- CBoolVector emptyStreamVector;
- emptyStreamVector.Reserve((int)numFiles);
- for(i = 0; i < numFiles; i++)
- emptyStreamVector.Add(false);
- CBoolVector emptyFileVector;
- CBoolVector antiFileVector;
- CNum numEmptyStreams = 0;
-
- // int sizePrev = -1;
- // int posPrev = 0;
-
- while(true)
- {
- /*
- if (sizePrev >= 0)
- if (sizePrev != _inByteBack->GetProcessedSize() - posPrev)
- throw 2;
- */
- UInt64 type;
- RINOK(ReadID(type));
- if (type == NID::kEnd)
- break;
- UInt64 size;
- RINOK(ReadNumber(size));
-
- // sizePrev = size;
- // posPrev = _inByteBack->GetProcessedSize();
-
- database.ArchiveInfo.FileInfoPopIDs.Add(type);
- switch(type)
- {
- case NID::kName:
- {
- CStreamSwitch streamSwitch;
- RINOK(streamSwitch.Set(this, &dataVector));
- RINOK(ReadFileNames(database.Files))
- break;
- }
- case NID::kWinAttributes:
- {
- CBoolVector boolVector;
- RINOK(ReadBoolVector2(database.Files.Size(), boolVector))
- CStreamSwitch streamSwitch;
- RINOK(streamSwitch.Set(this, &dataVector));
- for(i = 0; i < numFiles; i++)
- {
- CFileItem &file = database.Files[i];
- if (file.AreAttributesDefined = boolVector[i])
- {
- RINOK(ReadUInt32(file.Attributes));
- }
- }
- break;
- }
- case NID::kStartPos:
- {
- CBoolVector boolVector;
- RINOK(ReadBoolVector2(database.Files.Size(), boolVector))
- CStreamSwitch streamSwitch;
- RINOK(streamSwitch.Set(this, &dataVector));
- for(i = 0; i < numFiles; i++)
- {
- CFileItem &file = database.Files[i];
- if (file.IsStartPosDefined = boolVector[i])
- {
- RINOK(ReadUInt64(file.StartPos));
- }
- }
- break;
- }
- case NID::kEmptyStream:
- {
- RINOK(ReadBoolVector(numFiles, emptyStreamVector))
- for (i = 0; i < (CNum)emptyStreamVector.Size(); i++)
- if (emptyStreamVector[i])
- numEmptyStreams++;
- emptyFileVector.Reserve(numEmptyStreams);
- antiFileVector.Reserve(numEmptyStreams);
- for (i = 0; i < numEmptyStreams; i++)
- {
- emptyFileVector.Add(false);
- antiFileVector.Add(false);
- }
- break;
- }
- case NID::kEmptyFile:
- {
- RINOK(ReadBoolVector(numEmptyStreams, emptyFileVector))
- break;
- }
- case NID::kAnti:
- {
- RINOK(ReadBoolVector(numEmptyStreams, antiFileVector))
- break;
- }
- case NID::kCreationTime:
- case NID::kLastWriteTime:
- case NID::kLastAccessTime:
- {
- RINOK(ReadTime(dataVector, database.Files, type))
- break;
- }
- default:
- {
- database.ArchiveInfo.FileInfoPopIDs.DeleteBack();
- RINOK(SkeepData(size));
- }
- }
- }
-
- CNum emptyFileIndex = 0;
- CNum sizeIndex = 0;
- for(i = 0; i < numFiles; i++)
- {
- CFileItem &file = database.Files[i];
- file.HasStream = !emptyStreamVector[i];
- if(file.HasStream)
- {
- file.IsDirectory = false;
- file.IsAnti = false;
- file.UnPackSize = unPackSizes[sizeIndex];
- file.FileCRC = digests[sizeIndex];
- file.IsFileCRCDefined = digestsDefined[sizeIndex];
- sizeIndex++;
- }
- else
- {
- file.IsDirectory = !emptyFileVector[emptyFileIndex];
- file.IsAnti = antiFileVector[emptyFileIndex];
- emptyFileIndex++;
- file.UnPackSize = 0;
- file.IsFileCRCDefined = false;
- }
- }
- return S_OK;
-}
-
-
-void CArchiveDatabaseEx::FillFolderStartPackStream()
-{
- FolderStartPackStreamIndex.Clear();
- FolderStartPackStreamIndex.Reserve(Folders.Size());
- CNum startPos = 0;
- for(int i = 0; i < Folders.Size(); i++)
- {
- FolderStartPackStreamIndex.Add(startPos);
- startPos += (CNum)Folders[i].PackStreams.Size();
- }
-}
-
-void CArchiveDatabaseEx::FillStartPos()
-{
- PackStreamStartPositions.Clear();
- PackStreamStartPositions.Reserve(PackSizes.Size());
- UInt64 startPos = 0;
- for(int i = 0; i < PackSizes.Size(); i++)
- {
- PackStreamStartPositions.Add(startPos);
- startPos += PackSizes[i];
- }
-}
-
-void CArchiveDatabaseEx::FillFolderStartFileIndex()
-{
- FolderStartFileIndex.Clear();
- FolderStartFileIndex.Reserve(Folders.Size());
- FileIndexToFolderIndexMap.Clear();
- FileIndexToFolderIndexMap.Reserve(Files.Size());
-
- int folderIndex = 0;
- CNum indexInFolder = 0;
- for (int i = 0; i < Files.Size(); i++)
- {
- const CFileItem &file = Files[i];
- bool emptyStream = !file.HasStream;
- if (emptyStream && indexInFolder == 0)
- {
- FileIndexToFolderIndexMap.Add(kNumNoIndex);
- continue;
- }
- if (indexInFolder == 0)
- {
- // v3.13 incorrectly worked with empty folders
- // v4.07: Loop for skipping empty folders
- while(true)
- {
- if (folderIndex >= Folders.Size())
- throw CInArchiveException(CInArchiveException::kIncorrectHeader);
- FolderStartFileIndex.Add(i); // check it
- if (NumUnPackStreamsVector[folderIndex] != 0)
- break;
- folderIndex++;
- }
- }
- FileIndexToFolderIndexMap.Add(folderIndex);
- if (emptyStream)
- continue;
- indexInFolder++;
- if (indexInFolder >= NumUnPackStreamsVector[folderIndex])
- {
- folderIndex++;
- indexInFolder = 0;
- }
- }
-}
-
-HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
- #ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
- #endif
- )
-{
- database.Clear();
- database.ArchiveInfo.StartPosition = _arhiveBeginStreamPosition;
-
-
- RINOK(SafeReadDirect(&database.ArchiveInfo.Version.Major, 1));
- RINOK(SafeReadDirect(&database.ArchiveInfo.Version.Minor, 1));
- if (database.ArchiveInfo.Version.Major != kMajorVersion)
- throw CInArchiveException(CInArchiveException::kUnsupportedVersion);
-
- #ifdef _7Z_VOL
- if (_finishSignature)
- {
- RINOK(_stream->Seek(_position - (4 + kFinishHeaderSize) -
- (kSignatureSize + 2), STREAM_SEEK_SET, &_position));
- }
- #endif
-
- UInt32 crcFromArchive;
- RINOK(SafeReadDirectUInt32(crcFromArchive));
-
- UInt64 nextHeaderOffset;
- UInt64 nextHeaderSize;
- UInt32 nextHeaderCRC;
- CCRC crc;
- RINOK(SafeReadDirectUInt64(nextHeaderOffset));
- crc.UpdateUInt64(nextHeaderOffset);
- RINOK(SafeReadDirectUInt64(nextHeaderSize));
- crc.UpdateUInt64(nextHeaderSize);
- RINOK(SafeReadDirectUInt32(nextHeaderCRC));
- crc.UpdateUInt32(nextHeaderCRC);
-
- #ifdef _7Z_VOL
- UInt64 archiveStartOffset; // data offset from end if that struct
- UInt64 additionalStartBlockSize; // start signature & start header size
- if (_finishSignature)
- {
- RINOK(SafeReadDirectUInt64(archiveStartOffset));
- crc.UpdateUInt64(archiveStartOffset);
- RINOK(SafeReadDirectUInt64(additionalStartBlockSize));
- crc.UpdateUInt64(additionalStartBlockSize);
- database.ArchiveInfo.StartPositionAfterHeader = _position + archiveStartOffset;
- }
- else
- #endif
- {
- database.ArchiveInfo.StartPositionAfterHeader = _position;
- }
- if (crc.GetDigest() != crcFromArchive)
- throw CInArchiveException(CInArchiveException::kIncorrectHeader);
-
- if (nextHeaderSize == 0)
- return S_OK;
-
- if (nextHeaderSize >= 0xFFFFFFFF)
- return E_FAIL;
-
- RINOK(_stream->Seek(nextHeaderOffset, STREAM_SEEK_CUR, &_position));
-
- CByteBuffer buffer2;
- buffer2.SetCapacity((size_t)nextHeaderSize);
- RINOK(SafeReadDirect(buffer2, (UInt32)nextHeaderSize));
- if (!CCRC::VerifyDigest(nextHeaderCRC, buffer2, (UInt32)nextHeaderSize))
- throw CInArchiveException(CInArchiveException::kIncorrectHeader);
-
- CStreamSwitch streamSwitch;
- streamSwitch.Set(this, buffer2);
-
- CObjectVector<CByteBuffer> dataVector;
-
- while (true)
- {
- UInt64 type;
- RINOK(ReadID(type));
- if (type == NID::kHeader)
- break;
- if (type != NID::kEncodedHeader)
- throw CInArchiveException(CInArchiveException::kIncorrectHeader);
- HRESULT result = ReadAndDecodePackedStreams(
- database.ArchiveInfo.StartPositionAfterHeader,
- database.ArchiveInfo.DataStartPosition2,
- dataVector
- #ifndef _NO_CRYPTO
- , getTextPassword
- #endif
- );
- RINOK(result);
- if (dataVector.Size() == 0)
- return S_OK;
- if (dataVector.Size() > 1)
- throw CInArchiveException(CInArchiveException::kIncorrectHeader);
- streamSwitch.Remove();
- streamSwitch.Set(this, dataVector.Front());
- }
-
- return ReadHeader(database
- #ifndef _NO_CRYPTO
- , getTextPassword
- #endif
- );
-}
-
-}}
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zIn.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zIn.h
deleted file mode 100644
index a6c5ef032..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zIn.h
+++ /dev/null
@@ -1,288 +0,0 @@
-// 7zIn.h
-
-#ifndef __7Z_IN_H
-#define __7Z_IN_H
-
-#include "../../IStream.h"
-#include "../../IPassword.h"
-#include "../../../Common/MyCom.h"
-#include "../../Common/InBuffer.h"
-
-#include "7zHeader.h"
-#include "7zItem.h"
-
-namespace NArchive {
-namespace N7z {
-
-class CInArchiveException
-{
-public:
- enum CCauseType
- {
- kUnsupportedVersion = 0,
- kUnexpectedEndOfArchive = 0,
- kIncorrectHeader,
- } Cause;
- CInArchiveException(CCauseType cause);
-};
-
-struct CInArchiveInfo
-{
- CArchiveVersion Version;
- UInt64 StartPosition;
- UInt64 StartPositionAfterHeader;
- UInt64 DataStartPosition;
- UInt64 DataStartPosition2;
- CRecordVector<UInt64> FileInfoPopIDs;
- void Clear()
- {
- FileInfoPopIDs.Clear();
- }
-};
-
-
-struct CArchiveDatabaseEx: public CArchiveDatabase
-{
- CInArchiveInfo ArchiveInfo;
- CRecordVector<UInt64> PackStreamStartPositions;
- CRecordVector<CNum> FolderStartPackStreamIndex;
- CRecordVector<CNum> FolderStartFileIndex;
- CRecordVector<CNum> FileIndexToFolderIndexMap;
-
- void Clear()
- {
- CArchiveDatabase::Clear();
- ArchiveInfo.Clear();
- PackStreamStartPositions.Clear();
- FolderStartPackStreamIndex.Clear();
- FolderStartFileIndex.Clear();
- FileIndexToFolderIndexMap.Clear();
- }
-
- void FillFolderStartPackStream();
- void FillStartPos();
- void FillFolderStartFileIndex();
-
- void Fill()
- {
- FillFolderStartPackStream();
- FillStartPos();
- FillFolderStartFileIndex();
- }
-
- UInt64 GetFolderStreamPos(int folderIndex, int indexInFolder) const
- {
- return ArchiveInfo.DataStartPosition +
- PackStreamStartPositions[FolderStartPackStreamIndex[folderIndex] +
- indexInFolder];
- }
-
- UInt64 GetFolderFullPackSize(int folderIndex) const
- {
- CNum packStreamIndex = FolderStartPackStreamIndex[folderIndex];
- const CFolder &folder = Folders[folderIndex];
- UInt64 size = 0;
- for (int i = 0; i < folder.PackStreams.Size(); i++)
- size += PackSizes[packStreamIndex + i];
- return size;
- }
-
- UInt64 GetFolderPackStreamSize(int folderIndex, int streamIndex) const
- {
- return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex];
- }
-
- UInt64 GetFilePackSize(CNum fileIndex) const
- {
- CNum folderIndex = FileIndexToFolderIndexMap[fileIndex];
- if (folderIndex >= 0)
- {
- if (FolderStartFileIndex[folderIndex] == fileIndex)
- return GetFolderFullPackSize(folderIndex);
- }
- return 0;
- }
-};
-
-class CInByte2
-{
- const Byte *_buffer;
- size_t _size;
- size_t _pos;
-public:
- void Init(const Byte *buffer, size_t size)
- {
- _buffer = buffer;
- _size = size;
- _pos = 0;
- }
- bool ReadByte(Byte &b)
- {
- if(_pos >= _size)
- return false;
- b = _buffer[_pos++];
- return true;
- }
- void ReadBytes(void *data, size_t size, size_t &processedSize)
- {
- for(processedSize = 0; processedSize < size && _pos < _size; processedSize++)
- ((Byte *)data)[processedSize] = _buffer[_pos++];
- }
-
- bool ReadBytes(void *data, size_t size)
- {
- size_t processedSize;
- ReadBytes(data, size, processedSize);
- return (processedSize == size);
- }
-
- size_t GetProcessedSize() const { return _pos; }
-};
-
-class CStreamSwitch;
-class CInArchive
-{
- friend class CStreamSwitch;
-
- CMyComPtr<IInStream> _stream;
- #ifdef _7Z_VOL
- bool _finishSignature;
- #endif
-
- CObjectVector<CInByte2> _inByteVector;
- CInByte2 *_inByteBack;
-
- UInt64 _arhiveBeginStreamPosition;
- UInt64 _position;
-
- void AddByteStream(const Byte *buffer, size_t size)
- {
- _inByteVector.Add(CInByte2());
- _inByteBack = &_inByteVector.Back();
- _inByteBack->Init(buffer, size);
- }
-
- void DeleteByteStream()
- {
- _inByteVector.DeleteBack();
- if (!_inByteVector.IsEmpty())
- _inByteBack = &_inByteVector.Back();
- }
-
-private:
- HRESULT FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
- #ifdef _7Z_VOL
- HRESULT FindFinishSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
- #endif
-
- HRESULT ReadFileNames(CObjectVector<CFileItem> &files);
-
- HRESULT ReadDirect(IInStream *stream, void *data, UInt32 size,
- UInt32 *processedSize);
- HRESULT ReadDirect(void *data, UInt32 size, UInt32 *processedSize);
- HRESULT SafeReadDirect(void *data, UInt32 size);
- HRESULT SafeReadDirectByte(Byte &b);
- HRESULT SafeReadDirectUInt32(UInt32 &value);
- HRESULT SafeReadDirectUInt64(UInt64 &value);
-
- HRESULT ReadBytes(void *data, size_t size)
- {
- if (!_inByteBack->ReadBytes(data, size))
- return E_FAIL;
- return S_OK;
- }
-
- HRESULT ReadByte(Byte &b)
- {
- if (!_inByteBack->ReadByte(b))
- return E_FAIL;
- return S_OK;
- }
-
- HRESULT ReadWideCharLE(wchar_t &c)
- {
- Byte b1;
- if (!_inByteBack->ReadByte(b1))
- return E_FAIL;
- Byte b2;
- if (!_inByteBack->ReadByte(b2))
- return E_FAIL;
- c = (wchar_t(b2) << 8) + b1;
- return S_OK;
- }
-
- HRESULT ReadNumber(UInt64 &value);
- HRESULT ReadNum(CNum &value);
- HRESULT ReadID(UInt64 &value) { return ReadNumber(value); }
- HRESULT ReadUInt32(UInt32 &value);
- HRESULT ReadUInt64(UInt64 &value);
-
- HRESULT SkeepData(UInt64 size);
- HRESULT SkeepData();
- HRESULT WaitAttribute(UInt64 attribute);
-
- HRESULT ReadArchiveProperties(CInArchiveInfo &archiveInfo);
- HRESULT GetNextFolderItem(CFolder &itemInfo);
- HRESULT ReadHashDigests(int numItems,
- CRecordVector<bool> &digestsDefined, CRecordVector<UInt32> &digests);
-
- HRESULT ReadPackInfo(
- UInt64 &dataOffset,
- CRecordVector<UInt64> &packSizes,
- CRecordVector<bool> &packCRCsDefined,
- CRecordVector<UInt32> &packCRCs);
-
- HRESULT ReadUnPackInfo(
- const CObjectVector<CByteBuffer> *dataVector,
- CObjectVector<CFolder> &folders);
-
- HRESULT ReadSubStreamsInfo(
- const CObjectVector<CFolder> &folders,
- CRecordVector<CNum> &numUnPackStreamsInFolders,
- CRecordVector<UInt64> &unPackSizes,
- CRecordVector<bool> &digestsDefined,
- CRecordVector<UInt32> &digests);
-
- HRESULT ReadStreamsInfo(
- const CObjectVector<CByteBuffer> *dataVector,
- UInt64 &dataOffset,
- CRecordVector<UInt64> &packSizes,
- CRecordVector<bool> &packCRCsDefined,
- CRecordVector<UInt32> &packCRCs,
- CObjectVector<CFolder> &folders,
- CRecordVector<CNum> &numUnPackStreamsInFolders,
- CRecordVector<UInt64> &unPackSizes,
- CRecordVector<bool> &digestsDefined,
- CRecordVector<UInt32> &digests);
-
-
- HRESULT GetNextFileItem(CFileItem &itemInfo);
- HRESULT ReadBoolVector(int numItems, CBoolVector &v);
- HRESULT ReadBoolVector2(int numItems, CBoolVector &v);
- HRESULT ReadTime(const CObjectVector<CByteBuffer> &dataVector,
- CObjectVector<CFileItem> &files, UInt64 type);
- HRESULT ReadAndDecodePackedStreams(UInt64 baseOffset, UInt64 &dataOffset,
- CObjectVector<CByteBuffer> &dataVector
- #ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
- #endif
- );
- HRESULT ReadHeader(CArchiveDatabaseEx &database
- #ifndef _NO_CRYPTO
- ,ICryptoGetTextPassword *getTextPassword
- #endif
- );
-public:
- HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
- void Close();
-
- HRESULT ReadDatabase(CArchiveDatabaseEx &database
- #ifndef _NO_CRYPTO
- ,ICryptoGetTextPassword *getTextPassword
- #endif
- );
-};
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zItem.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zItem.h
deleted file mode 100644
index c50a0bcf4..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zItem.h
+++ /dev/null
@@ -1,181 +0,0 @@
-// 7zItem.h
-
-#ifndef __7Z_ITEM_H
-#define __7Z_ITEM_H
-
-#include "../../../Common/Buffer.h"
-#include "7zMethodID.h"
-#include "7zHeader.h"
-
-namespace NArchive {
-namespace N7z {
-
-struct CAltCoderInfo
-{
- CMethodID MethodID;
- CByteBuffer Properties;
-};
-
-typedef UInt32 CNum;
-const CNum kNumMax = 0x7FFFFFFF;
-const CNum kNumNoIndex = 0xFFFFFFFF;
-
-struct CCoderInfo
-{
- CNum NumInStreams;
- CNum NumOutStreams;
- CObjectVector<CAltCoderInfo> AltCoders;
- bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
-};
-
-struct CBindPair
-{
- CNum InIndex;
- CNum OutIndex;
-};
-
-struct CFolder
-{
- CObjectVector<CCoderInfo> Coders;
- CRecordVector<CBindPair> BindPairs;
- CRecordVector<CNum> PackStreams;
- CRecordVector<UInt64> UnPackSizes;
- UInt32 UnPackCRC;
- bool UnPackCRCDefined;
-
- CFolder(): UnPackCRCDefined(false) {}
-
- UInt64 GetUnPackSize() const // test it
- {
- if (UnPackSizes.IsEmpty())
- return 0;
- for (int i = UnPackSizes.Size() - 1; i >= 0; i--)
- if (FindBindPairForOutStream(i) < 0)
- return UnPackSizes[i];
- throw 1;
- }
-
- CNum GetNumOutStreams() const
- {
- CNum result = 0;
- for (int i = 0; i < Coders.Size(); i++)
- result += Coders[i].NumOutStreams;
- return result;
- }
-
- int FindBindPairForInStream(CNum inStreamIndex) const
- {
- for(int i = 0; i < BindPairs.Size(); i++)
- if (BindPairs[i].InIndex == inStreamIndex)
- return i;
- return -1;
- }
- int FindBindPairForOutStream(CNum outStreamIndex) const
- {
- for(int i = 0; i < BindPairs.Size(); i++)
- if (BindPairs[i].OutIndex == outStreamIndex)
- return i;
- return -1;
- }
- int FindPackStreamArrayIndex(CNum inStreamIndex) const
- {
- for(int i = 0; i < PackStreams.Size(); i++)
- if (PackStreams[i] == inStreamIndex)
- return i;
- return -1;
- }
-};
-
-typedef FILETIME CArchiveFileTime;
-
-class CFileItem
-{
-public:
- CArchiveFileTime CreationTime;
- CArchiveFileTime LastWriteTime;
- CArchiveFileTime LastAccessTime;
- UInt64 UnPackSize;
- UInt64 StartPos;
- UInt32 Attributes;
- UInt32 FileCRC;
- UString Name;
-
- bool HasStream; // Test it !!! it means that there is
- // stream in some folder. It can be empty stream
- bool IsDirectory;
- bool IsAnti;
- bool IsFileCRCDefined;
- bool AreAttributesDefined;
- bool IsCreationTimeDefined;
- bool IsLastWriteTimeDefined;
- bool IsLastAccessTimeDefined;
- bool IsStartPosDefined;
-
- /*
- const bool HasStream() const {
- return !IsDirectory && !IsAnti && UnPackSize != 0; }
- */
- CFileItem():
- HasStream(true),
- IsDirectory(false),
- IsAnti(false),
- IsFileCRCDefined(false),
- AreAttributesDefined(false),
- IsCreationTimeDefined(false),
- IsLastWriteTimeDefined(false),
- IsLastAccessTimeDefined(false),
- IsStartPosDefined(false)
- {}
- void SetAttributes(UInt32 attributes)
- {
- AreAttributesDefined = true;
- Attributes = attributes;
- }
- void SetCreationTime(const CArchiveFileTime &creationTime)
- {
- IsCreationTimeDefined = true;
- CreationTime = creationTime;
- }
- void SetLastWriteTime(const CArchiveFileTime &lastWriteTime)
- {
- IsLastWriteTimeDefined = true;
- LastWriteTime = lastWriteTime;
- }
- void SetLastAccessTime(const CArchiveFileTime &lastAccessTime)
- {
- IsLastAccessTimeDefined = true;
- LastAccessTime = lastAccessTime;
- }
-};
-
-struct CArchiveDatabase
-{
- CRecordVector<UInt64> PackSizes;
- CRecordVector<bool> PackCRCsDefined;
- CRecordVector<UInt32> PackCRCs;
- CObjectVector<CFolder> Folders;
- CRecordVector<CNum> NumUnPackStreamsVector;
- CObjectVector<CFileItem> Files;
- void Clear()
- {
- PackSizes.Clear();
- PackCRCsDefined.Clear();
- PackCRCs.Clear();
- Folders.Clear();
- NumUnPackStreamsVector.Clear();
- Files.Clear();
- }
- bool IsEmpty() const
- {
- return (PackSizes.IsEmpty() &&
- PackCRCsDefined.IsEmpty() &&
- PackCRCs.IsEmpty() &&
- Folders.IsEmpty() &&
- NumUnPackStreamsVector.IsEmpty() &&
- Files.IsEmpty());
- }
-};
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zMethodID.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zMethodID.cpp
deleted file mode 100644
index a7b1296e9..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zMethodID.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-// 7zMethodID.cpp
-
-#include "StdAfx.h"
-
-#include "7zMethodID.h"
-
-namespace NArchive {
-namespace N7z {
-
-static wchar_t GetHex(Byte value)
-{
- return (value < 10) ? ('0' + value) : ('A' + (value - 10));
-}
-
-static bool HexCharToInt(wchar_t value, Byte &result)
-{
- if (value >= '0' && value <= '9')
- result = value - '0';
- else if (value >= 'a' && value <= 'f')
- result = 10 + value - 'a';
- else if (value >= 'A' && value <= 'F')
- result = 10 + value - 'A';
- else
- return false;
- return true;
-}
-
-static bool TwoHexCharsToInt(wchar_t valueHigh, wchar_t valueLow, Byte &result)
-{
- Byte resultHigh, resultLow;
- if (!HexCharToInt(valueHigh, resultHigh))
- return false;
- if (!HexCharToInt(valueLow, resultLow))
- return false;
- result = (resultHigh << 4) + resultLow;
- return true;
-}
-
-UString CMethodID::ConvertToString() const
-{
- UString result;
- for (int i = 0; i < IDSize; i++)
- {
- Byte b = ID[i];
- result += GetHex(b >> 4);
- result += GetHex(b & 0xF);
- }
- return result;
-}
-
-bool CMethodID::ConvertFromString(const UString &srcString)
-{
- int length = srcString.Length();
- if ((length & 1) != 0 || (length >> 1) > kMethodIDSize)
- return false;
- IDSize = length / 2;
- UInt32 i;
- for(i = 0; i < IDSize; i++)
- if (!TwoHexCharsToInt(srcString[i * 2], srcString[i * 2 + 1], ID[i]))
- return false;
- for(; i < kMethodIDSize; i++)
- ID[i] = 0;
- return true;
-}
-
-bool operator==(const CMethodID &a1, const CMethodID &a2)
-{
- if (a1.IDSize != a2.IDSize)
- return false;
- for (UInt32 i = 0; i < a1.IDSize; i++)
- if (a1.ID[i] != a2.ID[i])
- return false;
- return true;
-}
-
-}}
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zMethodID.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zMethodID.h
deleted file mode 100644
index 6bff152d6..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zMethodID.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// 7zMethodID.h
-
-#ifndef __7Z_METHOD_ID_H
-#define __7Z_METHOD_ID_H
-
-#include "../../../Common/String.h"
-#include "../../../Common/Types.h"
-
-namespace NArchive {
-namespace N7z {
-
-const int kMethodIDSize = 15;
-
-struct CMethodID
-{
- Byte ID[kMethodIDSize];
- Byte IDSize;
- UString ConvertToString() const;
- bool ConvertFromString(const UString &srcString);
-};
-
-bool operator==(const CMethodID &a1, const CMethodID &a2);
-
-inline bool operator!=(const CMethodID &a1, const CMethodID &a2)
- { return !(a1 == a2); }
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zMethods.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zMethods.cpp
deleted file mode 100644
index 32f59003b..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zMethods.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-// 7zMethods.cpp
-
-#include "StdAfx.h"
-
-#include "7zMethods.h"
-
-#include "../../../Windows/FileFind.h"
-#include "../../../Windows/DLL.h"
-#include "../../../Windows/PropVariant.h"
-#include "../../../Windows/Synchronization.h"
-
-#include "../../ICoder.h"
-#include "../Common/CodecsPath.h"
-
-using namespace NWindows;
-
-namespace NArchive {
-namespace N7z {
-
-static CObjectVector<CMethodInfo2> g_Methods;
-static bool g_Loaded = false;
-
-typedef UInt32 (WINAPI *GetNumberOfMethodsFunc)(UInt32 *numMethods);
-
-typedef UInt32 (WINAPI *GetMethodPropertyFunc)(
- UInt32 index, PROPID propID, PROPVARIANT *value);
-
-static void Load(const CSysString &folderPrefix)
-{
- NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*")));
- NFile::NFind::CFileInfo fileInfo;
- while (enumerator.Next(fileInfo))
- {
- if (fileInfo.IsDirectory())
- continue;
- CSysString filePath = folderPrefix + fileInfo.Name;
- {
- NDLL::CLibrary library;
- if (!library.LoadEx(filePath, LOAD_LIBRARY_AS_DATAFILE))
- continue;
- }
- NDLL::CLibrary library;
- if (!library.Load(filePath))
- continue;
- GetMethodPropertyFunc getMethodProperty = (GetMethodPropertyFunc)
- library.GetProcAddress("GetMethodProperty");
- if (getMethodProperty == NULL)
- continue;
-
- UInt32 numMethods = 1;
- GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)
- library.GetProcAddress("GetNumberOfMethods");
- if (getNumberOfMethodsFunc != NULL)
- if (getNumberOfMethodsFunc(&numMethods) != S_OK)
- continue;
-
- for(UInt32 i = 0; i < numMethods; i++)
- {
- CMethodInfo2 info;
- info.FilePath = filePath;
-
- NWindows::NCOM::CPropVariant propVariant;
- if (getMethodProperty(i, NMethodPropID::kID, &propVariant) != S_OK)
- continue;
- if (propVariant.vt != VT_BSTR)
- continue;
- info.MethodID.IDSize = SysStringByteLen(propVariant.bstrVal);
- memmove(info.MethodID.ID, propVariant.bstrVal, info.MethodID.IDSize);
- propVariant.Clear();
-
- if (getMethodProperty(i, NMethodPropID::kName, &propVariant) != S_OK)
- continue;
- if (propVariant.vt == VT_EMPTY)
- {
- }
- else if (propVariant.vt == VT_BSTR)
- info.Name = propVariant.bstrVal;
- else
- continue;
- propVariant.Clear();
-
- if (getMethodProperty (i, NMethodPropID::kEncoder, &propVariant) != S_OK)
- continue;
- if (propVariant.vt == VT_EMPTY)
- info.EncoderIsAssigned = false;
- else if (propVariant.vt == VT_BSTR)
- {
- info.EncoderIsAssigned = true;
- info.Encoder = *(const GUID *)propVariant.bstrVal;
- }
- else
- continue;
- propVariant.Clear();
-
- if (getMethodProperty (i, NMethodPropID::kDecoder, &propVariant) != S_OK)
- continue;
- if (propVariant.vt == VT_EMPTY)
- info.DecoderIsAssigned = false;
- else if (propVariant.vt == VT_BSTR)
- {
- info.DecoderIsAssigned = true;
- info.Decoder = *(const GUID *)propVariant.bstrVal;
- }
- else
- continue;
- propVariant.Clear();
-
- if (getMethodProperty (i, NMethodPropID::kInStreams, &propVariant) != S_OK)
- continue;
- if (propVariant.vt == VT_EMPTY)
- info.NumInStreams = 1;
- else if (propVariant.vt == VT_UI4)
- info.NumInStreams = propVariant.ulVal;
- else
- continue;
- propVariant.Clear();
-
- if (getMethodProperty (i, NMethodPropID::kOutStreams, &propVariant) != S_OK)
- continue;
- if (propVariant.vt == VT_EMPTY)
- info.NumOutStreams = 1;
- else if (propVariant.vt == VT_UI4)
- info.NumOutStreams = propVariant.ulVal;
- else
- continue;
- propVariant.Clear();
-
- g_Methods.Add(info);
- }
- }
-}
-
-static NSynchronization::CCriticalSection g_CriticalSection;
-
-void LoadMethodMap()
-{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- if (g_Loaded)
- return;
- g_Loaded = true;
- Load(GetCodecsFolderPrefix());
-}
-
-bool GetMethodInfo(const CMethodID &methodID, CMethodInfo &methodInfo)
-{
- for(int i = 0; i < g_Methods.Size(); i++)
- {
- const CMethodInfo2 &method = g_Methods[i];
- if (method.MethodID == methodID)
- {
- methodInfo = (CMethodInfo)method;
- return true;
- }
- }
- return false;
-}
-
-bool GetMethodInfo(const UString &name, CMethodInfo2 &methodInfo)
-{
- for(int i = 0; i < g_Methods.Size(); i++)
- {
- const CMethodInfo2 &method = g_Methods[i];
- if (method.Name.CompareNoCase(name) == 0)
- {
- methodInfo = method;
- return true;
- }
- }
- return false;
-}
-
-}}
-
-
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zMethods.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zMethods.h
deleted file mode 100644
index 429199d04..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zMethods.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// 7zMethods.h
-
-#ifndef __7Z_METHODS_H
-#define __7Z_METHODS_H
-
-#include "7zMethodID.h"
-
-namespace NArchive {
-namespace N7z {
-
-struct CMethodInfo
-{
- UString Name;
- bool EncoderIsAssigned;
- bool DecoderIsAssigned;
- UInt32 NumInStreams;
- UInt32 NumOutStreams;
- CLSID Encoder;
- CLSID Decoder;
- // UString Description;
- CSysString FilePath;
-};
-
-struct CMethodInfo2: public CMethodInfo
-{
- CMethodID MethodID;
-};
-
-void LoadMethodMap();
-bool GetMethodInfo(const CMethodID &methodID, CMethodInfo &methodInfo);
-bool GetMethodInfo(const UString &name, CMethodInfo2 &methodInfo);
-
-}}
-
-#endif
-
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zProperties.cpp b/other-licenses/7zstub/src/7zip/Archive/7z/7zProperties.cpp
deleted file mode 100644
index d474be095..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zProperties.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-// 7zProperties.cpp
-
-#include "StdAfx.h"
-
-#include "7zProperties.h"
-#include "7zHeader.h"
-#include "7zHandler.h"
-
-// #define _MULTI_PACK
-
-namespace NArchive {
-namespace N7z {
-
-struct CPropMap
-{
- UInt64 FilePropID;
- STATPROPSTG StatPROPSTG;
-};
-
-CPropMap kPropMap[] =
-{
- { NID::kName, NULL, kpidPath, VT_BSTR},
- { NID::kSize, NULL, kpidSize, VT_UI8},
- { NID::kPackInfo, NULL, kpidPackedSize, VT_UI8},
-
- #ifdef _MULTI_PACK
- { 100, L"Pack0", kpidPackedSize0, VT_UI8},
- { 101, L"Pack1", kpidPackedSize1, VT_UI8},
- { 102, L"Pack2", kpidPackedSize2, VT_UI8},
- { 103, L"Pack3", kpidPackedSize3, VT_UI8},
- { 104, L"Pack4", kpidPackedSize4, VT_UI8},
- #endif
-
- { NID::kCreationTime, NULL, kpidCreationTime, VT_FILETIME},
- { NID::kLastWriteTime, NULL, kpidLastWriteTime, VT_FILETIME},
- { NID::kLastAccessTime, NULL, kpidLastAccessTime, VT_FILETIME},
- { NID::kWinAttributes, NULL, kpidAttributes, VT_UI4},
- { NID::kStartPos, NULL, kpidPosition, VT_UI4},
-
-
- { NID::kCRC, NULL, kpidCRC, VT_UI4},
-
- { NID::kAnti, L"Anti", kpidIsAnti, VT_BOOL},
- // { 97, NULL, kpidSolid, VT_BOOL},
- #ifndef _SFX
- { 98, NULL, kpidMethod, VT_BSTR},
- { 99, L"Block", kpidBlock, VT_UI4}
- #endif
- // { L"ID", kpidID, VT_BSTR},
- // { L"UnPack Version", kpidUnPackVersion, VT_UI1},
- // { L"Host OS", kpidHostOS, VT_BSTR}
-};
-
-static const int kPropMapSize = sizeof(kPropMap) / sizeof(kPropMap[0]);
-
-static int FindPropInMap(UInt64 filePropID)
-{
- for (int i = 0; i < kPropMapSize; i++)
- if (kPropMap[i].FilePropID == filePropID)
- return i;
- return -1;
-}
-
-static void CopyOneItem(CRecordVector<UInt64> &src,
- CRecordVector<UInt64> &dest, UInt32 item)
-{
- for (int i = 0; i < src.Size(); i++)
- if (src[i] == item)
- {
- dest.Add(item);
- src.Delete(i);
- return;
- }
-}
-
-static void RemoveOneItem(CRecordVector<UInt64> &src, UInt32 item)
-{
- for (int i = 0; i < src.Size(); i++)
- if (src[i] == item)
- {
- src.Delete(i);
- return;
- }
-}
-
-static void InsertToHead(CRecordVector<UInt64> &dest, UInt32 item)
-{
- for (int i = 0; i < dest.Size(); i++)
- if (dest[i] == item)
- {
- dest.Delete(i);
- break;
- }
- dest.Insert(0, item);
-}
-
-void CHandler::FillPopIDs()
-{
- _fileInfoPopIDs.Clear();
-
- #ifdef _7Z_VOL
- if(_volumes.Size() < 1)
- return;
- const CVolume &volume = _volumes.Front();
- const CArchiveDatabaseEx &_database = volume.Database;
- #endif
-
- CRecordVector<UInt64> fileInfoPopIDs = _database.ArchiveInfo.FileInfoPopIDs;
-
- RemoveOneItem(fileInfoPopIDs, NID::kEmptyStream);
- RemoveOneItem(fileInfoPopIDs, NID::kEmptyFile);
-
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kName);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kAnti);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kSize);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kPackInfo);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kCreationTime);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kLastWriteTime);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kLastAccessTime);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kWinAttributes);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kCRC);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kComment);
- _fileInfoPopIDs += fileInfoPopIDs;
-
- #ifndef _SFX
- _fileInfoPopIDs.Add(98);
- _fileInfoPopIDs.Add(99);
- #endif
- #ifdef _MULTI_PACK
- _fileInfoPopIDs.Add(100);
- _fileInfoPopIDs.Add(101);
- _fileInfoPopIDs.Add(102);
- _fileInfoPopIDs.Add(103);
- _fileInfoPopIDs.Add(104);
- #endif
-
- #ifndef _SFX
- InsertToHead(_fileInfoPopIDs, NID::kLastWriteTime);
- InsertToHead(_fileInfoPopIDs, NID::kPackInfo);
- InsertToHead(_fileInfoPopIDs, NID::kSize);
- InsertToHead(_fileInfoPopIDs, NID::kName);
- #endif
-}
-
-STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
-{
- *numProperties = _fileInfoPopIDs.Size();
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- if((int)index >= _fileInfoPopIDs.Size())
- return E_INVALIDARG;
- int indexInMap = FindPropInMap(_fileInfoPopIDs[index]);
- if (indexInMap == -1)
- return E_INVALIDARG;
- const STATPROPSTG &srcItem = kPropMap[indexInMap].StatPROPSTG;
- *propID = srcItem.propid;
- *varType = srcItem.vt;
- *name = 0;
- return S_OK;
-}
-
-}}
diff --git a/other-licenses/7zstub/src/7zip/Archive/7z/7zProperties.h b/other-licenses/7zstub/src/7zip/Archive/7z/7zProperties.h
deleted file mode 100644
index 2149e327e..000000000
--- a/other-licenses/7zstub/src/7zip/Archive/7z/7zProperties.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// 7zProperties.h
-
-#ifndef __7Z_PROPERTIES_H
-#define __7Z_PROPERTIES_H
-
-#include "../../PropID.h"
-
-namespace NArchive {
-namespace N7z {
-
-enum // PropID
-{
- kpidPackedSize0 = kpidUserDefined,
- kpidPackedSize1,
- kpidPackedSize2,
- kpidPackedSize3,
- kpidPackedSize4,
-};
-
-}}
-
-#endif