]>
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 #include <wx/object.h>
18 #include <wx/stream.h>
19 #include <wx/fstream.h>
21 #define BUF_TEMP_SIZE 10000
23 #if !USE_SHARED_LIBRARY
24 IMPLEMENT_CLASS(wxFileStreamBase
, wxStream
)
25 IMPLEMENT_CLASS(wxFileInputStream
, wxFileStreamBase
)
26 IMPLEMENT_CLASS(wxFileOutputStream
, wxFileStreamBase
)
27 IMPLEMENT_CLASS(wxFileStream
, wxFileStreamBase
)
30 wxFileStreamBase::wxFileStreamBase(const wxString
& fileName
, int iolimit
)
46 m_file
= fopen(fileName
, open_mode
);
47 fseek(m_file
, 0, SEEK_SET
);
53 wxFileStreamBase::~wxFileStreamBase()
58 wxInputStream
& wxFileStreamBase::Read(void *buffer
, size_t size
)
60 m_lastread
= fread(buffer
, 1, size
, m_file
);
65 wxOutputStream
& wxFileStreamBase::Write(const void *buffer
, size_t size
)
67 m_lastwrite
= fwrite(buffer
, 1, size
, m_file
);
68 m_bad
= ferror(m_file
) != 0;
72 size_t wxFileStreamBase::SeekI(int pos
, wxWhenceType whence
)
76 if (whence
== wxBeginPosition
)
77 real_whence
= SEEK_SET
;
78 else if (whence
== wxCurrentPosition
)
79 real_whence
= SEEK_CUR
;
80 else if (whence
== wxEndPosition
)
81 real_whence
= SEEK_END
;
83 fseek(m_file
, pos
, real_whence
);
87 size_t wxFileStreamBase::TellI() const
92 size_t wxFileStreamBase::TellO() const
97 size_t wxFileStreamBase::SeekO(int pos
, wxWhenceType whence
)
99 return SeekI(pos
, whence
);
102 void wxFileStreamBase::Sync()