mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-15 00:11:40 -06:00
4.20
This commit is contained in:
committed by
Kornel Lesiński
parent
8c1b5c7b7e
commit
3c510ba80b
@@ -126,6 +126,14 @@ SOURCE=.\StdAfx.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -134,12 +142,28 @@ SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
@@ -186,6 +210,10 @@ SOURCE=..\Common\CodecsPath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DummyOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -44,13 +44,13 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfProperties(UINT32 *numProperties)
|
||||
STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetPropertyInfo(UINT32 index,
|
||||
STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
@@ -62,25 +62,25 @@ STDMETHODIMP CHandler::GetPropertyInfo(UINT32 index,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UINT32 *numProperties)
|
||||
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetArchivePropertyInfo(UINT32 index,
|
||||
STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UINT32 *numItems)
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = 1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
|
||||
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
@@ -101,7 +101,7 @@ STDMETHODIMP CHandler::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *va
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
const UINT64 *maxCheckStartPosition,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
IArchiveOpenCallback *openArchiveCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
@@ -109,15 +109,15 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
{
|
||||
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_streamStartPosition));
|
||||
const int kSignatureSize = 3;
|
||||
BYTE buffer[kSignatureSize];
|
||||
UINT32 processedSize;
|
||||
Byte buffer[kSignatureSize];
|
||||
UInt32 processedSize;
|
||||
RINOK(stream->Read(buffer, kSignatureSize, &processedSize));
|
||||
if (processedSize != kSignatureSize)
|
||||
return S_FALSE;
|
||||
if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h')
|
||||
return S_FALSE;
|
||||
|
||||
UINT64 endPosition;
|
||||
UInt64 endPosition;
|
||||
RINOK(stream->Seek(0, STREAM_SEEK_END, &endPosition));
|
||||
_item.PackSize = endPosition - _streamStartPosition;
|
||||
|
||||
@@ -138,11 +138,11 @@ STDMETHODIMP CHandler::Close()
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
|
||||
INT32 testModeSpec, IArchiveExtractCallback *extractCallback)
|
||||
STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool allFilesMode = (numItems == UINT32(-1));
|
||||
bool allFilesMode = (numItems == UInt32(-1));
|
||||
if (!allFilesMode)
|
||||
{
|
||||
if (numItems == 0)
|
||||
@@ -157,12 +157,12 @@ STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
|
||||
|
||||
extractCallback->SetTotal(_item.PackSize);
|
||||
|
||||
UINT64 currentTotalPacked = 0;
|
||||
UInt64 currentTotalPacked = 0, currentTotalUnPacked = 0;
|
||||
|
||||
RINOK(extractCallback->SetCompleted(¤tTotalPacked));
|
||||
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
INT32 askMode;
|
||||
Int32 askMode;
|
||||
askMode = testMode ? NArchive::NExtract::NAskMode::kTest :
|
||||
NArchive::NExtract::NAskMode::kExtract;
|
||||
|
||||
@@ -171,8 +171,27 @@ STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
|
||||
if(!testMode && !realOutStream)
|
||||
return S_OK;
|
||||
|
||||
|
||||
extractCallback->PrepareOperation(askMode);
|
||||
|
||||
#ifndef COMPRESS_BZIP2
|
||||
CCoderLibrary lib;
|
||||
#endif
|
||||
CMyComPtr<ICompressCoder> decoder;
|
||||
#ifdef COMPRESS_BZIP2
|
||||
decoder = new NCompress::NBZip2::CDecoder;
|
||||
#else
|
||||
HRESULT loadResult = lib.LoadAndCreateCoder(
|
||||
GetBZip2CodecPath(),
|
||||
CLSID_CCompressBZip2Decoder, &decoder);
|
||||
if (loadResult != S_OK)
|
||||
{
|
||||
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
CDummyOutStream *outStreamSpec = new CDummyOutStream;
|
||||
CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
|
||||
outStreamSpec->Init(realOutStream);
|
||||
@@ -182,31 +201,72 @@ STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
|
||||
CLocalProgress *localProgressSpec = new CLocalProgress;
|
||||
CMyComPtr<ICompressProgressInfo> progress = localProgressSpec;
|
||||
localProgressSpec->Init(extractCallback, true);
|
||||
|
||||
CLocalCompressProgressInfo *localCompressProgressSpec =
|
||||
new CLocalCompressProgressInfo;
|
||||
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
|
||||
|
||||
RINOK(_stream->Seek(_streamStartPosition, STREAM_SEEK_SET, NULL));
|
||||
|
||||
#ifndef COMPRESS_BZIP2
|
||||
CCoderLibrary lib;
|
||||
#endif
|
||||
CMyComPtr<ICompressCoder> decoder;
|
||||
#ifdef COMPRESS_BZIP2
|
||||
decoder = new NCompress::NBZip2::CDecoder;
|
||||
#else
|
||||
RINOK(lib.LoadAndCreateCoder(
|
||||
GetBZip2CodecPath(),
|
||||
CLSID_CCompressBZip2Decoder, &decoder));
|
||||
#endif
|
||||
|
||||
HRESULT result = decoder->Code(_stream, outStream, NULL, NULL, progress);
|
||||
HRESULT result;
|
||||
|
||||
bool firstItem = true;
|
||||
while(true)
|
||||
{
|
||||
localCompressProgressSpec->Init(progress,
|
||||
¤tTotalPacked,
|
||||
¤tTotalUnPacked);
|
||||
|
||||
const int kSignatureSize = 3;
|
||||
Byte buffer[kSignatureSize];
|
||||
UInt32 processedSize;
|
||||
RINOK(_stream->Read(buffer, kSignatureSize, &processedSize));
|
||||
if (processedSize < kSignatureSize)
|
||||
{
|
||||
if (firstItem)
|
||||
return E_FAIL;
|
||||
break;
|
||||
}
|
||||
if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h')
|
||||
{
|
||||
if (firstItem)
|
||||
return E_FAIL;
|
||||
outStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK))
|
||||
return S_OK;
|
||||
}
|
||||
firstItem = false;
|
||||
|
||||
UInt64 dataStartPos;
|
||||
RINOK(_stream->Seek((UInt64)(Int64)(-3), STREAM_SEEK_CUR, &dataStartPos));
|
||||
|
||||
result = decoder->Code(_stream, outStream, NULL, NULL, compressProgress);
|
||||
|
||||
if (result != S_OK)
|
||||
break;
|
||||
|
||||
CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize;
|
||||
decoder.QueryInterface(IID_ICompressGetInStreamProcessedSize,
|
||||
&getInStreamProcessedSize);
|
||||
if (!getInStreamProcessedSize)
|
||||
break;
|
||||
|
||||
UInt64 packSize;
|
||||
RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&packSize));
|
||||
UInt64 pos;
|
||||
RINOK(_stream->Seek(dataStartPos + packSize, STREAM_SEEK_SET, &pos));
|
||||
currentTotalPacked = pos - _streamStartPosition;
|
||||
}
|
||||
outStream.Release();
|
||||
if (result == S_FALSE)
|
||||
RINOK(extractCallback->SetOperationResult(
|
||||
NArchive::NExtract::NOperationResult::kDataError))
|
||||
else if (result == S_OK)
|
||||
RINOK(extractCallback->SetOperationResult(
|
||||
NArchive::NExtract::NOperationResult::kOK))
|
||||
|
||||
int retResult;
|
||||
if (result == S_OK)
|
||||
retResult = NArchive::NExtract::NOperationResult::kOK;
|
||||
else
|
||||
return result;
|
||||
retResult = NArchive::NExtract::NOperationResult::kDataError;
|
||||
|
||||
RINOK(extractCallback->SetOperationResult(retResult));
|
||||
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// BZip2/Handler.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __BZIP2_HANDLER_H
|
||||
#define __BZIP2_HANDLER_H
|
||||
|
||||
@@ -15,45 +13,52 @@ namespace NBZip2 {
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
public IOutArchive,
|
||||
public ISetProperties,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CMyComPtr<IInStream> _stream;
|
||||
NArchive::NBZip2::CItem _item;
|
||||
UInt64 _streamStartPosition;
|
||||
|
||||
UInt32 _numPasses;
|
||||
void InitMethodProperties() { _numPasses = 1; }
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP2(
|
||||
MY_UNKNOWN_IMP3(
|
||||
IInArchive,
|
||||
IOutArchive
|
||||
IOutArchive,
|
||||
ISetProperties
|
||||
)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UINT64 *maxCheckStartPosition,
|
||||
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(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,
|
||||
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
|
||||
STDMETHOD(GetNumberOfArchiveProperties)(UINT32 *numProperties);
|
||||
STDMETHOD(GetArchivePropertyInfo)(UINT32 index,
|
||||
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
|
||||
|
||||
// IOutArchiveHandler
|
||||
|
||||
STDMETHOD(UpdateItems)(IOutStream *outStream, UINT32 numItems,
|
||||
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
|
||||
IArchiveUpdateCallback *updateCallback);
|
||||
STDMETHOD(GetFileTimeType)(UInt32 *type);
|
||||
|
||||
STDMETHOD(GetFileTimeType)(UINT32 *type);
|
||||
// ISetProperties
|
||||
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
|
||||
|
||||
private:
|
||||
CMyComPtr<IInStream> _stream;
|
||||
NArchive::NBZip2::CItem _item;
|
||||
UINT64 _streamStartPosition;
|
||||
CHandler() { InitMethodProperties(); }
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -5,41 +5,40 @@
|
||||
#include "BZip2Handler.h"
|
||||
#include "BZip2Update.h"
|
||||
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/String.h"
|
||||
#include "Common/StringToInt.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static const int kNumItemInArchive = 1;
|
||||
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
STDMETHODIMP CHandler::GetFileTimeType(UINT32 *type)
|
||||
STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
|
||||
{
|
||||
*type = NFileTimeType::kUnix;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT CopyStreams(IInStream *inStream, IOutStream *outStream,
|
||||
IArchiveUpdateCallback *updateCallback)
|
||||
static HRESULT CopyStreams(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, IArchiveUpdateCallback *updateCallback)
|
||||
{
|
||||
CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
|
||||
return copyCoder->Code(inStream, outStream, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::UpdateItems(IOutStream *outStream, UINT32 numItems,
|
||||
STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
|
||||
IArchiveUpdateCallback *updateCallback)
|
||||
{
|
||||
if (numItems != 1)
|
||||
return E_INVALIDARG;
|
||||
|
||||
INT32 newData;
|
||||
INT32 newProperties;
|
||||
UINT32 indexInArchive;
|
||||
Int32 newData;
|
||||
Int32 newProperties;
|
||||
UInt32 indexInArchive;
|
||||
if (!updateCallback)
|
||||
return E_FAIL;
|
||||
RINOK(updateCallback->GetUpdateItemInfo(0,
|
||||
@@ -47,17 +46,6 @@ STDMETHODIMP CHandler::UpdateItems(IOutStream *outStream, UINT32 numItems,
|
||||
|
||||
if (IntToBool(newProperties))
|
||||
{
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
RINOK(updateCallback->GetProperty(0, kpidAttributes, &propVariant));
|
||||
if (propVariant.vt == VT_UI4)
|
||||
{
|
||||
if (NFile::NFind::NAttributes::IsDirectory(propVariant.ulVal))
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
else if (propVariant.vt != VT_EMPTY)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
RINOK(updateCallback->GetProperty(0, kpidIsFolder, &propVariant));
|
||||
@@ -73,15 +61,15 @@ STDMETHODIMP CHandler::UpdateItems(IOutStream *outStream, UINT32 numItems,
|
||||
|
||||
if (IntToBool(newData))
|
||||
{
|
||||
UINT64 size;
|
||||
UInt64 size;
|
||||
{
|
||||
NCOM::CPropVariant propVariant;
|
||||
RINOK(updateCallback->GetProperty(0, kpidSize, &propVariant));
|
||||
if (propVariant.vt != VT_UI8)
|
||||
return E_INVALIDARG;
|
||||
size = *(UINT64 *)(&propVariant.uhVal);
|
||||
size = propVariant.uhVal.QuadPart;
|
||||
}
|
||||
return UpdateArchive(size, outStream, 0, updateCallback);
|
||||
return UpdateArchive(size, outStream, 0, _numPasses, updateCallback);
|
||||
}
|
||||
if (indexInArchive != 0)
|
||||
return E_INVALIDARG;
|
||||
@@ -89,4 +77,83 @@ STDMETHODIMP CHandler::UpdateItems(IOutStream *outStream, UINT32 numItems,
|
||||
return CopyStreams(_stream, outStream, updateCallback);
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
|
||||
{
|
||||
InitMethodProperties();
|
||||
for (int i = 0; i < numProperties; i++)
|
||||
{
|
||||
UString name = UString(names[i]);
|
||||
name.MakeUpper();
|
||||
if (name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
|
||||
const PROPVARIANT &value = values[i];
|
||||
|
||||
if (name[0] == 'X')
|
||||
{
|
||||
name.Delete(0);
|
||||
UInt32 level = 9;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
level = value.ulVal;
|
||||
}
|
||||
else if (value.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
const wchar_t *start = name;
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (end - start != name.Length())
|
||||
return E_INVALIDARG;
|
||||
level = (UInt32)v;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
if (level < 7)
|
||||
_numPasses = 1;
|
||||
else if (level < 9)
|
||||
_numPasses = 2;
|
||||
else
|
||||
_numPasses = 7;
|
||||
continue;
|
||||
}
|
||||
else if (name.Left(4) == L"PASS")
|
||||
{
|
||||
name.Delete(0, 4);
|
||||
UInt32 numPasses = 1;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
numPasses = value.ulVal;
|
||||
}
|
||||
else if (value.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
const wchar_t *start = name;
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (end - start != name.Length())
|
||||
return E_INVALIDARG;
|
||||
numPasses = (UInt32)v;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (numPasses < 1 || numPasses > 10)
|
||||
return E_INVALIDARG;
|
||||
_numPasses = numPasses;
|
||||
continue;
|
||||
}
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Archive/BZip2Item.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __ARCHIVE_BZIP2_ITEM_H
|
||||
#define __ARCHIVE_BZIP2_ITEM_H
|
||||
|
||||
@@ -10,8 +8,8 @@ namespace NBZip2 {
|
||||
|
||||
struct CItem
|
||||
{
|
||||
UINT64 PackSize;
|
||||
UINT64 UnPackSize;
|
||||
UInt64 PackSize;
|
||||
UInt64 UnPackSize;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Windows/Defs.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "BZip2Update.h"
|
||||
|
||||
@@ -21,17 +20,17 @@ extern CSysString GetBZip2CodecPath();
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
HRESULT UpdateArchive(UINT64 unpackSize,
|
||||
IOutStream *outStream,
|
||||
HRESULT UpdateArchive(UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
int indexInClient,
|
||||
UInt32 numPasses,
|
||||
IArchiveUpdateCallback *updateCallback)
|
||||
{
|
||||
RINOK(updateCallback->SetTotal(unpackSize));
|
||||
|
||||
UINT64 complexity = 0;
|
||||
UInt64 complexity = 0;
|
||||
RINOK(updateCallback->SetCompleted(&complexity));
|
||||
|
||||
CMyComPtr<IInStream> fileInStream;
|
||||
CMyComPtr<ISequentialInStream> fileInStream;
|
||||
|
||||
RINOK(updateCallback->GetStream(indexInClient, &fileInStream));
|
||||
|
||||
@@ -49,6 +48,27 @@ HRESULT UpdateArchive(UINT64 unpackSize,
|
||||
RINOK(lib.LoadAndCreateCoder(GetBZip2CodecPath(),
|
||||
CLSID_CCompressBZip2Encoder, &encoder));
|
||||
#endif
|
||||
|
||||
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
|
||||
encoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
|
||||
if (setCoderProperties)
|
||||
{
|
||||
/*
|
||||
NWindows::NCOM::CPropVariant properties[2] =
|
||||
{
|
||||
dictionary, numPasses
|
||||
};
|
||||
PROPID propIDs[2] =
|
||||
{
|
||||
NCoderPropID::kDictionarySize,
|
||||
NCoderPropID::kNumPasses,
|
||||
};
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, 2));
|
||||
*/
|
||||
NWindows::NCOM::CPropVariant property = numPasses;
|
||||
PROPID propID = NCoderPropID::kNumPasses;
|
||||
RINOK(setCoderProperties->SetCoderProperties(&propID, &property, 1));
|
||||
}
|
||||
|
||||
RINOK(encoder->Code(fileInStream, outStream, NULL, NULL, localProgress));
|
||||
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
// BZip2Update.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __BZIP2_UPDATE_H
|
||||
#define __BZIP2_UPDATE_H
|
||||
|
||||
#include "Common/Types.h"
|
||||
|
||||
#include "../IArchive.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
HRESULT UpdateArchive(
|
||||
UINT64 unpackSize,
|
||||
IOutStream *outStream,
|
||||
UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
int indexInClient,
|
||||
UInt32 numPasses,
|
||||
IArchiveUpdateCallback *updateCallback);
|
||||
|
||||
}}
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#define INITGUID
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Common/String.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "BZip2Handler.h"
|
||||
#include "../../ICoder.h"
|
||||
@@ -99,6 +97,14 @@ STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
case NArchive::kKeepName:
|
||||
propVariant = true;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
const char sig[] = { 'B', 'Z', 'h' };
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(sig, 3)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "StdAfx.h"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// stdafx.h
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -75,8 +75,8 @@ IDI_ICON1 ICON DISCARDABLE "bz2.ico"
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,12,0,0
|
||||
PRODUCTVERSION 3,12,0,0
|
||||
FILEVERSION 4,19,0,0
|
||||
PRODUCTVERSION 4,19,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -94,14 +94,14 @@ BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "Igor Pavlov\0"
|
||||
VALUE "FileDescription", "BZip2 Plugin for 7-Zip\0"
|
||||
VALUE "FileVersion", "3, 12, 0, 0\0"
|
||||
VALUE "FileVersion", "4, 19, 0, 0\0"
|
||||
VALUE "InternalName", "bz2\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2003 Igor Pavlov\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 1999-2005 Igor Pavlov\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "bz.dll\0"
|
||||
VALUE "OriginalFilename", "bz2.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "7-Zip\0"
|
||||
VALUE "ProductVersion", "3, 12, 0, 0\0"
|
||||
VALUE "ProductVersion", "4, 19, 0, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
|
||||
Reference in New Issue
Block a user