zipstrm.h 19 KB

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