]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wfstream.cpp
More _T() in asserts...
[wxWidgets.git] / src / common / wfstream.cpp
index 885bab4cf975ac8c1fdac0d6e06861e847e290d6..50c662d35ceeb33dd33ac5ac4b31e4f244042f2a 100644 (file)
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
-#include <stdio.h>
-#include <wx/stream.h>
-#include <wx/wfstream.h>
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+  #pragma hdrstop
 #endif
 
+#if wxUSE_STREAMS && wxUSE_FILE
+
+#include <stdio.h>
+#include "wx/stream.h"
+#include "wx/wfstream.h"
+
 // ----------------------------------------------------------------------------
 // wxFileInputStream
 // ----------------------------------------------------------------------------
@@ -32,7 +35,6 @@ wxFileInputStream::wxFileInputStream(const wxString& fileName)
 {
   m_file = new wxFile(fileName, wxFile::read);
   m_file_destroy = TRUE;
-  m_i_streambuf->SetBufferIO(1024);
 }
 
 wxFileInputStream::wxFileInputStream()
@@ -46,14 +48,12 @@ wxFileInputStream::wxFileInputStream(wxFile& file)
 {
   m_file = &file;
   m_file_destroy = FALSE;
-  m_i_streambuf->SetBufferIO(1024);
 }
 
 wxFileInputStream::wxFileInputStream(int fd)
 {
   m_file = new wxFile(fd);
   m_file_destroy = TRUE;
-  m_i_streambuf->SetBufferIO(1024);
 }
 
 wxFileInputStream::~wxFileInputStream()
@@ -74,7 +74,18 @@ size_t wxFileInputStream::StreamSize() const
 
 size_t wxFileInputStream::OnSysRead(void *buffer, size_t size)
 {
-  return m_file->Read(buffer, size);
+  off_t ret;
+
+  ret = m_file->Read(buffer, size);
+
+  if (m_file->Eof())
+    m_lasterror = wxStream_EOF;
+  if (ret == wxInvalidOffset) {
+    m_lasterror = wxStream_READ_ERR;
+    ret = 0;
+  } 
+
+  return ret;
 }
 
 off_t wxFileInputStream::OnSysSeek(off_t pos, wxSeekMode mode)
@@ -95,20 +106,17 @@ wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
 {
   m_file = new wxFile(fileName, wxFile::write);
   m_file_destroy = TRUE;
-  m_o_streambuf->SetBufferIO(1024);
 }
 
 wxFileOutputStream::wxFileOutputStream(wxFile& file)
 {
   m_file = &file;
   m_file_destroy = FALSE;
-  m_o_streambuf->SetBufferIO(1024);
 }
 
 wxFileOutputStream::wxFileOutputStream()
   : wxOutputStream()
 {
-  m_o_streambuf->SetBufferIO(1024);
   m_file_destroy = FALSE;
   m_file = NULL;
 }
@@ -117,7 +125,6 @@ wxFileOutputStream::wxFileOutputStream(int fd)
 {
   m_file = new wxFile(fd);
   m_file_destroy = TRUE;
-  m_o_streambuf->SetBufferIO(1024);
 }
 
 wxFileOutputStream::~wxFileOutputStream()
@@ -131,7 +138,10 @@ wxFileOutputStream::~wxFileOutputStream()
 size_t wxFileOutputStream::OnSysWrite(const void *buffer, size_t size)
 {
   size_t ret = m_file->Write(buffer, size);
-  m_lasterror = wxStream_EOF; // TODO
+  if (m_file->Error())
+    m_lasterror = wxStream_WRITE_ERR;
+  else
+    m_lasterror = wxStream_NOERROR;
   return ret;
 }
 
@@ -163,3 +173,7 @@ wxFileStream::wxFileStream(const wxString& fileName)
  : wxFileInputStream(fileName), wxFileOutputStream(*wxFileInputStream::m_file)
 {
 }
+
+#endif
+  // wxUSE_STREAMS && wxUSE_FILE
+