mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 13:15:04 -06:00
Use the new callback function names.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
#include "ZstdDecoder.h"
|
#include "ZstdDecoder.h"
|
||||||
|
|
||||||
int ZstdRead(void *arg, ZSTDMT_Buffer * in)
|
int ZstdRead(void *arg, ZSTDCB_Buffer * in)
|
||||||
{
|
{
|
||||||
struct ZstdStream *x = (struct ZstdStream*)arg;
|
struct ZstdStream *x = (struct ZstdStream*)arg;
|
||||||
size_t size = in->size;
|
size_t size = in->size;
|
||||||
@@ -28,7 +28,7 @@ int ZstdRead(void *arg, ZSTDMT_Buffer * in)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZstdWrite(void *arg, ZSTDMT_Buffer * out)
|
int ZstdWrite(void *arg, ZSTDCB_Buffer * out)
|
||||||
{
|
{
|
||||||
struct ZstdStream *x = (struct ZstdStream*)arg;
|
struct ZstdStream *x = (struct ZstdStream*)arg;
|
||||||
UInt32 todo = (UInt32)out->size;
|
UInt32 todo = (UInt32)out->size;
|
||||||
@@ -85,7 +85,7 @@ CDecoder::~CDecoder()
|
|||||||
|
|
||||||
HRESULT CDecoder::ErrorOut(size_t code)
|
HRESULT CDecoder::ErrorOut(size_t code)
|
||||||
{
|
{
|
||||||
const char *strError = ZSTDMT_getErrorString(code);
|
const char *strError = ZSTDCB_getErrorString(code);
|
||||||
wchar_t wstrError[200+5]; /* no malloc here, /TR */
|
wchar_t wstrError[200+5]; /* no malloc here, /TR */
|
||||||
|
|
||||||
mbstowcs(wstrError, strError, 200);
|
mbstowcs(wstrError, strError, 200);
|
||||||
@@ -109,7 +109,7 @@ STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte * prop, UInt32 size)
|
|||||||
|
|
||||||
STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
|
STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
|
||||||
{
|
{
|
||||||
const UInt32 kNumThreadsMax = ZSTDMT_THREAD_MAX;
|
const UInt32 kNumThreadsMax = ZSTDCB_THREAD_MAX;
|
||||||
if (numThreads < 1) numThreads = 1;
|
if (numThreads < 1) numThreads = 1;
|
||||||
if (numThreads > kNumThreadsMax) numThreads = kNumThreadsMax;
|
if (numThreads > kNumThreadsMax) numThreads = kNumThreadsMax;
|
||||||
_numThreads = numThreads;
|
_numThreads = numThreads;
|
||||||
@@ -132,7 +132,7 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 * outSize)
|
|||||||
HRESULT CDecoder::CodeSpec(ISequentialInStream * inStream,
|
HRESULT CDecoder::CodeSpec(ISequentialInStream * inStream,
|
||||||
ISequentialOutStream * outStream, ICompressProgressInfo * progress)
|
ISequentialOutStream * outStream, ICompressProgressInfo * progress)
|
||||||
{
|
{
|
||||||
ZSTDMT_RdWr_t rdwr;
|
ZSTDCB_RdWr_t rdwr;
|
||||||
size_t result;
|
size_t result;
|
||||||
HRESULT res = S_OK;
|
HRESULT res = S_OK;
|
||||||
|
|
||||||
@@ -153,20 +153,20 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream * inStream,
|
|||||||
rdwr.arg_write = (void *)&Wr;
|
rdwr.arg_write = (void *)&Wr;
|
||||||
|
|
||||||
/* 2) create decompression context */
|
/* 2) create decompression context */
|
||||||
ZSTDMT_DCtx *ctx = ZSTDMT_createDCtx(_numThreads, _inputSize);
|
ZSTDCB_DCtx *ctx = ZSTDCB_createDCtx(_numThreads, _inputSize);
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
/* 3) decompress */
|
/* 3) decompress */
|
||||||
result = ZSTDMT_decompressDCtx(ctx, &rdwr);
|
result = ZSTDCB_decompressDCtx(ctx, &rdwr);
|
||||||
if (ZSTDMT_isError(result)) {
|
if (ZSTDCB_isError(result)) {
|
||||||
if (result == (size_t)-ZSTDMT_error_canceled)
|
if (result == (size_t)-ZSTDCB_error_canceled)
|
||||||
return E_ABORT;
|
return E_ABORT;
|
||||||
return ErrorOut(result);
|
return ErrorOut(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4) free resources */
|
/* 4) free resources */
|
||||||
ZSTDMT_freeDCtx(ctx);
|
ZSTDCB_freeDCtx(ctx);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,10 @@ struct ZstdStream {
|
|||||||
ICompressProgressInfo *progress;
|
ICompressProgressInfo *progress;
|
||||||
UInt64 *processedIn;
|
UInt64 *processedIn;
|
||||||
UInt64 *processedOut;
|
UInt64 *processedOut;
|
||||||
CCriticalSection *cs;
|
|
||||||
int flags;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int ZstdRead(void *Stream, ZSTDMT_Buffer * in);
|
extern int ZstdRead(void *Stream, ZSTDCB_Buffer * in);
|
||||||
extern int ZstdWrite(void *Stream, ZSTDMT_Buffer * in);
|
extern int ZstdWrite(void *Stream, ZSTDCB_Buffer * in);
|
||||||
|
|
||||||
namespace NCompress {
|
namespace NCompress {
|
||||||
namespace NZSTD {
|
namespace NZSTD {
|
||||||
@@ -55,7 +53,6 @@ class CDecoder:public ICompressCoder,
|
|||||||
CMyComPtr < ISequentialInStream > _inStream;
|
CMyComPtr < ISequentialInStream > _inStream;
|
||||||
|
|
||||||
DProps _props;
|
DProps _props;
|
||||||
CCriticalSection cs;
|
|
||||||
|
|
||||||
UInt64 _processedIn;
|
UInt64 _processedIn;
|
||||||
UInt64 _processedOut;
|
UInt64 _processedOut;
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ CEncoder::CEncoder():
|
|||||||
CEncoder::~CEncoder()
|
CEncoder::~CEncoder()
|
||||||
{
|
{
|
||||||
if (_ctx)
|
if (_ctx)
|
||||||
ZSTDMT_freeCCtx(_ctx);
|
ZSTDCB_freeCCtx(_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CEncoder::ErrorOut(size_t code)
|
HRESULT CEncoder::ErrorOut(size_t code)
|
||||||
{
|
{
|
||||||
const char *strError = ZSTDMT_getErrorString(code);
|
const char *strError = ZSTDCB_getErrorString(code);
|
||||||
wchar_t wstrError[200+5]; /* no malloc here, /TR */
|
wchar_t wstrError[200+5]; /* no malloc here, /TR */
|
||||||
|
|
||||||
mbstowcs(wstrError, strError, 200);
|
mbstowcs(wstrError, strError, 200);
|
||||||
@@ -54,7 +54,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID * propIDs, const PROPVARI
|
|||||||
|
|
||||||
/* level 1..22 */
|
/* level 1..22 */
|
||||||
_props._level = static_cast < Byte > (prop.ulVal);
|
_props._level = static_cast < Byte > (prop.ulVal);
|
||||||
Byte mylevel = static_cast < Byte > (ZSTDMT_LEVEL_MAX);
|
Byte mylevel = static_cast < Byte > (ZSTDCB_LEVEL_MAX);
|
||||||
if (_props._level > mylevel)
|
if (_props._level > mylevel)
|
||||||
_props._level = mylevel;
|
_props._level = mylevel;
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
|
|||||||
ISequentialOutStream *outStream, const UInt64 * /*inSize*/ ,
|
ISequentialOutStream *outStream, const UInt64 * /*inSize*/ ,
|
||||||
const UInt64 * /*outSize */, ICompressProgressInfo *progress)
|
const UInt64 * /*outSize */, ICompressProgressInfo *progress)
|
||||||
{
|
{
|
||||||
ZSTDMT_RdWr_t rdwr;
|
ZSTDCB_RdWr_t rdwr;
|
||||||
size_t result;
|
size_t result;
|
||||||
HRESULT res = S_OK;
|
HRESULT res = S_OK;
|
||||||
|
|
||||||
@@ -112,14 +112,14 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
|
|||||||
|
|
||||||
/* 2) create compression context, if needed */
|
/* 2) create compression context, if needed */
|
||||||
if (!_ctx)
|
if (!_ctx)
|
||||||
_ctx = ZSTDMT_createCCtx(_numThreads, _props._level, _inputSize);
|
_ctx = ZSTDCB_createCCtx(_numThreads, _props._level, _inputSize);
|
||||||
if (!_ctx)
|
if (!_ctx)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
/* 3) compress */
|
/* 3) compress */
|
||||||
result = ZSTDMT_compressCCtx(_ctx, &rdwr);
|
result = ZSTDCB_compressCCtx(_ctx, &rdwr);
|
||||||
if (ZSTDMT_isError(result)) {
|
if (ZSTDCB_isError(result)) {
|
||||||
if (result == (size_t)-ZSTDMT_error_canceled)
|
if (result == (size_t)-ZSTDCB_error_canceled)
|
||||||
return E_ABORT;
|
return E_ABORT;
|
||||||
return ErrorOut(result);
|
return ErrorOut(result);
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
|
|||||||
|
|
||||||
STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads)
|
STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads)
|
||||||
{
|
{
|
||||||
const UInt32 kNumThreadsMax = ZSTDMT_THREAD_MAX;
|
const UInt32 kNumThreadsMax = ZSTDCB_THREAD_MAX;
|
||||||
if (numThreads < 1) numThreads = 1;
|
if (numThreads < 1) numThreads = 1;
|
||||||
if (numThreads > kNumThreadsMax) numThreads = kNumThreadsMax;
|
if (numThreads > kNumThreadsMax) numThreads = kNumThreadsMax;
|
||||||
_numThreads = numThreads;
|
_numThreads = numThreads;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class CEncoder:
|
|||||||
UInt32 _inputSize;
|
UInt32 _inputSize;
|
||||||
UInt32 _numThreads;
|
UInt32 _numThreads;
|
||||||
|
|
||||||
ZSTDMT_CCtx *_ctx;
|
ZSTDCB_CCtx *_ctx;
|
||||||
HRESULT CEncoder::ErrorOut(size_t code);
|
HRESULT CEncoder::ErrorOut(size_t code);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user