]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/stream.cpp
Changed the focus-window event handling back
[wxWidgets.git] / src / common / stream.cpp
index f2bb737c0d266072769c9f8e48a3ee253b9984ff..305c8c51289c527f8ed04f7ec525380d9fe69f4d 100644 (file)
@@ -251,8 +251,8 @@ void wxStreamBuffer::PutChar(char c)
     return;
   }
 
-  if (!GetDataLeft() && !FlushBuffer()) {
-    CHECK_ERROR(wxStream_READ_ERR);
+  if (GetDataLeft() == 0 && !FlushBuffer()) {
+    CHECK_ERROR(wxStream_WRITE_ERR);
     return;
   }
 
@@ -285,6 +285,9 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size)
 {
   wxASSERT(m_stream != NULL);
 
+  if (m_mode == write)
+    return 0;
+
   // ------------------
   // Buffering disabled
   // ------------------
@@ -334,6 +337,9 @@ size_t wxStreamBuffer::Read(wxStreamBuffer *s_buf)
   char buf[BUF_TEMP_SIZE];
   size_t s = 0, bytes_read = BUF_TEMP_SIZE;
 
+  if (m_mode == write)
+    return 0;
+
   while (bytes_read == BUF_TEMP_SIZE) {
     bytes_read = Read(buf, bytes_read);
     bytes_read = s_buf->Write(buf, bytes_read);
@@ -346,6 +352,9 @@ size_t wxStreamBuffer::Write(const void *buffer, size_t size)
 {
   wxASSERT(m_stream != NULL);
 
+  if (m_mode == read)
+    return 0;
+
   // ------------------
   // Buffering disabled
   // ------------------
@@ -392,6 +401,9 @@ size_t wxStreamBuffer::Write(wxStreamBuffer *sbuf)
   char buf[BUF_TEMP_SIZE];
   size_t s = 0, bytes_count = BUF_TEMP_SIZE, b_count2;
 
+  if (m_mode == read)
+    return 0;
+
   while (bytes_count == BUF_TEMP_SIZE) {
     b_count2 = sbuf->Read(buf, bytes_count);
     bytes_count = Write(buf, b_count2);