+ m_o_streambuf->FlushBuffer();
+ m_parent_o_stream->Sync();
+}
+
+size_t wxBufferedOutputStream::OnSysWrite(const void *buffer, size_t bufsize)
+{
+ return m_parent_o_stream->Write(buffer, bufsize).LastWrite();
+}
+
+wxFileOffset wxBufferedOutputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
+{
+ return m_parent_o_stream->SeekO(seek, mode);
+}
+
+wxFileOffset wxBufferedOutputStream::OnSysTell() const
+{
+ return m_parent_o_stream->TellO();
+}
+
+wxFileOffset wxBufferedOutputStream::GetLength() const
+{
+ return m_parent_o_stream->GetLength() + m_o_streambuf->GetIntPosition();
+}
+
+void wxBufferedOutputStream::SetOutputStreamBuffer(wxStreamBuffer *buffer)
+{
+ wxCHECK_RET( buffer, wxT("wxBufferedOutputStream needs buffer") );
+
+ delete m_o_streambuf;
+ m_o_streambuf = buffer;
+}
+
+// ---------------------------------------------------------------------------
+// wxWrapperInputStream implementation
+// ---------------------------------------------------------------------------
+
+wxWrapperInputStream::wxWrapperInputStream()
+{
+ m_lasterror = wxSTREAM_READ_ERROR;
+}
+
+wxWrapperInputStream::wxWrapperInputStream(wxInputStream& stream)
+ : wxFilterInputStream(stream)
+{
+ SynchronizeLastError();
+}
+
+wxWrapperInputStream::wxWrapperInputStream(wxInputStream *stream)
+ : wxFilterInputStream(stream)
+{
+ if ( m_parent_i_stream )
+ SynchronizeLastError();
+ else
+ m_lasterror = wxSTREAM_READ_ERROR;
+}
+
+void wxWrapperInputStream::InitParentStream(wxInputStream& stream)
+{
+ wxCHECK_RET( !m_parent_i_stream, "Can't init parent stream twice" );
+
+ m_parent_i_stream = &stream;
+
+ SynchronizeLastError();
+}
+
+void wxWrapperInputStream::InitParentStream(wxInputStream* stream)
+{
+ wxCHECK_RET( !m_parent_i_stream, "Can't init parent stream twice" );
+
+ m_parent_i_stream = stream;
+
+ if ( m_parent_i_stream )
+ {
+ m_owns = true;
+
+ SynchronizeLastError();
+ }
+}
+
+wxFileOffset wxWrapperInputStream::GetLength() const
+{
+ wxCHECK_MSG(m_parent_i_stream, wxInvalidOffset, "Stream not valid");
+
+ wxON_BLOCK_EXIT_THIS0(wxWrapperInputStream::SynchronizeLastError);
+ return m_parent_i_stream->GetLength();
+}
+
+bool wxWrapperInputStream::IsSeekable() const
+{
+ wxCHECK_MSG(m_parent_i_stream, false, "Stream not valid");
+ return m_parent_i_stream->IsSeekable();
+}
+
+size_t wxWrapperInputStream::OnSysRead(void *buffer, size_t size)
+{
+ wxCHECK_MSG(m_parent_i_stream, false, "Stream not valid");
+
+ wxON_BLOCK_EXIT_THIS0(wxWrapperInputStream::SynchronizeLastError);
+
+ m_parent_i_stream->Read(buffer, size);
+ return m_parent_i_stream->LastRead();
+}
+
+wxFileOffset wxWrapperInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
+{
+ wxCHECK_MSG(IsSeekable(), false, "Stream not seekable");
+
+ wxON_BLOCK_EXIT_THIS0(wxWrapperInputStream::SynchronizeLastError);
+ return m_parent_i_stream->SeekI (pos, mode);
+}
+
+wxFileOffset wxWrapperInputStream::OnSysTell() const
+{
+ wxCHECK_MSG(m_parent_i_stream, false, "Stream not valid");
+
+ wxON_BLOCK_EXIT_THIS0(wxWrapperInputStream::SynchronizeLastError);
+ return m_parent_i_stream->TellI();