]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/stream.cpp
Solving link problem with 16 bits versions (wxProcessEvent, wxSpinEvent)
[wxWidgets.git] / src / common / stream.cpp
index b22e5adb46b3625cc672851de27f6873b0d4f7f6..fdfc9123339422458b9a29b0742c56b2db1124ef 100644 (file)
@@ -371,7 +371,9 @@ off_t wxStreamBuffer::Seek(off_t pos, wxSeekMode mode)
     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 {
@@ -499,7 +501,7 @@ size_t wxInputStream::GetWBack(char *buf, size_t bsize)
   return s_toget;
 }
 
-size_t wxInputStream::Ungetch(void *buf, size_t bufsize)
+size_t wxInputStream::Ungetch(const void *buf, size_t bufsize)
 {
   char *ptrback;
 
@@ -643,9 +645,56 @@ wxOutputStream& wxOutputStream::operator<<(wxObject& obj)
 }
 #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()
 {