+ m_file_destroy = false;
+ m_file = NULL;
+}
+
+wxFFileInputStream::wxFFileInputStream(wxFFile& file)
+{
+ m_file = &file;
+ m_file_destroy = false;
+}
+
+wxFFileInputStream::wxFFileInputStream(FILE *file)
+{
+ m_file = new wxFFile(file);
+ m_file_destroy = true;
+}
+
+wxFFileInputStream::~wxFFileInputStream()
+{
+ if (m_file_destroy)
+ delete m_file;
+}
+
+wxFileOffset wxFFileInputStream::GetLength() const
+{
+ return m_file->Length();
+}
+
+size_t wxFFileInputStream::OnSysRead(void *buffer, size_t size)
+{
+ ssize_t ret = m_file->Read(buffer, size);
+
+ // It is not safe to call Eof() if the file is not opened.
+ if (!m_file->IsOpened() || m_file->Eof())
+ m_lasterror = wxSTREAM_EOF;
+ if (ret == wxInvalidOffset)
+ {
+ m_lasterror = wxSTREAM_READ_ERROR;
+ ret = 0;
+ }
+
+ return ret;
+}
+
+wxFileOffset wxFFileInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
+{
+#ifdef __VMS
+#pragma message disable intsignchange
+#endif
+ wxASSERT_MSG( pos >= LONG_MIN && pos <= LONG_MAX, _T("no huge wxFFile support") );
+ return ( m_file->Seek((long)pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset );
+#ifdef __VMS
+#pragma message enable intsignchange
+#endif
+}
+
+wxFileOffset wxFFileInputStream::OnSysTell() const
+{
+ return m_file->Tell();
+}
+
+// ----------------------------------------------------------------------------
+// wxFFileOutputStream
+// ----------------------------------------------------------------------------
+
+wxFFileOutputStream::wxFFileOutputStream(const wxString& fileName)
+{
+ m_file = new wxFFile(fileName, _T("w+b"));
+ m_file_destroy = true;
+
+ if (!m_file->IsOpened())
+ {
+ m_lasterror = wxSTREAM_WRITE_ERROR;
+ }
+ else
+ {
+ if (m_file->Error())
+ m_lasterror = wxSTREAM_WRITE_ERROR;
+ }
+}
+
+wxFFileOutputStream::wxFFileOutputStream(wxFFile& file)
+{
+ m_file = &file;
+ m_file_destroy = false;
+}
+
+wxFFileOutputStream::wxFFileOutputStream()
+ : wxOutputStream()
+{
+ m_file_destroy = false;
+ m_file = NULL;
+}
+
+wxFFileOutputStream::wxFFileOutputStream(FILE *file)
+{
+ m_file = new wxFFile(file);
+ m_file_destroy = true;
+}
+
+wxFFileOutputStream::~wxFFileOutputStream()
+{
+ if (m_file_destroy)
+ {
+ Sync();
+ delete m_file;
+ }
+}
+
+size_t wxFFileOutputStream::OnSysWrite(const void *buffer, size_t size)
+{
+ size_t ret = m_file->Write(buffer, size);
+ // It is not safe to call Error() if the file is not opened.
+ if (!m_file->IsOpened() || m_file->Error())
+ m_lasterror = wxSTREAM_WRITE_ERROR;
+ else
+ m_lasterror = wxSTREAM_NO_ERROR;
+ return ret;
+}
+
+wxFileOffset wxFFileOutputStream::OnSysTell() const
+{
+ return m_file->Tell();
+}
+
+wxFileOffset wxFFileOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
+{
+#ifdef __VMS
+#pragma message disable intsignchange
+#endif
+ wxASSERT_MSG( pos >= LONG_MIN && pos <= LONG_MAX, _T("no huge wxFFile support") );
+ return ( m_file->Seek((long)pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset );
+#ifdef __VMS
+#pragma message enable intsignchange
+#endif
+}
+
+void wxFFileOutputStream::Sync()
+{
+ wxOutputStream::Sync();
+ m_file->Flush();
+}
+
+wxFileOffset wxFFileOutputStream::GetLength() const
+{
+ return m_file->Length();
+}
+
+// ----------------------------------------------------------------------------
+// wxFFileStream
+// ----------------------------------------------------------------------------
+
+wxFFileStream::wxFFileStream(const wxString& fileName)
+ : wxFFileInputStream(fileName)
+{
+ wxFFileOutputStream::m_file = wxFFileInputStream::m_file;