- m_contentStream->SeekI(m_pos);
- m_contentStream->Read(buffer, bufsize);
- m_pos +=bufsize;
- m_contentStream->SeekI(m_pos);
- return bufsize;
+ if (m_contentStream->SeekI(m_pos) == wxInvalidOffset)
+ {
+ m_lasterror = wxSTREAM_EOF;
+ return 0;
+ }
+
+ size_t read = m_contentStream->Read(buffer, bufsize).LastRead();
+ m_pos += read;
+
+ if (m_contentStream->SeekI(m_pos) == wxInvalidOffset)
+ {
+ m_lasterror = wxSTREAM_READ_ERROR;
+ return 0;
+ }
+
+ if (read != bufsize)
+ m_lasterror = m_contentStream->GetLastError();
+
+ return read;