Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / other-licenses / 7zstub / src / 7zip / Archive / 7z / 7zItem.h
blobc50a0bcf41c1a54803d6b7f8214df9e2f5989c63
1 // 7zItem.h
3 #ifndef __7Z_ITEM_H
4 #define __7Z_ITEM_H
6 #include "../../../Common/Buffer.h"
7 #include "7zMethodID.h"
8 #include "7zHeader.h"
10 namespace NArchive {
11 namespace N7z {
13 struct CAltCoderInfo
15 CMethodID MethodID;
16 CByteBuffer Properties;
19 typedef UInt32 CNum;
20 const CNum kNumMax = 0x7FFFFFFF;
21 const CNum kNumNoIndex = 0xFFFFFFFF;
23 struct CCoderInfo
25 CNum NumInStreams;
26 CNum NumOutStreams;
27 CObjectVector<CAltCoderInfo> AltCoders;
28 bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
31 struct CBindPair
33 CNum InIndex;
34 CNum OutIndex;
37 struct CFolder
39 CObjectVector<CCoderInfo> Coders;
40 CRecordVector<CBindPair> BindPairs;
41 CRecordVector<CNum> PackStreams;
42 CRecordVector<UInt64> UnPackSizes;
43 UInt32 UnPackCRC;
44 bool UnPackCRCDefined;
46 CFolder(): UnPackCRCDefined(false) {}
48 UInt64 GetUnPackSize() const // test it
50 if (UnPackSizes.IsEmpty())
51 return 0;
52 for (int i = UnPackSizes.Size() - 1; i >= 0; i--)
53 if (FindBindPairForOutStream(i) < 0)
54 return UnPackSizes[i];
55 throw 1;
58 CNum GetNumOutStreams() const
60 CNum result = 0;
61 for (int i = 0; i < Coders.Size(); i++)
62 result += Coders[i].NumOutStreams;
63 return result;
66 int FindBindPairForInStream(CNum inStreamIndex) const
68 for(int i = 0; i < BindPairs.Size(); i++)
69 if (BindPairs[i].InIndex == inStreamIndex)
70 return i;
71 return -1;
73 int FindBindPairForOutStream(CNum outStreamIndex) const
75 for(int i = 0; i < BindPairs.Size(); i++)
76 if (BindPairs[i].OutIndex == outStreamIndex)
77 return i;
78 return -1;
80 int FindPackStreamArrayIndex(CNum inStreamIndex) const
82 for(int i = 0; i < PackStreams.Size(); i++)
83 if (PackStreams[i] == inStreamIndex)
84 return i;
85 return -1;
89 typedef FILETIME CArchiveFileTime;
91 class CFileItem
93 public:
94 CArchiveFileTime CreationTime;
95 CArchiveFileTime LastWriteTime;
96 CArchiveFileTime LastAccessTime;
97 UInt64 UnPackSize;
98 UInt64 StartPos;
99 UInt32 Attributes;
100 UInt32 FileCRC;
101 UString Name;
103 bool HasStream; // Test it !!! it means that there is
104 // stream in some folder. It can be empty stream
105 bool IsDirectory;
106 bool IsAnti;
107 bool IsFileCRCDefined;
108 bool AreAttributesDefined;
109 bool IsCreationTimeDefined;
110 bool IsLastWriteTimeDefined;
111 bool IsLastAccessTimeDefined;
112 bool IsStartPosDefined;
115 const bool HasStream() const {
116 return !IsDirectory && !IsAnti && UnPackSize != 0; }
118 CFileItem():
119 HasStream(true),
120 IsDirectory(false),
121 IsAnti(false),
122 IsFileCRCDefined(false),
123 AreAttributesDefined(false),
124 IsCreationTimeDefined(false),
125 IsLastWriteTimeDefined(false),
126 IsLastAccessTimeDefined(false),
127 IsStartPosDefined(false)
129 void SetAttributes(UInt32 attributes)
131 AreAttributesDefined = true;
132 Attributes = attributes;
134 void SetCreationTime(const CArchiveFileTime &creationTime)
136 IsCreationTimeDefined = true;
137 CreationTime = creationTime;
139 void SetLastWriteTime(const CArchiveFileTime &lastWriteTime)
141 IsLastWriteTimeDefined = true;
142 LastWriteTime = lastWriteTime;
144 void SetLastAccessTime(const CArchiveFileTime &lastAccessTime)
146 IsLastAccessTimeDefined = true;
147 LastAccessTime = lastAccessTime;
151 struct CArchiveDatabase
153 CRecordVector<UInt64> PackSizes;
154 CRecordVector<bool> PackCRCsDefined;
155 CRecordVector<UInt32> PackCRCs;
156 CObjectVector<CFolder> Folders;
157 CRecordVector<CNum> NumUnPackStreamsVector;
158 CObjectVector<CFileItem> Files;
159 void Clear()
161 PackSizes.Clear();
162 PackCRCsDefined.Clear();
163 PackCRCs.Clear();
164 Folders.Clear();
165 NumUnPackStreamsVector.Clear();
166 Files.Clear();
168 bool IsEmpty() const
170 return (PackSizes.IsEmpty() &&
171 PackCRCsDefined.IsEmpty() &&
172 PackCRCs.IsEmpty() &&
173 Folders.IsEmpty() &&
174 NumUnPackStreamsVector.IsEmpty() &&
175 Files.IsEmpty());
181 #endif