Add xxHash functionss to context menu

This commit is contained in:
Tino Reichardt
2018-11-01 08:00:13 +01:00
parent ed069bab9e
commit f4bf9c8d29
7 changed files with 98 additions and 3 deletions

View File

@@ -14,6 +14,8 @@ COMMON_OBJS = \
$O\StringToInt.obj \
$O\UTFConvert.obj \
$O\Wildcard.obj \
$O\XXH32Reg.obj \
$O\XXH64Reg.obj \
$O\XzCrc64Init.obj \
$O\XzCrc64Reg.obj \

View File

@@ -133,8 +133,8 @@ C_OBJS = \
!include "../../LzmaDec.mak"
COMPRESS_OBJS = $(COMPRESS_OBJS) \
$O\ZstdEncoder.obj \
$O\ZstdDecoder.obj \
$O\ZstdEncoder.obj \
$O\ZstdRegister.obj \
ZSTD_OBJS = \

View File

@@ -44,7 +44,6 @@ WIN_OBJS = \
$O\Shell.obj \
$O\System.obj \
$O\Synchronization.obj \
$O\System.obj \
$O\Window.obj \
WIN_CTRL_OBJS = \
@@ -152,8 +151,8 @@ C_OBJS = \
!include "../../LzmaDec.mak"
COMPRESS_OBJS = $(COMPRESS_OBJS) \
$O\ZstdEncoder.obj \
$O\ZstdDecoder.obj \
$O\ZstdEncoder.obj \
$O\ZstdRegister.obj \
ZSTD_OBJS = \

View File

@@ -225,6 +225,8 @@ static const CHashCommand g_HashCommands[] =
{ CZipContextMenu::kHash_CRC64, "CRC-64", "CRC64" },
{ CZipContextMenu::kHash_SHA1, "SHA-1", "SHA1" },
{ CZipContextMenu::kHash_SHA256, "SHA-256", "SHA256" },
{ CZipContextMenu::kHash_XXH32, "XXH-32", "XXH32" },
{ CZipContextMenu::kHash_XXH64, "XXH-64", "XXH64" },
{ CZipContextMenu::kHash_All, "*", "*" }
};
@@ -928,6 +930,8 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
case kHash_CRC64:
case kHash_SHA1:
case kHash_SHA256:
case kHash_XXH32:
case kHash_XXH64:
case kHash_All:
{
for (unsigned i = 0; i < ARRAY_SIZE(g_HashCommands); i++)

View File

@@ -36,6 +36,8 @@ public:
kHash_CRC64,
kHash_SHA1,
kHash_SHA256,
kHash_XXH32,
kHash_XXH64,
kHash_All
};

44
CPP/Common/XXH32Reg.cpp Normal file
View File

@@ -0,0 +1,44 @@
// XXH32Reg.cpp
#include "StdAfx.h"
#define XXH_STATIC_LINKING_ONLY
#include "../../C/CpuArch.h"
#include "../../C/zstd/xxhash.h"
#include "../Common/MyCom.h"
#include "../7zip/Common/RegisterCodec.h"
class CXXH32Hasher:
public IHasher,
public CMyUnknownImp
{
XXH32_state_t *_ctx;
Byte mtDummy[1 << 7];
public:
CXXH32Hasher() { _ctx = XXH32_createState(); }
~CXXH32Hasher() { XXH32_freeState(_ctx); }
MY_UNKNOWN_IMP1(IHasher)
INTERFACE_IHasher(;)
};
STDMETHODIMP_(void) CXXH32Hasher::Init() throw()
{
XXH32_reset(_ctx, 0);
}
STDMETHODIMP_(void) CXXH32Hasher::Update(const void *data, UInt32 size) throw()
{
XXH32_update(_ctx, data, size);
}
STDMETHODIMP_(void) CXXH32Hasher::Final(Byte *digest) throw()
{
UInt32 val = XXH32_digest(_ctx);
SetUi32(digest, val);
}
REGISTER_HASHER(CXXH32Hasher, 0x202, "XXH32", 4)

44
CPP/Common/XXH64Reg.cpp Normal file
View File

@@ -0,0 +1,44 @@
// XXH64Reg.cpp
#include "StdAfx.h"
#define XXH_STATIC_LINKING_ONLY
#include "../../C/CpuArch.h"
#include "../../C/zstd/xxhash.h"
#include "../Common/MyCom.h"
#include "../7zip/Common/RegisterCodec.h"
class CXXH64Hasher:
public IHasher,
public CMyUnknownImp
{
XXH64_state_t *_ctx;
Byte mtDummy[1 << 7];
public:
CXXH64Hasher() { _ctx = XXH64_createState(); }
~CXXH64Hasher() { XXH64_freeState(_ctx); }
MY_UNKNOWN_IMP1(IHasher)
INTERFACE_IHasher(;)
};
STDMETHODIMP_(void) CXXH64Hasher::Init() throw()
{
XXH64_reset(_ctx, 0);
}
STDMETHODIMP_(void) CXXH64Hasher::Update(const void *data, UInt32 size) throw()
{
XXH64_update(_ctx, data, size);
}
STDMETHODIMP_(void) CXXH64Hasher::Final(Byte *digest) throw()
{
UInt64 val = XXH64_digest(_ctx);
SetUi64(digest, val);
}
REGISTER_HASHER(CXXH64Hasher, 0x203, "XXH64", 8)