mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 08:07:09 -06:00
4.30 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
bcd1db2f5a
commit
e18587ba51
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user