Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarIn.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarIn.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,126 @@ 1.4 +// RarIn.h 1.5 + 1.6 +#ifndef __ARCHIVE_RAR_IN_H 1.7 +#define __ARCHIVE_RAR_IN_H 1.8 + 1.9 +#include "Common/DynamicBuffer.h" 1.10 +#include "Common/MyCom.h" 1.11 + 1.12 +#include "../../ICoder.h" 1.13 +#include "../../IStream.h" 1.14 + 1.15 +#include "../../Common/StreamObjects.h" 1.16 + 1.17 +#include "../../Crypto/RarAes.h" 1.18 + 1.19 +#include "RarHeader.h" 1.20 +#include "RarItem.h" 1.21 + 1.22 +namespace NArchive { 1.23 +namespace NRar { 1.24 + 1.25 +class CInArchiveException 1.26 +{ 1.27 +public: 1.28 + enum CCauseType 1.29 + { 1.30 + kUnexpectedEndOfArchive = 0, 1.31 + kArchiveHeaderCRCError, 1.32 + kFileHeaderCRCError, 1.33 + kIncorrectArchive 1.34 + } 1.35 + Cause; 1.36 + CInArchiveException(CCauseType cause) : Cause(cause) {} 1.37 +}; 1.38 + 1.39 +class CInArchiveInfo 1.40 +{ 1.41 +public: 1.42 + UInt64 StartPosition; 1.43 + UInt16 Flags; 1.44 + UInt64 CommentPosition; 1.45 + UInt16 CommentSize; 1.46 + bool IsSolid() const { return (Flags & NHeader::NArchive::kSolid) != 0; } 1.47 + bool IsCommented() const { return (Flags & NHeader::NArchive::kComment) != 0; } 1.48 + bool IsVolume() const { return (Flags & NHeader::NArchive::kVolume) != 0; } 1.49 + bool HaveNewVolumeName() const { return (Flags & NHeader::NArchive::kNewVolName) != 0; } 1.50 + bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; } 1.51 +}; 1.52 + 1.53 +class CInArchive 1.54 +{ 1.55 + CMyComPtr<IInStream> m_Stream; 1.56 + 1.57 + UInt64 m_StreamStartPosition; 1.58 + UInt64 m_Position; 1.59 + UInt64 m_ArchiveStartPosition; 1.60 + 1.61 + NHeader::NArchive::CHeader360 m_ArchiveHeader; 1.62 + CDynamicBuffer<char> m_NameBuffer; 1.63 + CDynamicBuffer<wchar_t> _unicodeNameBuffer; 1.64 + bool m_SeekOnArchiveComment; 1.65 + UInt64 m_ArchiveCommentPosition; 1.66 + 1.67 + void ReadName(CItemEx &item, int nameSize); 1.68 + void ReadHeaderReal(CItemEx &item); 1.69 + 1.70 + HRESULT ReadBytes(void *data, UInt32 size, UInt32 *aProcessedSize); 1.71 + bool ReadBytesAndTestSize(void *data, UInt32 size); 1.72 + void ReadBytesAndTestResult(void *data, UInt32 size); 1.73 + 1.74 + HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit); 1.75 + HRESULT Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit); 1.76 + 1.77 + void ThrowExceptionWithCode(CInArchiveException::CCauseType cause); 1.78 + void ThrowUnexpectedEndOfArchiveException(); 1.79 + 1.80 + void AddToSeekValue(UInt64 addValue); 1.81 + 1.82 +protected: 1.83 + 1.84 + CDynamicBuffer<Byte> m_FileHeaderData; 1.85 + 1.86 + NHeader::NBlock::CBlock m_BlockHeader; 1.87 + 1.88 + NCrypto::NRar29::CDecoder *m_RarAESSpec; 1.89 + CMyComPtr<ICompressFilter> m_RarAES; 1.90 + 1.91 + Byte *m_CurData; // it must point to start of Rar::Block 1.92 + UInt32 m_CurPos; 1.93 + UInt32 m_PosLimit; 1.94 + Byte ReadByte(); 1.95 + UInt16 ReadUInt16(); 1.96 + UInt32 ReadUInt32(); 1.97 + void ReadTime(Byte mask, CRarTime &rarTime); 1.98 + 1.99 + CBuffer<Byte> m_DecryptedData; 1.100 + UInt32 m_DecryptedDataSize; 1.101 + 1.102 + bool m_CryptoMode; 1.103 + UInt32 m_CryptoPos; 1.104 + void FinishCryptoBlock() 1.105 + { 1.106 + if (m_CryptoMode) 1.107 + while ((m_CryptoPos & 0xF) != 0) 1.108 + { 1.109 + m_CryptoPos++; 1.110 + m_Position++; 1.111 + } 1.112 + } 1.113 + 1.114 +public: 1.115 + HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit); 1.116 + void Close(); 1.117 + HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword); 1.118 + 1.119 + void SkipArchiveComment(); 1.120 + 1.121 + void GetArchiveInfo(CInArchiveInfo &archiveInfo) const; 1.122 + 1.123 + bool SeekInArchive(UInt64 position); 1.124 + ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size); 1.125 +}; 1.126 + 1.127 +}} 1.128 + 1.129 +#endif