Implement new features for finding class factories. Put seek inside 2.6 compat ifdef.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42509 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -270,7 +270,7 @@ private:
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// 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
|
class WXDLLIMPEXP_BASE wxZipOutputStream : public wxArchiveOutputStream
|
||||||
{
|
{
|
||||||
@@ -278,6 +278,9 @@ public:
|
|||||||
wxZipOutputStream(wxOutputStream& stream,
|
wxZipOutputStream(wxOutputStream& stream,
|
||||||
int level = -1,
|
int level = -1,
|
||||||
wxMBConv& conv = wxConvLocal);
|
wxMBConv& conv = wxConvLocal);
|
||||||
|
wxZipOutputStream(wxOutputStream *stream,
|
||||||
|
int level = -1,
|
||||||
|
wxMBConv& conv = wxConvLocal);
|
||||||
virtual WXZIPFIX ~wxZipOutputStream();
|
virtual WXZIPFIX ~wxZipOutputStream();
|
||||||
|
|
||||||
bool PutNextEntry(wxZipEntry *entry) { return DoCreate(entry); }
|
bool PutNextEntry(wxZipEntry *entry) { return DoCreate(entry); }
|
||||||
@@ -316,6 +319,8 @@ protected:
|
|||||||
{ return m_offsetAdjustment != wxInvalidOffset; }
|
{ return m_offsetAdjustment != wxInvalidOffset; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void Init(int level);
|
||||||
|
|
||||||
bool WXZIPFIX PutNextEntry(wxArchiveEntry *entry);
|
bool WXZIPFIX PutNextEntry(wxArchiveEntry *entry);
|
||||||
bool WXZIPFIX CopyEntry(wxArchiveEntry *entry, wxArchiveInputStream& stream);
|
bool WXZIPFIX CopyEntry(wxArchiveEntry *entry, wxArchiveInputStream& stream);
|
||||||
bool WXZIPFIX CopyArchiveMetaData(wxArchiveInputStream& stream);
|
bool WXZIPFIX CopyArchiveMetaData(wxArchiveInputStream& stream);
|
||||||
@@ -329,7 +334,7 @@ private:
|
|||||||
class wxStoredOutputStream *m_store;
|
class wxStoredOutputStream *m_store;
|
||||||
class wxZlibOutputStream2 *m_deflate;
|
class wxZlibOutputStream2 *m_deflate;
|
||||||
class wxZipStreamLink *m_backlink;
|
class wxZipStreamLink *m_backlink;
|
||||||
wx__ZipEntryList m_entries;
|
wxZipEntryList_ m_entries;
|
||||||
char *m_initialData;
|
char *m_initialData;
|
||||||
size_t m_initialSize;
|
size_t m_initialSize;
|
||||||
wxZipEntry *m_pending;
|
wxZipEntry *m_pending;
|
||||||
@@ -356,8 +361,9 @@ public:
|
|||||||
typedef wxZipEntry entry_type;
|
typedef wxZipEntry entry_type;
|
||||||
|
|
||||||
wxZipInputStream(wxInputStream& stream, wxMBConv& conv = wxConvLocal);
|
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)
|
wxZipInputStream(const wxString& archive, const wxString& file)
|
||||||
: wxArchiveInputStream(OpenFile(archive), wxConvLocal) { Init(file); }
|
: wxArchiveInputStream(OpenFile(archive), wxConvLocal) { Init(file); }
|
||||||
#endif
|
#endif
|
||||||
@@ -378,7 +384,7 @@ protected:
|
|||||||
size_t WXZIPFIX OnSysRead(void *buffer, size_t size);
|
size_t WXZIPFIX OnSysRead(void *buffer, size_t size);
|
||||||
wxFileOffset OnSysTell() const { return m_decomp ? m_decomp->TellI() : 0; }
|
wxFileOffset OnSysTell() const { return m_decomp ? m_decomp->TellI() : 0; }
|
||||||
|
|
||||||
#if 1 //WXWIN_COMPATIBILITY_2_6
|
#if WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
|
||||||
wxFileOffset WXZIPFIX OnSysSeek(wxFileOffset seek, wxSeekMode mode);
|
wxFileOffset WXZIPFIX OnSysSeek(wxFileOffset seek, wxSeekMode mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -389,7 +395,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void Init();
|
void Init();
|
||||||
void Init(const wxString& file);
|
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(); }
|
wxArchiveEntry *DoGetNextEntry() { return GetNextEntry(); }
|
||||||
|
|
||||||
@@ -414,7 +422,6 @@ private:
|
|||||||
class wxStoredInputStream *m_store;
|
class wxStoredInputStream *m_store;
|
||||||
class wxZlibInputStream2 *m_inflate;
|
class wxZlibInputStream2 *m_inflate;
|
||||||
class wxRawInputStream *m_rawin;
|
class wxRawInputStream *m_rawin;
|
||||||
class wxFFileInputStream *m_ffile;
|
|
||||||
wxZipEntry m_entry;
|
wxZipEntry m_entry;
|
||||||
bool m_raw;
|
bool m_raw;
|
||||||
size_t m_headerSize;
|
size_t m_headerSize;
|
||||||
@@ -434,7 +441,7 @@ private:
|
|||||||
friend bool wxZipOutputStream::CopyArchiveMetaData(
|
friend bool wxZipOutputStream::CopyArchiveMetaData(
|
||||||
wxZipInputStream& inputStream);
|
wxZipInputStream& inputStream);
|
||||||
|
|
||||||
#if 1 //WXWIN_COMPATIBILITY_2_6
|
#if WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
|
||||||
bool m_allowSeeking;
|
bool m_allowSeeking;
|
||||||
friend class wxZipFSInputStream;
|
friend class wxZipFSInputStream;
|
||||||
#endif
|
#endif
|
||||||
@@ -468,17 +475,26 @@ public:
|
|||||||
typedef wxZipPairIter pairiter_type;
|
typedef wxZipPairIter pairiter_type;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxZipClassFactory();
|
||||||
|
|
||||||
wxZipEntry *NewEntry() const
|
wxZipEntry *NewEntry() const
|
||||||
{ return new wxZipEntry; }
|
{ return new wxZipEntry; }
|
||||||
wxZipInputStream *NewStream(wxInputStream& stream) const
|
wxZipInputStream *NewStream(wxInputStream& stream) const
|
||||||
{ return new wxZipInputStream(stream, GetConv()); }
|
{ return new wxZipInputStream(stream, GetConv()); }
|
||||||
wxZipOutputStream *NewStream(wxOutputStream& stream) const
|
wxZipOutputStream *NewStream(wxOutputStream& stream) const
|
||||||
{ return new wxZipOutputStream(stream, -1, GetConv()); }
|
{ 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,
|
wxString GetInternalName(const wxString& name,
|
||||||
wxPathFormat format = wxPATH_NATIVE) const
|
wxPathFormat format = wxPATH_NATIVE) const
|
||||||
{ return wxZipEntry::GetInternalName(name, format); }
|
{ return wxZipEntry::GetInternalName(name, format); }
|
||||||
|
|
||||||
|
const wxChar * const *GetProtocols(wxStreamProtocolType type
|
||||||
|
= wxSTREAM_PROTOCOL) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxArchiveEntry *DoNewEntry() const
|
wxArchiveEntry *DoNewEntry() const
|
||||||
{ return NewEntry(); }
|
{ return NewEntry(); }
|
||||||
@@ -486,6 +502,10 @@ protected:
|
|||||||
{ return NewStream(stream); }
|
{ return NewStream(stream); }
|
||||||
wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const
|
wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const
|
||||||
{ return NewStream(stream); }
|
{ return NewStream(stream); }
|
||||||
|
wxArchiveInputStream *DoNewStream(wxInputStream *stream) const
|
||||||
|
{ return NewStream(stream); }
|
||||||
|
wxArchiveOutputStream *DoNewStream(wxOutputStream *stream) const
|
||||||
|
{ return NewStream(stream); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxZipClassFactory)
|
DECLARE_DYNAMIC_CLASS(wxZipClassFactory)
|
||||||
|
@@ -38,7 +38,7 @@ class wxZipFSInputStream : public wxZipInputStream
|
|||||||
: wxZipInputStream(*file->GetStream())
|
: wxZipInputStream(*file->GetStream())
|
||||||
{
|
{
|
||||||
m_file = file;
|
m_file = file;
|
||||||
#if 1 //WXWIN_COMPATIBILITY_2_6
|
#if WXWIN_COMPATIBILITY_2_6
|
||||||
m_allowSeeking = true;
|
m_allowSeeking = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
#include "wx/buffer.h"
|
#include "wx/buffer.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/ptr_scpd.h"
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
#include "wx/link.h"
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
// value for the 'version needed to extract' field (20 means 2.0)
|
// value for the 'version needed to extract' field (20 means 2.0)
|
||||||
@@ -77,8 +76,6 @@ enum {
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxZipEntry, wxArchiveEntry)
|
IMPLEMENT_DYNAMIC_CLASS(wxZipEntry, wxArchiveEntry)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxZipClassFactory, wxArchiveClassFactory)
|
IMPLEMENT_DYNAMIC_CLASS(wxZipClassFactory, wxArchiveClassFactory)
|
||||||
|
|
||||||
wxFORCE_LINK_THIS_MODULE(zipstrm)
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Helpers
|
// Helpers
|
||||||
@@ -139,6 +136,34 @@ static wxFileOffset QuietSeek(wxInputStream& stream, wxFileOffset pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Class factory
|
||||||
|
|
||||||
|
wxZipClassFactory g_wxZipClassFactory;
|
||||||
|
|
||||||
|
wxZipClassFactory::wxZipClassFactory()
|
||||||
|
{
|
||||||
|
if (this == &g_wxZipClassFactory)
|
||||||
|
PushFront();
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxChar * const *
|
||||||
|
wxZipClassFactory::GetProtocols(wxStreamProtocolType type) const
|
||||||
|
{
|
||||||
|
static const wxChar *protocols[] = { _T("zip"), NULL };
|
||||||
|
static const wxChar *mimetypes[] = { _T("application/zip"), NULL };
|
||||||
|
static const wxChar *fileexts[] = { _T(".zip"), _T(".htb"), NULL };
|
||||||
|
static const wxChar *empty[] = { NULL };
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case wxSTREAM_PROTOCOL: return protocols;
|
||||||
|
case wxSTREAM_MIMETYPE: return mimetypes;
|
||||||
|
case wxSTREAM_FILEEXTENSION: return fileexts;
|
||||||
|
default: return empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Read a zip header
|
// Read a zip header
|
||||||
|
|
||||||
@@ -614,7 +639,7 @@ static void Unique(wxZipMemory*& zm, size_t size)
|
|||||||
// Collection of weak references to entries
|
// Collection of weak references to entries
|
||||||
|
|
||||||
WX_DECLARE_HASH_MAP(long, wxZipEntry*, wxIntegerHash,
|
WX_DECLARE_HASH_MAP(long, wxZipEntry*, wxIntegerHash,
|
||||||
wxIntegerEqual, wx__OffsetZipEntryMap);
|
wxIntegerEqual, wxOffsetZipEntryMap_);
|
||||||
|
|
||||||
class wxZipWeakLinks
|
class wxZipWeakLinks
|
||||||
{
|
{
|
||||||
@@ -635,10 +660,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
~wxZipWeakLinks() { wxASSERT(IsEmpty()); }
|
~wxZipWeakLinks() { wxASSERT(IsEmpty()); }
|
||||||
|
|
||||||
typedef wx__OffsetZipEntryMap::key_type key_type;
|
typedef wxOffsetZipEntryMap_::key_type key_type;
|
||||||
|
|
||||||
int m_ref;
|
int m_ref;
|
||||||
wx__OffsetZipEntryMap m_entries;
|
wxOffsetZipEntryMap_ m_entries;
|
||||||
|
|
||||||
wxSUPPRESS_GCC_PRIVATE_DTOR_WARNING(wxZipWeakLinks)
|
wxSUPPRESS_GCC_PRIVATE_DTOR_WARNING(wxZipWeakLinks)
|
||||||
};
|
};
|
||||||
@@ -652,7 +677,7 @@ wxZipWeakLinks *wxZipWeakLinks::AddEntry(wxZipEntry *entry, wxFileOffset key)
|
|||||||
|
|
||||||
wxZipEntry *wxZipWeakLinks::GetEntry(wxFileOffset key) const
|
wxZipEntry *wxZipWeakLinks::GetEntry(wxFileOffset key) const
|
||||||
{
|
{
|
||||||
wx__OffsetZipEntryMap::const_iterator it =
|
wxOffsetZipEntryMap_::const_iterator it =
|
||||||
m_entries.find(wx_truncate_cast(key_type, key));
|
m_entries.find(wx_truncate_cast(key_type, key));
|
||||||
return it != m_entries.end() ? it->second : NULL;
|
return it != m_entries.end() ? it->second : NULL;
|
||||||
}
|
}
|
||||||
@@ -1279,8 +1304,8 @@ private:
|
|||||||
// Input stream
|
// Input stream
|
||||||
|
|
||||||
// leave the default wxZipEntryPtr free for users
|
// leave the default wxZipEntryPtr free for users
|
||||||
wxDECLARE_SCOPED_PTR(wxZipEntry, wx__ZipEntryPtr)
|
wxDECLARE_SCOPED_PTR(wxZipEntry, wxZipEntryPtr_)
|
||||||
wxDEFINE_SCOPED_PTR (wxZipEntry, wx__ZipEntryPtr)
|
wxDEFINE_SCOPED_PTR (wxZipEntry, wxZipEntryPtr_)
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
//
|
//
|
||||||
@@ -1291,7 +1316,14 @@ wxZipInputStream::wxZipInputStream(wxInputStream& stream,
|
|||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1 //WXWIN_COMPATIBILITY_2_6
|
wxZipInputStream::wxZipInputStream(wxInputStream *stream,
|
||||||
|
wxMBConv& conv /*=wxConvLocal*/)
|
||||||
|
: wxArchiveInputStream(stream, conv)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
|
||||||
|
|
||||||
// Part of the compatibility constructor, which has been made inline to
|
// Part of the compatibility constructor, which has been made inline to
|
||||||
// avoid a problem with it not being exported by mingw 3.2.3
|
// avoid a problem with it not being exported by mingw 3.2.3
|
||||||
@@ -1302,10 +1334,11 @@ void wxZipInputStream::Init(const wxString& file)
|
|||||||
wxLogNull nolog;
|
wxLogNull nolog;
|
||||||
Init();
|
Init();
|
||||||
m_allowSeeking = true;
|
m_allowSeeking = true;
|
||||||
m_ffile = wx_static_cast(wxFFileInputStream*, m_parent_i_stream);
|
wxFFileInputStream *ffile;
|
||||||
wx__ZipEntryPtr entry;
|
ffile = wx_static_cast(wxFFileInputStream*, m_parent_i_stream);
|
||||||
|
wxZipEntryPtr_ entry;
|
||||||
|
|
||||||
if (m_ffile->Ok()) {
|
if (ffile->Ok()) {
|
||||||
do {
|
do {
|
||||||
entry.reset(GetNextEntry());
|
entry.reset(GetNextEntry());
|
||||||
}
|
}
|
||||||
@@ -1316,13 +1349,13 @@ void wxZipInputStream::Init(const wxString& file)
|
|||||||
m_lasterror = wxSTREAM_READ_ERROR;
|
m_lasterror = wxSTREAM_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxInputStream& wxZipInputStream::OpenFile(const wxString& archive)
|
wxInputStream* wxZipInputStream::OpenFile(const wxString& archive)
|
||||||
{
|
{
|
||||||
wxLogNull nolog;
|
wxLogNull nolog;
|
||||||
return *new wxFFileInputStream(archive);
|
return new wxFFileInputStream(archive);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // WXWIN_COMPATIBILITY_2_6
|
#endif // WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
|
||||||
|
|
||||||
void wxZipInputStream::Init()
|
void wxZipInputStream::Init()
|
||||||
{
|
{
|
||||||
@@ -1340,8 +1373,7 @@ void wxZipInputStream::Init()
|
|||||||
m_signature = 0;
|
m_signature = 0;
|
||||||
m_TotalEntries = 0;
|
m_TotalEntries = 0;
|
||||||
m_lasterror = m_parent_i_stream->GetLastError();
|
m_lasterror = m_parent_i_stream->GetLastError();
|
||||||
m_ffile = NULL;
|
#if WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
|
||||||
#if 1 //WXWIN_COMPATIBILITY_2_6
|
|
||||||
m_allowSeeking = false;
|
m_allowSeeking = false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1353,7 +1385,6 @@ wxZipInputStream::~wxZipInputStream()
|
|||||||
delete m_store;
|
delete m_store;
|
||||||
delete m_inflate;
|
delete m_inflate;
|
||||||
delete m_rawin;
|
delete m_rawin;
|
||||||
delete m_ffile;
|
|
||||||
|
|
||||||
m_weaklinks->Release(this);
|
m_weaklinks->Release(this);
|
||||||
|
|
||||||
@@ -1524,7 +1555,7 @@ wxZipEntry *wxZipInputStream::GetNextEntry()
|
|||||||
if (!IsOk())
|
if (!IsOk())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
wx__ZipEntryPtr entry(new wxZipEntry(m_entry));
|
wxZipEntryPtr_ entry(new wxZipEntry(m_entry));
|
||||||
entry->m_backlink = m_weaklinks->AddEntry(entry.get(), entry->GetKey());
|
entry->m_backlink = m_weaklinks->AddEntry(entry.get(), entry->GetKey());
|
||||||
return entry.release();
|
return entry.release();
|
||||||
}
|
}
|
||||||
@@ -1851,7 +1882,7 @@ size_t wxZipInputStream::OnSysRead(void *buffer, size_t size)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1 //WXWIN_COMPATIBILITY_2_6
|
#if WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
|
||||||
|
|
||||||
// Borrowed from VS's zip stream (c) 1999 Vaclav Slavik
|
// Borrowed from VS's zip stream (c) 1999 Vaclav Slavik
|
||||||
//
|
//
|
||||||
@@ -1916,39 +1947,52 @@ wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // WXWIN_COMPATIBILITY_2_6
|
#endif // WXWIN_COMPATIBILITY_2_6 && wxUSE_FFILE
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Output stream
|
// Output stream
|
||||||
|
|
||||||
#include "wx/listimpl.cpp"
|
#include "wx/listimpl.cpp"
|
||||||
WX_DEFINE_LIST(wx__ZipEntryList)
|
WX_DEFINE_LIST(wxZipEntryList_)
|
||||||
|
|
||||||
wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
|
wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
|
||||||
int level /*=-1*/,
|
int level /*=-1*/,
|
||||||
wxMBConv& conv /*=wxConvLocal*/)
|
wxMBConv& conv /*=wxConvLocal*/)
|
||||||
: wxArchiveOutputStream(stream, conv),
|
: wxArchiveOutputStream(stream, conv)
|
||||||
m_store(new wxStoredOutputStream(stream)),
|
|
||||||
m_deflate(NULL),
|
|
||||||
m_backlink(NULL),
|
|
||||||
m_initialData(new char[OUTPUT_LATENCY]),
|
|
||||||
m_initialSize(0),
|
|
||||||
m_pending(NULL),
|
|
||||||
m_raw(false),
|
|
||||||
m_headerOffset(0),
|
|
||||||
m_headerSize(0),
|
|
||||||
m_entrySize(0),
|
|
||||||
m_comp(NULL),
|
|
||||||
m_level(level),
|
|
||||||
m_offsetAdjustment(wxInvalidOffset)
|
|
||||||
{
|
{
|
||||||
|
Init(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxZipOutputStream::wxZipOutputStream(wxOutputStream *stream,
|
||||||
|
int level /*=-1*/,
|
||||||
|
wxMBConv& conv /*=wxConvLocal*/)
|
||||||
|
: wxArchiveOutputStream(stream, conv)
|
||||||
|
{
|
||||||
|
Init(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxZipOutputStream::Init(int level)
|
||||||
|
{
|
||||||
|
m_store = new wxStoredOutputStream(*m_parent_o_stream);
|
||||||
|
m_deflate = NULL;
|
||||||
|
m_backlink = NULL;
|
||||||
|
m_initialData = new char[OUTPUT_LATENCY];
|
||||||
|
m_initialSize = 0;
|
||||||
|
m_pending = NULL;
|
||||||
|
m_raw = false;
|
||||||
|
m_headerOffset = 0;
|
||||||
|
m_headerSize = 0;
|
||||||
|
m_entrySize = 0;
|
||||||
|
m_comp = NULL;
|
||||||
|
m_level = level;
|
||||||
|
m_offsetAdjustment = wxInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxZipOutputStream::~wxZipOutputStream()
|
wxZipOutputStream::~wxZipOutputStream()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
WX_CLEAR_LIST(wx__ZipEntryList, m_entries);
|
WX_CLEAR_LIST(wxZipEntryList_, m_entries);
|
||||||
delete m_store;
|
delete m_store;
|
||||||
delete m_deflate;
|
delete m_deflate;
|
||||||
delete m_pending;
|
delete m_pending;
|
||||||
@@ -1977,7 +2021,7 @@ bool wxZipOutputStream::PutNextDirEntry(
|
|||||||
bool wxZipOutputStream::CopyEntry(wxZipEntry *entry,
|
bool wxZipOutputStream::CopyEntry(wxZipEntry *entry,
|
||||||
wxZipInputStream& inputStream)
|
wxZipInputStream& inputStream)
|
||||||
{
|
{
|
||||||
wx__ZipEntryPtr e(entry);
|
wxZipEntryPtr_ e(entry);
|
||||||
|
|
||||||
return
|
return
|
||||||
inputStream.DoOpen(e.get(), true) &&
|
inputStream.DoOpen(e.get(), true) &&
|
||||||
@@ -2147,7 +2191,7 @@ bool wxZipOutputStream::CloseCompressor(wxOutputStream *comp)
|
|||||||
void wxZipOutputStream::CreatePendingEntry(const void *buffer, size_t size)
|
void wxZipOutputStream::CreatePendingEntry(const void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
wxASSERT(IsOk() && m_pending && !m_comp);
|
wxASSERT(IsOk() && m_pending && !m_comp);
|
||||||
wx__ZipEntryPtr spPending(m_pending);
|
wxZipEntryPtr_ spPending(m_pending);
|
||||||
m_pending = NULL;
|
m_pending = NULL;
|
||||||
|
|
||||||
Buffer bufs[] = {
|
Buffer bufs[] = {
|
||||||
@@ -2188,7 +2232,7 @@ void wxZipOutputStream::CreatePendingEntry(const void *buffer, size_t size)
|
|||||||
void wxZipOutputStream::CreatePendingEntry()
|
void wxZipOutputStream::CreatePendingEntry()
|
||||||
{
|
{
|
||||||
wxASSERT(IsOk() && m_pending && !m_comp);
|
wxASSERT(IsOk() && m_pending && !m_comp);
|
||||||
wx__ZipEntryPtr spPending(m_pending);
|
wxZipEntryPtr_ spPending(m_pending);
|
||||||
m_pending = NULL;
|
m_pending = NULL;
|
||||||
m_lasterror = wxSTREAM_WRITE_ERROR;
|
m_lasterror = wxSTREAM_WRITE_ERROR;
|
||||||
|
|
||||||
@@ -2242,8 +2286,10 @@ bool wxZipOutputStream::Close()
|
|||||||
{
|
{
|
||||||
CloseEntry();
|
CloseEntry();
|
||||||
|
|
||||||
if (m_lasterror == wxSTREAM_WRITE_ERROR || m_entries.size() == 0)
|
if (m_lasterror == wxSTREAM_WRITE_ERROR || m_entries.size() == 0) {
|
||||||
|
wxFilterOutputStream::Close();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
wxZipEndRec endrec;
|
wxZipEndRec endrec;
|
||||||
|
|
||||||
@@ -2252,7 +2298,7 @@ bool wxZipOutputStream::Close()
|
|||||||
endrec.SetOffset(m_headerOffset);
|
endrec.SetOffset(m_headerOffset);
|
||||||
endrec.SetComment(m_Comment);
|
endrec.SetComment(m_Comment);
|
||||||
|
|
||||||
wx__ZipEntryList::iterator it;
|
wxZipEntryList_::iterator it;
|
||||||
wxFileOffset size = 0;
|
wxFileOffset size = 0;
|
||||||
|
|
||||||
for (it = m_entries.begin(); it != m_entries.end(); ++it) {
|
for (it = m_entries.begin(); it != m_entries.end(); ++it) {
|
||||||
@@ -2265,7 +2311,8 @@ bool wxZipOutputStream::Close()
|
|||||||
endrec.Write(*m_parent_o_stream, GetConv());
|
endrec.Write(*m_parent_o_stream, GetConv());
|
||||||
|
|
||||||
m_lasterror = m_parent_o_stream->GetLastError();
|
m_lasterror = m_parent_o_stream->GetLastError();
|
||||||
if (!IsOk())
|
|
||||||
|
if (!wxFilterOutputStream::Close() || !IsOk())
|
||||||
return false;
|
return false;
|
||||||
m_lasterror = wxSTREAM_EOF;
|
m_lasterror = wxSTREAM_EOF;
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user