]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fstream.cpp
no message
[wxWidgets.git] / src / common / fstream.cpp
index d1bfb0637bc0d4020de5e7ba0b73189491e59ca3..7012e2b20a5fbd222f3fc22330b4f1ce03432962 100644 (file)
 #pragma hdrstop
 #endif
 
-#define BUF_TEMP_SIZE 10000
-
 // ----------------------------------------------------------------------------
 // wxFileInputStream
 // ----------------------------------------------------------------------------
 
 wxFileInputStream::wxFileInputStream(const wxString& fileName)
-  : wxFile(fileName, read)
+  : wxInputStream()
 {
-  m_lastread = 0;
+  m_file = new wxFile(fileName, wxFile::read);
+  m_file_destroy = TRUE;
+  m_i_streambuf->SetBufferIO(1024);
+}
+
+wxFileInputStream::wxFileInputStream()
+  : wxInputStream()
+{
+  m_file_destroy = FALSE;
+  m_file = NULL;
 }
 
 wxFileInputStream::~wxFileInputStream()
 {
+  if (m_file_destroy)
+    delete m_file;
 }
 
-wxInputStream& wxFileInputStream::Read(void *buffer, size_t size)
+char wxFileInputStream::Peek()
 {
-  m_lastread = wxFile::Read(buffer, size);
-  return *this;
+  return 0;
 }
 
-off_t wxFileInputStream::SeekI(off_t pos, wxSeekMode mode)
+size_t wxFileInputStream::OnSysRead(void *buffer, size_t size)
 {
-  return wxFile::Seek(pos, mode);
+  return m_file->Read(buffer, size);
 }
 
-off_t wxFileInputStream::TellI() const
+off_t wxFileInputStream::OnSysSeek(off_t pos, wxSeekMode mode)
 {
-  return wxFile::Tell();
+  return m_file->Seek(pos, mode);
+}
+
+off_t wxFileInputStream::OnSysTell() const
+{
+  return m_file->Tell();
 }
 
 // ----------------------------------------------------------------------------
@@ -60,46 +73,47 @@ off_t wxFileInputStream::TellI() const
 // ----------------------------------------------------------------------------
 
 wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
- : wxFile(fileName, write)
 {
-  m_lastwrite = 0;
+  m_file = new wxFile(fileName, wxFile::write);
+  m_file_destroy = TRUE;
+  m_o_streambuf->SetBufferIO(1024);
 }
 
-wxFileOutputStream::~wxFileOutputStream()
+wxFileOutputStream::wxFileOutputStream()
+  : wxOutputStream()
 {
+  m_o_streambuf->SetBufferIO(1024);
+  m_file_destroy = FALSE;
+  m_file = NULL;
 }
 
-wxOutputStream& wxFileOutputStream::Write(const void *buffer, size_t size)
-{
-  m_lastwrite = wxFile::Write(buffer, size);
-  m_bad = wxFile::Error();
-  return *this;
-}
-
-off_t wxFileOutputStream::TellO() const
+wxFileOutputStream::~wxFileOutputStream()
 {
-  return wxFile::Tell();
+  if (m_file_destroy) {
+    Sync();
+    delete m_file;
+  }
 }
 
-off_t wxFileOutputStream::SeekO(off_t pos, wxSeekMode mode)
+size_t wxFileOutputStream::OnSysWrite(const void *buffer, size_t size)
 {
-  return wxFile::Seek(pos, mode);
+  size_t ret = m_file->Write(buffer, size);
+  m_lasterror = wxStream_EOF; // TODO
+  return ret;
 }
 
-void wxFileOutputStream::Sync()
+off_t wxFileOutputStream::OnSysTell() const
 {
-  wxFile::Flush();
+  return m_file->Tell();
 }
 
-// ----------------------------------------------------------------------------
-// wxFileStream
-// ----------------------------------------------------------------------------
-
-wxFileStream::wxFileStream(const wxString& fileName)
-  : wxFile(fileName, read_write)
+off_t wxFileOutputStream::OnSysSeek(off_t pos, wxSeekMode mode)
 {
+  return m_file->Seek(pos, mode);
 }
 
-wxFileStream::~wxFileStream()
+void wxFileOutputStream::Sync()
 {
+  wxOutputStream::Sync();
+  m_file->Flush();
 }