Make Eof() consistent with other streams
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36298 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -27,7 +27,6 @@ public:
|
|||||||
wxMemoryInputStream(const wxMemoryOutputStream& stream);
|
wxMemoryInputStream(const wxMemoryOutputStream& stream);
|
||||||
virtual ~wxMemoryInputStream();
|
virtual ~wxMemoryInputStream();
|
||||||
virtual wxFileOffset GetLength() const { return m_length; }
|
virtual wxFileOffset GetLength() const { return m_length; }
|
||||||
virtual bool Eof() const;
|
|
||||||
virtual bool IsSeekable() const { return true; }
|
virtual bool IsSeekable() const { return true; }
|
||||||
|
|
||||||
char Peek();
|
char Peek();
|
||||||
|
@@ -88,11 +88,6 @@ char wxMemoryInputStream::Peek()
|
|||||||
return buf[pos];
|
return buf[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMemoryInputStream::Eof() const
|
|
||||||
{
|
|
||||||
return !m_i_streambuf->GetBytesLeft();
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t wxMemoryInputStream::OnSysRead(void *buffer, size_t nbytes)
|
size_t wxMemoryInputStream::OnSysRead(void *buffer, size_t nbytes)
|
||||||
{
|
{
|
||||||
size_t pos = m_i_streambuf->GetIntPosition();
|
size_t pos = m_i_streambuf->GetIntPosition();
|
||||||
|
@@ -169,7 +169,7 @@ size_t wxStoredInputStream::OnSysRead(void *buffer, size_t size)
|
|||||||
count = m_parent_i_stream->Read(buffer, count).LastRead();
|
count = m_parent_i_stream->Read(buffer, count).LastRead();
|
||||||
m_pos += count;
|
m_pos += count;
|
||||||
|
|
||||||
if (m_pos == m_len)
|
if (m_pos == m_len && count < size)
|
||||||
m_lasterror = wxSTREAM_EOF;
|
m_lasterror = wxSTREAM_EOF;
|
||||||
else if (!*m_parent_i_stream)
|
else if (!*m_parent_i_stream)
|
||||||
m_lasterror = wxSTREAM_READ_ERROR;
|
m_lasterror = wxSTREAM_READ_ERROR;
|
||||||
|
@@ -131,14 +131,16 @@ size_t wxZlibInputStream::OnSysRead(void *buffer, size_t size)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Z_STREAM_END:
|
case Z_STREAM_END:
|
||||||
// Unread any data taken from past the end of the deflate stream, so that
|
if (m_inflate->avail_out) {
|
||||||
// any additional data can be read from the underlying stream (the crc
|
// Unread any data taken from past the end of the deflate stream, so that
|
||||||
// in a gzip for example)
|
// any additional data can be read from the underlying stream (the crc
|
||||||
if (m_inflate->avail_in) {
|
// in a gzip for example)
|
||||||
m_parent_i_stream->Ungetch(m_inflate->next_in, m_inflate->avail_in);
|
if (m_inflate->avail_in) {
|
||||||
m_inflate->avail_in = 0;
|
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;
|
break;
|
||||||
|
|
||||||
case Z_BUF_ERROR:
|
case Z_BUF_ERROR:
|
||||||
|
Reference in New Issue
Block a user