mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 17:15:00 -06:00
23.01
This commit is contained in:
@@ -45,9 +45,8 @@ namespace NRar5 {
|
||||
|
||||
static const unsigned kMarkerSize = 8;
|
||||
|
||||
#define SIGNATURE { 0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0 }
|
||||
|
||||
static const Byte kMarker[kMarkerSize] = SIGNATURE;
|
||||
static const Byte kMarker[kMarkerSize] =
|
||||
{ 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0 };
|
||||
|
||||
static const size_t kCommentSize_Max = (size_t)1 << 16;
|
||||
|
||||
@@ -252,7 +251,7 @@ void CItem::PrintInfo(AString &s) const
|
||||
rem++;
|
||||
|
||||
s.Add_Space_if_NotEmpty();
|
||||
PrintType(s, g_ExtraTypes, ARRAY_SIZE(g_ExtraTypes), id);
|
||||
PrintType(s, g_ExtraTypes, Z7_ARRAY_SIZE(g_ExtraTypes), id);
|
||||
|
||||
if (id == NExtraID::kTime)
|
||||
{
|
||||
@@ -262,10 +261,10 @@ void CItem::PrintInfo(AString &s) const
|
||||
if (num != 0)
|
||||
{
|
||||
s += ':';
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(g_ExtraTimeFlags); i++)
|
||||
for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_ExtraTimeFlags); i++)
|
||||
if ((flags & ((UInt64)1 << i)) != 0)
|
||||
s += g_ExtraTimeFlags[i];
|
||||
flags &= ~(((UInt64)1 << ARRAY_SIZE(g_ExtraTimeFlags)) - 1);
|
||||
flags &= ~(((UInt64)1 << Z7_ARRAY_SIZE(g_ExtraTimeFlags)) - 1);
|
||||
if (flags != 0)
|
||||
{
|
||||
s += '_';
|
||||
@@ -279,7 +278,7 @@ void CItem::PrintInfo(AString &s) const
|
||||
if (linkInfo.Parse(Extra + offset, (unsigned)rem))
|
||||
{
|
||||
s += ':';
|
||||
PrintType(s, g_LinkTypes, ARRAY_SIZE(g_LinkTypes), linkInfo.Type);
|
||||
PrintType(s, g_LinkTypes, Z7_ARRAY_SIZE(g_LinkTypes), linkInfo.Type);
|
||||
UInt64 flags = linkInfo.Flags;
|
||||
if (flags != 0)
|
||||
{
|
||||
@@ -349,12 +348,12 @@ bool CItem::FindExtra_Version(UInt64 &version) const
|
||||
bool CItem::FindExtra_Link(CLinkInfo &link) const
|
||||
{
|
||||
unsigned size;
|
||||
int offset = FindExtra(NExtraID::kLink, size);
|
||||
const int offset = FindExtra(NExtraID::kLink, size);
|
||||
if (offset < 0)
|
||||
return false;
|
||||
if (!link.Parse(Extra + (unsigned)offset, size))
|
||||
return false;
|
||||
link.NameOffset += offset;
|
||||
link.NameOffset += (unsigned)offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -481,10 +480,10 @@ bool CHash::Check(const CItem &item, NCrypto::NRar5::CDecoder *cryptoDecoderSpec
|
||||
}
|
||||
|
||||
|
||||
class COutStreamWithHash:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_NOQIB_1(
|
||||
COutStreamWithHash
|
||||
, ISequentialOutStream
|
||||
)
|
||||
ISequentialOutStream *_stream;
|
||||
UInt64 _pos;
|
||||
UInt64 _size;
|
||||
@@ -495,8 +494,6 @@ public:
|
||||
|
||||
COutStreamWithHash(): _destBuf(NULL) {}
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
|
||||
void Init(const CItem &item, Byte *destBuf)
|
||||
{
|
||||
@@ -516,7 +513,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
STDMETHODIMP COutStreamWithHash::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(COutStreamWithHash::Write(const void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
HRESULT result = S_OK;
|
||||
if (_size_Defined)
|
||||
@@ -550,7 +547,7 @@ class CInArchive
|
||||
NCrypto::NRar5::CDecoder *m_CryptoDecoderSpec;
|
||||
CMyComPtr<ICompressFilter> m_CryptoDecoder;
|
||||
|
||||
CLASS_NO_COPY(CInArchive)
|
||||
Z7_CLASS_NO_COPY(CInArchive)
|
||||
|
||||
HRESULT ReadStream_Check(void *data, size_t size);
|
||||
|
||||
@@ -591,7 +588,7 @@ public:
|
||||
static HRESULT MySetPassword(ICryptoGetTextPassword *getTextPassword, NCrypto::NRar5::CDecoder *cryptoDecoderSpec)
|
||||
{
|
||||
CMyComBSTR_Wipe password;
|
||||
RINOK(getTextPassword->CryptoGetTextPassword(&password));
|
||||
RINOK(getTextPassword->CryptoGetTextPassword(&password))
|
||||
AString_Wipe utf8;
|
||||
const unsigned kPasswordLen_MAX = 127;
|
||||
UString_Wipe unicode;
|
||||
@@ -615,7 +612,7 @@ bool CInArchive::ReadVar(UInt64 &val)
|
||||
HRESULT CInArchive::ReadStream_Check(void *data, size_t size)
|
||||
{
|
||||
size_t size2 = size;
|
||||
RINOK(ReadStream(_stream, data, &size2));
|
||||
RINOK(ReadStream(_stream, data, &size2))
|
||||
if (size2 == size)
|
||||
return S_OK;
|
||||
UnexpectedEnd = true;
|
||||
@@ -637,23 +634,23 @@ HRESULT CInArchive::ReadBlockHeader(CHeader &h)
|
||||
|
||||
if (m_CryptoMode)
|
||||
{
|
||||
RINOK(ReadStream_Check(buf, kBufSize));
|
||||
RINOK(ReadStream_Check(buf, kBufSize))
|
||||
memcpy(m_CryptoDecoderSpec->_iv, buf, AES_BLOCK_SIZE);
|
||||
RINOK(m_CryptoDecoderSpec->Init());
|
||||
RINOK(m_CryptoDecoderSpec->Init())
|
||||
|
||||
_buf.AllocAtLeast(1 << 12);
|
||||
if (!(Byte *)_buf)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
memcpy(_buf, buf + AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
if (m_CryptoDecoderSpec->Filter(_buf, AES_BLOCK_SIZE) != AES_BLOCK_SIZE)
|
||||
if (m_CryptoDecoder->Filter(_buf, AES_BLOCK_SIZE) != AES_BLOCK_SIZE)
|
||||
return E_FAIL;
|
||||
memcpy(buf, _buf, AES_BLOCK_SIZE);
|
||||
filled = AES_BLOCK_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(ReadStream_Check(buf, kStartSize));
|
||||
RINOK(ReadStream_Check(buf, kStartSize))
|
||||
filled = kStartSize;
|
||||
}
|
||||
|
||||
@@ -680,10 +677,10 @@ HRESULT CInArchive::ReadBlockHeader(CHeader &h)
|
||||
|
||||
size_t rem = allocSize - filled;
|
||||
AddToSeekValue(allocSize + (m_CryptoMode ? AES_BLOCK_SIZE : 0));
|
||||
RINOK(ReadStream_Check(_buf + filled, rem));
|
||||
RINOK(ReadStream_Check(_buf + filled, rem))
|
||||
if (m_CryptoMode)
|
||||
{
|
||||
if (m_CryptoDecoderSpec->Filter(_buf + filled, (UInt32)rem) != rem)
|
||||
if (m_CryptoDecoder->Filter(_buf + filled, (UInt32)rem) != rem)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
@@ -804,19 +801,19 @@ HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit,
|
||||
UInt64 arcStartPos = StreamStartPosition;
|
||||
{
|
||||
Byte marker[kMarkerSize];
|
||||
RINOK(ReadStream_FALSE(stream, marker, kMarkerSize));
|
||||
RINOK(ReadStream_FALSE(stream, marker, kMarkerSize))
|
||||
if (memcmp(marker, kMarker, kMarkerSize) == 0)
|
||||
Position += kMarkerSize;
|
||||
else
|
||||
{
|
||||
if (searchHeaderSizeLimit && *searchHeaderSizeLimit == 0)
|
||||
return S_FALSE;
|
||||
RINOK(stream->Seek(StreamStartPosition, STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(stream, StreamStartPosition))
|
||||
RINOK(FindSignatureInStream(stream, kMarker, kMarkerSize,
|
||||
searchHeaderSizeLimit, arcStartPos));
|
||||
searchHeaderSizeLimit, arcStartPos))
|
||||
arcStartPos += StreamStartPosition;
|
||||
Position = arcStartPos + kMarkerSize;
|
||||
RINOK(stream->Seek(Position, STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(stream, Position))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,7 +821,7 @@ HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit,
|
||||
_stream = stream;
|
||||
|
||||
CHeader h;
|
||||
RINOK(ReadBlockHeader(h));
|
||||
RINOK(ReadBlockHeader(h))
|
||||
info.IsEncrypted = false;
|
||||
|
||||
if (h.Type == NHeaderType::kArcEncrypt)
|
||||
@@ -843,9 +840,9 @@ HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit,
|
||||
}
|
||||
|
||||
RINOK(m_CryptoDecoderSpec->SetDecoderProps(
|
||||
_buf + _bufPos, (unsigned)(_bufSize - _bufPos), false, false));
|
||||
_buf + _bufPos, (unsigned)(_bufSize - _bufPos), false, false))
|
||||
|
||||
RINOK(MySetPassword(getTextPassword, m_CryptoDecoderSpec));
|
||||
RINOK(MySetPassword(getTextPassword, m_CryptoDecoderSpec))
|
||||
|
||||
if (!m_CryptoDecoderSpec->CalcKey_and_CheckPassword())
|
||||
{
|
||||
@@ -853,7 +850,7 @@ HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit,
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
RINOK(ReadBlockHeader(h));
|
||||
RINOK(ReadBlockHeader(h))
|
||||
}
|
||||
|
||||
if (h.Type != NHeaderType::kArc)
|
||||
@@ -1052,16 +1049,16 @@ HRESULT CUnpacker::Create(DECL_EXTERNAL_CODECS_LOC_VARS const CItem &item, bool
|
||||
if (!lzCoder)
|
||||
{
|
||||
const UInt32 methodID = 0x40305;
|
||||
RINOK(CreateCoder_Id(EXTERNAL_CODECS_LOC_VARS methodID, false, lzCoder));
|
||||
RINOK(CreateCoder_Id(EXTERNAL_CODECS_LOC_VARS methodID, false, lzCoder))
|
||||
if (!lzCoder)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
CMyComPtr<ICompressSetDecoderProperties2> csdp;
|
||||
RINOK(lzCoder.QueryInterface(IID_ICompressSetDecoderProperties2, &csdp));
|
||||
RINOK(lzCoder.QueryInterface(IID_ICompressSetDecoderProperties2, &csdp))
|
||||
|
||||
Byte props[2] = { (Byte)(item.GetDictSize()), (Byte)(isSolid ? 1 : 0) };
|
||||
RINOK(csdp->SetDecoderProperties2(props, 2));
|
||||
RINOK(csdp->SetDecoderProperties2(props, 2))
|
||||
}
|
||||
|
||||
unsigned cryptoSize = 0;
|
||||
@@ -1081,7 +1078,7 @@ HRESULT CUnpacker::Create(DECL_EXTERNAL_CODECS_LOC_VARS const CItem &item, bool
|
||||
cryptoDecoder = cryptoDecoderSpec;
|
||||
}
|
||||
|
||||
RINOK(cryptoDecoderSpec->SetDecoderProps(item.Extra + (unsigned)cryptoOffset, cryptoSize, true, item.IsService()));
|
||||
RINOK(cryptoDecoderSpec->SetDecoderProps(item.Extra + (unsigned)cryptoOffset, cryptoSize, true, item.IsService()))
|
||||
|
||||
if (!getTextPassword)
|
||||
{
|
||||
@@ -1089,7 +1086,7 @@ HRESULT CUnpacker::Create(DECL_EXTERNAL_CODECS_LOC_VARS const CItem &item, bool
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
RINOK(MySetPassword(getTextPassword, cryptoDecoderSpec));
|
||||
RINOK(MySetPassword(getTextPassword, cryptoDecoderSpec))
|
||||
|
||||
if (!cryptoDecoderSpec->CalcKey_and_CheckPassword())
|
||||
wrongPassword = True;
|
||||
@@ -1273,7 +1270,7 @@ HRESULT CTempBuf::Decode(DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
_buf.ChangeSize_KeepData(newSize, _offset);
|
||||
|
||||
Byte *data = (Byte *)_buf + _offset;
|
||||
RINOK(ReadStream_FALSE(inStream, data, packSize));
|
||||
RINOK(ReadStream_FALSE(inStream, data, packSize))
|
||||
|
||||
_offset += packSize;
|
||||
|
||||
@@ -1293,7 +1290,7 @@ HRESULT CTempBuf::Decode(DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
if (_offset == 0)
|
||||
{
|
||||
RINOK(unpacker.DecodeToBuf(EXTERNAL_CODECS_LOC_VARS
|
||||
item, item.PackSize, inStream, destBuf));
|
||||
item, item.PackSize, inStream, destBuf))
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1301,7 +1298,7 @@ HRESULT CTempBuf::Decode(DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMyComPtr<ISequentialInStream> bufInStream = bufInStreamSpec;
|
||||
bufInStreamSpec->Init(_buf, _offset);
|
||||
RINOK(unpacker.DecodeToBuf(EXTERNAL_CODECS_LOC_VARS
|
||||
item, _offset, bufInStream, destBuf));
|
||||
item, _offset, bufInStream, destBuf))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1367,12 +1364,12 @@ UInt64 CHandler::GetPackSize(unsigned refIndex) const
|
||||
size += item.PackSize;
|
||||
if (item.NextItem < 0)
|
||||
return size;
|
||||
index = item.NextItem;
|
||||
index = (unsigned)item.NextItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
@@ -1501,7 +1498,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
Z7_COM7F_IMF(CHandler::GetNumberOfItems(UInt32 *numItems))
|
||||
{
|
||||
*numItems = _refs.Size();
|
||||
return S_OK;
|
||||
@@ -1515,20 +1512,20 @@ static const Byte kRawProps[] =
|
||||
};
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetNumRawProps(UInt32 *numProps)
|
||||
Z7_COM7F_IMF(CHandler::GetNumRawProps(UInt32 *numProps))
|
||||
{
|
||||
*numProps = ARRAY_SIZE(kRawProps);
|
||||
*numProps = Z7_ARRAY_SIZE(kRawProps);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID)
|
||||
Z7_COM7F_IMF(CHandler::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID))
|
||||
{
|
||||
*propID = kRawProps[index];
|
||||
*name = 0;
|
||||
*name = NULL;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentType)
|
||||
Z7_COM7F_IMF(CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentType))
|
||||
{
|
||||
*parentType = NParentType::kDir;
|
||||
*parent = (UInt32)(Int32)-1;
|
||||
@@ -1549,7 +1546,7 @@ STDMETHODIMP CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentTyp
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)
|
||||
Z7_COM7F_IMF(CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType))
|
||||
{
|
||||
*data = NULL;
|
||||
*dataSize = 0;
|
||||
@@ -1660,7 +1657,7 @@ static void TimeRecordToProp(const CItem &item, unsigned stampIndex, NCOM::CProp
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
@@ -1680,7 +1677,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
AString s;
|
||||
if (ref.Parent >= 0)
|
||||
{
|
||||
CItem &mainItem = _items[_refs[ref.Parent].Item];
|
||||
const CItem &mainItem = _items[_refs[ref.Parent].Item];
|
||||
s = mainItem.Name;
|
||||
}
|
||||
|
||||
@@ -1856,7 +1853,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
|
||||
if (flags != 0)
|
||||
{
|
||||
AString s2 = FlagsToString(k_FileFlags, ARRAY_SIZE(k_FileFlags), flags);
|
||||
AString s2 = FlagsToString(k_FileFlags, Z7_ARRAY_SIZE(k_FileFlags), flags);
|
||||
if (!s2.IsEmpty())
|
||||
{
|
||||
s.Add_OptSpaced(s2);
|
||||
@@ -1872,7 +1869,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
|
||||
|
||||
case kpidHostOS:
|
||||
if (item.HostOS < ARRAY_SIZE(kHostOS))
|
||||
if (item.HostOS < Z7_ARRAY_SIZE(kHostOS))
|
||||
prop = kHostOS[(size_t)item.HostOS];
|
||||
else
|
||||
prop = (UInt64)item.HostOS;
|
||||
@@ -1933,24 +1930,24 @@ static int FindLink(const CHandler &handler, const CUIntVector &sorted,
|
||||
{
|
||||
if (left > 0)
|
||||
{
|
||||
unsigned refIndex = sorted[left - 1];
|
||||
const unsigned refIndex = sorted[left - 1];
|
||||
if (CompareItemsPaths(handler, index, refIndex, &s) == 0)
|
||||
return refIndex;
|
||||
return (int)refIndex;
|
||||
}
|
||||
if (right < sorted.Size())
|
||||
{
|
||||
unsigned refIndex = sorted[right];
|
||||
const unsigned refIndex = sorted[right];
|
||||
if (CompareItemsPaths(handler, index, refIndex, &s) == 0)
|
||||
return refIndex;
|
||||
return (int)refIndex;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned mid = (left + right) / 2;
|
||||
unsigned refIndex = sorted[mid];
|
||||
int compare = CompareItemsPaths2(handler, index, refIndex, &s);
|
||||
const unsigned mid = (left + right) / 2;
|
||||
const unsigned refIndex = sorted[mid];
|
||||
const int compare = CompareItemsPaths2(handler, index, refIndex, &s);
|
||||
if (compare == 0)
|
||||
return refIndex;
|
||||
return (int)refIndex;
|
||||
if (compare < 0)
|
||||
right = mid;
|
||||
else
|
||||
@@ -2062,7 +2059,7 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
UString baseName;
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
|
||||
RINOK(openVolumeCallback->GetProperty(kpidName, &prop))
|
||||
if (prop.vt != VT_BSTR)
|
||||
break;
|
||||
baseName = prop.bstrVal;
|
||||
@@ -2087,14 +2084,12 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
}
|
||||
|
||||
UInt64 endPos = 0;
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &arch.StreamStartPosition));
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos));
|
||||
RINOK(inStream->Seek(arch.StreamStartPosition, STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_GetPos_GetSize(inStream, arch.StreamStartPosition, endPos))
|
||||
|
||||
if (openCallback)
|
||||
{
|
||||
totalBytes += endPos;
|
||||
RINOK(openCallback->SetTotal(NULL, &totalBytes));
|
||||
RINOK(openCallback->SetTotal(NULL, &totalBytes))
|
||||
}
|
||||
|
||||
CInArcInfo arcInfoOpen;
|
||||
@@ -2136,7 +2131,7 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
break;
|
||||
}
|
||||
|
||||
RINOK(inStream->Seek(arch.Position, STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(inStream, arch.Position))
|
||||
|
||||
{
|
||||
CInArchive::CHeader h;
|
||||
@@ -2168,11 +2163,11 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
{
|
||||
// for multivolume archives RAR can add ZERO bytes at the end for alignment.
|
||||
// We must skip these bytes to prevent phySize warning.
|
||||
RINOK(inStream->Seek(arcInfo.EndPos, STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(inStream, arcInfo.EndPos))
|
||||
bool areThereNonZeros;
|
||||
UInt64 numZeros;
|
||||
const UInt64 maxSize = 1 << 12;
|
||||
RINOK(ReadZeroTail(inStream, areThereNonZeros, numZeros, maxSize));
|
||||
RINOK(ReadZeroTail(inStream, areThereNonZeros, numZeros, maxSize))
|
||||
if (!areThereNonZeros && numZeros != 0 && numZeros <= maxSize)
|
||||
arcInfo.EndPos += numZeros;
|
||||
}
|
||||
@@ -2226,7 +2221,7 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
&& item.GetMethod() == 0
|
||||
&& !item.IsSplit())
|
||||
{
|
||||
RINOK(unpacker.DecodeToBuf(EXTERNAL_CODECS_VARS item, item.PackSize, inStream, _comment));
|
||||
RINOK(unpacker.DecodeToBuf(EXTERNAL_CODECS_VARS item, item.PackSize, inStream, _comment))
|
||||
needAdd = false;
|
||||
}
|
||||
}
|
||||
@@ -2273,7 +2268,7 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
{
|
||||
if (_acls.IsEmpty() || acl != _acls.Back())
|
||||
_acls.Add(acl);
|
||||
mainItem.ACL = _acls.Size() - 1;
|
||||
mainItem.ACL = (int)_acls.Size() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2292,7 +2287,7 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
if (item.IsNextForItem(prevItem))
|
||||
{
|
||||
ref2.Last = _items.Size();
|
||||
prevItem.NextItem = ref2.Last;
|
||||
prevItem.NextItem = (int)ref2.Last;
|
||||
needAdd = false;
|
||||
}
|
||||
}
|
||||
@@ -2302,9 +2297,9 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
if (needAdd)
|
||||
{
|
||||
if (item.IsSplitAfter())
|
||||
prevSplitFile = _refs.Size();
|
||||
prevSplitFile = (int)_refs.Size();
|
||||
if (!item.IsService())
|
||||
prevMainFile = _refs.Size();
|
||||
prevMainFile = (int)_refs.Size();
|
||||
_refs.Add(ref);
|
||||
}
|
||||
}
|
||||
@@ -2325,7 +2320,7 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
{
|
||||
UInt64 numFiles = _items.Size();
|
||||
UInt64 numBytes = curBytes + item.DataPos;
|
||||
RINOK(openCallback->SetCompleted(&numFiles, &numBytes));
|
||||
RINOK(openCallback->SetCompleted(&numFiles, &numBytes))
|
||||
}
|
||||
|
||||
if (!isOk_packSize)
|
||||
@@ -2353,9 +2348,9 @@ HRESULT CHandler::Open2(IInStream *stream,
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
Z7_COM7F_IMF(CHandler::Open(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
IArchiveOpenCallback *openCallback)
|
||||
IArchiveOpenCallback *openCallback))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
Close();
|
||||
@@ -2363,7 +2358,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
Z7_COM7F_IMF(CHandler::Close())
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
_missingVolName.Empty();
|
||||
@@ -2380,10 +2375,10 @@ STDMETHODIMP CHandler::Close()
|
||||
}
|
||||
|
||||
|
||||
class CVolsInStream:
|
||||
public ISequentialInStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_NOQIB_1(
|
||||
CVolsInStream
|
||||
, ISequentialInStream
|
||||
)
|
||||
UInt64 _rem;
|
||||
ISequentialInStream *_stream;
|
||||
const CObjectVector<CArc> *_arcs;
|
||||
@@ -2394,22 +2389,19 @@ public:
|
||||
private:
|
||||
CHash _hash;
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
void Init(const CObjectVector<CArc> *arcs,
|
||||
const CObjectVector<CItem> *items,
|
||||
unsigned itemIndex)
|
||||
{
|
||||
_arcs = arcs;
|
||||
_items = items;
|
||||
_itemIndex = itemIndex;
|
||||
_itemIndex = (int)itemIndex;
|
||||
_stream = NULL;
|
||||
CrcIsOK = true;
|
||||
}
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
|
||||
STDMETHODIMP CVolsInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CVolsInStream::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
@@ -2423,7 +2415,7 @@ STDMETHODIMP CVolsInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
break;
|
||||
const CItem &item = (*_items)[_itemIndex];
|
||||
IInStream *s = (*_arcs)[item.VolIndex].Stream;
|
||||
RINOK(s->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(s, item.GetDataPosition()))
|
||||
_stream = s;
|
||||
if (CrcIsOK && item.IsSplitAfter())
|
||||
_hash.Init(item);
|
||||
@@ -2472,10 +2464,10 @@ static int FindLinkBuf(CObjectVector<CLinkFile> &linkFiles, unsigned index)
|
||||
{
|
||||
if (left == right)
|
||||
return -1;
|
||||
unsigned mid = (left + right) / 2;
|
||||
unsigned linkIndex = linkFiles[mid].Index;
|
||||
const unsigned mid = (left + right) / 2;
|
||||
const unsigned linkIndex = linkFiles[mid].Index;
|
||||
if (index == linkIndex)
|
||||
return mid;
|
||||
return (int)mid;
|
||||
if (index < linkIndex)
|
||||
right = mid;
|
||||
else
|
||||
@@ -2512,14 +2504,14 @@ static HRESULT CopyData_with_Progress(const Byte *data, size_t size,
|
||||
cur = kStepSize;
|
||||
cur32 = (UInt32)cur;
|
||||
}
|
||||
RINOK(outStream->Write(data + pos, cur32, &cur32));
|
||||
RINOK(outStream->Write(data + pos, cur32, &cur32))
|
||||
if (cur32 == 0)
|
||||
return E_FAIL;
|
||||
pos += cur32;
|
||||
if (progress)
|
||||
{
|
||||
UInt64 pos64 = pos;
|
||||
RINOK(progress->SetRatioInfo(&pos64, &pos64));
|
||||
RINOK(progress->SetRatioInfo(&pos64, &pos64))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2527,12 +2519,11 @@ static HRESULT CopyData_with_Progress(const Byte *data, size_t size,
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
Int32 testMode, IArchiveExtractCallback *extractCallback)
|
||||
Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
Int32 testMode, IArchiveExtractCallback *extractCallback))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
bool allFilesMode = (numItems == (UInt32)(Int32)-1);
|
||||
const bool allFilesMode = (numItems == (UInt32)(Int32)-1);
|
||||
if (allFilesMode)
|
||||
numItems = _refs.Size();
|
||||
if (numItems == 0)
|
||||
@@ -2706,7 +2697,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
const CItem &linkItem = _items[_refs[(unsigned)linkIndex].Item];
|
||||
if (!linkItem.IsSolid() || linkItem.Size > k_CopyLinkFile_MaxSize)
|
||||
continue;
|
||||
int bufIndex = FindLinkBuf(linkFiles, linkIndex);
|
||||
const int bufIndex = FindLinkBuf(linkFiles, (unsigned)linkIndex);
|
||||
if (bufIndex < 0)
|
||||
return E_FAIL;
|
||||
linkFiles[bufIndex].NumLinks++;
|
||||
@@ -2715,7 +2706,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
if (total != 0 || !isThereUndefinedSize)
|
||||
{
|
||||
RINOK(extractCallback->SetTotal(total));
|
||||
RINOK(extractCallback->SetTotal(total))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2745,7 +2736,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
totalPacked += curPackSize;
|
||||
lps->InSize = totalPacked;
|
||||
lps->OutSize = totalUnpacked;
|
||||
RINOK(lps->SetCur());
|
||||
RINOK(lps->SetCur())
|
||||
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
|
||||
@@ -2781,7 +2772,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
curPackSize = GetPackSize(index);
|
||||
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode))
|
||||
|
||||
bool isSolid = false;
|
||||
if (!item->IsService())
|
||||
@@ -2793,8 +2784,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
if (item->IsDir())
|
||||
{
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
|
||||
RINOK(extractCallback->PrepareOperation(askMode))
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK))
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2815,12 +2806,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
curUnpackSize = lastItem2.Size;
|
||||
else
|
||||
curUnpackSize = 0;
|
||||
curPackSize = GetPackSize(index2);
|
||||
curPackSize = GetPackSize((unsigned)index2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned)index2 < index)
|
||||
bufIndex = FindLinkBuf(linkFiles, index2);
|
||||
bufIndex = FindLinkBuf(linkFiles, (unsigned)index2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2839,8 +2830,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
opRes = DecoderRes_to_OpRes(linkFile.Res, linkFile.crcOK);
|
||||
}
|
||||
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
RINOK(extractCallback->SetOperationResult(opRes));
|
||||
RINOK(extractCallback->PrepareOperation(askMode))
|
||||
RINOK(extractCallback->SetOperationResult(opRes))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -2874,7 +2865,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
if (needCallback)
|
||||
{
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
RINOK(extractCallback->PrepareOperation(askMode))
|
||||
}
|
||||
|
||||
if (bufIndex >= 0)
|
||||
@@ -2889,7 +2880,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
if (needCallback)
|
||||
if (realOutStream)
|
||||
{
|
||||
RINOK(CopyData_with_Progress(linkFile.Data, linkFile.Data.Size(), realOutStream, progress));
|
||||
RINOK(CopyData_with_Progress(linkFile.Data, linkFile.Data.Size(), realOutStream, progress))
|
||||
}
|
||||
|
||||
if (--linkFile.NumLinks == 0)
|
||||
@@ -2898,7 +2889,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
if (needCallback)
|
||||
{
|
||||
RINOK(extractCallback->SetOperationResult(DecoderRes_to_OpRes(linkFile.Res, linkFile.crcOK)));
|
||||
RINOK(extractCallback->SetOperationResult(DecoderRes_to_OpRes(linkFile.Res, linkFile.crcOK)))
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -2912,7 +2903,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
NExtract::NOperationResult::kUnsupportedMethod:
|
||||
NExtract::NOperationResult::kOK;
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(opRes));
|
||||
RINOK(extractCallback->SetOperationResult(opRes))
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2930,7 +2921,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
if (wrongPassword)
|
||||
{
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kWrongPassword));
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kWrongPassword))
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2955,7 +2946,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
return result;
|
||||
}
|
||||
|
||||
RINOK(extractCallback->SetOperationResult(opRes));
|
||||
RINOK(extractCallback->SetOperationResult(opRes))
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2973,7 +2964,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
IMPL_ISetCompressCodecsInfo
|
||||
|
||||
REGISTER_ARC_I(
|
||||
"Rar5", "rar r00", 0, 0xCC,
|
||||
"Rar5", "rar r00", NULL, 0xCC,
|
||||
kMarker,
|
||||
0,
|
||||
NArcInfoFlags::kFindSignature,
|
||||
@@ -2982,31 +2973,27 @@ REGISTER_ARC_I(
|
||||
}}
|
||||
|
||||
|
||||
class CBlake2spHasher:
|
||||
public IHasher,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CBlake2spHasher
|
||||
, IHasher
|
||||
)
|
||||
CBlake2sp _blake;
|
||||
Byte mtDummy[1 << 7];
|
||||
|
||||
public:
|
||||
Byte _mtDummy[1 << 7]; // it's public to eliminate clang warning: unused private field
|
||||
CBlake2spHasher() { Init(); }
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
INTERFACE_IHasher(;)
|
||||
};
|
||||
|
||||
STDMETHODIMP_(void) CBlake2spHasher::Init() throw()
|
||||
Z7_COM7F_IMF2(void, CBlake2spHasher::Init())
|
||||
{
|
||||
Blake2sp_Init(&_blake);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(void) CBlake2spHasher::Update(const void *data, UInt32 size) throw()
|
||||
Z7_COM7F_IMF2(void, CBlake2spHasher::Update(const void *data, UInt32 size))
|
||||
{
|
||||
Blake2sp_Update(&_blake, (const Byte *)data, size);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(void) CBlake2spHasher::Final(Byte *digest) throw()
|
||||
Z7_COM7F_IMF2(void, CBlake2spHasher::Final(Byte *digest))
|
||||
{
|
||||
Blake2sp_Final(&_blake, digest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user