Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2010-11-02 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:04 +0300
commitc65230d8585317f7cd58ae2982067385269fdee9 (patch)
tree436513094ff5034da4c88def9609f0ea376065c6 /CPP/7zip/Archive/Rar
parent2eb60a059819da595efb8e1de49f04c241f5b981 (diff)
9.189.18
Diffstat (limited to 'CPP/7zip/Archive/Rar')
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.cpp19
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.h1
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHeader.h20
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.cpp9
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.h2
5 files changed, 32 insertions, 19 deletions
diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp
index 8906614a..54709f6c 100755
--- a/CPP/7zip/Archive/Rar/RarHandler.cpp
+++ b/CPP/7zip/Archive/Rar/RarHandler.cpp
@@ -46,7 +46,7 @@ static const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
static const wchar_t *kUnknownOS = L"Unknown";
-STATPROPSTG kProps[] =
+static const STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
{ NULL, kpidIsDir, VT_BOOL},
@@ -68,7 +68,7 @@ STATPROPSTG kProps[] =
{ NULL, kpidUnpackVer, VT_UI1}
};
-STATPROPSTG kArcProps[] =
+static const STATPROPSTG kArcProps[] =
{
{ NULL, kpidSolid, VT_BOOL},
{ NULL, kpidNumBlocks, VT_UI4},
@@ -93,7 +93,7 @@ UInt64 CHandler::GetPackSize(int refIndex) const
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
- // COM_TRY_BEGIN
+ COM_TRY_BEGIN
NWindows::NCOM::CPropVariant prop;
switch(propID)
{
@@ -112,10 +112,11 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
prop = (UInt32)numBlocks;
break;
}
+ case kpidError: if (!_errorMessage.IsEmpty()) prop = _errorMessage; break;
}
prop.Detach(value);
return S_OK;
- // COM_TRY_END
+ COM_TRY_END
}
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
@@ -396,7 +397,14 @@ HRESULT CHandler::Open2(IInStream *stream,
for (;;)
{
bool decryptionError;
- HRESULT result = archive.GetNextItem(item, getTextPassword, decryptionError);
+ AString errorMessageLoc;
+ HRESULT result = archive.GetNextItem(item, getTextPassword, decryptionError, errorMessageLoc);
+ if (errorMessageLoc)
+ {
+ if (!_errorMessage.IsEmpty())
+ _errorMessage += '\n';
+ _errorMessage += errorMessageLoc;
+ }
if (result == S_FALSE)
{
if (decryptionError && _items.IsEmpty())
@@ -461,6 +469,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
STDMETHODIMP CHandler::Close()
{
COM_TRY_BEGIN
+ _errorMessage.Empty();
_refItems.Clear();
_items.Clear();
_archives.Clear();
diff --git a/CPP/7zip/Archive/Rar/RarHandler.h b/CPP/7zip/Archive/Rar/RarHandler.h
index 58e3fefc..c8015b2a 100755
--- a/CPP/7zip/Archive/Rar/RarHandler.h
+++ b/CPP/7zip/Archive/Rar/RarHandler.h
@@ -32,6 +32,7 @@ private:
CObjectVector<CItemEx> _items;
CObjectVector<CInArchive> _archives;
NArchive::NRar::CInArchiveInfo _archiveInfo;
+ AString _errorMessage;
DECL_EXTERNAL_CODECS_VARS
diff --git a/CPP/7zip/Archive/Rar/RarHeader.h b/CPP/7zip/Archive/Rar/RarHeader.h
index 4df42e62..8bb1da21 100755
--- a/CPP/7zip/Archive/Rar/RarHeader.h
+++ b/CPP/7zip/Archive/Rar/RarHeader.h
@@ -18,16 +18,16 @@ namespace NBlockType
{
enum EBlockType
{
- kMarker = 0x72,
- kArchiveHeader = 0x73,
- kFileHeader = 0x74,
- kCommentHeader = 0x75,
- kOldAuthenticity = 0x76,
- kSubBlock = 0x77,
- kRecoveryRecord = 0x78,
- kAuthenticity = 0x79,
-
- kEndOfArchive = 0x7B // Is not safe
+ kMarker = 0x72,
+ kArchiveHeader,
+ kFileHeader,
+ kCommentHeader,
+ kOldAuthenticity,
+ kOldSubBlock,
+ kRecoveryRecord,
+ kAuthenticity,
+ kSubBlock,
+ kEndOfArchive
};
}
diff --git a/CPP/7zip/Archive/Rar/RarIn.cpp b/CPP/7zip/Archive/Rar/RarIn.cpp
index c5d30fac..7d64c6fd 100755
--- a/CPP/7zip/Archive/Rar/RarIn.cpp
+++ b/CPP/7zip/Archive/Rar/RarIn.cpp
@@ -372,14 +372,14 @@ void CInArchive::AddToSeekValue(UInt64 addValue)
m_Position += addValue;
}
-HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword, bool &decryptionError)
+HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword, bool &decryptionError, AString &errorMessage)
{
decryptionError = false;
if (m_SeekOnArchiveComment)
SkipArchiveComment();
for (;;)
{
- if(!SeekInArchive(m_Position))
+ if (!SeekInArchive(m_Position))
return S_FALSE;
if (!m_CryptoMode && (m_ArchiveHeader.Flags &
NHeader::NArchive::kBlockHeadersAreEncrypted) != 0)
@@ -438,8 +438,11 @@ HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPa
}
m_FileHeaderData.EnsureCapacity(7);
- if(!ReadBytesAndTestSize((Byte *)m_FileHeaderData, 7))
+ if (!ReadBytesAndTestSize((Byte *)m_FileHeaderData, 7))
+ {
+ errorMessage = "Unexpected end of archive";
return S_FALSE;
+ }
m_CurData = (Byte *)m_FileHeaderData;
m_CurPos = 0;
diff --git a/CPP/7zip/Archive/Rar/RarIn.h b/CPP/7zip/Archive/Rar/RarIn.h
index 5d9f67a3..75c98cc4 100755
--- a/CPP/7zip/Archive/Rar/RarIn.h
+++ b/CPP/7zip/Archive/Rar/RarIn.h
@@ -110,7 +110,7 @@ class CInArchive
public:
HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
void Close();
- HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword, bool &decryptionError);
+ HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword, bool &decryptionError, AString &errorMessage);
void SkipArchiveComment();