wxZipMemory *Unique(size_t size);
private:
- ~wxZipMemory() { delete m_data; }
+ ~wxZipMemory() { delete [] m_data; }
char *m_data;
size_t m_size;
}
if (zm->m_capacity < size) {
- delete zm->m_data;
+ delete [] zm->m_data;
zm->m_data = new char[size];
zm->m_capacity = size;
}
// Collection of weak references to entries
WX_DECLARE_HASH_MAP(long, wxZipEntry*, wxIntegerHash,
- wxIntegerEqual, _wxOffsetZipEntryMap);
+ wxIntegerEqual, wx__OffsetZipEntryMap);
class wxZipWeakLinks
{
wxZipWeakLinks *AddEntry(wxZipEntry *entry, 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;
bool IsEmpty() const { return m_entries.empty(); }
~wxZipWeakLinks() { wxASSERT(IsEmpty()); }
int m_ref;
- _wxOffsetZipEntryMap m_entries;
+ wx__OffsetZipEntryMap m_entries;
};
wxZipWeakLinks *wxZipWeakLinks::AddEntry(wxZipEntry *entry, wxFileOffset key)
{
- m_entries[(_wxOffsetZipEntryMap::key_type)key] = entry;
+ m_entries[(wx__OffsetZipEntryMap::key_type)key] = entry;
m_ref++;
return this;
}
wxZipEntry *wxZipWeakLinks::GetEntry(wxFileOffset key) const
{
- _wxOffsetZipEntryMap::const_iterator it =
- m_entries.find((_wxOffsetZipEntryMap::key_type)key);
+ wx__OffsetZipEntryMap::const_iterator it =
+ m_entries.find((wx__OffsetZipEntryMap::key_type)key);
return it != m_entries.end() ? it->second : NULL;
}
{
bool isDir = IsDir() && !m_Name.empty();
+ // optimisations for common (and easy) cases
switch (wxFileName::GetFormat(format)) {
case wxPATH_DOS:
{
/////////////////////////////////////////////////////////////////////////////
// Input stream
-wxDECLARE_SCOPED_PTR(wxZipEntry, _wxZipEntryPtr)
-wxDEFINE_SCOPED_PTR (wxZipEntry, _wxZipEntryPtr)
+// leave the default wxZipEntryPtr free for users
+wxDECLARE_SCOPED_PTR(wxZipEntry, wx__ZipEntryPtr)
+wxDEFINE_SCOPED_PTR (wxZipEntry, wx__ZipEntryPtr)
// constructor
//
wxMBConv& conv /*=wxConvLocal*/)
: wxArchiveInputStream(stream, conv)
{
- m_ffile = NULL;
Init();
}
-// Compatibility constructor
+#if 1 //WXWIN_COMPATIBILITY_2_6
+
+// Part of the compatibility constructor, which has been made inline to
+// avoid a problem with it not being exported by mingw 3.2.3
//
-wxZipInputStream::wxZipInputStream(const wxString& archive,
- const wxString& file)
- : wxArchiveInputStream(OpenFile(archive), wxConvLocal)
+void wxZipInputStream::Init(const wxString& file)
{
// no error messages
wxLogNull nolog;
Init();
- _wxZipEntryPtr entry;
+ m_allowSeeking = true;
+ m_ffile = wx_static_cast(wxFFileInputStream*, m_parent_i_stream);
+ wx__ZipEntryPtr entry;
if (m_ffile->Ok()) {
do {
wxInputStream& wxZipInputStream::OpenFile(const wxString& archive)
{
wxLogNull nolog;
- m_ffile = new wxFFileInputStream(archive);
- return *m_ffile;
+ return *new wxFFileInputStream(archive);
}
+#endif // WXWIN_COMPATIBILITY_2_6
+
void wxZipInputStream::Init()
{
m_store = new wxStoredInputStream(*m_parent_i_stream);
m_signature = 0;
m_TotalEntries = 0;
m_lasterror = m_parent_i_stream->GetLastError();
+ m_ffile = NULL;
+#if 1 //WXWIN_COMPATIBILITY_2_6
+ m_allowSeeking = false;
+#endif
}
wxZipInputStream::~wxZipInputStream()
if (!IsOk())
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());
return entry.release();
}
return count;
}
+#if 1 //WXWIN_COMPATIBILITY_2_6
+
// Borrowed from VS's zip stream (c) 1999 Vaclav Slavik
//
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;
if (!IsOpened())
if ((AtHeader() && !DoOpen()) || !OpenDecompressor())
return pos;
}
+#endif // WXWIN_COMPATIBILITY_2_6
+
/////////////////////////////////////////////////////////////////////////////
// Output stream
#include "wx/listimpl.cpp"
-WX_DEFINE_LIST(_wxZipEntryList);
+WX_DEFINE_LIST(wx__ZipEntryList);
wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
int level /*=-1*/,
wxZipOutputStream::~wxZipOutputStream()
{
Close();
- WX_CLEAR_LIST(_wxZipEntryList, m_entries);
+ WX_CLEAR_LIST(wx__ZipEntryList, m_entries);
delete m_store;
delete m_deflate;
delete m_pending;
bool wxZipOutputStream::CopyEntry(wxZipEntry *entry,
wxZipInputStream& inputStream)
{
- _wxZipEntryPtr e(entry);
+ wx__ZipEntryPtr e(entry);
return
inputStream.DoOpen(e.get(), true) &&
// and if this is the first entry test for seekability
if (m_headerOffset == 0 && m_parent_o_stream->IsSeekable()) {
+#if wxUSE_LOG
bool logging = wxLog::IsEnabled();
wxLogNull nolog;
+#endif // wxUSE_LOG
wxFileOffset here = m_parent_o_stream->TellO();
if (here != wxInvalidOffset && here >= 4) {
if (m_parent_o_stream->SeekO(here - 4) == here - 4) {
m_offsetAdjustment = here - 4;
+#if wxUSE_LOG
wxLog::EnableLogging(logging);
+#endif // wxUSE_LOG
m_parent_o_stream->SeekO(here);
}
}
void wxZipOutputStream::CreatePendingEntry(const void *buffer, size_t size)
{
wxASSERT(IsOk() && m_pending && !m_comp);
- _wxZipEntryPtr spPending(m_pending);
+ wx__ZipEntryPtr spPending(m_pending);
m_pending = NULL;
Buffer bufs[] = {
void wxZipOutputStream::CreatePendingEntry()
{
wxASSERT(IsOk() && m_pending && !m_comp);
- _wxZipEntryPtr spPending(m_pending);
+ wx__ZipEntryPtr spPending(m_pending);
m_pending = NULL;
m_lasterror = wxSTREAM_WRITE_ERROR;
endrec.SetOffset(m_headerOffset);
endrec.SetComment(m_Comment);
- _wxZipEntryList::iterator it;
+ wx__ZipEntryList::iterator it;
wxFileOffset size = 0;
for (it = m_entries.begin(); it != m_entries.end(); ++it) {