X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/593d4b0dffa77c74444dca03eb1e01c7b5f8a220..704a4b7524e05d7bf4d208eb1b30be9989abef4c:/src/common/wfstream.cpp diff --git a/src/common/wfstream.cpp b/src/common/wfstream.cpp index 4d798f3c79..4bae72adc7 100644 --- a/src/common/wfstream.cpp +++ b/src/common/wfstream.cpp @@ -15,14 +15,21 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#include -#include -#include #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/defs.h" #endif +#if wxUSE_STREAMS && wxUSE_FILE + +#include +#include +#include + // ---------------------------------------------------------------------------- // wxFileInputStream // ---------------------------------------------------------------------------- @@ -32,7 +39,6 @@ wxFileInputStream::wxFileInputStream(const wxString& fileName) { m_file = new wxFile(fileName, wxFile::read); m_file_destroy = TRUE; - m_i_streambuf->SetBufferIO(1024); } wxFileInputStream::wxFileInputStream() @@ -42,6 +48,18 @@ wxFileInputStream::wxFileInputStream() m_file = NULL; } +wxFileInputStream::wxFileInputStream(wxFile& file) +{ + m_file = &file; + m_file_destroy = FALSE; +} + +wxFileInputStream::wxFileInputStream(int fd) +{ + m_file = new wxFile(fd); + m_file_destroy = TRUE; +} + wxFileInputStream::~wxFileInputStream() { if (m_file_destroy) @@ -60,7 +78,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) @@ -81,24 +110,27 @@ 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; } +wxFileOutputStream::wxFileOutputStream(int fd) +{ + m_file = new wxFile(fd); + m_file_destroy = TRUE; +} + wxFileOutputStream::~wxFileOutputStream() { if (m_file_destroy) { @@ -142,3 +174,7 @@ wxFileStream::wxFileStream(const wxString& fileName) : wxFileInputStream(fileName), wxFileOutputStream(*wxFileInputStream::m_file) { } + +#endif + // wxUSE_STREAMS && wxUSE_FILE +