]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/zipstrm.cpp
Darwin fixes (OW,BCC,MinGW,DMC tested).
[wxWidgets.git] / src / common / zipstrm.cpp
index 9fbff10320fe87b1ee1456ae455a498a6af82d31..6bf4f2aed31c108af149660e825707066acdf14c 100644 (file)
@@ -3,10 +3,10 @@
 // Purpose:     input stream for ZIP archive access
 // Author:      Vaclav Slavik
 // Copyright:   (c) 1999 Vaclav Slavik
-// Licence:     wxWindows Licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "zipstrm.h"
 #endif
 
@@ -40,15 +40,16 @@ wxZipInputStream::wxZipInputStream(const wxString& archive, const wxString& file
 
     m_Pos = 0;
     m_Size = 0;
-    m_Archive = (void*) unzOpen(archive.mb_str());
+    m_Archive = (void*) unzOpen(archive.mb_str(wxConvFile));
     if (m_Archive == NULL)
     {
-        m_lasterror = wxStream_READ_ERR;
+        m_lasterror = wxSTREAM_READ_ERROR;
         return;
     }
-    if (unzLocateFile((unzFile)m_Archive, file.mb_str(), 0) != UNZ_OK)
+    // TODO what encoding does ZIP use?
+    if (unzLocateFile((unzFile)m_Archive, file.ToAscii(), 0) != UNZ_OK)
     {
-        m_lasterror = wxStream_READ_ERR;
+        m_lasterror = wxSTREAM_READ_ERROR;
         return;
     }
 
@@ -56,7 +57,7 @@ wxZipInputStream::wxZipInputStream(const wxString& archive, const wxString& file
 
     if (unzOpenCurrentFile((unzFile)m_Archive) != UNZ_OK)
     {
-        m_lasterror = wxStream_READ_ERR;
+        m_lasterror = wxSTREAM_READ_ERROR;
         return;
     }
     m_Size = (size_t)zinfo.uncompressed_size;
@@ -76,21 +77,21 @@ wxZipInputStream::~wxZipInputStream()
 
 bool wxZipInputStream::Eof() const
 {
-    wxASSERT_MSG( m_Pos <= (off_t)m_Size,
+    wxASSERT_MSG( m_Pos <= (wxFileOffset)m_Size,
                   _T("wxZipInputStream: invalid current position") );
 
-    return m_Pos >= (off_t)m_Size;
+    return m_Pos >= (wxFileOffset)m_Size;
 }
 
 
 size_t wxZipInputStream::OnSysRead(void *buffer, size_t bufsize)
 {
-    wxASSERT_MSG( m_Pos <= (off_t)m_Size,
+    wxASSERT_MSG( m_Pos <= (wxFileOffset)m_Size,
                   _T("wxZipInputStream: invalid current position") );
 
-    if ( m_Pos >= (off_t)m_Size )
+    if ( m_Pos >= (wxFileOffset)m_Size )
     {
-        m_lasterror = wxStream_EOF;
+        m_lasterror = wxSTREAM_EOF;
         return 0;
     }
 
@@ -105,14 +106,14 @@ size_t wxZipInputStream::OnSysRead(void *buffer, size_t bufsize)
 
 
 
-off_t wxZipInputStream::OnSysSeek(off_t seek, wxSeekMode mode)
+wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
 {
-    // NB: since ZIP files don't natively support seeking, we have to 
+    // NB: since ZIP files don't natively support seeking, we have to
     //     implement a brute force workaround -- reading all the data
-    //     between current and the new position (or between beginning of 
+    //     between current and the new position (or between beginning of
     //     the file and new position...)
 
-    off_t nextpos;
+    wxFileOffset nextpos;
 
     switch ( mode )
     {
@@ -122,7 +123,7 @@ off_t wxZipInputStream::OnSysSeek(off_t seek, wxSeekMode mode)
         default : nextpos = m_Pos; break; /* just to fool compiler, never happens */
     }
 
-    size_t toskip = 0;
+    size_t toskip;
     if ( nextpos > m_Pos )
     {
         toskip = nextpos - m_Pos;
@@ -132,12 +133,12 @@ off_t wxZipInputStream::OnSysSeek(off_t seek, wxSeekMode mode)
         unzCloseCurrentFile((unzFile)m_Archive);
         if (unzOpenCurrentFile((unzFile)m_Archive) != UNZ_OK)
         {
-            m_lasterror = wxStream_READ_ERR;
+            m_lasterror = wxSTREAM_READ_ERROR;
             return m_Pos;
         }
         toskip = nextpos;
     }
-        
+
     if ( toskip > 0 )
     {
         const size_t BUFSIZE = 4096;