diff options
Diffstat (limited to 'CPP/7zip')
-rw-r--r-- | CPP/7zip/Archive/Rar/Rar5Handler.cpp | 19 | ||||
-rw-r--r-- | CPP/7zip/Archive/Rar/Rar5Handler.h | 4 | ||||
-rw-r--r-- | CPP/7zip/Compress/Rar2Decoder.cpp | 14 | ||||
-rw-r--r-- | CPP/7zip/Compress/Rar2Decoder.h | 21 |
4 files changed, 44 insertions, 14 deletions
diff --git a/CPP/7zip/Archive/Rar/Rar5Handler.cpp b/CPP/7zip/Archive/Rar/Rar5Handler.cpp index 4fb63505..d70a5686 100644 --- a/CPP/7zip/Archive/Rar/Rar5Handler.cpp +++ b/CPP/7zip/Archive/Rar/Rar5Handler.cpp @@ -231,6 +231,18 @@ bool CItem::Is_CopyLink() const return FindExtra_Link(link) && link.Type == NLinkType::kFileCopy; } +bool CItem::Is_HardLink() const +{ + CLinkInfo link; + return FindExtra_Link(link) && link.Type == NLinkType::kHardLink; +} + +bool CItem::Is_CopyLink_or_HardLink() const +{ + CLinkInfo link; + return FindExtra_Link(link) && (link.Type == NLinkType::kFileCopy || link.Type == NLinkType::kHardLink); +} + void CItem::Link_to_Prop(unsigned linkType, NWindows::NCOM::CPropVariant &prop) const { CLinkInfo link; @@ -2587,7 +2599,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, { if (testMode) { - if (item->Is_CopyLink() && item->PackSize == 0) + if (item->NeedUse_as_CopyLink_or_HardLink()) { RINOK(extractCallback->PrepareOperation(askMode)); RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); @@ -2599,6 +2611,9 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, if (item->IsService()) continue; + if (item->NeedUse_as_HardLink()) + continue; + bool needDecode = false; for (unsigned n = i + 1; n < _refs.Size(); n++) @@ -2639,7 +2654,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, continue; } - if (item->Is_CopyLink() && item->PackSize == 0) + if (item->NeedUse_as_CopyLink()) { RINOK(extractCallback->SetOperationResult( realOutStream ? diff --git a/CPP/7zip/Archive/Rar/Rar5Handler.h b/CPP/7zip/Archive/Rar/Rar5Handler.h index cf741c7c..27e937de 100644 --- a/CPP/7zip/Archive/Rar/Rar5Handler.h +++ b/CPP/7zip/Archive/Rar/Rar5Handler.h @@ -262,8 +262,12 @@ struct CItem bool FindExtra_Link(CLinkInfo &link) const; void Link_to_Prop(unsigned linkType, NWindows::NCOM::CPropVariant &prop) const; bool Is_CopyLink() const; + bool Is_HardLink() const; + bool Is_CopyLink_or_HardLink() const; bool NeedUse_as_CopyLink() const { return PackSize == 0 && Is_CopyLink(); } + bool NeedUse_as_HardLink() const { return PackSize == 0 && Is_HardLink(); } + bool NeedUse_as_CopyLink_or_HardLink() const { return PackSize == 0 && Is_CopyLink_or_HardLink(); } bool GetAltStreamName(AString &name) const; diff --git a/CPP/7zip/Compress/Rar2Decoder.cpp b/CPP/7zip/Compress/Rar2Decoder.cpp index b3f2b4b3..db67433a 100644 --- a/CPP/7zip/Compress/Rar2Decoder.cpp +++ b/CPP/7zip/Compress/Rar2Decoder.cpp @@ -80,7 +80,8 @@ static const UInt32 kHistorySize = 1 << 20; static const UInt32 kWindowReservSize = (1 << 22) + 256; CDecoder::CDecoder(): - m_IsSolid(false) + m_IsSolid(false), + m_TablesOK(false) { } @@ -100,6 +101,8 @@ UInt32 CDecoder::ReadBits(unsigned numBits) { return m_InBitStream.ReadBits(numB bool CDecoder::ReadTables(void) { + m_TablesOK = false; + Byte levelLevels[kLevelTableSize]; Byte newLevels[kMaxTableSize]; m_AudioMode = (ReadBits(1) == 1); @@ -170,6 +173,9 @@ bool CDecoder::ReadTables(void) } memcpy(m_LastLevels, newLevels, kMaxTableSize); + + m_TablesOK = true; + return true; } @@ -340,10 +346,12 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream * return S_FALSE; return S_OK; } - if (!ReadTables()) - return S_FALSE; + ReadTables(); } + if (!m_TablesOK) + return S_FALSE; + UInt64 startPos = m_OutWindowStream.GetProcessedSize(); while (pos < unPackSize) { diff --git a/CPP/7zip/Compress/Rar2Decoder.h b/CPP/7zip/Compress/Rar2Decoder.h index 3a0535cc..0d8142b5 100644 --- a/CPP/7zip/Compress/Rar2Decoder.h +++ b/CPP/7zip/Compress/Rar2Decoder.h @@ -119,26 +119,29 @@ class CDecoder : { CLzOutWindow m_OutWindowStream; CBitDecoder m_InBitStream; + + UInt32 m_RepDistPtr; + UInt32 m_RepDists[kNumRepDists]; + + UInt32 m_LastLength; + + bool m_IsSolid; + bool m_TablesOK; + bool m_AudioMode; + NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder; NHuffman::CDecoder<kNumHuffmanBits, kDistTableSize> m_DistDecoder; NHuffman::CDecoder<kNumHuffmanBits, kLenTableSize> m_LenDecoder; NHuffman::CDecoder<kNumHuffmanBits, kMMTableSize> m_MMDecoders[NMultimedia::kNumChanelsMax]; NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder; - bool m_AudioMode; + UInt64 m_PackSize; - NMultimedia::CFilter2 m_MmFilter; unsigned m_NumChannels; + NMultimedia::CFilter2 m_MmFilter; - UInt32 m_RepDists[kNumRepDists]; - UInt32 m_RepDistPtr; - - UInt32 m_LastLength; - Byte m_LastLevels[kMaxTableSize]; - UInt64 m_PackSize; - bool m_IsSolid; void InitStructures(); UInt32 ReadBits(unsigned numBits); |