mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-09 14:07:08 -06:00
4.30 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
bcd1db2f5a
commit
e18587ba51
@@ -18,9 +18,10 @@ static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#endif
|
||||
|
||||
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
#include "../../Compress/LZMA/LZMAEncoder.h"
|
||||
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
@@ -114,7 +115,7 @@ static void ConvertBindInfoToFolderItemInfo(const NCoderMixer2::CBindInfo &bindI
|
||||
folder.PackStreams.Add(bindInfo.InStreams[i]);
|
||||
}
|
||||
|
||||
HRESULT CEncoder::CreateMixerCoder()
|
||||
HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
{
|
||||
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
|
||||
_mixerCoder = _mixerCoderSpec;
|
||||
@@ -203,6 +204,30 @@ HRESULT CEncoder::CreateMixerCoder()
|
||||
return E_FAIL;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool tryReduce = false;
|
||||
UInt32 reducedDictionarySize = 1 << 10;
|
||||
if (inSizeForReduce != 0 && methodFull.MethodID == k_LZMA)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
const UInt32 step = (reducedDictionarySize >> 1);
|
||||
if (reducedDictionarySize >= *inSizeForReduce)
|
||||
{
|
||||
tryReduce = true;
|
||||
break;
|
||||
}
|
||||
reducedDictionarySize += step;
|
||||
if (reducedDictionarySize >= *inSizeForReduce)
|
||||
{
|
||||
tryReduce = true;
|
||||
break;
|
||||
}
|
||||
if (reducedDictionarySize >= ((UInt32)11 << 30))
|
||||
break;
|
||||
reducedDictionarySize += step;
|
||||
}
|
||||
}
|
||||
|
||||
if (methodFull.CoderProperties.Size() > 0)
|
||||
{
|
||||
@@ -215,7 +240,10 @@ HRESULT CEncoder::CreateMixerCoder()
|
||||
{
|
||||
const CProperty &property = methodFull.CoderProperties[i];
|
||||
propIDs.Add(property.PropID);
|
||||
values[i] = property.Value;
|
||||
NWindows::NCOM::CPropVariant value = property.Value;
|
||||
if (tryReduce && property.PropID == NCoderPropID::kDictionarySize && value.vt == VT_UI4 && reducedDictionarySize < value.ulVal)
|
||||
value.ulVal = reducedDictionarySize;
|
||||
values[i] = value;
|
||||
}
|
||||
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
|
||||
if (methodFull.IsSimpleCoder())
|
||||
@@ -308,7 +336,7 @@ HRESULT CEncoder::CreateMixerCoder()
|
||||
}
|
||||
|
||||
HRESULT CEncoder::Encode(ISequentialInStream *inStream,
|
||||
const UInt64 *inStreamSize,
|
||||
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
|
||||
CFolder &folderItem,
|
||||
ISequentialOutStream *outStream,
|
||||
CRecordVector<UInt64> &packSizes,
|
||||
@@ -316,7 +344,7 @@ HRESULT CEncoder::Encode(ISequentialInStream *inStream,
|
||||
{
|
||||
if (_mixerCoderSpec == NULL)
|
||||
{
|
||||
RINOK(CreateMixerCoder());
|
||||
RINOK(CreateMixerCoder(inSizeForReduce));
|
||||
}
|
||||
_mixerCoderSpec->ReInit();
|
||||
// _mixerCoderSpec->SetCoderInfo(0, NULL, NULL, progress);
|
||||
|
||||
@@ -38,13 +38,13 @@ class CEncoder
|
||||
NCoderMixer2::CBindReverseConverter *_bindReverseConverter;
|
||||
CRecordVector<CMethodID> _decompressionMethods;
|
||||
|
||||
HRESULT CreateMixerCoder();
|
||||
HRESULT CreateMixerCoder(const UInt64 *inSizeForReduce);
|
||||
|
||||
public:
|
||||
CEncoder(const CCompressionMethodMode &options);
|
||||
~CEncoder();
|
||||
HRESULT Encode(ISequentialInStream *inStream,
|
||||
const UInt64 *inStreamSize,
|
||||
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
|
||||
CFolder &folderItem,
|
||||
ISequentialOutStream *outStream,
|
||||
CRecordVector<UInt64> &packSizes,
|
||||
|
||||
@@ -81,7 +81,7 @@ const wchar_t *kDefaultMethodName = kLZMAMethodName;
|
||||
|
||||
static const wchar_t *kMatchFinderForHeaders = L"BT2";
|
||||
static const UInt32 kDictionaryForHeaders = 1 << 20;
|
||||
static const UInt32 kNumFastBytesForHeaders = 254;
|
||||
static const UInt32 kNumFastBytesForHeaders = 273;
|
||||
|
||||
static bool IsLZMAMethod(const UString &methodName)
|
||||
{ return (methodName.CompareNoCase(kLZMAMethodName) == 0); }
|
||||
|
||||
@@ -576,8 +576,8 @@ HRESULT COutArchive::EncodeStream(CEncoder &encoder, const Byte *data, size_t da
|
||||
CFolder folderItem;
|
||||
folderItem.UnPackCRCDefined = true;
|
||||
folderItem.UnPackCRC = CCRC::CalculateDigest(data, dataSize);
|
||||
RINOK(encoder.Encode(stream, NULL, folderItem, SeqStream,
|
||||
packSizes, NULL));
|
||||
UInt64 dataSize64 = dataSize;
|
||||
RINOK(encoder.Encode(stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL));
|
||||
folders.Add(folderItem);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -566,11 +566,21 @@ static HRESULT Update2(
|
||||
UInt64 complexity = 0;
|
||||
for(i = 0; i < folderRefs.Size(); i++)
|
||||
complexity += database->GetFolderFullPackSize(folderRefs[i]);
|
||||
UInt64 inSizeForReduce = 0;
|
||||
for(i = 0; i < updateItems.Size(); i++)
|
||||
{
|
||||
const CUpdateItem &updateItem = updateItems[i];
|
||||
if (updateItem.NewData)
|
||||
{
|
||||
complexity += updateItem.Size;
|
||||
if (numSolidFiles == 1)
|
||||
{
|
||||
if (updateItem.Size > inSizeForReduce)
|
||||
inSizeForReduce = updateItem.Size;
|
||||
}
|
||||
else
|
||||
inSizeForReduce += updateItem.Size;
|
||||
}
|
||||
}
|
||||
RINOK(updateCallback->SetTotal(complexity));
|
||||
complexity = 0;
|
||||
@@ -636,6 +646,10 @@ static HRESULT Update2(
|
||||
SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter,
|
||||
updateItems, groups);
|
||||
|
||||
const UInt32 kMinReduceSize = (1 << 16);
|
||||
if (inSizeForReduce < kMinReduceSize)
|
||||
inSizeForReduce = kMinReduceSize;
|
||||
|
||||
for (int groupIndex = 0; groupIndex < groups.Size(); groupIndex++)
|
||||
{
|
||||
const CSolidGroup &group = groups[groupIndex];
|
||||
@@ -708,7 +722,7 @@ static HRESULT Update2(
|
||||
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
|
||||
localCompressProgressSpec->Init(localProgress, &complexity, NULL);
|
||||
|
||||
RINOK(encoder.Encode(solidInStream, NULL, folderItem,
|
||||
RINOK(encoder.Encode(solidInStream, NULL, &inSizeForReduce, folderItem,
|
||||
archive.SeqStream, newDatabase.PackSizes, compressProgress));
|
||||
// for()
|
||||
// newDatabase.PackCRCsDefined.Add(false);
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "../../../Common/MyInitGuid.h"
|
||||
#include "../../../Common/ComTry.h"
|
||||
#ifdef _WIN32
|
||||
#include "../../../Common/Alloc.h"
|
||||
#endif
|
||||
|
||||
#include "../../ICoder.h"
|
||||
|
||||
@@ -18,12 +21,32 @@ DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
|
||||
#endif
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +256,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_items.Clear();
|
||||
_stream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,17 @@ DEFINE_GUID(CLSID_CBZip2Handler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x02, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COMPRESS_BZIP2
|
||||
#include "../Common/CodecsPath.h"
|
||||
@@ -34,7 +45,12 @@ extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -86,10 +102,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"bz2 tbz2";
|
||||
propVariant = L"bz2 bzip2 tbz2 tbz";
|
||||
break;
|
||||
case NArchive::kAddExtension:
|
||||
propVariant = L"* .tar";
|
||||
propVariant = L"* * .tar .tar";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = true;
|
||||
|
||||
@@ -224,6 +224,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
m_Database.Clear();
|
||||
m_Stream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ static const int kBufferSize = 1 << 17;
|
||||
|
||||
CFilterCoder::CFilterCoder()
|
||||
{
|
||||
_buffer = (Byte *)::BigAlloc(kBufferSize);
|
||||
_buffer = (Byte *)::MidAlloc(kBufferSize);
|
||||
}
|
||||
|
||||
CFilterCoder::~CFilterCoder()
|
||||
{
|
||||
BigFree(_buffer);
|
||||
::MidFree(_buffer);
|
||||
}
|
||||
|
||||
HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 size)
|
||||
|
||||
@@ -36,7 +36,7 @@ class CInStreamWithCRC:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInStream)
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
|
||||
@@ -21,6 +21,17 @@ DEFINE_GUID(CLSID_CCompressDeflateDecoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COMPRESS_DEFLATE
|
||||
#include "../Common/CodecsPath.h"
|
||||
@@ -34,7 +45,12 @@ extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -85,10 +101,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"gz tgz";
|
||||
propVariant = L"gz gzip tgz tpz";
|
||||
break;
|
||||
case NArchive::kAddExtension:
|
||||
propVariant = L"* .tar";
|
||||
propVariant = L"* * .tar .tar";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = true;
|
||||
|
||||
@@ -192,7 +192,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
m_Method.NumPasses = value.ulVal;
|
||||
if (m_Method.NumPasses < 1 || m_Method.NumPasses > 4)
|
||||
if (m_Method.NumPasses < 1 || m_Method.NumPasses > 10)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
else if (name == L"FB")
|
||||
@@ -200,8 +200,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
m_Method.NumFastBytes = value.ulVal;
|
||||
/*
|
||||
if (m_Method.NumFastBytes < 3 || m_Method.NumFastBytes > 255)
|
||||
return E_INVALIDARG;
|
||||
*/
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
|
||||
@@ -270,6 +270,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_items.Clear();
|
||||
_stream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,17 @@ DEFINE_GUID(CLSID_CCrypto_AES128_Decoder,
|
||||
#include "RarHandler.h"
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
void GetCryptoFolderPrefix(TCHAR *path)
|
||||
{
|
||||
@@ -54,7 +65,12 @@ extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -276,6 +276,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_sizes.Clear();
|
||||
_streams.Clear();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_items.Clear();
|
||||
_inStream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -120,10 +120,12 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
|
||||
RIF(OctalToNumber32(cur, 8, item.Mode));
|
||||
cur += 8;
|
||||
|
||||
RIF(OctalToNumber32(cur, 8, item.UID));
|
||||
if (!OctalToNumber32(cur, 8, item.UID))
|
||||
item.UID = 0;
|
||||
cur += 8;
|
||||
|
||||
RIF(OctalToNumber32(cur, 8, item.GID));
|
||||
if (!OctalToNumber32(cur, 8, item.GID))
|
||||
item.GID = 0;
|
||||
cur += 8;
|
||||
|
||||
RIF(OctalToNumber(cur, 12, item.Size));
|
||||
|
||||
@@ -70,7 +70,10 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"z";
|
||||
propVariant = L"z taz";
|
||||
break;
|
||||
case NArchive::kAddExtension:
|
||||
propVariant = L"* .tar";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = false;
|
||||
|
||||
@@ -50,12 +50,28 @@ DEFINE_GUID(CLSID_CZipHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x01, 0x00, 0x00);
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,14 @@ SOURCE=..\..\..\Common\CRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Random.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -57,7 +57,7 @@ CAddCommon::CAddCommon(const CCompressionMethodMode &options):
|
||||
_cryptoStreamSpec(0)
|
||||
{}
|
||||
|
||||
static HRESULT GetStreamCRC(IInStream *inStream, UInt32 &resultCRC)
|
||||
static HRESULT GetStreamCRC(ISequentialInStream *inStream, UInt32 &resultCRC)
|
||||
{
|
||||
CCRC crc;
|
||||
crc.Init();
|
||||
@@ -76,7 +76,7 @@ static HRESULT GetStreamCRC(IInStream *inStream, UInt32 &resultCRC)
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
|
||||
HRESULT CAddCommon::Compress(ISequentialInStream *inStream, IOutStream *outStream,
|
||||
UInt64 inSize, ICompressProgressInfo *progress, CCompressingResult &operationResult)
|
||||
{
|
||||
/*
|
||||
@@ -88,13 +88,25 @@ HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
CMyComPtr<IInStream> inStream2;
|
||||
int numTestMethods = _options.MethodSequence.Size();
|
||||
if (numTestMethods > 1 || _options.PasswordIsDefined)
|
||||
{
|
||||
inStream->QueryInterface(IID_IInStream, (void **)&inStream2);
|
||||
if (!inStream2)
|
||||
{
|
||||
if (_options.PasswordIsDefined)
|
||||
return E_NOTIMPL;
|
||||
numTestMethods = 1;
|
||||
}
|
||||
}
|
||||
Byte method;
|
||||
UInt64 resultSize = 0;
|
||||
COutStreamReleaser outStreamReleaser;
|
||||
for(int i = 0; i < numTestMethods; i++)
|
||||
{
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
if (inStream2)
|
||||
RINOK(inStream2->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
if (_options.PasswordIsDefined)
|
||||
{
|
||||
@@ -109,7 +121,7 @@ HRESULT CAddCommon::Compress(IInStream *inStream, IOutStream *outStream,
|
||||
(const Byte *)(const char *)_options.Password, _options.Password.Length()));
|
||||
UInt32 crc;
|
||||
RINOK(GetStreamCRC(inStream, crc));
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
RINOK(inStream2->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
RINOK(_cryptoStreamSpec->SetOutStream(outStream));
|
||||
outStreamReleaser.FilterCoder = _cryptoStreamSpec;
|
||||
RINOK(_filterSpec->CryptoSetCRC(crc));
|
||||
|
||||
@@ -41,7 +41,7 @@ class CAddCommon
|
||||
|
||||
public:
|
||||
CAddCommon(const CCompressionMethodMode &options);
|
||||
HRESULT Compress(IInStream *inStream, IOutStream *outStream,
|
||||
HRESULT Compress(ISequentialInStream *inStream, IOutStream *outStream,
|
||||
UInt64 inSize, ICompressProgressInfo *progress, CCompressingResult &operationResult);
|
||||
};
|
||||
|
||||
|
||||
@@ -323,6 +323,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
m_Items.Clear();
|
||||
m_Archive.Close();
|
||||
m_ArchiveIsOpen = false;
|
||||
return S_OK;
|
||||
|
||||
@@ -303,8 +303,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
{
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
/*
|
||||
if (value.ulVal < 3 || value.ulVal > 255)
|
||||
return E_INVALIDARG;
|
||||
*/
|
||||
m_NumFastBytes = value.ulVal;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -121,9 +121,22 @@ static HRESULT UpdateOneFile(IInStream *inStream,
|
||||
else
|
||||
{
|
||||
{
|
||||
CInStreamWithCRC *inStreamSpec = new CInStreamWithCRC;
|
||||
CMyComPtr<IInStream> inStream(inStreamSpec);
|
||||
inStreamSpec->Init(fileInStream);
|
||||
CSequentialInStreamWithCRC *inSecStreamSpec = 0;
|
||||
CInStreamWithCRC *inStreamSpec = 0;
|
||||
CMyComPtr<ISequentialInStream> fileSecInStream;
|
||||
if (fileInStream)
|
||||
{
|
||||
inStreamSpec = new CInStreamWithCRC;
|
||||
fileSecInStream = inStreamSpec;
|
||||
inStreamSpec->Init(fileInStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
inSecStreamSpec = new CSequentialInStreamWithCRC;
|
||||
fileSecInStream = inSecStreamSpec;
|
||||
inSecStreamSpec->Init(fileInStream2);
|
||||
}
|
||||
|
||||
CCompressingResult compressingResult;
|
||||
CMyComPtr<IOutStream> outStream;
|
||||
archive.CreateStreamForCompressing(&outStream);
|
||||
@@ -132,20 +145,26 @@ static HRESULT UpdateOneFile(IInStream *inStream,
|
||||
CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
|
||||
localProgressSpec->Init(updateCallback, true);
|
||||
|
||||
CLocalCompressProgressInfo *localCompressProgressSpec =
|
||||
new CLocalCompressProgressInfo;
|
||||
CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
|
||||
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
|
||||
|
||||
localCompressProgressSpec->Init(localProgress, ¤tComplexity, NULL);
|
||||
|
||||
RINOK(compressor.Compress(inStream, outStream,
|
||||
fileSize, compressProgress, compressingResult));
|
||||
RINOK(compressor.Compress(fileSecInStream, outStream, fileSize, compressProgress, compressingResult));
|
||||
|
||||
fileHeader.PackSize = compressingResult.PackSize;
|
||||
fileHeader.CompressionMethod = compressingResult.Method;
|
||||
fileHeader.ExtractVersion.Version = compressingResult.ExtractVersion;
|
||||
fileHeader.FileCRC = inStreamSpec->GetCRC();
|
||||
fileHeader.UnPackSize = inStreamSpec->GetSize();
|
||||
if (inStreamSpec != 0)
|
||||
{
|
||||
fileHeader.FileCRC = inStreamSpec->GetCRC();
|
||||
fileHeader.UnPackSize = inStreamSpec->GetSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
fileHeader.FileCRC = inSecStreamSpec->GetCRC();
|
||||
fileHeader.UnPackSize = inSecStreamSpec->GetSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
fileHeader.SetEncrypted(options.PasswordIsDefined);
|
||||
|
||||
@@ -138,6 +138,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
m_Items.Clear();
|
||||
m_InStream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user