使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 479b1995ef435713c2cf4f0da8de3a6af6c30922
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
////////////////////////////////////////////////////////////////////////////////
// This source file is part of the ZipArchive library source distribution and
// is Copyrighted 2000 - 2011 by Artpol Software - Tadeusz Dracz
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// For the licensing details refer to the License.txt file.
//
// Web Site: http://www.artpol-software.com
////////////////////////////////////////////////////////////////////////////////
 
/**
* \file ZipExtraField.h
* Includes the CZipExtraField class.
*
*/
 
#if !defined(ZIPARCHIVE_ZIPEXTRAFIELD_DOT_H)
#define ZIPARCHIVE_ZIPEXTRAFIELD_DOT_H
 
#if _MSC_VER > 1000
#pragma once
#endif
 
#include "ZipExport.h"
#include "ZipExtraData.h"
#include "ZipCollections.h"
#include "ZipStorage.h"
 
#define ZIP_EXTRA_PKZIP 0x0001
 
#define ZIP_EXTRA_ZARCH_NAME 0x5A4C // ZL - ZipArchive Library
 
#define ZIP_EXTRA_ZARCH_SEEK 0x5A4D 
 
#define ZIP_EXTRA_WINZIP_AES 0x9901
 
#define ZIP_EXTRA_UNICODE_PATH 0x7075
#define ZIP_EXTRA_UNICODE_COMMENT 0x6375
 
 
#if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
    #pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
#endif
 
/**
    Represents a local or central extra field in a zip archive.
    This is a collection of extra data records (CZipExtraData).
 
    \see
        <a href="kb">0610242300</a>
    \see
        CZipExtraData
*/
class ZIP_API CZipExtraField
{
    friend class CZipFileHeader;
public:
    CZipExtraField()
    {
    }
    CZipExtraField(const CZipExtraField& arr)
    {        
        *this = arr;
    }
    CZipExtraField& operator=(const CZipExtraField& field)
    {
        Clear();
        for (int i = 0; i < field.GetCount(); i++)
            Add(new CZipExtraData(*field.GetAt(i)));
        return *this;
    }
 
    /**
        Returns the total size the extra data will occupy in the archive.
 
        \return
            The size in bytes.
    */
    int GetTotalSize() const;
 
    /**
        Validates the current size of the extra field.
 
        \return
            \c false, if the size is larger than allowed; \c false otherwise.
    */
    bool Validate() const
    {
        return GetTotalSize() <= (int)USHRT_MAX;
    }
    
    /**
        Returns the number of extra data records included in the extra field.
 
        \return
            The number of extra fields included.
    */
    int GetCount() const
    {
        return (int)m_aData.GetSize();
    }
 
    /**
        Returns the extra data record at the given index.
 
        \param index
            The index of extra data record to retrieve.
 
        \return
            The extra data record.
    */
    CZipExtraData* GetAt(int index) const
    {        
        return m_aData.GetAt(index);
    }
 
    /**
        Removes the extra data record at the given index.
 
        \param index
            The index of the extra data record to remove.
    */
    void RemoveAt(int index)
    {
        delete (GetAt(index));
        m_aData.RemoveAt(index);
    }
 
    /**
        Adds a new extra data record to the extra field.
 
        \param pExtra
            The extra data record to add.
 
        \return
            The index of \a pExtra in the internal collection.
    */
    int Add(CZipExtraData* pExtra)
    {
        return (int)m_aData.Add(pExtra);
    }
 
    /**
        Creates a new extra data record with the given ID
        and adds it to the extra field.
 
        \param headerID
            The extra data ID.
 
        \return
            The created extra data record.
 
        \see
            CZipExtraData::GetHeaderID
    */
    CZipExtraData* CreateNew(WORD headerID)
    {
        int temp;
        return CreateNew(headerID, temp);
    }
 
    /**
        Creates a new extra data record with the given ID
        and adds it to the extra field.
 
        \param headerID
            The extra data ID.
 
        \param idx
            Receives the value of the index of the new 
            extra data in the internal collection.
 
        \return
            The created extra data record.
 
        \see
            CZipExtraData::GetHeaderID
    */
    CZipExtraData* CreateNew(WORD headerID, int& idx)
    {
        CZipExtraData* pData = new CZipExtraData(headerID);
        pData->m_bHasSize = HasSize(headerID);
        idx = (int)m_aData.Add(pData);
        return pData;
    }
 
    /**
        Removes all extra data records from the central extra field
        that are internally used by the ZipArchive Library.
    */
    void RemoveInternalHeaders();
 
    /**
        Removes all extra data records from the local extra field
        that are internally used by the ZipArchive Library.
    */
    void RemoveInternalLocalHeaders();
 
    /**
        Removes the extra data with the given ID.
 
        \param headerID
            The ID of the extra data to remove.
    */
    void Remove(WORD headerID);
 
    /**
        Searches the extra field for the extra data record with the given ID.
 
        \param headerID
            The ID of the extra data to search.
 
        \return
            The found extra data record or \c NULL, if the extra data could not be found.
    */
    CZipExtraData* Lookup(WORD headerID) const
    {
        int temp;
        return Lookup(headerID, temp);
    }
 
    /**
        Returns the value indicating whether the extra data record with the given ID is present in the extra field.
 
        \param headerID
            The ID of the extra data to check.
 
        \return 
            \c true, if the extra data record with the given ID is present in the extra field; \c false otherwise.
    */
    bool HasHeader(WORD headerID)
    {
        return Lookup(headerID) != NULL;
    }
 
    /**
        Searches the extra field for the extra data record with the given ID.
 
        \param headerID
            The ID of the extra data to search.
 
        \param index
            Receives the value of the index of the found 
            extra data in the internal collection.
 
        \return
            The found extra data record or \c NULL, if the extra data could not be found.
    */
    CZipExtraData* Lookup(WORD headerID, int& index) const;
    ~CZipExtraField()
    {
        Clear();
    }
 
    /**
        An array of headers that do not write extra data size.
 
        \see
            <a href="kb">0610242300|read</a>
    */
    static CZipArray<WORD> m_aNoSizeExtraHeadersID;
 
    /**
        Returns the value indicating whether the extra data record with the given ID writes its size.
 
        \param headerID
            The ID of extra data to examine.
 
        \return
            \c true, if the extra data record writes its size; \c false otherwise.
 
        \see
            m_aNoSizeExtraHeadersID            
    */
    static bool HasSize(WORD headerID)
    {
        ZIP_ARRAY_SIZE_TYPE size = m_aNoSizeExtraHeadersID.GetSize();
        for (ZIP_ARRAY_SIZE_TYPE i = 0; i < size; i++)
        {
            if (m_aNoSizeExtraHeadersID.GetAt(i) == headerID)
                return false;
        }
        return true;
    }
 
protected:
 
    /**
        Removes all extra data records from the extra field.
    */
    void Clear()
    {
        for (int i = 0; i < GetCount(); i++)
            delete (GetAt(i));
        m_aData.RemoveAll();
    }    
 
    /**
        Reads the extra field from \a buffer.
 
        \param pStorage
            The storage to read the data from.
 
        \param uSize
            The size of the data to read.
 
        \return
            \c false, if \a uSize was smaller than the declared extra field size; \c true otherwise.
    */
    bool Read(CZipStorage* pStorage, WORD uSize);
 
    /**
        Writes the extra field to \a buffer.
 
        \param buffer
            The buffer to write to.
    */
    void Write(char* buffer) const;    
    
private:
    
    CZipArray<CZipExtraData*> m_aData;
};
 
 
#endif // !defined(ZIPARCHIVE_ZIPEXTRAFIELD_DOT_H)