Add m_allowSeeking for updated filesystem handler to use. Also switch to
using 'wx__' prefix for private symbols, and add some comments. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -262,7 +262,7 @@ private:
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// wxZipOutputStream
|
// wxZipOutputStream
|
||||||
|
|
||||||
WX_DECLARE_LIST_WITH_DECL(wxZipEntry, _wxZipEntryList, class WXDLLIMPEXP_BASE);
|
WX_DECLARE_LIST_WITH_DECL(wxZipEntry, wx__ZipEntryList, class WXDLLIMPEXP_BASE);
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxZipOutputStream : public wxArchiveOutputStream
|
class WXDLLIMPEXP_BASE wxZipOutputStream : public wxArchiveOutputStream
|
||||||
{
|
{
|
||||||
@@ -320,7 +320,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;
|
||||||
_wxZipEntryList m_entries;
|
wx__ZipEntryList m_entries;
|
||||||
char *m_initialData;
|
char *m_initialData;
|
||||||
size_t m_initialSize;
|
size_t m_initialSize;
|
||||||
wxZipEntry *m_pending;
|
wxZipEntry *m_pending;
|
||||||
@@ -347,7 +347,11 @@ public:
|
|||||||
typedef wxZipEntry entry_type;
|
typedef wxZipEntry entry_type;
|
||||||
|
|
||||||
wxZipInputStream(wxInputStream& stream, wxMBConv& conv = wxConvLocal);
|
wxZipInputStream(wxInputStream& stream, wxMBConv& conv = wxConvLocal);
|
||||||
|
|
||||||
|
#if 1 //WXWIN_COMPATIBILITY_2_6
|
||||||
wxZipInputStream(const wxString& archive, const wxString& file);
|
wxZipInputStream(const wxString& archive, const wxString& file);
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual ~wxZipInputStream();
|
virtual ~wxZipInputStream();
|
||||||
|
|
||||||
bool OpenEntry(wxZipEntry& entry) { return DoOpen(&entry); }
|
bool OpenEntry(wxZipEntry& entry) { return DoOpen(&entry); }
|
||||||
@@ -363,8 +367,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
size_t OnSysRead(void *buffer, size_t size);
|
size_t 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; }
|
||||||
wxFileOffset OnSysSeek(wxFileOffset seek, wxSeekMode mode);
|
|
||||||
|
|
||||||
|
#if 1 //WXWIN_COMPATIBILITY_2_6
|
||||||
|
wxFileOffset OnSysSeek(wxFileOffset seek, wxSeekMode mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// this protected interface isn't yet finalised
|
||||||
virtual wxInputStream *OpenDecompressor(wxInputStream& stream);
|
virtual wxInputStream *OpenDecompressor(wxInputStream& stream);
|
||||||
virtual bool CloseDecompressor(wxInputStream *decomp);
|
virtual bool CloseDecompressor(wxInputStream *decomp);
|
||||||
|
|
||||||
@@ -415,6 +423,11 @@ private:
|
|||||||
friend bool wxZipOutputStream::CopyArchiveMetaData(
|
friend bool wxZipOutputStream::CopyArchiveMetaData(
|
||||||
wxZipInputStream& inputStream);
|
wxZipInputStream& inputStream);
|
||||||
|
|
||||||
|
#if 1 //WXWIN_COMPATIBILITY_2_6
|
||||||
|
bool m_allowSeeking;
|
||||||
|
friend class wxZipFSInputStream;
|
||||||
|
#endif
|
||||||
|
|
||||||
DECLARE_NO_COPY_CLASS(wxZipInputStream)
|
DECLARE_NO_COPY_CLASS(wxZipInputStream)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -546,7 +546,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, _wxOffsetZipEntryMap);
|
wxIntegerEqual, wx__OffsetZipEntryMap);
|
||||||
|
|
||||||
class wxZipWeakLinks
|
class wxZipWeakLinks
|
||||||
{
|
{
|
||||||
@@ -560,7 +560,7 @@ public:
|
|||||||
|
|
||||||
wxZipWeakLinks *AddEntry(wxZipEntry *entry, wxFileOffset key);
|
wxZipWeakLinks *AddEntry(wxZipEntry *entry, wxFileOffset key);
|
||||||
void RemoveEntry(wxFileOffset key)
|
void RemoveEntry(wxFileOffset key)
|
||||||
{ m_entries.erase((_wxOffsetZipEntryMap::key_type)key); }
|
{ m_entries.erase((wx__OffsetZipEntryMap::key_type)key); }
|
||||||
wxZipEntry *GetEntry(wxFileOffset key) const;
|
wxZipEntry *GetEntry(wxFileOffset key) const;
|
||||||
bool IsEmpty() const { return m_entries.empty(); }
|
bool IsEmpty() const { return m_entries.empty(); }
|
||||||
|
|
||||||
@@ -568,20 +568,20 @@ private:
|
|||||||
~wxZipWeakLinks() { wxASSERT(IsEmpty()); }
|
~wxZipWeakLinks() { wxASSERT(IsEmpty()); }
|
||||||
|
|
||||||
int m_ref;
|
int m_ref;
|
||||||
_wxOffsetZipEntryMap m_entries;
|
wx__OffsetZipEntryMap m_entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxZipWeakLinks *wxZipWeakLinks::AddEntry(wxZipEntry *entry, wxFileOffset key)
|
wxZipWeakLinks *wxZipWeakLinks::AddEntry(wxZipEntry *entry, wxFileOffset key)
|
||||||
{
|
{
|
||||||
m_entries[(_wxOffsetZipEntryMap::key_type)key] = entry;
|
m_entries[(wx__OffsetZipEntryMap::key_type)key] = entry;
|
||||||
m_ref++;
|
m_ref++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxZipEntry *wxZipWeakLinks::GetEntry(wxFileOffset key) const
|
wxZipEntry *wxZipWeakLinks::GetEntry(wxFileOffset key) const
|
||||||
{
|
{
|
||||||
_wxOffsetZipEntryMap::const_iterator it =
|
wx__OffsetZipEntryMap::const_iterator it =
|
||||||
m_entries.find((_wxOffsetZipEntryMap::key_type)key);
|
m_entries.find((wx__OffsetZipEntryMap::key_type)key);
|
||||||
return it != m_entries.end() ? it->second : NULL;
|
return it != m_entries.end() ? it->second : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,6 +684,7 @@ wxString wxZipEntry::GetName(wxPathFormat format /*=wxPATH_NATIVE*/) const
|
|||||||
{
|
{
|
||||||
bool isDir = IsDir() && !m_Name.empty();
|
bool isDir = IsDir() && !m_Name.empty();
|
||||||
|
|
||||||
|
// optimisations for common (and easy) cases
|
||||||
switch (wxFileName::GetFormat(format)) {
|
switch (wxFileName::GetFormat(format)) {
|
||||||
case wxPATH_DOS:
|
case wxPATH_DOS:
|
||||||
{
|
{
|
||||||
@@ -1171,8 +1172,9 @@ private:
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Input stream
|
// Input stream
|
||||||
|
|
||||||
wxDECLARE_SCOPED_PTR(wxZipEntry, _wxZipEntryPtr)
|
// leave the default wxZipEntryPtr free for users
|
||||||
wxDEFINE_SCOPED_PTR (wxZipEntry, _wxZipEntryPtr)
|
wxDECLARE_SCOPED_PTR(wxZipEntry, wx__ZipEntryPtr)
|
||||||
|
wxDEFINE_SCOPED_PTR (wxZipEntry, wx__ZipEntryPtr)
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
//
|
//
|
||||||
@@ -1180,10 +1182,15 @@ wxZipInputStream::wxZipInputStream(wxInputStream& stream,
|
|||||||
wxMBConv& conv /*=wxConvLocal*/)
|
wxMBConv& conv /*=wxConvLocal*/)
|
||||||
: wxArchiveInputStream(stream, conv)
|
: wxArchiveInputStream(stream, conv)
|
||||||
{
|
{
|
||||||
|
#if 1 //WXWIN_COMPATIBILITY_2_6
|
||||||
|
m_allowSeeking = false;
|
||||||
|
#endif
|
||||||
m_ffile = NULL;
|
m_ffile = NULL;
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1 //WXWIN_COMPATIBILITY_2_6
|
||||||
|
|
||||||
// Compatibility constructor
|
// Compatibility constructor
|
||||||
//
|
//
|
||||||
wxZipInputStream::wxZipInputStream(const wxString& archive,
|
wxZipInputStream::wxZipInputStream(const wxString& archive,
|
||||||
@@ -1193,7 +1200,8 @@ wxZipInputStream::wxZipInputStream(const wxString& archive,
|
|||||||
// no error messages
|
// no error messages
|
||||||
wxLogNull nolog;
|
wxLogNull nolog;
|
||||||
Init();
|
Init();
|
||||||
_wxZipEntryPtr entry;
|
m_allowSeeking = true;
|
||||||
|
wx__ZipEntryPtr entry;
|
||||||
|
|
||||||
if (m_ffile->Ok()) {
|
if (m_ffile->Ok()) {
|
||||||
do {
|
do {
|
||||||
@@ -1213,6 +1221,8 @@ wxInputStream& wxZipInputStream::OpenFile(const wxString& archive)
|
|||||||
return *m_ffile;
|
return *m_ffile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2_6
|
||||||
|
|
||||||
void wxZipInputStream::Init()
|
void wxZipInputStream::Init()
|
||||||
{
|
{
|
||||||
m_store = new wxStoredInputStream(*m_parent_i_stream);
|
m_store = new wxStoredInputStream(*m_parent_i_stream);
|
||||||
@@ -1416,7 +1426,7 @@ wxZipEntry *wxZipInputStream::GetNextEntry()
|
|||||||
if (!IsOk())
|
if (!IsOk())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
_wxZipEntryPtr entry(new wxZipEntry(m_entry));
|
wx__ZipEntryPtr 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();
|
||||||
}
|
}
|
||||||
@@ -1742,11 +1752,15 @@ size_t wxZipInputStream::OnSysRead(void *buffer, size_t size)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1 //WXWIN_COMPATIBILITY_2_6
|
||||||
|
|
||||||
// Borrowed from VS's zip stream (c) 1999 Vaclav Slavik
|
// Borrowed from VS's zip stream (c) 1999 Vaclav Slavik
|
||||||
//
|
//
|
||||||
wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
|
wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
|
||||||
{
|
{
|
||||||
if (!m_ffile)
|
// seeking works when the stream is created with the compatibility
|
||||||
|
// constructor
|
||||||
|
if (!m_allowSeeking)
|
||||||
return wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
if (!IsOpened())
|
if (!IsOpened())
|
||||||
if ((AtHeader() && !DoOpen()) || !OpenDecompressor())
|
if ((AtHeader() && !DoOpen()) || !OpenDecompressor())
|
||||||
@@ -1804,12 +1818,14 @@ wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2_6
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Output stream
|
// Output stream
|
||||||
|
|
||||||
#include "wx/listimpl.cpp"
|
#include "wx/listimpl.cpp"
|
||||||
WX_DEFINE_LIST(_wxZipEntryList);
|
WX_DEFINE_LIST(wx__ZipEntryList);
|
||||||
|
|
||||||
wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
|
wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
|
||||||
int level /*=-1*/,
|
int level /*=-1*/,
|
||||||
@@ -1834,7 +1850,7 @@ wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
|
|||||||
wxZipOutputStream::~wxZipOutputStream()
|
wxZipOutputStream::~wxZipOutputStream()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
WX_CLEAR_LIST(_wxZipEntryList, m_entries);
|
WX_CLEAR_LIST(wx__ZipEntryList, m_entries);
|
||||||
delete m_store;
|
delete m_store;
|
||||||
delete m_deflate;
|
delete m_deflate;
|
||||||
delete m_pending;
|
delete m_pending;
|
||||||
@@ -1863,7 +1879,7 @@ bool wxZipOutputStream::PutNextDirEntry(
|
|||||||
bool wxZipOutputStream::CopyEntry(wxZipEntry *entry,
|
bool wxZipOutputStream::CopyEntry(wxZipEntry *entry,
|
||||||
wxZipInputStream& inputStream)
|
wxZipInputStream& inputStream)
|
||||||
{
|
{
|
||||||
_wxZipEntryPtr e(entry);
|
wx__ZipEntryPtr e(entry);
|
||||||
|
|
||||||
return
|
return
|
||||||
inputStream.DoOpen(e.get(), true) &&
|
inputStream.DoOpen(e.get(), true) &&
|
||||||
@@ -2033,7 +2049,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);
|
||||||
_wxZipEntryPtr spPending(m_pending);
|
wx__ZipEntryPtr spPending(m_pending);
|
||||||
m_pending = NULL;
|
m_pending = NULL;
|
||||||
|
|
||||||
Buffer bufs[] = {
|
Buffer bufs[] = {
|
||||||
@@ -2074,7 +2090,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);
|
||||||
_wxZipEntryPtr spPending(m_pending);
|
wx__ZipEntryPtr spPending(m_pending);
|
||||||
m_pending = NULL;
|
m_pending = NULL;
|
||||||
m_lasterror = wxSTREAM_WRITE_ERROR;
|
m_lasterror = wxSTREAM_WRITE_ERROR;
|
||||||
|
|
||||||
@@ -2138,7 +2154,7 @@ bool wxZipOutputStream::Close()
|
|||||||
endrec.SetOffset(m_headerOffset);
|
endrec.SetOffset(m_headerOffset);
|
||||||
endrec.SetComment(m_Comment);
|
endrec.SetComment(m_Comment);
|
||||||
|
|
||||||
_wxZipEntryList::iterator it;
|
wx__ZipEntryList::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) {
|
||||||
|
Reference in New Issue
Block a user