mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-13 14:11:34 -06:00
23.01
This commit is contained in:
@@ -3,11 +3,13 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../C/CpuArch.h"
|
||||
#include "../../../C/7zVersion.h"
|
||||
|
||||
#include "../../Common/ComTry.h"
|
||||
#include "../../Common/MyCom.h"
|
||||
|
||||
#include "../../Windows/Defs.h"
|
||||
#include "../../Windows/PropVariant.h"
|
||||
|
||||
#include "../ICoder.h"
|
||||
|
||||
@@ -21,7 +23,7 @@ extern const CHasherInfo *g_Hashers[];
|
||||
|
||||
static void SetPropFromAscii(const char *s, PROPVARIANT *prop) throw()
|
||||
{
|
||||
UINT len = (UINT)strlen(s);
|
||||
const UINT len = (UINT)strlen(s);
|
||||
BSTR dest = ::SysAllocStringLen(NULL, len);
|
||||
if (dest)
|
||||
{
|
||||
@@ -45,7 +47,7 @@ static HRESULT MethodToClassID(UInt16 typeId, CMethodId id, PROPVARIANT *value)
|
||||
clsId.Data1 = k_7zip_GUID_Data1;
|
||||
clsId.Data2 = k_7zip_GUID_Data2;
|
||||
clsId.Data3 = typeId;
|
||||
SetUi64(clsId.Data4, id);
|
||||
SetUi64(clsId.Data4, id)
|
||||
return SetPropGUID(clsId, value);
|
||||
}
|
||||
|
||||
@@ -61,7 +63,7 @@ static HRESULT FindCodecClassId(const GUID *clsid, bool isCoder2, bool isFilter,
|
||||
if (clsid->Data3 == k_7zip_GUID_Data3_Decoder) encode = false;
|
||||
else if (clsid->Data3 != k_7zip_GUID_Data3_Encoder) return S_OK;
|
||||
|
||||
UInt64 id = GetUi64(clsid->Data4);
|
||||
const UInt64 id = GetUi64(clsid->Data4);
|
||||
|
||||
for (unsigned i = 0; i < g_NumCodecs; i++)
|
||||
{
|
||||
@@ -75,7 +77,7 @@ static HRESULT FindCodecClassId(const GUID *clsid, bool isCoder2, bool isFilter,
|
||||
if (codec.NumStreams == 1 ? isCoder2 : !isCoder2)
|
||||
return E_NOINTERFACE;
|
||||
|
||||
index = i;
|
||||
index = (int)i;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -169,7 +171,7 @@ STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject)
|
||||
|
||||
bool isFilter = false;
|
||||
bool isCoder2 = false;
|
||||
bool isCoder = (*iid == IID_ICompressCoder) != 0;
|
||||
const bool isCoder = (*iid == IID_ICompressCoder) != 0;
|
||||
if (!isCoder)
|
||||
{
|
||||
isFilter = (*iid == IID_ICompressFilter) != 0;
|
||||
@@ -183,13 +185,13 @@ STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject)
|
||||
|
||||
bool encode;
|
||||
int codecIndex;
|
||||
HRESULT res = FindCodecClassId(clsid, isCoder2, isFilter, encode, codecIndex);
|
||||
const HRESULT res = FindCodecClassId(clsid, isCoder2, isFilter, encode, codecIndex);
|
||||
if (res != S_OK)
|
||||
return res;
|
||||
if (codecIndex < 0)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
|
||||
return CreateCoderMain(codecIndex, encode, outObject);
|
||||
return CreateCoderMain((unsigned)codecIndex, encode, outObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -255,8 +257,8 @@ STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
|
||||
}
|
||||
|
||||
|
||||
STDAPI GetNumberOfMethods(UINT32 *numCodecs);
|
||||
STDAPI GetNumberOfMethods(UINT32 *numCodecs)
|
||||
STDAPI GetNumberOfMethods(UInt32 *numCodecs);
|
||||
STDAPI GetNumberOfMethods(UInt32 *numCodecs)
|
||||
{
|
||||
*numCodecs = g_NumCodecs;
|
||||
return S_OK;
|
||||
@@ -271,10 +273,10 @@ static int FindHasherClassId(const GUID *clsid) throw()
|
||||
clsid->Data2 != k_7zip_GUID_Data2 ||
|
||||
clsid->Data3 != k_7zip_GUID_Data3_Hasher)
|
||||
return -1;
|
||||
UInt64 id = GetUi64(clsid->Data4);
|
||||
const UInt64 id = GetUi64(clsid->Data4);
|
||||
for (unsigned i = 0; i < g_NumCodecs; i++)
|
||||
if (id == g_Hashers[i]->Id)
|
||||
return i;
|
||||
return (int)i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -292,11 +294,11 @@ STDAPI CreateHasher(const GUID *clsid, IHasher **outObject);
|
||||
STDAPI CreateHasher(const GUID *clsid, IHasher **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
int index = FindHasherClassId(clsid);
|
||||
*outObject = NULL;
|
||||
const int index = FindHasherClassId(clsid);
|
||||
if (index < 0)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
return CreateHasher2(index, outObject);
|
||||
return CreateHasher2((UInt32)(unsigned)index, outObject);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -326,17 +328,7 @@ STDAPI GetHasherProp(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
class CHashers:
|
||||
public IHashers,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(IHashers)
|
||||
|
||||
STDMETHOD_(UInt32, GetNumHashers)();
|
||||
STDMETHOD(GetHasherProp)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(CreateHasher)(UInt32 index, IHasher **hasher);
|
||||
};
|
||||
Z7_CLASS_IMP_COM_1(CHashers, IHashers) };
|
||||
|
||||
STDAPI GetHashers(IHashers **hashers);
|
||||
STDAPI GetHashers(IHashers **hashers)
|
||||
@@ -349,17 +341,38 @@ STDAPI GetHashers(IHashers **hashers)
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP_(UInt32) CHashers::GetNumHashers()
|
||||
Z7_COM7F_IMF2(UInt32, CHashers::GetNumHashers())
|
||||
{
|
||||
return g_NumHashers;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHashers::GetHasherProp(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
Z7_COM7F_IMF(CHashers::GetHasherProp(UInt32 index, PROPID propID, PROPVARIANT *value))
|
||||
{
|
||||
return ::GetHasherProp(index, propID, value);
|
||||
}
|
||||
|
||||
STDMETHODIMP CHashers::CreateHasher(UInt32 index, IHasher **hasher)
|
||||
Z7_COM7F_IMF(CHashers::CreateHasher(UInt32 index, IHasher **hasher))
|
||||
{
|
||||
return ::CreateHasher2(index, hasher);
|
||||
}
|
||||
|
||||
|
||||
STDAPI GetModuleProp(PROPID propID, PROPVARIANT *value);
|
||||
STDAPI GetModuleProp(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
::VariantClear((VARIANTARG *)value);
|
||||
switch (propID)
|
||||
{
|
||||
case NModulePropID::kInterfaceType:
|
||||
{
|
||||
NWindows::NCOM::PropVarEm_Set_UInt32(value, NModuleInterfaceType::k_IUnknown_VirtDestructor_ThisModule);
|
||||
break;
|
||||
}
|
||||
case NModulePropID::kVersion:
|
||||
{
|
||||
NWindows::NCOM::PropVarEm_Set_UInt32(value, (MY_VER_MAJOR << 16) | MY_VER_MINOR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user