X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e49f47aa77457548df1a86f74c285ea3226b3cce..520e470fdd0daef09c77938db642e4583933c90d:/src/common/fstream.cpp diff --git a/src/common/fstream.cpp b/src/common/fstream.cpp index d1bfb0637b..7012e2b20a 100644 --- a/src/common/fstream.cpp +++ b/src/common/fstream.cpp @@ -23,36 +23,49 @@ #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(); }