]> git.saurik.com Git - wxWidgets.git/blame - include/wx/zipstrm.h
Add lambda-friendly wxDialog::ShowWindowModalThenDo().
[wxWidgets.git] / include / wx / zipstrm.h
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
ce7208d4 2// Name: wx/zipstrm.h
00375592
VZ
3// Purpose: Streams for Zip files
4// Author: Mike Wetherell
00375592 5// Copyright: (c) Mike Wetherell
65571936 6// Licence: wxWindows licence
5526e819
VS
7/////////////////////////////////////////////////////////////////////////////
8
00375592
VZ
9#ifndef _WX_WXZIPSTREAM_H__
10#define _WX_WXZIPSTREAM_H__
5526e819 11
d1af991f 12#include "wx/defs.h"
5526e819 13
5410f572 14#if wxUSE_ZIPSTREAM
d1af991f 15
00375592 16#include "wx/archive.h"
00375592 17#include "wx/filename.h"
5526e819 18
fe47da7b
MW
19// some methods from wxZipInputStream and wxZipOutputStream stream do not get
20// exported/imported when compiled with Mingw versions before 3.4.2. So they
21// are imported/exported individually as a workaround
22#if (defined(__GNUWIN32__) || defined(__MINGW32__)) \
23 && (!defined __GNUC__ \
24 || !defined __GNUC_MINOR__ \
25 || !defined __GNUC_PATCHLEVEL__ \
26 || __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 30402)
ce7208d4 27#define WXZIPFIX WXDLLIMPEXP_BASE
fe47da7b
MW
28#else
29#define WXZIPFIX
30#endif
5526e819 31
00375592
VZ
32/////////////////////////////////////////////////////////////////////////////
33// constants
34
35// Compression Method, only 0 (store) and 8 (deflate) are supported here
36//
37enum wxZipMethod
38{
39 wxZIP_METHOD_STORE,
40 wxZIP_METHOD_SHRINK,
41 wxZIP_METHOD_REDUCE1,
42 wxZIP_METHOD_REDUCE2,
43 wxZIP_METHOD_REDUCE3,
44 wxZIP_METHOD_REDUCE4,
45 wxZIP_METHOD_IMPLODE,
46 wxZIP_METHOD_TOKENIZE,
47 wxZIP_METHOD_DEFLATE,
48 wxZIP_METHOD_DEFLATE64,
49 wxZIP_METHOD_BZIP2 = 12,
50 wxZIP_METHOD_DEFAULT = 0xffff
51};
52
53// Originating File-System.
ce7208d4 54//
00375592
VZ
55// These are Pkware's values. Note that Info-zip disagree on some of them,
56// most notably NTFS.
57//
58enum wxZipSystem
59{
60 wxZIP_SYSTEM_MSDOS,
61 wxZIP_SYSTEM_AMIGA,
62 wxZIP_SYSTEM_OPENVMS,
63 wxZIP_SYSTEM_UNIX,
64 wxZIP_SYSTEM_VM_CMS,
65 wxZIP_SYSTEM_ATARI_ST,
66 wxZIP_SYSTEM_OS2_HPFS,
67 wxZIP_SYSTEM_MACINTOSH,
68 wxZIP_SYSTEM_Z_SYSTEM,
69 wxZIP_SYSTEM_CPM,
70 wxZIP_SYSTEM_WINDOWS_NTFS,
71 wxZIP_SYSTEM_MVS,
72 wxZIP_SYSTEM_VSE,
73 wxZIP_SYSTEM_ACORN_RISC,
74 wxZIP_SYSTEM_VFAT,
75 wxZIP_SYSTEM_ALTERNATE_MVS,
76 wxZIP_SYSTEM_BEOS,
77 wxZIP_SYSTEM_TANDEM,
78 wxZIP_SYSTEM_OS_400
79};
80
81// Dos/Win file attributes
82//
83enum wxZipAttributes
84{
85 wxZIP_A_RDONLY = 0x01,
86 wxZIP_A_HIDDEN = 0x02,
87 wxZIP_A_SYSTEM = 0x04,
88 wxZIP_A_SUBDIR = 0x10,
89 wxZIP_A_ARCH = 0x20,
90
91 wxZIP_A_MASK = 0x37
92};
93
94// Values for the flags field in the zip headers
95//
96enum wxZipFlags
97{
98 wxZIP_ENCRYPTED = 0x0001,
99 wxZIP_DEFLATE_NORMAL = 0x0000, // normal compression
100 wxZIP_DEFLATE_EXTRA = 0x0002, // extra compression
101 wxZIP_DEFLATE_FAST = 0x0004, // fast compression
102 wxZIP_DEFLATE_SUPERFAST = 0x0006, // superfast compression
103 wxZIP_DEFLATE_MASK = 0x0006,
104 wxZIP_SUMS_FOLLOW = 0x0008, // crc and sizes come after the data
105 wxZIP_ENHANCED = 0x0010,
106 wxZIP_PATCH = 0x0020,
107 wxZIP_STRONG_ENC = 0x0040,
108 wxZIP_UNUSED = 0x0F80,
109 wxZIP_RESERVED = 0xF000
110};
111
112// Forward decls
113//
b5dbe15d
VS
114class WXDLLIMPEXP_FWD_BASE wxZipEntry;
115class WXDLLIMPEXP_FWD_BASE wxZipInputStream;
00375592
VZ
116
117
118/////////////////////////////////////////////////////////////////////////////
119// wxZipNotifier
5526e819 120
00375592 121class WXDLLIMPEXP_BASE wxZipNotifier
5526e819 122{
f6bcfd97 123public:
00375592
VZ
124 virtual ~wxZipNotifier() { }
125
126 virtual void OnEntryUpdated(wxZipEntry& entry) = 0;
127};
128
129
130/////////////////////////////////////////////////////////////////////////////
131// Zip Entry - holds the meta data for a file in the zip
132
133class WXDLLIMPEXP_BASE wxZipEntry : public wxArchiveEntry
134{
135public:
136 wxZipEntry(const wxString& name = wxEmptyString,
137 const wxDateTime& dt = wxDateTime::Now(),
138 wxFileOffset size = wxInvalidOffset);
139 virtual ~wxZipEntry();
140
141 wxZipEntry(const wxZipEntry& entry);
142 wxZipEntry& operator=(const wxZipEntry& entry);
143
144 // Get accessors
145 wxDateTime GetDateTime() const { return m_DateTime; }
146 wxFileOffset GetSize() const { return m_Size; }
147 wxFileOffset GetOffset() const { return m_Offset; }
148 wxString GetInternalName() const { return m_Name; }
149 int GetMethod() const { return m_Method; }
150 int GetFlags() const { return m_Flags; }
151 wxUint32 GetCrc() const { return m_Crc; }
152 wxFileOffset GetCompressedSize() const { return m_CompressedSize; }
153 int GetSystemMadeBy() const { return m_SystemMadeBy; }
154 wxString GetComment() const { return m_Comment; }
155 wxUint32 GetExternalAttributes() const { return m_ExternalAttributes; }
156 wxPathFormat GetInternalFormat() const { return wxPATH_UNIX; }
157 int GetMode() const;
158 const char *GetLocalExtra() const;
159 size_t GetLocalExtraLen() const;
160 const char *GetExtra() const;
161 size_t GetExtraLen() const;
162 wxString GetName(wxPathFormat format = wxPATH_NATIVE) const;
163
164 // is accessors
165 inline bool IsDir() const;
166 inline bool IsText() const;
167 inline bool IsReadOnly() const;
168 inline bool IsMadeByUnix() const;
169
170 // set accessors
171 void SetDateTime(const wxDateTime& dt) { m_DateTime = dt; }
172 void SetSize(wxFileOffset size) { m_Size = size; }
ceefc965 173 void SetMethod(int method) { m_Method = (wxUint16)method; }
00375592
VZ
174 void SetComment(const wxString& comment) { m_Comment = comment; }
175 void SetExternalAttributes(wxUint32 attr ) { m_ExternalAttributes = attr; }
176 void SetSystemMadeBy(int system);
177 void SetMode(int mode);
178 void SetExtra(const char *extra, size_t len);
179 void SetLocalExtra(const char *extra, size_t len);
180
181 inline void SetName(const wxString& name,
182 wxPathFormat format = wxPATH_NATIVE);
183
184 static wxString GetInternalName(const wxString& name,
185 wxPathFormat format = wxPATH_NATIVE,
186 bool *pIsDir = NULL);
187
188 // set is accessors
189 void SetIsDir(bool isDir = true);
190 inline void SetIsReadOnly(bool isReadOnly = true);
191 inline void SetIsText(bool isText = true);
f6bcfd97 192
00375592
VZ
193 wxZipEntry *Clone() const { return ZipClone(); }
194
195 void SetNotifier(wxZipNotifier& notifier);
196 void UnsetNotifier();
f6bcfd97
BP
197
198protected:
00375592
VZ
199 // Internal attributes
200 enum { TEXT_ATTR = 1 };
201
202 // protected Get accessors
203 int GetVersionNeeded() const { return m_VersionNeeded; }
204 wxFileOffset GetKey() const { return m_Key; }
205 int GetVersionMadeBy() const { return m_VersionMadeBy; }
206 int GetDiskStart() const { return m_DiskStart; }
207 int GetInternalAttributes() const { return m_InternalAttributes; }
208
ceefc965 209 void SetVersionNeeded(int version) { m_VersionNeeded = (wxUint16)version; }
00375592 210 void SetOffset(wxFileOffset offset) { m_Offset = offset; }
ceefc965
WS
211 void SetFlags(int flags) { m_Flags = (wxUint16)flags; }
212 void SetVersionMadeBy(int version) { m_VersionMadeBy = (wxUint8)version; }
00375592
VZ
213 void SetCrc(wxUint32 crc) { m_Crc = crc; }
214 void SetCompressedSize(wxFileOffset size) { m_CompressedSize = size; }
215 void SetKey(wxFileOffset offset) { m_Key = offset; }
ceefc965
WS
216 void SetDiskStart(int start) { m_DiskStart = (wxUint16)start; }
217 void SetInternalAttributes(int attr) { m_InternalAttributes = (wxUint16)attr; }
00375592
VZ
218
219 virtual wxZipEntry *ZipClone() const { return new wxZipEntry(*this); }
220
221 void Notify();
f6bcfd97 222
e3a10e0c 223private:
00375592
VZ
224 wxArchiveEntry* DoClone() const { return ZipClone(); }
225
226 size_t ReadLocal(wxInputStream& stream, wxMBConv& conv);
227 size_t WriteLocal(wxOutputStream& stream, wxMBConv& conv) const;
228
229 size_t ReadCentral(wxInputStream& stream, wxMBConv& conv);
230 size_t WriteCentral(wxOutputStream& stream, wxMBConv& conv) const;
231
232 size_t ReadDescriptor(wxInputStream& stream);
233 size_t WriteDescriptor(wxOutputStream& stream, wxUint32 crc,
234 wxFileOffset compressedSize, wxFileOffset size);
235
236 wxUint8 m_SystemMadeBy; // one of enum wxZipSystem
237 wxUint8 m_VersionMadeBy; // major * 10 + minor
238
239 wxUint16 m_VersionNeeded; // ver needed to extract (20 i.e. v2.0)
240 wxUint16 m_Flags;
241 wxUint16 m_Method; // compression method (one of wxZipMethod)
242 wxDateTime m_DateTime;
243 wxUint32 m_Crc;
244 wxFileOffset m_CompressedSize;
588066b7 245 wxFileOffset m_Size;
00375592
VZ
246 wxString m_Name; // in internal format
247 wxFileOffset m_Key; // the original offset for copied entries
248 wxFileOffset m_Offset; // file offset of the entry
249
250 wxString m_Comment;
251 wxUint16 m_DiskStart; // for multidisk archives, not unsupported
252 wxUint16 m_InternalAttributes; // bit 0 set for text files
253 wxUint32 m_ExternalAttributes; // system specific depends on SystemMadeBy
254
255 class wxZipMemory *m_Extra;
256 class wxZipMemory *m_LocalExtra;
257
258 wxZipNotifier *m_zipnotifier;
259 class wxZipWeakLinks *m_backlink;
f6bcfd97 260
00375592
VZ
261 friend class wxZipInputStream;
262 friend class wxZipOutputStream;
263
264 DECLARE_DYNAMIC_CLASS(wxZipEntry)
265};
266
267
268/////////////////////////////////////////////////////////////////////////////
ce7208d4 269// wxZipOutputStream
00375592 270
8fc574b4 271WX_DECLARE_LIST_WITH_DECL(wxZipEntry, wxZipEntryList_, class WXDLLIMPEXP_BASE);
00375592
VZ
272
273class WXDLLIMPEXP_BASE wxZipOutputStream : public wxArchiveOutputStream
274{
275public:
276 wxZipOutputStream(wxOutputStream& stream,
277 int level = -1,
278 wxMBConv& conv = wxConvLocal);
8fc574b4
MW
279 wxZipOutputStream(wxOutputStream *stream,
280 int level = -1,
281 wxMBConv& conv = wxConvLocal);
fe47da7b 282 virtual WXZIPFIX ~wxZipOutputStream();
00375592
VZ
283
284 bool PutNextEntry(wxZipEntry *entry) { return DoCreate(entry); }
285
fe47da7b
MW
286 bool WXZIPFIX PutNextEntry(const wxString& name,
287 const wxDateTime& dt = wxDateTime::Now(),
288 wxFileOffset size = wxInvalidOffset);
00375592 289
fe47da7b
MW
290 bool WXZIPFIX PutNextDirEntry(const wxString& name,
291 const wxDateTime& dt = wxDateTime::Now());
00375592 292
fe47da7b
MW
293 bool WXZIPFIX CopyEntry(wxZipEntry *entry, wxZipInputStream& inputStream);
294 bool WXZIPFIX CopyArchiveMetaData(wxZipInputStream& inputStream);
00375592 295
fe47da7b
MW
296 void WXZIPFIX Sync();
297 bool WXZIPFIX CloseEntry();
298 bool WXZIPFIX Close();
00375592
VZ
299
300 void SetComment(const wxString& comment) { m_Comment = comment; }
301
302 int GetLevel() const { return m_level; }
fe47da7b 303 void WXZIPFIX SetLevel(int level);
ce7208d4 304
00375592 305protected:
fe47da7b 306 virtual size_t WXZIPFIX OnSysWrite(const void *buffer, size_t size);
00375592
VZ
307 virtual wxFileOffset OnSysTell() const { return m_entrySize; }
308
fe47da7b 309 // this protected interface isn't yet finalised
00375592 310 struct Buffer { const char *m_data; size_t m_size; };
fe47da7b
MW
311 virtual wxOutputStream* WXZIPFIX OpenCompressor(wxOutputStream& stream,
312 wxZipEntry& entry,
313 const Buffer bufs[]);
314 virtual bool WXZIPFIX CloseCompressor(wxOutputStream *comp);
00375592 315
fe47da7b
MW
316 bool IsParentSeekable() const
317 { return m_offsetAdjustment != wxInvalidOffset; }
00375592
VZ
318
319private:
8fc574b4
MW
320 void Init(int level);
321
e3a10e0c
MW
322 bool WXZIPFIX PutNextEntry(wxArchiveEntry *entry);
323 bool WXZIPFIX CopyEntry(wxArchiveEntry *entry, wxArchiveInputStream& stream);
324 bool WXZIPFIX CopyArchiveMetaData(wxArchiveInputStream& stream);
325
fe47da7b 326 bool IsOpened() const { return m_comp || m_pending; }
00375592
VZ
327
328 bool DoCreate(wxZipEntry *entry, bool raw = false);
329 void CreatePendingEntry(const void *buffer, size_t size);
330 void CreatePendingEntry();
331
332 class wxStoredOutputStream *m_store;
333 class wxZlibOutputStream2 *m_deflate;
334 class wxZipStreamLink *m_backlink;
8fc574b4 335 wxZipEntryList_ m_entries;
00375592
VZ
336 char *m_initialData;
337 size_t m_initialSize;
338 wxZipEntry *m_pending;
339 bool m_raw;
340 wxFileOffset m_headerOffset;
341 size_t m_headerSize;
342 wxFileOffset m_entrySize;
343 wxUint32 m_crcAccumulator;
344 wxOutputStream *m_comp;
345 int m_level;
346 wxFileOffset m_offsetAdjustment;
347 wxString m_Comment;
dd0af4bb 348 bool m_endrecWritten;
00375592 349
c0c133e1 350 wxDECLARE_NO_COPY_CLASS(wxZipOutputStream);
00375592
VZ
351};
352
353
354/////////////////////////////////////////////////////////////////////////////
ce7208d4 355// wxZipInputStream
00375592
VZ
356
357class WXDLLIMPEXP_BASE wxZipInputStream : public wxArchiveInputStream
358{
359public:
360 typedef wxZipEntry entry_type;
361
362 wxZipInputStream(wxInputStream& stream, wxMBConv& conv = wxConvLocal);
8fc574b4 363 wxZipInputStream(wxInputStream *stream, wxMBConv& conv = wxConvLocal);
d13a08ab 364
8fc574b4 365#if WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
fe47da7b
MW
366 wxZipInputStream(const wxString& archive, const wxString& file)
367 : wxArchiveInputStream(OpenFile(archive), wxConvLocal) { Init(file); }
d13a08ab
MW
368#endif
369
fe47da7b 370 virtual WXZIPFIX ~wxZipInputStream();
00375592
VZ
371
372 bool OpenEntry(wxZipEntry& entry) { return DoOpen(&entry); }
fe47da7b 373 bool WXZIPFIX CloseEntry();
00375592
VZ
374
375 wxZipEntry *GetNextEntry();
376
fe47da7b
MW
377 wxString WXZIPFIX GetComment();
378 int WXZIPFIX GetTotalEntries();
00375592
VZ
379
380 virtual wxFileOffset GetLength() const { return m_entry.GetSize(); }
381
382protected:
fe47da7b 383 size_t WXZIPFIX OnSysRead(void *buffer, size_t size);
00375592 384 wxFileOffset OnSysTell() const { return m_decomp ? m_decomp->TellI() : 0; }
d13a08ab 385
0441868f 386#if WXWIN_COMPATIBILITY_2_6
fe47da7b 387 wxFileOffset WXZIPFIX OnSysSeek(wxFileOffset seek, wxSeekMode mode);
d13a08ab 388#endif
00375592 389
d13a08ab 390 // this protected interface isn't yet finalised
fe47da7b
MW
391 virtual wxInputStream* WXZIPFIX OpenDecompressor(wxInputStream& stream);
392 virtual bool WXZIPFIX CloseDecompressor(wxInputStream *decomp);
00375592
VZ
393
394private:
395 void Init();
fe47da7b 396 void Init(const wxString& file);
8fc574b4
MW
397#if WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
398 static wxInputStream *OpenFile(const wxString& archive);
399#endif
00375592 400
e3a10e0c
MW
401 wxArchiveEntry *DoGetNextEntry() { return GetNextEntry(); }
402
403 bool WXZIPFIX OpenEntry(wxArchiveEntry& entry);
404
00375592
VZ
405 wxStreamError ReadLocal(bool readEndRec = false);
406 wxStreamError ReadCentral();
407
408 wxUint32 ReadSignature();
409 bool FindEndRecord();
410 bool LoadEndRecord();
ce7208d4 411
00375592
VZ
412 bool AtHeader() const { return m_headerSize == 0; }
413 bool AfterHeader() const { return m_headerSize > 0 && !m_decomp; }
414 bool IsOpened() const { return m_decomp != NULL; }
415
416 wxZipStreamLink *MakeLink(wxZipOutputStream *out);
417
418 bool DoOpen(wxZipEntry *entry = NULL, bool raw = false);
419 bool OpenDecompressor(bool raw = false);
420
421 class wxStoredInputStream *m_store;
422 class wxZlibInputStream2 *m_inflate;
423 class wxRawInputStream *m_rawin;
00375592
VZ
424 wxZipEntry m_entry;
425 bool m_raw;
426 size_t m_headerSize;
427 wxUint32 m_crcAccumulator;
428 wxInputStream *m_decomp;
429 bool m_parentSeekable;
430 class wxZipWeakLinks *m_weaklinks;
431 class wxZipStreamLink *m_streamlink;
432 wxFileOffset m_offsetAdjustment;
433 wxFileOffset m_position;
434 wxUint32 m_signature;
435 size_t m_TotalEntries;
436 wxString m_Comment;
437
438 friend bool wxZipOutputStream::CopyEntry(
439 wxZipEntry *entry, wxZipInputStream& inputStream);
440 friend bool wxZipOutputStream::CopyArchiveMetaData(
441 wxZipInputStream& inputStream);
22f3361e 442
5c80cef4 443#if WXWIN_COMPATIBILITY_2_6
d13a08ab 444 bool m_allowSeeking;
5c80cef4 445 friend class wxArchiveFSHandler;
d13a08ab
MW
446#endif
447
c0c133e1 448 wxDECLARE_NO_COPY_CLASS(wxZipInputStream);
5526e819
VS
449};
450
451
81f90336
MW
452/////////////////////////////////////////////////////////////////////////////
453// Iterators
454
455#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
456typedef wxArchiveIterator<wxZipInputStream> wxZipIter;
457typedef wxArchiveIterator<wxZipInputStream,
458 std::pair<wxString, wxZipEntry*> > wxZipPairIter;
459#endif
460
461
00375592
VZ
462/////////////////////////////////////////////////////////////////////////////
463// wxZipClassFactory
5526e819 464
00375592
VZ
465class WXDLLIMPEXP_BASE wxZipClassFactory : public wxArchiveClassFactory
466{
467public:
81f90336
MW
468 typedef wxZipEntry entry_type;
469 typedef wxZipInputStream instream_type;
470 typedef wxZipOutputStream outstream_type;
471 typedef wxZipNotifier notifier_type;
472#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
473 typedef wxZipIter iter_type;
474 typedef wxZipPairIter pairiter_type;
475#endif
476
8fc574b4
MW
477 wxZipClassFactory();
478
00375592
VZ
479 wxZipEntry *NewEntry() const
480 { return new wxZipEntry; }
481 wxZipInputStream *NewStream(wxInputStream& stream) const
482 { return new wxZipInputStream(stream, GetConv()); }
483 wxZipOutputStream *NewStream(wxOutputStream& stream) const
484 { return new wxZipOutputStream(stream, -1, GetConv()); }
8fc574b4
MW
485 wxZipInputStream *NewStream(wxInputStream *stream) const
486 { return new wxZipInputStream(stream, GetConv()); }
487 wxZipOutputStream *NewStream(wxOutputStream *stream) const
488 { return new wxZipOutputStream(stream, -1, GetConv()); }
00375592
VZ
489
490 wxString GetInternalName(const wxString& name,
491 wxPathFormat format = wxPATH_NATIVE) const
492 { return wxZipEntry::GetInternalName(name, format); }
493
8fc574b4
MW
494 const wxChar * const *GetProtocols(wxStreamProtocolType type
495 = wxSTREAM_PROTOCOL) const;
496
00375592
VZ
497protected:
498 wxArchiveEntry *DoNewEntry() const
499 { return NewEntry(); }
500 wxArchiveInputStream *DoNewStream(wxInputStream& stream) const
501 { return NewStream(stream); }
502 wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const
503 { return NewStream(stream); }
8fc574b4
MW
504 wxArchiveInputStream *DoNewStream(wxInputStream *stream) const
505 { return NewStream(stream); }
506 wxArchiveOutputStream *DoNewStream(wxOutputStream *stream) const
507 { return NewStream(stream); }
00375592
VZ
508
509private:
510 DECLARE_DYNAMIC_CLASS(wxZipClassFactory)
511};
512
513
00375592
VZ
514/////////////////////////////////////////////////////////////////////////////
515// wxZipEntry inlines
516
f44eaed6 517inline bool wxZipEntry::IsText() const
00375592
VZ
518{
519 return (m_InternalAttributes & TEXT_ATTR) != 0;
520}
521
f44eaed6 522inline bool wxZipEntry::IsDir() const
00375592
VZ
523{
524 return (m_ExternalAttributes & wxZIP_A_SUBDIR) != 0;
525}
526
f44eaed6 527inline bool wxZipEntry::IsReadOnly() const
00375592
VZ
528{
529 return (m_ExternalAttributes & wxZIP_A_RDONLY) != 0;
530}
531
f44eaed6 532inline bool wxZipEntry::IsMadeByUnix() const
00375592
VZ
533{
534 const int pattern =
535 (1 << wxZIP_SYSTEM_OPENVMS) |
536 (1 << wxZIP_SYSTEM_UNIX) |
537 (1 << wxZIP_SYSTEM_ATARI_ST) |
538 (1 << wxZIP_SYSTEM_ACORN_RISC) |
539 (1 << wxZIP_SYSTEM_BEOS) | (1 << wxZIP_SYSTEM_TANDEM);
540
541 // note: some unix zippers put madeby = dos
542 return (m_SystemMadeBy == wxZIP_SYSTEM_MSDOS
543 && (m_ExternalAttributes & ~0xFFFF))
544 || ((pattern >> m_SystemMadeBy) & 1);
545}
546
f44eaed6 547inline void wxZipEntry::SetIsText(bool isText)
00375592
VZ
548{
549 if (isText)
550 m_InternalAttributes |= TEXT_ATTR;
551 else
552 m_InternalAttributes &= ~TEXT_ATTR;
553}
554
f44eaed6 555inline void wxZipEntry::SetIsReadOnly(bool isReadOnly)
00375592
VZ
556{
557 if (isReadOnly)
558 SetMode(GetMode() & ~0222);
559 else
560 SetMode(GetMode() | 0200);
561}
562
f44eaed6
RN
563inline void wxZipEntry::SetName(const wxString& name,
564 wxPathFormat format /*=wxPATH_NATIVE*/)
00375592
VZ
565{
566 bool isDir;
567 m_Name = GetInternalName(name, format, &isDir);
568 SetIsDir(isDir);
569}
570
571
5410f572 572#endif // wxUSE_ZIPSTREAM
00375592
VZ
573
574#endif // _WX_WXZIPSTREAM_H__