mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 09:15:00 -06:00
Update to 7-Zip Version 21.02
This commit is contained in:
@@ -137,7 +137,7 @@ bool CBondsChecks::CheckCoder(unsigned coderIndex)
|
||||
return false;
|
||||
_coderUsed[coderIndex] = true;
|
||||
|
||||
UInt32 start = BindInfo->Coder_to_Stream[coderIndex];
|
||||
const UInt32 start = BindInfo->Coder_to_Stream[coderIndex];
|
||||
|
||||
for (unsigned i = 0; i < coder.NumStreams; i++)
|
||||
{
|
||||
@@ -146,10 +146,10 @@ bool CBondsChecks::CheckCoder(unsigned coderIndex)
|
||||
if (BindInfo->IsStream_in_PackStreams(ind))
|
||||
continue;
|
||||
|
||||
int bond = BindInfo->FindBond_for_PackStream(ind);
|
||||
const int bond = BindInfo->FindBond_for_PackStream(ind);
|
||||
if (bond < 0)
|
||||
return false;
|
||||
if (!CheckCoder(BindInfo->Bonds[bond].UnpackIndex))
|
||||
if (!CheckCoder(BindInfo->Bonds[(unsigned)bond].UnpackIndex))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -246,15 +246,15 @@ bool CMixer::Is_UnpackSize_Correct_for_Coder(UInt32 coderIndex)
|
||||
if (coderIndex == _bi.UnpackCoder)
|
||||
return true;
|
||||
|
||||
int bond = _bi.FindBond_for_UnpackStream(coderIndex);
|
||||
const int bond = _bi.FindBond_for_UnpackStream(coderIndex);
|
||||
if (bond < 0)
|
||||
throw 20150213;
|
||||
|
||||
/*
|
||||
UInt32 coderIndex, coderStreamIndex;
|
||||
_bi.GetCoder_for_Stream(_bi.Bonds[bond].PackIndex, coderIndex, coderStreamIndex);
|
||||
_bi.GetCoder_for_Stream(_bi.Bonds[(unsigned)bond].PackIndex, coderIndex, coderStreamIndex);
|
||||
*/
|
||||
UInt32 nextCoder = _bi.Stream_to_Coder[_bi.Bonds[bond].PackIndex];
|
||||
const UInt32 nextCoder = _bi.Stream_to_Coder[_bi.Bonds[(unsigned)bond].PackIndex];
|
||||
|
||||
if (!IsFilter_Vector[nextCoder])
|
||||
return false;
|
||||
@@ -267,11 +267,11 @@ bool CMixer::Is_PackSize_Correct_for_Stream(UInt32 streamIndex)
|
||||
if (_bi.IsStream_in_PackStreams(streamIndex))
|
||||
return true;
|
||||
|
||||
int bond = _bi.FindBond_for_PackStream(streamIndex);
|
||||
const int bond = _bi.FindBond_for_PackStream(streamIndex);
|
||||
if (bond < 0)
|
||||
throw 20150213;
|
||||
|
||||
UInt32 nextCoder = _bi.Bonds[bond].UnpackIndex;
|
||||
const UInt32 nextCoder = _bi.Bonds[(unsigned)bond].UnpackIndex;
|
||||
|
||||
if (!IsFilter_Vector[nextCoder])
|
||||
return false;
|
||||
@@ -281,8 +281,8 @@ bool CMixer::Is_PackSize_Correct_for_Stream(UInt32 streamIndex)
|
||||
|
||||
bool CMixer::Is_PackSize_Correct_for_Coder(UInt32 coderIndex)
|
||||
{
|
||||
UInt32 startIndex = _bi.Coder_to_Stream[coderIndex];
|
||||
UInt32 numStreams = _bi.Coders[coderIndex].NumStreams;
|
||||
const UInt32 startIndex = _bi.Coder_to_Stream[coderIndex];
|
||||
const UInt32 numStreams = _bi.Coders[coderIndex].NumStreams;
|
||||
for (UInt32 i = 0; i < numStreams; i++)
|
||||
if (!Is_PackSize_Correct_for_Stream(startIndex + i))
|
||||
return false;
|
||||
@@ -293,19 +293,19 @@ bool CMixer::IsThere_ExternalCoder_in_PackTree(UInt32 coderIndex)
|
||||
{
|
||||
if (IsExternal_Vector[coderIndex])
|
||||
return true;
|
||||
UInt32 startIndex = _bi.Coder_to_Stream[coderIndex];
|
||||
UInt32 numStreams = _bi.Coders[coderIndex].NumStreams;
|
||||
const UInt32 startIndex = _bi.Coder_to_Stream[coderIndex];
|
||||
const UInt32 numStreams = _bi.Coders[coderIndex].NumStreams;
|
||||
for (UInt32 i = 0; i < numStreams; i++)
|
||||
{
|
||||
UInt32 si = startIndex + i;
|
||||
const UInt32 si = startIndex + i;
|
||||
if (_bi.IsStream_in_PackStreams(si))
|
||||
continue;
|
||||
|
||||
int bond = _bi.FindBond_for_PackStream(si);
|
||||
const int bond = _bi.FindBond_for_PackStream(si);
|
||||
if (bond < 0)
|
||||
throw 20150213;
|
||||
|
||||
if (IsThere_ExternalCoder_in_PackTree(_bi.Bonds[bond].UnpackIndex))
|
||||
if (IsThere_ExternalCoder_in_PackTree(_bi.Bonds[(unsigned)bond].UnpackIndex))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -360,7 +360,7 @@ CCoder &CMixerST::GetCoder(unsigned index)
|
||||
return _coders[index];
|
||||
}
|
||||
|
||||
void CMixerST::ReInit() {}
|
||||
HRESULT CMixerST::ReInit2() { return S_OK; }
|
||||
|
||||
HRESULT CMixerST::GetInStream2(
|
||||
ISequentialInStream * const *inStreams, /* const UInt64 * const *inSizes, */
|
||||
@@ -444,18 +444,18 @@ HRESULT CMixerST::GetInStream(
|
||||
}
|
||||
}
|
||||
|
||||
int bond = FindBond_for_Stream(
|
||||
const int bond = FindBond_for_Stream(
|
||||
true, // forInputStream
|
||||
inStreamIndex);
|
||||
if (bond < 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
RINOK(GetInStream2(inStreams, /* inSizes, */
|
||||
_bi.Bonds[bond].Get_OutIndex(EncodeMode), &seqInStream));
|
||||
_bi.Bonds[(unsigned)bond].Get_OutIndex(EncodeMode), &seqInStream));
|
||||
|
||||
while (_binderStreams.Size() <= (unsigned)bond)
|
||||
_binderStreams.AddNew();
|
||||
CStBinderStream &bs = _binderStreams[bond];
|
||||
CStBinderStream &bs = _binderStreams[(unsigned)bond];
|
||||
|
||||
if (bs.StreamRef || bs.InStreamSpec)
|
||||
return E_NOTIMPL;
|
||||
@@ -498,13 +498,13 @@ HRESULT CMixerST::GetOutStream(
|
||||
}
|
||||
}
|
||||
|
||||
int bond = FindBond_for_Stream(
|
||||
const int bond = FindBond_for_Stream(
|
||||
false, // forInputStream
|
||||
outStreamIndex);
|
||||
if (bond < 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
UInt32 inStreamIndex = _bi.Bonds[bond].Get_InIndex(EncodeMode);
|
||||
UInt32 inStreamIndex = _bi.Bonds[(unsigned)bond].Get_InIndex(EncodeMode);
|
||||
|
||||
UInt32 coderIndex = inStreamIndex;
|
||||
UInt32 coderStreamIndex = 0;
|
||||
@@ -560,7 +560,7 @@ HRESULT CMixerST::GetOutStream(
|
||||
|
||||
while (_binderStreams.Size() <= (unsigned)bond)
|
||||
_binderStreams.AddNew();
|
||||
CStBinderStream &bs = _binderStreams[bond];
|
||||
CStBinderStream &bs = _binderStreams[(unsigned)bond];
|
||||
|
||||
if (bs.StreamRef || bs.OutStreamSpec)
|
||||
return E_NOTIMPL;
|
||||
@@ -610,13 +610,13 @@ HRESULT CMixerST::FinishStream(UInt32 streamIndex)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int bond = FindBond_for_Stream(
|
||||
const int bond = FindBond_for_Stream(
|
||||
false, // forInputStream
|
||||
streamIndex);
|
||||
if (bond < 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
UInt32 inStreamIndex = _bi.Bonds[bond].Get_InIndex(EncodeMode);
|
||||
UInt32 inStreamIndex = _bi.Bonds[(unsigned)bond].Get_InIndex(EncodeMode);
|
||||
|
||||
UInt32 coderIndex = inStreamIndex;
|
||||
UInt32 coderStreamIndex = 0;
|
||||
@@ -654,7 +654,7 @@ void CMixerST::SelectMainCoder(bool useFirst)
|
||||
unsigned ci = _bi.UnpackCoder;
|
||||
|
||||
int firstNonFilter = -1;
|
||||
int firstAllowed = ci;
|
||||
unsigned firstAllowed = ci;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -674,7 +674,7 @@ void CMixerST::SelectMainCoder(bool useFirst)
|
||||
UInt32 st = _bi.Coder_to_Stream[ci];
|
||||
if (_bi.IsStream_in_PackStreams(st))
|
||||
break;
|
||||
int bond = _bi.FindBond_for_PackStream(st);
|
||||
const int bond = _bi.FindBond_for_PackStream(st);
|
||||
if (bond < 0)
|
||||
throw 20150213;
|
||||
|
||||
@@ -682,15 +682,15 @@ void CMixerST::SelectMainCoder(bool useFirst)
|
||||
break;
|
||||
|
||||
if (firstNonFilter == -1 && !IsFilter_Vector[ci])
|
||||
firstNonFilter = ci;
|
||||
firstNonFilter = (int)ci;
|
||||
|
||||
ci = _bi.Bonds[bond].UnpackIndex;
|
||||
ci = _bi.Bonds[(unsigned)bond].UnpackIndex;
|
||||
}
|
||||
|
||||
if (useFirst)
|
||||
ci = firstAllowed;
|
||||
else if (firstNonFilter >= 0)
|
||||
ci = firstNonFilter;
|
||||
ci = (unsigned)firstNonFilter;
|
||||
|
||||
MainCoderIndex = ci;
|
||||
}
|
||||
@@ -919,7 +919,8 @@ HRESULT CMixerMT::SetBindInfo(const CBindInfo &bindInfo)
|
||||
_streamBinders.Clear();
|
||||
FOR_VECTOR (i, _bi.Bonds)
|
||||
{
|
||||
RINOK(_streamBinders.AddNew().CreateEvents());
|
||||
// RINOK(_streamBinders.AddNew().CreateEvents());
|
||||
_streamBinders.AddNew();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -941,10 +942,13 @@ CCoder &CMixerMT::GetCoder(unsigned index)
|
||||
return _coders[index];
|
||||
}
|
||||
|
||||
void CMixerMT::ReInit()
|
||||
HRESULT CMixerMT::ReInit2()
|
||||
{
|
||||
FOR_VECTOR (i, _streamBinders)
|
||||
_streamBinders[i].ReInit();
|
||||
{
|
||||
RINOK(_streamBinders[i].Create_ReInit());
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CMixerMT::SelectMainCoder(bool useFirst)
|
||||
@@ -962,10 +966,10 @@ void CMixerMT::SelectMainCoder(bool useFirst)
|
||||
UInt32 st = _bi.Coder_to_Stream[ci];
|
||||
if (_bi.IsStream_in_PackStreams(st))
|
||||
break;
|
||||
int bond = _bi.FindBond_for_PackStream(st);
|
||||
const int bond = _bi.FindBond_for_PackStream(st);
|
||||
if (bond < 0)
|
||||
throw 20150213;
|
||||
ci = _bi.Bonds[bond].UnpackIndex;
|
||||
ci = _bi.Bonds[(unsigned)bond].UnpackIndex;
|
||||
}
|
||||
|
||||
MainCoderIndex = ci;
|
||||
@@ -1012,9 +1016,9 @@ HRESULT CMixerMT::Init(ISequentialInStream * const *inStreams, ISequentialOutStr
|
||||
outCoderStreamIndex = EncodeMode ? coderStreamIndex : 0;
|
||||
}
|
||||
|
||||
_streamBinders[i].CreateStreams(
|
||||
&_coders[inCoderIndex].InStreams[inCoderStreamIndex],
|
||||
&_coders[outCoderIndex].OutStreams[outCoderStreamIndex]);
|
||||
_streamBinders[i].CreateStreams2(
|
||||
_coders[inCoderIndex].InStreams[inCoderStreamIndex],
|
||||
_coders[outCoderIndex].OutStreams[outCoderStreamIndex]);
|
||||
|
||||
CMyComPtr<ICompressSetBufSize> inSetSize, outSetSize;
|
||||
_coders[inCoderIndex].QueryInterface(IID_ICompressSetBufSize, (void **)&inSetSize);
|
||||
@@ -1072,18 +1076,31 @@ HRESULT CMixerMT::Code(
|
||||
for (i = 0; i < _coders.Size(); i++)
|
||||
if (i != MainCoderIndex)
|
||||
{
|
||||
RINOK(_coders[i].Create());
|
||||
const WRes wres = _coders[i].Create();
|
||||
if (wres != 0)
|
||||
return HRESULT_FROM_WIN32(wres);
|
||||
}
|
||||
|
||||
for (i = 0; i < _coders.Size(); i++)
|
||||
if (i != MainCoderIndex)
|
||||
_coders[i].Start();
|
||||
{
|
||||
const WRes wres = _coders[i].Start();
|
||||
if (wres != 0)
|
||||
return HRESULT_FROM_WIN32(wres);
|
||||
}
|
||||
|
||||
_coders[MainCoderIndex].Code(progress);
|
||||
|
||||
WRes wres = 0;
|
||||
for (i = 0; i < _coders.Size(); i++)
|
||||
if (i != MainCoderIndex)
|
||||
_coders[i].WaitExecuteFinish();
|
||||
{
|
||||
WRes wres2 = _coders[i].WaitExecuteFinish();
|
||||
if (wres == 0)
|
||||
wres = wres2;
|
||||
}
|
||||
if (wres != 0)
|
||||
return HRESULT_FROM_WIN32(wres);
|
||||
|
||||
RINOK(ReturnIfError(E_ABORT));
|
||||
RINOK(ReturnIfError(E_OUTOFMEMORY));
|
||||
|
||||
@@ -107,7 +107,7 @@ struct CBindInfo
|
||||
{
|
||||
FOR_VECTOR (i, Bonds)
|
||||
if (Bonds[i].PackIndex == packStream)
|
||||
return i;
|
||||
return (int)i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ struct CBindInfo
|
||||
{
|
||||
FOR_VECTOR (i, Bonds)
|
||||
if (Bonds[i].UnpackIndex == unpackStream)
|
||||
return i;
|
||||
return (int)i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ struct CBindInfo
|
||||
{
|
||||
FOR_VECTOR(i, PackStreams)
|
||||
if (PackStreams[i] == streamIndex)
|
||||
return i;
|
||||
return (int)i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -251,6 +251,7 @@ public:
|
||||
// , InternalPackSizeError(false)
|
||||
{}
|
||||
|
||||
virtual ~CMixer() {};
|
||||
/*
|
||||
Sequence of calling:
|
||||
|
||||
@@ -279,7 +280,7 @@ public:
|
||||
virtual void AddCoder(const CCreatedCoder &cod) = 0;
|
||||
virtual CCoder &GetCoder(unsigned index) = 0;
|
||||
virtual void SelectMainCoder(bool useFirst) = 0;
|
||||
virtual void ReInit() = 0;
|
||||
virtual HRESULT ReInit2() = 0;
|
||||
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish) = 0;
|
||||
virtual HRESULT Code(
|
||||
ISequentialInStream * const *inStreams,
|
||||
@@ -322,6 +323,8 @@ class CMixerST:
|
||||
public CMixer,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CLASS_NO_COPY(CMixerST)
|
||||
|
||||
HRESULT GetInStream2(ISequentialInStream * const *inStreams, /* const UInt64 * const *inSizes, */
|
||||
UInt32 outStreamIndex, ISequentialInStream **inStreamRes);
|
||||
HRESULT GetInStream(ISequentialInStream * const *inStreams, /* const UInt64 * const *inSizes, */
|
||||
@@ -345,7 +348,7 @@ public:
|
||||
virtual void AddCoder(const CCreatedCoder &cod);
|
||||
virtual CCoder &GetCoder(unsigned index);
|
||||
virtual void SelectMainCoder(bool useFirst);
|
||||
virtual void ReInit();
|
||||
virtual HRESULT ReInit2();
|
||||
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish)
|
||||
{ _coders[coderIndex].SetCoderInfo(unpackSize, packSizes, finish); }
|
||||
virtual HRESULT Code(
|
||||
@@ -402,7 +405,7 @@ public:
|
||||
};
|
||||
|
||||
CCoderMT(): EncodeMode(false) {}
|
||||
~CCoderMT() { CVirtThread::WaitThreadFinish(); }
|
||||
virtual ~CCoderMT() { CVirtThread::WaitThreadFinish(); }
|
||||
|
||||
void Code(ICompressProgressInfo *progress);
|
||||
};
|
||||
@@ -413,11 +416,14 @@ class CMixerMT:
|
||||
public CMixer,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CLASS_NO_COPY(CMixerMT)
|
||||
|
||||
CObjectVector<CStreamBinder> _streamBinders;
|
||||
|
||||
HRESULT Init(ISequentialInStream * const *inStreams, ISequentialOutStream * const *outStreams);
|
||||
HRESULT ReturnIfError(HRESULT code);
|
||||
|
||||
// virtual ~CMixerMT() {};
|
||||
public:
|
||||
CObjectVector<CCoderMT> _coders;
|
||||
|
||||
@@ -427,7 +433,7 @@ public:
|
||||
virtual void AddCoder(const CCreatedCoder &cod);
|
||||
virtual CCoder &GetCoder(unsigned index);
|
||||
virtual void SelectMainCoder(bool useFirst);
|
||||
virtual void ReInit();
|
||||
virtual HRESULT ReInit2();
|
||||
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish)
|
||||
{ _coders[coderIndex].SetCoderInfo(unpackSize, packSizes, finish); }
|
||||
virtual HRESULT Code(
|
||||
|
||||
@@ -179,8 +179,8 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
|
||||
}
|
||||
if (number > 64)
|
||||
return E_FAIL;
|
||||
for (int j = _methods.Size(); j <= (int)number; j++)
|
||||
_methods.Add(COneMethodInfo());
|
||||
for (unsigned j = _methods.Size(); j <= number; j++)
|
||||
_methods.AddNew();
|
||||
return _methods[number].ParseMethodFromPROPVARIANT(realName, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ namespace NArchive {
|
||||
namespace NItemName {
|
||||
|
||||
static const wchar_t kOsPathSepar = WCHAR_PATH_SEPARATOR;
|
||||
|
||||
#if WCHAR_PATH_SEPARATOR != L'/'
|
||||
static const wchar_t kUnixPathSepar = L'/';
|
||||
#endif
|
||||
|
||||
void ReplaceSlashes_OsToUnix
|
||||
#if WCHAR_PATH_SEPARATOR != L'/'
|
||||
@@ -44,17 +47,35 @@ UString GetOsPath_Remove_TailSlash(const UString &name)
|
||||
}
|
||||
|
||||
|
||||
void ReplaceToOsSlashes_Remove_TailSlash(UString &name)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
{
|
||||
void ReplaceToOsSlashes_Remove_TailSlash(UString &name, bool
|
||||
#if WCHAR_PATH_SEPARATOR != L'/'
|
||||
name.Replace(kUnixPathSepar, kOsPathSepar);
|
||||
useBackslashReplacement
|
||||
#endif
|
||||
|
||||
if (name.Back() == kOsPathSepar)
|
||||
name.DeleteBack();
|
||||
)
|
||||
{
|
||||
if (name.IsEmpty())
|
||||
return;
|
||||
|
||||
#if WCHAR_PATH_SEPARATOR != L'/'
|
||||
{
|
||||
// name.Replace(kUnixPathSepar, kOsPathSepar);
|
||||
const unsigned len = name.Len();
|
||||
for (unsigned i = 0; i < len; i++)
|
||||
{
|
||||
wchar_t c = name[i];
|
||||
if (c == L'/')
|
||||
c = WCHAR_PATH_SEPARATOR;
|
||||
else if (useBackslashReplacement && c == L'\\')
|
||||
c = WCHAR_IN_FILE_NAME_BACKSLASH_REPLACEMENT; // WSL scheme
|
||||
else
|
||||
continue;
|
||||
name.ReplaceOneCharAtPos(i, c);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (name.Back() == kOsPathSepar)
|
||||
name.DeleteBack();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +87,15 @@ bool HasTailSlash(const AString &name, UINT
|
||||
{
|
||||
if (name.IsEmpty())
|
||||
return false;
|
||||
char c =
|
||||
char c;
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
*CharPrevExA((WORD)codePage, name, name.Ptr(name.Len()), 0);
|
||||
#else
|
||||
name.Back();
|
||||
if (codePage != CP_UTF8)
|
||||
c = *CharPrevExA((WORD)codePage, name, name.Ptr(name.Len()), 0);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = name.Back();
|
||||
}
|
||||
return (c == '/');
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ void ReplaceSlashes_OsToUnix(UString &name);
|
||||
UString GetOsPath(const UString &name);
|
||||
UString GetOsPath_Remove_TailSlash(const UString &name);
|
||||
|
||||
void ReplaceToOsSlashes_Remove_TailSlash(UString &name);
|
||||
void ReplaceToOsSlashes_Remove_TailSlash(UString &name, bool useBackslashReplacement = false);
|
||||
|
||||
bool HasTailSlash(const AString &name, UINT codePage);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ STDMETHODIMP CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
UInt64 localPos = _pos - s.GlobalOffset;
|
||||
if (localPos != s.LocalPos)
|
||||
{
|
||||
RINOK(s.Stream->Seek(localPos, STREAM_SEEK_SET, &s.LocalPos));
|
||||
RINOK(s.Stream->Seek((Int64)localPos, STREAM_SEEK_SET, &s.LocalPos));
|
||||
}
|
||||
UInt64 rem = s.Size - localPos;
|
||||
if (size > rem)
|
||||
@@ -60,9 +60,9 @@ STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosi
|
||||
}
|
||||
if (offset < 0)
|
||||
return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
|
||||
_pos = offset;
|
||||
_pos = (UInt64)offset;
|
||||
if (newPosition)
|
||||
*newPosition = offset;
|
||||
*newPosition = (UInt64)offset;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ STDMETHODIMP COutStreamWithSha1::Write(const void *data, UInt32 size, UInt32 *pr
|
||||
if (_stream)
|
||||
result = _stream->Write(data, size, &size);
|
||||
if (_calculate)
|
||||
Sha1_Update(&_sha, (const Byte *)data, size);
|
||||
Sha1_Update(Sha(), (const Byte *)data, size);
|
||||
_size += size;
|
||||
if (processedSize)
|
||||
*processedSize = size;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "../../../../C/Sha1.h"
|
||||
|
||||
#include "../../../Common/MyBuffer2.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
#include "../../IStream.h"
|
||||
@@ -15,10 +16,16 @@ class COutStreamWithSha1:
|
||||
{
|
||||
CMyComPtr<ISequentialOutStream> _stream;
|
||||
UInt64 _size;
|
||||
CSha1 _sha;
|
||||
// CSha1 _sha;
|
||||
bool _calculate;
|
||||
CAlignedBuffer _sha;
|
||||
|
||||
CSha1 *Sha() { return (CSha1 *)(void *)(Byte *)_sha; }
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
COutStreamWithSha1(): _sha(sizeof(CSha1)) {}
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
@@ -26,11 +33,11 @@ public:
|
||||
{
|
||||
_size = 0;
|
||||
_calculate = calculate;
|
||||
Sha1_Init(&_sha);
|
||||
Sha1_Init(Sha());
|
||||
}
|
||||
void InitSha1() { Sha1_Init(&_sha); }
|
||||
void InitSha1() { Sha1_Init(Sha()); }
|
||||
UInt64 GetSize() const { return _size; }
|
||||
void Final(Byte *digest) { Sha1_Final(&_sha, digest); }
|
||||
void Final(Byte *digest) { Sha1_Final(Sha(), digest); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user