This commit is contained in:
Igor Pavlov
2023-12-22 17:17:05 +00:00
committed by Kornel
parent ec44a8a070
commit a36c48cece
954 changed files with 42199 additions and 25482 deletions

View File

@@ -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);
}

View File

@@ -1,7 +1,7 @@
// Rar5Handler.h
#ifndef __RAR5_HANDLER_H
#define __RAR5_HANDLER_H
#ifndef ZIP7_INC_RAR5_HANDLER_H
#define ZIP7_INC_RAR5_HANDLER_H
#include "../../../../C/Blake2.h"
@@ -374,12 +374,22 @@ struct CArc
};
class CHandler:
class CHandler Z7_final:
public IInArchive,
public IArchiveGetRawProps,
PUBLIC_ISetCompressCodecsInfo
Z7_PUBLIC_ISetCompressCodecsInfo_IFEC
public CMyUnknownImp
{
Z7_COM_QI_BEGIN2(IInArchive)
Z7_COM_QI_ENTRY(IArchiveGetRawProps)
Z7_COM_QI_ENTRY_ISetCompressCodecsInfo_IFEC
Z7_COM_QI_END
Z7_COM_ADDREF_RELEASE
Z7_IFACE_COM7_IMP(IInArchive)
Z7_IFACE_COM7_IMP(IArchiveGetRawProps)
DECL_ISetCompressCodecsInfo
public:
CRecordVector<CRefItem> _refs;
CObjectVector<CItem> _items;
@@ -402,18 +412,6 @@ private:
HRESULT Open2(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openCallback);
public:
MY_QUERYINTERFACE_BEGIN2(IInArchive)
MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps)
QUERY_ENTRY_ISetCompressCodecsInfo
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
INTERFACE_IInArchive(;)
INTERFACE_IArchiveGetRawProps(;)
DECL_ISetCompressCodecsInfo
};
}}

View File

@@ -44,9 +44,8 @@ using namespace NWindows;
namespace NArchive {
namespace NRar {
#define SIGNATURE { 0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 }
static const Byte kMarker[NHeader::kMarkerSize] = SIGNATURE;
static const Byte kMarker[NHeader::kMarkerSize] =
{ 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
const unsigned kPasswordLen_MAX = 127;
@@ -184,35 +183,33 @@ HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
HeaderErrorWarning = false;
m_CryptoMode = false;
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition));
RINOK(stream->Seek(0, STREAM_SEEK_END, &ArcInfo.FileSize));
RINOK(stream->Seek(m_StreamStartPosition, STREAM_SEEK_SET, NULL));
RINOK(InStream_GetPos_GetSize(stream, m_StreamStartPosition, ArcInfo.FileSize))
m_Position = m_StreamStartPosition;
UInt64 arcStartPos = m_StreamStartPosition;
{
Byte marker[NHeader::kMarkerSize];
RINOK(ReadStream_FALSE(stream, marker, NHeader::kMarkerSize));
RINOK(ReadStream_FALSE(stream, marker, NHeader::kMarkerSize))
if (memcmp(marker, kMarker, NHeader::kMarkerSize) == 0)
m_Position += NHeader::kMarkerSize;
else
{
if (searchHeaderSizeLimit && *searchHeaderSizeLimit == 0)
return S_FALSE;
RINOK(stream->Seek(m_StreamStartPosition, STREAM_SEEK_SET, NULL));
RINOK(InStream_SeekSet(stream, m_StreamStartPosition))
RINOK(FindSignatureInStream(stream, kMarker, NHeader::kMarkerSize,
searchHeaderSizeLimit, arcStartPos));
searchHeaderSizeLimit, arcStartPos))
m_Position = arcStartPos + NHeader::kMarkerSize;
RINOK(stream->Seek(m_Position, STREAM_SEEK_SET, NULL));
RINOK(InStream_SeekSet(stream, m_Position))
}
}
Byte buf[NHeader::NArchive::kArchiveHeaderSize + 1];
RINOK(ReadStream_FALSE(stream, buf, NHeader::NArchive::kArchiveHeaderSize));
RINOK(ReadStream_FALSE(stream, buf, NHeader::NArchive::kArchiveHeaderSize))
AddToSeekValue(NHeader::NArchive::kArchiveHeaderSize);
UInt32 blockSize = Get16(buf + 5);
const UInt32 blockSize = Get16(buf + 5);
ArcInfo.EncryptVersion = 0;
ArcInfo.Flags = Get16(buf + 3);
@@ -238,7 +235,7 @@ HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
size_t commentSize = blockSize - headerSize;
_comment.Alloc(commentSize);
RINOK(ReadStream_FALSE(stream, _comment, commentSize));
RINOK(ReadStream_FALSE(stream, _comment, commentSize))
AddToSeekValue(commentSize);
m_Stream = stream;
ArcInfo.StartPos = arcStartPos;
@@ -368,7 +365,7 @@ static int ReadTime(const Byte *p, unsigned size, Byte mask, CRarTime &rarTime)
return -1;
for (unsigned i = 0; i < numDigits; i++)
rarTime.SubTime[3 - numDigits + i] = p[i];
return numDigits;
return (int)numDigits;
}
#define READ_TIME(_mask_, _ttt_) \
@@ -480,10 +477,10 @@ bool CInArchive::ReadHeaderReal(const Byte *p, unsigned size, CItem &item)
Byte cMask = (Byte)(b & 0xF);
if ((mMask & 8) != 0)
{
READ_TIME(mMask, item.MTime);
READ_TIME(mMask, item.MTime)
}
READ_TIME_2(cMask, item.CTimeDefined, item.CTime);
READ_TIME_2(aMask, item.ATimeDefined, item.ATime);
READ_TIME_2(cMask, item.CTimeDefined, item.CTime)
READ_TIME_2(aMask, item.ATimeDefined, item.ATime)
}
unsigned fileHeaderWithNameSize = 7 + (unsigned)(p - pStart);
@@ -508,13 +505,13 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
error = k_ErrorType_OK;
for (;;)
{
m_Stream->Seek(m_Position, STREAM_SEEK_SET, NULL);
RINOK(InStream_SeekSet(m_Stream, m_Position))
ArcInfo.EndPos = m_Position;
if (!m_CryptoMode && (ArcInfo.Flags &
NHeader::NArchive::kBlockHeadersAreEncrypted) != 0)
{
m_CryptoMode = false;
if (getTextPassword == 0)
if (!getTextPassword)
{
error = k_ErrorType_DecryptionError;
return S_OK; // return S_FALSE;
@@ -565,9 +562,9 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
if (!m_DecryptedDataAligned.IsAllocated())
return E_OUTOFMEMORY;
}
RINOK(m_RarAES->Init());
RINOK(m_RarAES->Init())
size_t decryptedDataSizeT = kDecryptedBufferSize;
RINOK(ReadStream(m_Stream, m_DecryptedDataAligned, &decryptedDataSizeT));
RINOK(ReadStream(m_Stream, m_DecryptedDataAligned, &decryptedDataSizeT))
m_DecryptedDataSize = (UInt32)decryptedDataSizeT;
m_DecryptedDataSize = m_RarAES->Filter(m_DecryptedDataAligned, m_DecryptedDataSize);
@@ -577,7 +574,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
m_FileHeaderData.AllocAtLeast(7);
size_t processed = 7;
RINOK(ReadBytesSpec((Byte *)m_FileHeaderData, &processed));
RINOK(ReadBytesSpec((Byte *)m_FileHeaderData, &processed))
if (processed != 7)
{
if (processed != 0)
@@ -715,7 +712,7 @@ HRESULT CInArchive::GetNextItem(CItem &item, ICryptoGetTextPassword *getTextPass
FinishCryptoBlock();
m_CryptoMode = false;
// Move Position to compressed Data;
m_Stream->Seek(m_Position, STREAM_SEEK_SET, NULL);
RINOK(InStream_SeekSet(m_Stream, m_Position))
AddToSeekValue(item.PackSize); // m_Position points to next header;
// if (okItem)
return S_OK;
@@ -828,7 +825,7 @@ bool CHandler::IsSolid(unsigned refIndex) const
return item.IsSolid();
}
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value))
{
COM_TRY_BEGIN
NCOM::CPropVariant prop;
@@ -838,7 +835,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
case kpidSolid: prop = _arcInfo.IsSolid(); break;
case kpidCharacts:
{
AString s (FlagsToString(k_Flags, ARRAY_SIZE(k_Flags), _arcInfo.Flags));
AString s (FlagsToString(k_Flags, Z7_ARRAY_SIZE(k_Flags), _arcInfo.Flags));
// FLAGS_TO_PROP(k_Flags, _arcInfo.Flags, prop);
if (_arcInfo.Is_DataCRC_Defined())
{
@@ -935,7 +932,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
COM_TRY_END
}
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
Z7_COM7F_IMF(CHandler::GetNumberOfItems(UInt32 *numItems))
{
*numItems = _refItems.Size();
return S_OK;
@@ -969,7 +966,7 @@ static void RarTimeToProp(const CRarTime &rarTime, NCOM::CPropVariant &prop)
*/
}
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
{
COM_TRY_BEGIN
NCOM::CPropVariant prop;
@@ -1087,7 +1084,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;
@@ -1119,16 +1116,15 @@ HRESULT CHandler::Open2(IInStream *stream,
else
inStream = stream;
UInt64 endPos = 0;
RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos));
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
UInt64 endPos;
RINOK(InStream_AtBegin_GetSize(inStream, endPos))
if (openCallback)
{
totalBytes += endPos;
RINOK(openCallback->SetTotal(NULL, &totalBytes));
RINOK(openCallback->SetTotal(NULL, &totalBytes))
}
RINOK(archive.Open(inStream, maxCheckStartPosition));
RINOK(archive.Open(inStream, maxCheckStartPosition))
_isArc = true;
CItem item;
@@ -1157,7 +1153,7 @@ HRESULT CHandler::Open2(IInStream *stream,
// AddErrorMessage(errorMessageLoc);
}
RINOK(result);
RINOK(result)
if (!filled)
{
@@ -1169,11 +1165,11 @@ HRESULT CHandler::Open2(IInStream *stream,
/* if there is recovery record for multivolume archive,
RAR adds 18 bytes (ZERO bytes) at the end for alignment.
We must skip these bytes to prevent phySize warning. */
RINOK(inStream->Seek(archive.ArcInfo.EndPos, STREAM_SEEK_SET, NULL));
RINOK(InStream_SeekSet(inStream, archive.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)
archive.ArcInfo.EndPos += numZeros;
}
@@ -1210,7 +1206,7 @@ HRESULT CHandler::Open2(IInStream *stream,
{
UInt64 numFiles = _items.Size();
UInt64 numBytes = curBytes + item.Position;
RINOK(openCallback->SetCompleted(&numFiles, &numBytes));
RINOK(openCallback->SetCompleted(&numFiles, &numBytes))
}
}
@@ -1260,9 +1256,9 @@ HRESULT CHandler::Open2(IInStream *stream,
return S_OK;
}
STDMETHODIMP CHandler::Open(IInStream *stream,
Z7_COM7F_IMF(CHandler::Open(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openCallback)
IArchiveOpenCallback *openCallback))
{
COM_TRY_BEGIN
Close();
@@ -1281,7 +1277,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
COM_TRY_END
}
STDMETHODIMP CHandler::Close()
Z7_COM7F_IMF(CHandler::Close())
{
COM_TRY_BEGIN
// _errorMessage.Empty();
@@ -1303,10 +1299,10 @@ struct CMethodItem
};
class CVolsInStream:
public ISequentialInStream,
public CMyUnknownImp
{
Z7_CLASS_IMP_NOQIB_1(
CVolsInStream
, ISequentialInStream
)
UInt64 _rem;
ISequentialInStream *_stream;
const CObjectVector<CArc> *_arcs;
@@ -1317,10 +1313,6 @@ class CVolsInStream:
bool _calcCrc;
public:
MY_UNKNOWN_IMP
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
void Init(const CObjectVector<CArc> *arcs,
const CObjectVector<CItem> *items,
const CRefItem &refItem)
@@ -1337,7 +1329,7 @@ public:
};
STDMETHODIMP CVolsInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
Z7_COM7F_IMF(CVolsInStream::Read(void *data, UInt32 size, UInt32 *processedSize))
{
if (processedSize)
*processedSize = 0;
@@ -1357,7 +1349,7 @@ STDMETHODIMP CVolsInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
// return S_FALSE;
}
IInStream *s = (*_arcs)[volIndex].Stream;
RINOK(s->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
RINOK(InStream_SeekSet(s, item.GetDataPosition()))
_stream = s;
_calcCrc = (CrcIsOK && item.IsSplitAfter());
_crc = CRC_INIT_VAL;
@@ -1397,16 +1389,16 @@ STDMETHODIMP CVolsInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
return S_OK;
}
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
CMyComPtr<ICryptoGetTextPassword> getTextPassword;
UInt64 censoredTotalUnPacked = 0,
UInt64 // censoredTotalUnPacked = 0,
// censoredTotalPacked = 0,
importantTotalUnPacked = 0;
// importantTotalPacked = 0;
bool allFilesMode = (numItems == (UInt32)(Int32)-1);
const bool allFilesMode = (numItems == (UInt32)(Int32)-1);
if (allFilesMode)
numItems = _refItems.Size();
if (numItems == 0)
@@ -1426,7 +1418,9 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
const CItem &item = _items[refItem.ItemIndex + refItem.NumItems - 1];
if (item.Is_Size_Defined())
censoredTotalUnPacked += item.Size;
{
// censoredTotalUnPacked += item.Size;
}
else
isThereUndefinedSize = true;
@@ -1458,7 +1452,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
if (importantTotalUnPacked != 0 || !isThereUndefinedSize)
{
RINOK(extractCallback->SetTotal(importantTotalUnPacked));
RINOK(extractCallback->SetTotal(importantTotalUnPacked))
}
UInt64 currentImportantTotalUnPacked = 0;
@@ -1494,7 +1488,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
{
lps->InSize = currentImportantTotalPacked;
lps->OutSize = currentImportantTotalUnPacked;
RINOK(lps->SetCur());
RINOK(lps->SetCur())
if (i >= importantIndexes.Size())
break;
@@ -1528,14 +1522,14 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
if (item.IgnoreItem())
continue;
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
RINOK(extractCallback->GetStream(index, &realOutStream, askMode))
if (!IsSolid(index))
solidStart = true;
if (item.IsDir())
{
RINOK(extractCallback->PrepareOperation(askMode));
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
RINOK(extractCallback->PrepareOperation(askMode))
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK))
continue;
}
@@ -1554,7 +1548,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
if (!realOutStream && !testMode)
askMode = NExtract::NAskMode::kSkip;
RINOK(extractCallback->PrepareOperation(askMode));
RINOK(extractCallback->PrepareOperation(askMode))
COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
@@ -1594,7 +1588,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
RINOK(rar3CryptoDecoder.QueryInterface(IID_ICompressSetDecoderProperties2,
&cryptoProperties));
*/
RINOK(rar3CryptoDecoderSpec->SetDecoderProperties2(item.Salt, item.HasSalt() ? sizeof(item.Salt) : 0));
RINOK(rar3CryptoDecoderSpec->SetDecoderProperties2(item.Salt, item.HasSalt() ? sizeof(item.Salt) : 0))
filterStreamSpec->Filter = rar3CryptoDecoder;
}
else if (item.UnPackVersion >= 20)
@@ -1609,7 +1603,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
else
{
outStream.Release();
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod));
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod))
continue;
}
@@ -1621,14 +1615,14 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
if (!getTextPassword)
{
outStream.Release();
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod));
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod))
continue;
}
// if (getTextPassword)
{
CMyComBSTR_Wipe password;
RINOK(getTextPassword->CryptoGetTextPassword(&password));
RINOK(getTextPassword->CryptoGetTextPassword(&password))
if (item.UnPackVersion >= 29)
{
@@ -1710,13 +1704,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
methodID += 2;
else
methodID += 3;
RINOK(CreateCoder_Id(EXTERNAL_CODECS_VARS methodID, false, mi.Coder));
RINOK(CreateCoder_Id(EXTERNAL_CODECS_VARS methodID, false, mi.Coder))
}
if (mi.Coder == 0)
if (!mi.Coder)
{
outStream.Release();
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod));
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod))
continue;
}
@@ -1726,7 +1720,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
RINOK(decoder.QueryInterface(IID_ICompressSetDecoderProperties2,
&compressSetDecoderProperties));
&compressSetDecoderProperties))
Byte isSolid = (Byte)((IsSolid(index) || item.IsSplitBefore()) ? 1: 0);
if (solidStart)
@@ -1736,14 +1730,14 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
}
RINOK(compressSetDecoderProperties->SetDecoderProperties2(&isSolid, 1));
RINOK(compressSetDecoderProperties->SetDecoderProperties2(&isSolid, 1))
commonCoder = decoder;
break;
}
default:
outStream.Release();
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod));
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod))
continue;
}
@@ -1769,7 +1763,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
else
return result;
}
RINOK(extractCallback->SetOperationResult(opRes));
RINOK(extractCallback->SetOperationResult(opRes))
}
return S_OK;
@@ -1779,7 +1773,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
IMPL_ISetCompressCodecsInfo
REGISTER_ARC_I(
"Rar", "rar r00", 0, 3,
"Rar", "rar r00", NULL, 3,
kMarker,
0,
NArcInfoFlags::kFindSignature,

View File

@@ -1,7 +1,7 @@
// RarHandler.h
#ifndef __RAR_HANDLER_H
#define __RAR_HANDLER_H
#ifndef ZIP7_INC_RAR_HANDLER_H
#define ZIP7_INC_RAR_HANDLER_H
#include "../IArchive.h"
@@ -67,11 +67,19 @@ struct CRefItem
unsigned NumItems;
};
class CHandler:
class CHandler Z7_final:
public IInArchive,
PUBLIC_ISetCompressCodecsInfo
Z7_PUBLIC_ISetCompressCodecsInfo_IFEC
public CMyUnknownImp
{
Z7_COM_QI_BEGIN2(IInArchive)
Z7_COM_QI_ENTRY_ISetCompressCodecsInfo_IFEC
Z7_COM_QI_END
Z7_COM_ADDREF_RELEASE
Z7_IFACE_COM7_IMP(IInArchive)
DECL_ISetCompressCodecsInfo
CRecordVector<CRefItem> _refItems;
CObjectVector<CItem> _items;
CObjectVector<CArc> _arcs;
@@ -99,16 +107,6 @@ class CHandler:
HRESULT Open2(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openCallback);
public:
MY_QUERYINTERFACE_BEGIN2(IInArchive)
QUERY_ENTRY_ISetCompressCodecsInfo
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
INTERFACE_IInArchive(;)
DECL_ISetCompressCodecsInfo
};
}}

View File

@@ -1,7 +1,7 @@
// Archive/RarHeader.h
#ifndef __ARCHIVE_RAR_HEADER_H
#define __ARCHIVE_RAR_HEADER_H
#ifndef ZIP7_INC_ARCHIVE_RAR_HEADER_H
#define ZIP7_INC_ARCHIVE_RAR_HEADER_H
#include "../../../Common/MyTypes.h"

View File

@@ -1,7 +1,7 @@
// RarItem.h
#ifndef __ARCHIVE_RAR_ITEM_H
#define __ARCHIVE_RAR_ITEM_H
#ifndef ZIP7_INC_ARCHIVE_RAR_ITEM_H
#define ZIP7_INC_ARCHIVE_RAR_ITEM_H
#include "../../../Common/StringConvert.h"

View File

@@ -1,7 +1,7 @@
// RarVol.h
#ifndef __ARCHIVE_RAR_VOL_H
#define __ARCHIVE_RAR_VOL_H
#ifndef ZIP7_INC_ARCHIVE_RAR_VOL_H
#define ZIP7_INC_ARCHIVE_RAR_VOL_H
#include "../../../Common/StringConvert.h"
@@ -22,7 +22,7 @@ class CVolumeName
UString _changed;
UString _after;
public:
CVolumeName(): _needChangeForNext(true) {};
CVolumeName(): _needChangeForNext(true) {}
bool InitName(const UString &name, bool newStyle = true)
{
@@ -52,7 +52,7 @@ public:
ext.IsEqualTo_Ascii_NoCase("r01"))
{
_changed = ext;
_before.SetFrom(name.Ptr(), dotPos + 1);
_before.SetFrom(name.Ptr(), (unsigned)dotPos + 1);
return true;
}
}
@@ -83,7 +83,7 @@ public:
_after.Empty();
_before = base;
_before += '.';
_before.Add_Dot();
_changed = "r00";
_needChangeForNext = false;
return true;

View File

@@ -1,8 +1,11 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#ifndef ZIP7_INC_STDAFX_H
#define ZIP7_INC_STDAFX_H
#if defined(_MSC_VER) && _MSC_VER >= 1800
#pragma warning(disable : 4464) // relative include path contains '..'
#endif
#include "../../../Common/Common.h"
#endif