/////////////////////////////////////////////////////////////////////////////
-// Name: zipstrm.h
+// Name: wx/zipstrm.h
// Purpose: Streams for Zip files
// Author: Mike Wetherell
-// RCS-ID: $Id$
// Copyright: (c) Mike Wetherell
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h"
-#if wxUSE_ZLIB && wxUSE_STREAMS && wxUSE_ZIPSTREAM
+#if wxUSE_ZIPSTREAM
#include "wx/archive.h"
-#include "wx/hashmap.h"
#include "wx/filename.h"
// some methods from wxZipInputStream and wxZipOutputStream stream do not get
|| !defined __GNUC_MINOR__ \
|| !defined __GNUC_PATCHLEVEL__ \
|| __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 30402)
-#define WXZIPFIX WXDLLIMPEXP_BASE
+#define WXZIPFIX WXDLLIMPEXP_BASE
#else
#define WXZIPFIX
#endif
};
// Originating File-System.
-//
+//
// These are Pkware's values. Note that Info-zip disagree on some of them,
// most notably NTFS.
//
// Forward decls
//
-class WXDLLIMPEXP_BASE wxZipEntry;
-class WXDLLIMPEXP_BASE wxZipInputStream;
+class WXDLLIMPEXP_FWD_BASE wxZipEntry;
+class WXDLLIMPEXP_FWD_BASE wxZipInputStream;
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// wxZipOutputStream
+// wxZipOutputStream
-WX_DECLARE_LIST_WITH_DECL(wxZipEntry, wx__ZipEntryList, class WXDLLIMPEXP_BASE);
+WX_DECLARE_LIST_WITH_DECL(wxZipEntry, wxZipEntryList_, class WXDLLIMPEXP_BASE);
class WXDLLIMPEXP_BASE wxZipOutputStream : public wxArchiveOutputStream
{
wxZipOutputStream(wxOutputStream& stream,
int level = -1,
wxMBConv& conv = wxConvLocal);
+ wxZipOutputStream(wxOutputStream *stream,
+ int level = -1,
+ wxMBConv& conv = wxConvLocal);
virtual WXZIPFIX ~wxZipOutputStream();
bool PutNextEntry(wxZipEntry *entry) { return DoCreate(entry); }
int GetLevel() const { return m_level; }
void WXZIPFIX SetLevel(int level);
-
+
protected:
virtual size_t WXZIPFIX OnSysWrite(const void *buffer, size_t size);
virtual wxFileOffset OnSysTell() const { return m_entrySize; }
{ return m_offsetAdjustment != wxInvalidOffset; }
private:
+ void Init(int level);
+
bool WXZIPFIX PutNextEntry(wxArchiveEntry *entry);
bool WXZIPFIX CopyEntry(wxArchiveEntry *entry, wxArchiveInputStream& stream);
bool WXZIPFIX CopyArchiveMetaData(wxArchiveInputStream& stream);
class wxStoredOutputStream *m_store;
class wxZlibOutputStream2 *m_deflate;
class wxZipStreamLink *m_backlink;
- wx__ZipEntryList m_entries;
+ wxZipEntryList_ m_entries;
char *m_initialData;
size_t m_initialSize;
wxZipEntry *m_pending;
int m_level;
wxFileOffset m_offsetAdjustment;
wxString m_Comment;
+ bool m_endrecWritten;
- DECLARE_NO_COPY_CLASS(wxZipOutputStream)
+ wxDECLARE_NO_COPY_CLASS(wxZipOutputStream);
};
/////////////////////////////////////////////////////////////////////////////
-// wxZipInputStream
+// wxZipInputStream
class WXDLLIMPEXP_BASE wxZipInputStream : public wxArchiveInputStream
{
typedef wxZipEntry entry_type;
wxZipInputStream(wxInputStream& stream, wxMBConv& conv = wxConvLocal);
+ wxZipInputStream(wxInputStream *stream, wxMBConv& conv = wxConvLocal);
-#if 1 //WXWIN_COMPATIBILITY_2_6
+#if WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
wxZipInputStream(const wxString& archive, const wxString& file)
: wxArchiveInputStream(OpenFile(archive), wxConvLocal) { Init(file); }
#endif
size_t WXZIPFIX OnSysRead(void *buffer, size_t size);
wxFileOffset OnSysTell() const { return m_decomp ? m_decomp->TellI() : 0; }
-#if 1 //WXWIN_COMPATIBILITY_2_6
+#if WXWIN_COMPATIBILITY_2_6
wxFileOffset WXZIPFIX OnSysSeek(wxFileOffset seek, wxSeekMode mode);
#endif
private:
void Init();
void Init(const wxString& file);
- wxInputStream& OpenFile(const wxString& archive);
+#if WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
+ static wxInputStream *OpenFile(const wxString& archive);
+#endif
wxArchiveEntry *DoGetNextEntry() { return GetNextEntry(); }
wxUint32 ReadSignature();
bool FindEndRecord();
bool LoadEndRecord();
-
+
bool AtHeader() const { return m_headerSize == 0; }
bool AfterHeader() const { return m_headerSize > 0 && !m_decomp; }
bool IsOpened() const { return m_decomp != NULL; }
class wxStoredInputStream *m_store;
class wxZlibInputStream2 *m_inflate;
class wxRawInputStream *m_rawin;
- class wxFFileInputStream *m_ffile;
wxZipEntry m_entry;
bool m_raw;
size_t m_headerSize;
friend bool wxZipOutputStream::CopyArchiveMetaData(
wxZipInputStream& inputStream);
-#if 1 //WXWIN_COMPATIBILITY_2_6
+#if WXWIN_COMPATIBILITY_2_6
bool m_allowSeeking;
- friend class wxZipFSInputStream;
+ friend class wxArchiveFSHandler;
#endif
- DECLARE_NO_COPY_CLASS(wxZipInputStream)
+ wxDECLARE_NO_COPY_CLASS(wxZipInputStream);
};
typedef wxZipPairIter pairiter_type;
#endif
+ wxZipClassFactory();
+
wxZipEntry *NewEntry() const
{ return new wxZipEntry; }
wxZipInputStream *NewStream(wxInputStream& stream) const
{ return new wxZipInputStream(stream, GetConv()); }
wxZipOutputStream *NewStream(wxOutputStream& stream) const
{ return new wxZipOutputStream(stream, -1, GetConv()); }
+ wxZipInputStream *NewStream(wxInputStream *stream) const
+ { return new wxZipInputStream(stream, GetConv()); }
+ wxZipOutputStream *NewStream(wxOutputStream *stream) const
+ { return new wxZipOutputStream(stream, -1, GetConv()); }
wxString GetInternalName(const wxString& name,
wxPathFormat format = wxPATH_NATIVE) const
{ return wxZipEntry::GetInternalName(name, format); }
+ const wxChar * const *GetProtocols(wxStreamProtocolType type
+ = wxSTREAM_PROTOCOL) const;
+
protected:
wxArchiveEntry *DoNewEntry() const
{ return NewEntry(); }
{ return NewStream(stream); }
wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const
{ return NewStream(stream); }
+ wxArchiveInputStream *DoNewStream(wxInputStream *stream) const
+ { return NewStream(stream); }
+ wxArchiveOutputStream *DoNewStream(wxOutputStream *stream) const
+ { return NewStream(stream); }
private:
DECLARE_DYNAMIC_CLASS(wxZipClassFactory)
}
-#endif // wxUSE_ZLIB && wxUSE_STREAMS && wxUSE_ZIPSTREAM
+#endif // wxUSE_ZIPSTREAM
#endif // _WX_WXZIPSTREAM_H__