Mercurial > vba-linux
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 // RarIn.h | |
2 | |
3 #ifndef __ARCHIVE_RAR_IN_H | |
4 #define __ARCHIVE_RAR_IN_H | |
5 | |
6 #include "Common/DynamicBuffer.h" | |
7 #include "Common/MyCom.h" | |
8 | |
9 #include "../../ICoder.h" | |
10 #include "../../IStream.h" | |
11 | |
12 #include "../../Common/StreamObjects.h" | |
13 | |
14 #include "../../Crypto/RarAes.h" | |
15 | |
16 #include "RarHeader.h" | |
17 #include "RarItem.h" | |
18 | |
19 namespace NArchive { | |
20 namespace NRar { | |
21 | |
22 class CInArchiveException | |
23 { | |
24 public: | |
25 enum CCauseType | |
26 { | |
27 kUnexpectedEndOfArchive = 0, | |
28 kArchiveHeaderCRCError, | |
29 kFileHeaderCRCError, | |
30 kIncorrectArchive | |
31 } | |
32 Cause; | |
33 CInArchiveException(CCauseType cause) : Cause(cause) {} | |
34 }; | |
35 | |
36 class CInArchiveInfo | |
37 { | |
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 }; | |
49 | |
50 class CInArchive | |
51 { | |
52 CMyComPtr<IInStream> m_Stream; | |
53 | |
54 UInt64 m_StreamStartPosition; | |
55 UInt64 m_Position; | |
56 UInt64 m_ArchiveStartPosition; | |
57 | |
58 NHeader::NArchive::CHeader360 m_ArchiveHeader; | |
59 CDynamicBuffer<char> m_NameBuffer; | |
60 CDynamicBuffer<wchar_t> _unicodeNameBuffer; | |
61 bool m_SeekOnArchiveComment; | |
62 UInt64 m_ArchiveCommentPosition; | |
63 | |
64 void ReadName(CItemEx &item, int nameSize); | |
65 void ReadHeaderReal(CItemEx &item); | |
66 | |
67 HRESULT ReadBytes(void *data, UInt32 size, UInt32 *aProcessedSize); | |
68 bool ReadBytesAndTestSize(void *data, UInt32 size); | |
69 void ReadBytesAndTestResult(void *data, UInt32 size); | |
70 | |
71 HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit); | |
72 HRESULT Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit); | |
73 | |
74 void ThrowExceptionWithCode(CInArchiveException::CCauseType cause); | |
75 void ThrowUnexpectedEndOfArchiveException(); | |
76 | |
77 void AddToSeekValue(UInt64 addValue); | |
78 | |
79 protected: | |
80 | |
81 CDynamicBuffer<Byte> m_FileHeaderData; | |
82 | |
83 NHeader::NBlock::CBlock m_BlockHeader; | |
84 | |
85 NCrypto::NRar29::CDecoder *m_RarAESSpec; | |
86 CMyComPtr<ICompressFilter> m_RarAES; | |
87 | |
88 Byte *m_CurData; // it must point to start of Rar::Block | |
89 UInt32 m_CurPos; | |
90 UInt32 m_PosLimit; | |
91 Byte ReadByte(); | |
92 UInt16 ReadUInt16(); | |
93 UInt32 ReadUInt32(); | |
94 void ReadTime(Byte mask, CRarTime &rarTime); | |
95 | |
96 CBuffer<Byte> m_DecryptedData; | |
97 UInt32 m_DecryptedDataSize; | |
98 | |
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 } | |
110 | |
111 public: | |
112 HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit); | |
113 void Close(); | |
114 HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword); | |
115 | |
116 void SkipArchiveComment(); | |
117 | |
118 void GetArchiveInfo(CInArchiveInfo &archiveInfo) const; | |
119 | |
120 bool SeekInArchive(UInt64 position); | |
121 ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size); | |
122 }; | |
123 | |
124 }} | |
125 | |
126 #endif |