]> git.saurik.com Git - wxWidgets.git/commitdiff
Make Eof() consistent with other streams
authorMichael Wetherell <mike.wetherell@ntlworld.com>
Wed, 30 Nov 2005 12:41:48 +0000 (12:41 +0000)
committerMichael Wetherell <mike.wetherell@ntlworld.com>
Wed, 30 Nov 2005 12:41:48 +0000 (12:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36298 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/mstream.h
src/common/mstream.cpp
src/common/zipstrm.cpp
src/common/zstream.cpp

index d1b8a6230cefdce7de1ce442074d41ab89ab6607..2857dc074d320ab5939fc7e86dc3d23a1dc97f26 100644 (file)
@@ -27,7 +27,6 @@ public:
     wxMemoryInputStream(const wxMemoryOutputStream& stream);
     virtual ~wxMemoryInputStream();
     virtual wxFileOffset GetLength() const { return m_length; }
-    virtual bool Eof() const;
     virtual bool IsSeekable() const { return true; }
 
     char Peek();
index ce78979686002f1825180bea4f98c74a2f299263..ab50d843865f1c8ee942ca2b6105678dc09d7bc3 100644 (file)
@@ -88,11 +88,6 @@ char wxMemoryInputStream::Peek()
     return buf[pos];
 }
 
-bool wxMemoryInputStream::Eof() const
-{
-    return !m_i_streambuf->GetBytesLeft();
-}
-
 size_t wxMemoryInputStream::OnSysRead(void *buffer, size_t nbytes)
 {
     size_t pos = m_i_streambuf->GetIntPosition();
index 0eb50af0da1c246dbe2f2cbe4093532903b19b12..b39c2856320a107cc7f50b6259ad356d07ea6188 100644 (file)
@@ -169,7 +169,7 @@ size_t wxStoredInputStream::OnSysRead(void *buffer, size_t size)
     count = m_parent_i_stream->Read(buffer, count).LastRead();
     m_pos += count;
 
-    if (m_pos == m_len)
+    if (m_pos == m_len && count < size)
         m_lasterror = wxSTREAM_EOF;
     else if (!*m_parent_i_stream)
         m_lasterror = wxSTREAM_READ_ERROR;
index bea30dce41d3214724b8c2e1209beafa9c611f0f..083ac372fbad895ecd1f120cb4e7a8b1607ed1a6 100644 (file)
@@ -131,14 +131,16 @@ size_t wxZlibInputStream::OnSysRead(void *buffer, size_t size)
         break;
 
     case Z_STREAM_END:
-      // Unread any data taken from past the end of the deflate stream, so that
-      // any additional data can be read from the underlying stream (the crc
-      // in a gzip for example)
-      if (m_inflate->avail_in) {
-        m_parent_i_stream->Ungetch(m_inflate->next_in, m_inflate->avail_in);
-        m_inflate->avail_in = 0;
+      if (m_inflate->avail_out) {
+        // Unread any data taken from past the end of the deflate stream, so that
+        // any additional data can be read from the underlying stream (the crc
+        // in a gzip for example)
+        if (m_inflate->avail_in) {
+          m_parent_i_stream->Ungetch(m_inflate->next_in, m_inflate->avail_in);
+          m_inflate->avail_in = 0;
+        }
+        m_lasterror = wxSTREAM_EOF;
       }
-      m_lasterror = wxSTREAM_EOF;
       break;
 
     case Z_BUF_ERROR: