]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/zipstrm.cpp
replaced gs_menuItems hack with a wxOwnerDrawn::m_isMenuItem field
[wxWidgets.git] / src / common / zipstrm.cpp
index 9675244428bee40ee2609bc9e21f60b3b7ab560f..a2e12cc38b6b4dbe98993cc8651e4585454579da 100644 (file)
@@ -7,10 +7,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-  #pragma implementation "zipstrm.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -34,6 +30,7 @@
 #include "wx/buffer.h"
 #include "wx/ptr_scpd.h"
 #include "wx/wfstream.h"
+#include "wx/link.h"
 #include "zlib.h"
 
 // value for the 'version needed to extract' field (20 means 2.0)
@@ -81,12 +78,7 @@ enum {
 IMPLEMENT_DYNAMIC_CLASS(wxZipEntry, wxArchiveEntry)
 IMPLEMENT_DYNAMIC_CLASS(wxZipClassFactory, wxArchiveClassFactory)
 
-//FORCE_LINK_ME(zipstrm)
-int _wx_link_dummy_func_zipstrm();
-int _wx_link_dummy_func_zipstrm()
-{
-    return 1;
-}
+wxFORCE_LINK_THIS_MODULE(zipstrm)
 
 
 /////////////////////////////////////////////////////////////////////////////
@@ -172,7 +164,7 @@ wxStoredInputStream::wxStoredInputStream(wxInputStream& stream)
 
 size_t wxStoredInputStream::OnSysRead(void *buffer, size_t size)
 {
-    size_t count = wxMin(size, (size_t)(m_len - m_pos));
+    size_t count = wxMin(size, wx_truncate_cast(size_t, m_len - m_pos));
     count = m_parent_i_stream->Read(buffer, count).LastRead();
     m_pos += count;
 
@@ -485,7 +477,7 @@ public:
     wxZipMemory *Unique(size_t size);
 
 private:
-    ~wxZipMemory() { delete m_data; }
+    ~wxZipMemory() { delete [] m_data; }
 
     char *m_data;
     size_t m_size;
@@ -505,7 +497,7 @@ wxZipMemory *wxZipMemory::Unique(size_t size)
     }
 
     if (zm->m_capacity < size) {
-        delete zm->m_data;
+        delete [] zm->m_data;
         zm->m_data = new char[size];
         zm->m_capacity = size;
     }
@@ -1182,25 +1174,21 @@ wxZipInputStream::wxZipInputStream(wxInputStream& stream,
                                    wxMBConv& conv /*=wxConvLocal*/)
   : wxArchiveInputStream(stream, conv)
 {
-#if 1 //WXWIN_COMPATIBILITY_2_6
-    m_allowSeeking = false;
-#endif
-    m_ffile = NULL;
     Init();
 }
 
 #if 1 //WXWIN_COMPATIBILITY_2_6
 
-// Compatibility constructor
+// 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();
     m_allowSeeking = true;
+    m_ffile = wx_static_cast(wxFFileInputStream*, m_parent_i_stream);
     wx__ZipEntryPtr entry;
 
     if (m_ffile->Ok()) {
@@ -1217,8 +1205,7 @@ wxZipInputStream::wxZipInputStream(const wxString& archive,
 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
@@ -1239,6 +1226,10 @@ void wxZipInputStream::Init()
     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()
@@ -1825,7 +1816,7 @@ wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
 // Output stream
 
 #include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wx__ZipEntryList);
+WX_DEFINE_LIST(wx__ZipEntryList)
 
 wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
                                      int level      /*=-1*/,