Mercurial > vba-linux
view 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 source
1 // RarIn.h3 #ifndef __ARCHIVE_RAR_IN_H4 #define __ARCHIVE_RAR_IN_H6 #include "Common/DynamicBuffer.h"7 #include "Common/MyCom.h"9 #include "../../ICoder.h"10 #include "../../IStream.h"12 #include "../../Common/StreamObjects.h"14 #include "../../Crypto/RarAes.h"16 #include "RarHeader.h"17 #include "RarItem.h"19 namespace NArchive {20 namespace NRar {22 class CInArchiveException23 {24 public:25 enum CCauseType26 {27 kUnexpectedEndOfArchive = 0,28 kArchiveHeaderCRCError,29 kFileHeaderCRCError,30 kIncorrectArchive31 }32 Cause;33 CInArchiveException(CCauseType cause) : Cause(cause) {}34 };36 class CInArchiveInfo37 {38 public:39 UInt64 StartPosition;40 UInt16 Flags;41 UInt64 CommentPosition;42 UInt16 CommentSize;43 bool IsSolid() const { return (Flags & NHeader::NArchive::kSolid) != 0; }44 bool IsCommented() const { return (Flags & NHeader::NArchive::kComment) != 0; }45 bool IsVolume() const { return (Flags & NHeader::NArchive::kVolume) != 0; }46 bool HaveNewVolumeName() const { return (Flags & NHeader::NArchive::kNewVolName) != 0; }47 bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; }48 };50 class CInArchive51 {52 CMyComPtr<IInStream> m_Stream;54 UInt64 m_StreamStartPosition;55 UInt64 m_Position;56 UInt64 m_ArchiveStartPosition;58 NHeader::NArchive::CHeader360 m_ArchiveHeader;59 CDynamicBuffer<char> m_NameBuffer;60 CDynamicBuffer<wchar_t> _unicodeNameBuffer;61 bool m_SeekOnArchiveComment;62 UInt64 m_ArchiveCommentPosition;64 void ReadName(CItemEx &item, int nameSize);65 void ReadHeaderReal(CItemEx &item);67 HRESULT ReadBytes(void *data, UInt32 size, UInt32 *aProcessedSize);68 bool ReadBytesAndTestSize(void *data, UInt32 size);69 void ReadBytesAndTestResult(void *data, UInt32 size);71 HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);72 HRESULT Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit);74 void ThrowExceptionWithCode(CInArchiveException::CCauseType cause);75 void ThrowUnexpectedEndOfArchiveException();77 void AddToSeekValue(UInt64 addValue);79 protected:81 CDynamicBuffer<Byte> m_FileHeaderData;83 NHeader::NBlock::CBlock m_BlockHeader;85 NCrypto::NRar29::CDecoder *m_RarAESSpec;86 CMyComPtr<ICompressFilter> m_RarAES;88 Byte *m_CurData; // it must point to start of Rar::Block89 UInt32 m_CurPos;90 UInt32 m_PosLimit;91 Byte ReadByte();92 UInt16 ReadUInt16();93 UInt32 ReadUInt32();94 void ReadTime(Byte mask, CRarTime &rarTime);96 CBuffer<Byte> m_DecryptedData;97 UInt32 m_DecryptedDataSize;99 bool m_CryptoMode;100 UInt32 m_CryptoPos;101 void FinishCryptoBlock()102 {103 if (m_CryptoMode)104 while ((m_CryptoPos & 0xF) != 0)105 {106 m_CryptoPos++;107 m_Position++;108 }109 }111 public:112 HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);113 void Close();114 HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword);116 void SkipArchiveComment();118 void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;120 bool SeekInArchive(UInt64 position);121 ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);122 };124 }}126 #endif