m_stream->m_lastcount = 1;
}
+char wxStreamBuffer::Peek()
+{
+ char c;
+
+ wxASSERT(m_stream != NULL && m_buffer_size != 0);
+
+ if (!GetDataLeft()) {
+ CHECK_ERROR(wxStream_READ_ERR);
+ return 0;
+ }
+
+ GetFromBuffer(&c, 1);
+ m_buffer_pos--;
+
+ return c;
+}
+
char wxStreamBuffer::GetChar()
{
char c;
buffer = (char *)buffer + buf_left; // ANSI C++ violation.
if (!FillBuffer()) {
- CHECK_ERROR(wxStream_READ_ERR);
+ CHECK_ERROR(wxStream_EOF);
return (m_stream->m_lastcount = orig_size-size);
}
} else {
diff = pos + GetIntPosition();
if ( (diff > last_access) || (diff < 0) ) {
- ret_off = m_stream->OnSysSeek(pos, wxFromCurrent);
+ // We must take into account the fact that we have read something
+ // previously.
+ ret_off = m_stream->OnSysSeek(diff-last_access, wxFromCurrent);
ResetBuffer();
return ret_off;
} else {
return s_toget;
}
-size_t wxInputStream::Ungetch(void *buf, size_t bufsize)
+size_t wxInputStream::Ungetch(const void *buf, size_t bufsize)
{
char *ptrback;
off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
{
- return wxInvalidOffset;
+ return OnSysSeek(pos, mode);
}
off_t wxInputStream::TellI() const
{
- return wxInvalidOffset;
+ return OnSysTell();
}
// --------------------
off_t wxOutputStream::TellO() const
{
- return wxInvalidOffset;
+ return OnSysTell();
}
off_t wxOutputStream::SeekO(off_t pos, wxSeekMode mode)
{
- return wxInvalidOffset;
+ return OnSysSeek(pos, mode);
}
void wxOutputStream::Sync()
}
#endif
+// ----------------------------------------------------------------------------
+// wxCountingOutputStream
+// ----------------------------------------------------------------------------
+
+wxCountingOutputStream::wxCountingOutputStream ()
+ : wxOutputStream()
+{
+ m_currentPos = 0;
+}
+
+size_t wxCountingOutputStream::GetSize() const
+{
+ return m_lastcount;
+}
+
+size_t wxCountingOutputStream::OnSysWrite(const void *buffer, size_t size)
+{
+ m_currentPos += size;
+ if (m_currentPos > m_lastcount) m_lastcount = m_currentPos;
+ return m_currentPos;
+}
+
+off_t wxCountingOutputStream::OnSysSeek(off_t pos, wxSeekMode mode)
+{
+ if (mode == wxFromStart)
+ {
+ m_currentPos = pos;
+ }
+ if (mode == wxFromEnd)
+ {
+ m_currentPos = m_lastcount + pos;
+ }
+ else
+ {
+ m_currentPos += pos;
+ }
+ if (m_currentPos > m_lastcount) m_lastcount = m_currentPos;
+
+ return m_currentPos; // ?
+}
+
+off_t wxCountingOutputStream::OnSysTell() const
+{
+ return m_currentPos; // ?
+}
+
// ----------------------------------------------------------------------------
// wxFilterInputStream
// ----------------------------------------------------------------------------
+
wxFilterInputStream::wxFilterInputStream()
: wxInputStream()
{
delete m_i_streambuf;
}
+char wxBufferedInputStream::Peek()
+{
+ return m_i_streambuf->Peek();
+}
+
wxInputStream& wxBufferedInputStream::Read(void *buffer, size_t size)
{
size_t retsize;