X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/07b732709364e538ab7ccc49d8f2643d9d28b49d..03715438eb3d56600ab3cba83fd43bc145978a4b:/src/common/stream.cpp diff --git a/src/common/stream.cpp b/src/common/stream.cpp index f2bb737c0d..1c34deffff 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -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); @@ -740,7 +752,12 @@ wxOutputStream& wxOutputStream::operator<<(const char *string) wxOutputStream& wxOutputStream::operator<<(wxString& string) { +#if wxUSE_UNICODE + const wxWX2MBbuf buf = string.mb_str(); + return *this << buf; +#else return Write(string, string.Len()); +#endif } wxOutputStream& wxOutputStream::operator<<(char c) @@ -752,32 +769,32 @@ wxOutputStream& wxOutputStream::operator<<(short i) { wxString strint; - strint.Printf("%i", i); - return Write(strint, strint.Len()); + strint.Printf(_T("%i"), i); + return *this << strint; } wxOutputStream& wxOutputStream::operator<<(int i) { wxString strint; - strint.Printf("%i", i); - return Write(strint, strint.Len()); + strint.Printf(_T("%i"), i); + return *this << strint; } wxOutputStream& wxOutputStream::operator<<(long i) { wxString strlong; - strlong.Printf("%i", i); - return Write((const char *)strlong, strlong.Len()); + strlong.Printf(_T("%i"), i); + return *this << strlong; } wxOutputStream& wxOutputStream::operator<<(double f) { wxString strfloat; - strfloat.Printf("%f", f); - return Write(strfloat, strfloat.Len()); + strfloat.Printf(_T("%f"), f); + return *this << strfloat; } #if wxUSE_SERIAL