+ wxZipEntry(const wxString& name = wxEmptyString,
+ const wxDateTime& dt = wxDateTime::Now(),
+ wxFileOffset size = wxInvalidOffset);
+ virtual ~wxZipEntry();
+
+ wxZipEntry(const wxZipEntry& entry);
+ wxZipEntry& operator=(const wxZipEntry& entry);
+
+ // Get accessors
+ wxDateTime GetDateTime() const { return m_DateTime; }
+ wxFileOffset GetSize() const { return m_Size; }
+ wxFileOffset GetOffset() const { return m_Offset; }
+ wxString GetInternalName() const { return m_Name; }
+ int GetMethod() const { return m_Method; }
+ int GetFlags() const { return m_Flags; }
+ wxUint32 GetCrc() const { return m_Crc; }
+ wxFileOffset GetCompressedSize() const { return m_CompressedSize; }
+ int GetSystemMadeBy() const { return m_SystemMadeBy; }
+ wxString GetComment() const { return m_Comment; }
+ wxUint32 GetExternalAttributes() const { return m_ExternalAttributes; }
+ wxPathFormat GetInternalFormat() const { return wxPATH_UNIX; }
+ int GetMode() const;
+ const char *GetLocalExtra() const;
+ size_t GetLocalExtraLen() const;
+ const char *GetExtra() const;
+ size_t GetExtraLen() const;
+ wxString GetName(wxPathFormat format = wxPATH_NATIVE) const;
+
+ // is accessors
+ inline bool IsDir() const;
+ inline bool IsText() const;
+ inline bool IsReadOnly() const;
+ inline bool IsMadeByUnix() const;
+
+ // set accessors
+ void SetDateTime(const wxDateTime& dt) { m_DateTime = dt; }
+ void SetSize(wxFileOffset size) { m_Size = size; }
+ void SetMethod(int method) { m_Method = (wxUint16)method; }
+ void SetComment(const wxString& comment) { m_Comment = comment; }
+ void SetExternalAttributes(wxUint32 attr ) { m_ExternalAttributes = attr; }
+ void SetSystemMadeBy(int system);
+ void SetMode(int mode);
+ void SetExtra(const char *extra, size_t len);
+ void SetLocalExtra(const char *extra, size_t len);
+
+ inline void SetName(const wxString& name,
+ wxPathFormat format = wxPATH_NATIVE);
+
+ static wxString GetInternalName(const wxString& name,
+ wxPathFormat format = wxPATH_NATIVE,
+ bool *pIsDir = NULL);
+
+ // set is accessors
+ void SetIsDir(bool isDir = true);
+ inline void SetIsReadOnly(bool isReadOnly = true);
+ inline void SetIsText(bool isText = true);
+
+ wxZipEntry *Clone() const { return ZipClone(); }
+
+ void SetNotifier(wxZipNotifier& notifier);
+ void UnsetNotifier();
+
+protected:
+ // Internal attributes
+ enum { TEXT_ATTR = 1 };
+
+ // protected Get accessors
+ int GetVersionNeeded() const { return m_VersionNeeded; }
+ wxFileOffset GetKey() const { return m_Key; }
+ int GetVersionMadeBy() const { return m_VersionMadeBy; }
+ int GetDiskStart() const { return m_DiskStart; }
+ int GetInternalAttributes() const { return m_InternalAttributes; }
+
+ void SetVersionNeeded(int version) { m_VersionNeeded = (wxUint16)version; }
+ void SetOffset(wxFileOffset offset) { m_Offset = offset; }
+ void SetFlags(int flags) { m_Flags = (wxUint16)flags; }
+ void SetVersionMadeBy(int version) { m_VersionMadeBy = (wxUint8)version; }
+ void SetCrc(wxUint32 crc) { m_Crc = crc; }
+ void SetCompressedSize(wxFileOffset size) { m_CompressedSize = size; }
+ void SetKey(wxFileOffset offset) { m_Key = offset; }
+ void SetDiskStart(int start) { m_DiskStart = (wxUint16)start; }
+ void SetInternalAttributes(int attr) { m_InternalAttributes = (wxUint16)attr; }
+
+ virtual wxZipEntry *ZipClone() const { return new wxZipEntry(*this); }
+
+ void Notify();
+
+private:
+ wxArchiveEntry* DoClone() const { return ZipClone(); }
+
+ size_t ReadLocal(wxInputStream& stream, wxMBConv& conv);
+ size_t WriteLocal(wxOutputStream& stream, wxMBConv& conv) const;
+
+ size_t ReadCentral(wxInputStream& stream, wxMBConv& conv);
+ size_t WriteCentral(wxOutputStream& stream, wxMBConv& conv) const;
+
+ size_t ReadDescriptor(wxInputStream& stream);
+ size_t WriteDescriptor(wxOutputStream& stream, wxUint32 crc,
+ wxFileOffset compressedSize, wxFileOffset size);
+
+ wxUint8 m_SystemMadeBy; // one of enum wxZipSystem
+ wxUint8 m_VersionMadeBy; // major * 10 + minor
+
+ wxUint16 m_VersionNeeded; // ver needed to extract (20 i.e. v2.0)
+ wxUint16 m_Flags;
+ wxUint16 m_Method; // compression method (one of wxZipMethod)
+ wxDateTime m_DateTime;
+ wxUint32 m_Crc;
+ wxFileOffset m_CompressedSize;
+ wxFileOffset m_Size;
+ wxString m_Name; // in internal format
+ wxFileOffset m_Key; // the original offset for copied entries
+ wxFileOffset m_Offset; // file offset of the entry
+
+ wxString m_Comment;
+ wxUint16 m_DiskStart; // for multidisk archives, not unsupported
+ wxUint16 m_InternalAttributes; // bit 0 set for text files
+ wxUint32 m_ExternalAttributes; // system specific depends on SystemMadeBy
+
+ class wxZipMemory *m_Extra;
+ class wxZipMemory *m_LocalExtra;
+
+ wxZipNotifier *m_zipnotifier;
+ class wxZipWeakLinks *m_backlink;
+
+ friend class wxZipInputStream;
+ friend class wxZipOutputStream;
+
+ DECLARE_DYNAMIC_CLASS(wxZipEntry)
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+// wxZipOutputStream
+
+WX_DECLARE_LIST_WITH_DECL(wxZipEntry, _wxZipEntryList, class WXDLLIMPEXP_BASE);
+
+class WXDLLIMPEXP_BASE wxZipOutputStream : public wxArchiveOutputStream
+{
+public:
+ wxZipOutputStream(wxOutputStream& stream,
+ int level = -1,
+ wxMBConv& conv = wxConvLocal);
+ virtual ~wxZipOutputStream();
+
+ bool PutNextEntry(wxZipEntry *entry) { return DoCreate(entry); }
+
+ bool PutNextEntry(const wxString& name,
+ const wxDateTime& dt = wxDateTime::Now(),
+ wxFileOffset size = wxInvalidOffset);
+
+ bool PutNextDirEntry(const wxString& name,
+ const wxDateTime& dt = wxDateTime::Now());
+
+ bool CopyEntry(wxZipEntry *entry, wxZipInputStream& inputStream);
+ bool CopyArchiveMetaData(wxZipInputStream& inputStream);
+
+ void Sync();
+ bool CloseEntry();
+ bool Close();
+
+ void SetComment(const wxString& comment) { m_Comment = comment; }
+
+ int GetLevel() const { return m_level; }
+ void SetLevel(int level);
+
+protected:
+ virtual size_t OnSysWrite(const void *buffer, size_t size);
+ virtual wxFileOffset OnSysTell() const { return m_entrySize; }
+
+ struct Buffer { const char *m_data; size_t m_size; };
+ virtual wxOutputStream *OpenCompressor(wxOutputStream& stream,
+ wxZipEntry& entry,
+ const Buffer bufs[]);
+ virtual bool CloseCompressor(wxOutputStream *comp);
+
+ bool IsParentSeekable() const { return m_offsetAdjustment
+ != wxInvalidOffset; }
+
+private:
+ bool PutNextEntry(wxArchiveEntry *entry);
+ bool CopyEntry(wxArchiveEntry *entry, wxArchiveInputStream& stream);
+ bool CopyArchiveMetaData(wxArchiveInputStream& stream);
+
+ bool IsOpened() const { return m_comp || m_pending; }
+
+ bool DoCreate(wxZipEntry *entry, bool raw = false);
+ void CreatePendingEntry(const void *buffer, size_t size);
+ void CreatePendingEntry();
+
+ class wxStoredOutputStream *m_store;
+ class wxZlibOutputStream2 *m_deflate;
+ class wxZipStreamLink *m_backlink;
+ _wxZipEntryList m_entries;
+ char *m_initialData;
+ size_t m_initialSize;
+ wxZipEntry *m_pending;
+ bool m_raw;
+ wxFileOffset m_headerOffset;
+ size_t m_headerSize;
+ wxFileOffset m_entrySize;
+ wxUint32 m_crcAccumulator;
+ wxOutputStream *m_comp;
+ int m_level;
+ wxFileOffset m_offsetAdjustment;
+ wxString m_Comment;
+
+ DECLARE_NO_COPY_CLASS(wxZipOutputStream)
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+// wxZipInputStream
+
+class WXDLLIMPEXP_BASE wxZipInputStream : public wxArchiveInputStream
+{
+public:
+ typedef wxZipEntry entry_type;
+
+ wxZipInputStream(wxInputStream& stream, wxMBConv& conv = wxConvLocal);