// seek/tell
// ----------------------------------------------------------------------------
-off_t wxStringInputStream::OnSysSeek(off_t ofs, wxSeekMode mode)
+wxFileOffset wxStringInputStream::OnSysSeek(wxFileOffset ofs, wxSeekMode mode)
{
+ const size_t ofsMax = m_str.length()*sizeof(wxChar);
+
switch ( mode )
{
case wxFromStart:
break;
case wxFromEnd:
- ofs += m_str.length()*sizeof(wxChar);
+ ofs += ofsMax;
break;
case wxFromCurrent:
return wxInvalidOffset;
}
+ if ( ofs < 0 || wx_static_cast(size_t, ofs) >= ofsMax )
+ return wxInvalidOffset;
+
m_pos = wx_static_cast(size_t, ofs);
return ofs;
}
-off_t wxStringInputStream::OnSysTell() const
+wxFileOffset wxStringInputStream::OnSysTell() const
{
- return wx_static_cast(off_t, m_pos);
+ return wx_static_cast(wxFileOffset, m_pos);
}
// ----------------------------------------------------------------------------
// wxStringOutputStream implementation
// ============================================================================
+// ----------------------------------------------------------------------------
+// seek/tell
+// ----------------------------------------------------------------------------
+
+wxFileOffset wxStringOutputStream::OnSysTell() const
+{
+ return wx_static_cast(wxFileOffset, m_pos);
+}
+
// ----------------------------------------------------------------------------
// actual IO
// ----------------------------------------------------------------------------
const wxChar *p = wx_static_cast(const wxChar *, buffer);
- m_str->Append(wxString(p, p + len + 1));
+ m_str->Append(wxString(p, p + len));
// return number of bytes actually written
- return len*sizeof(wxChar);
+ len *= sizeof(wxChar);
+ m_pos += len;
+
+ return len;
}
#endif // wxUSE_STREAMS