]>
git.saurik.com Git - wxWidgets.git/blob - src/common/fstream.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: "File stream" classes
4 // Author: Julian Smart
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "fstream.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
19 #include <wx/stream.h>
20 #include <wx/fstream.h>
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 wxFileInputStream::wxFileInputStream(const wxString
& fileName
)
33 m_file
= new wxFile(fileName
, wxFile::read
);
34 m_file_destroy
= TRUE
;
35 m_i_streambuf
->SetBufferIO(1024);
38 wxFileInputStream::wxFileInputStream()
41 m_file_destroy
= FALSE
;
45 wxFileInputStream::~wxFileInputStream()
51 char wxFileInputStream::Peek()
56 size_t wxFileInputStream::OnSysRead(void *buffer
, size_t size
)
58 return m_file
->Read(buffer
, size
);
61 off_t
wxFileInputStream::OnSysSeek(off_t pos
, wxSeekMode mode
)
63 return m_file
->Seek(pos
, mode
);
66 off_t
wxFileInputStream::OnSysTell() const
68 return m_file
->Tell();
71 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
75 wxFileOutputStream::wxFileOutputStream(const wxString
& fileName
)
77 m_file
= new wxFile(fileName
, wxFile::write
);
78 m_file_destroy
= TRUE
;
79 m_o_streambuf
->SetBufferIO(1024);
82 wxFileOutputStream::wxFileOutputStream()
85 m_o_streambuf
->SetBufferIO(1024);
86 m_file_destroy
= FALSE
;
90 wxFileOutputStream::~wxFileOutputStream()
98 size_t wxFileOutputStream::OnSysWrite(const void *buffer
, size_t size
)
100 size_t ret
= m_file
->Write(buffer
, size
);
101 m_lasterror
= wxStream_EOF
; // TODO
105 off_t
wxFileOutputStream::OnSysTell() const
107 return m_file
->Tell();
110 off_t
wxFileOutputStream::OnSysSeek(off_t pos
, wxSeekMode mode
)
112 return m_file
->Seek(pos
, mode
);
115 void wxFileOutputStream::Sync()
117 wxOutputStream::Sync();