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 {
char *wxInputStream::AllocSpaceWBack(size_t needed_size)
{
char *temp_b;
+ size_t old_size;
+ old_size = m_wbacksize;
m_wbacksize += needed_size;
if (!m_wback)
if (!temp_b)
return NULL;
m_wback = temp_b;
+ m_wbackcur += needed_size;
+
+ memmove(m_wback+needed_size, m_wback, old_size);
- return (char *)(m_wback+(m_wbacksize-needed_size));
+ return (char *)(m_wback);
}
size_t wxInputStream::GetWBack(char *buf, size_t bsize)
{
- size_t s_toget = m_wbacksize-m_wbackcur;
+ size_t s_toget = m_wbackcur;
if (!m_wback)
return 0;
if (bsize < s_toget)
s_toget = bsize;
- memcpy(buf, (m_wback+m_wbackcur), s_toget);
+ memcpy(buf, (m_wback+m_wbackcur-bsize), s_toget);
- m_wbackcur += s_toget;
- if (m_wbackcur == m_wbacksize) {
+ m_wbackcur -= s_toget;
+ if (m_wbackcur == 0) {
free(m_wback);
m_wback = (char *)NULL;
m_wbacksize = 0;
off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
{
+ //should be check and improve, just to remove a slight bug !
+ // I don't know whether it should be put as well in wxFileInputStream::OnSysSeek ?
+ if (m_lasterror==wxSTREAM_EOF) m_lasterror=wxSTREAM_NOERROR;
+
return OnSysSeek(pos, mode);
}
return m_lastcount;
}
-size_t wxCountingOutputStream::OnSysWrite(const void *buffer, size_t size)
+size_t wxCountingOutputStream::OnSysWrite(const void *WXUNUSED(buffer), size_t size)
{
m_currentPos += size;
if (m_currentPos > m_lastcount) m_lastcount = m_currentPos;
delete m_i_streambuf;
}
+char wxBufferedInputStream::Peek()
+{
+ return m_i_streambuf->Peek();
+}
+
wxInputStream& wxBufferedInputStream::Read(void *buffer, size_t size)
{
size_t retsize;