1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: File stream classes
4 // Author: Guilhem Lavaux
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_WXFSTREAM_H__
13 #define _WX_WXFSTREAM_H__
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "wfstream.h"
21 #if wxUSE_STREAMS && wxUSE_FILE
23 #include "wx/object.h"
24 #include "wx/string.h"
25 #include "wx/stream.h"
29 // ----------------------------------------------------------------------------
30 // wxFileStream using wxFile
31 // ----------------------------------------------------------------------------
33 class WXDLLIMPEXP_BASE wxFileInputStream
: public wxInputStream
{
35 wxFileInputStream(const wxString
& ifileName
);
36 wxFileInputStream(wxFile
& file
);
37 wxFileInputStream(int fd
);
40 size_t GetSize() const;
42 bool Ok() const { return m_file
->IsOpened(); }
47 size_t OnSysRead(void *buffer
, size_t size
);
48 off_t
OnSysSeek(off_t pos
, wxSeekMode mode
);
49 off_t
OnSysTell() const;
55 DECLARE_NO_COPY_CLASS(wxFileInputStream
)
58 class WXDLLIMPEXP_BASE wxFileOutputStream
: public wxOutputStream
{
60 wxFileOutputStream(const wxString
& fileName
);
61 wxFileOutputStream(wxFile
& file
);
62 wxFileOutputStream(int fd
);
63 virtual ~wxFileOutputStream();
65 // To solve an ambiguity on GCC
66 // inline wxOutputStream& Write(const void *buffer, size_t size)
67 // { return wxOutputStream::Write(buffer, size); }
70 size_t GetSize() const;
72 bool Ok() const { return m_file
->IsOpened(); }
77 size_t OnSysWrite(const void *buffer
, size_t size
);
78 off_t
OnSysSeek(off_t pos
, wxSeekMode mode
);
79 off_t
OnSysTell() const;
85 DECLARE_NO_COPY_CLASS(wxFileOutputStream
)
88 class WXDLLIMPEXP_BASE wxFileStream
: public wxFileInputStream
, public wxFileOutputStream
{
90 wxFileStream(const wxString
& fileName
);
93 // ----------------------------------------------------------------------------
94 // wxFFileStream using wxFFile
95 // ----------------------------------------------------------------------------
97 class WXDLLIMPEXP_BASE wxFFileInputStream
: public wxInputStream
{
99 wxFFileInputStream(const wxString
& ifileName
);
100 wxFFileInputStream(wxFFile
& file
);
101 wxFFileInputStream(FILE *file
);
102 ~wxFFileInputStream();
104 size_t GetSize() const;
106 bool Ok() const { return m_file
->IsOpened(); }
109 wxFFileInputStream();
111 size_t OnSysRead(void *buffer
, size_t size
);
112 off_t
OnSysSeek(off_t pos
, wxSeekMode mode
);
113 off_t
OnSysTell() const;
119 DECLARE_NO_COPY_CLASS(wxFFileInputStream
)
122 class WXDLLIMPEXP_BASE wxFFileOutputStream
: public wxOutputStream
{
124 wxFFileOutputStream(const wxString
& fileName
);
125 wxFFileOutputStream(wxFFile
& file
);
126 wxFFileOutputStream(FILE *file
);
127 virtual ~wxFFileOutputStream();
129 // To solve an ambiguity on GCC
130 // inline wxOutputStream& Write(const void *buffer, size_t size)
131 // { return wxOutputStream::Write(buffer, size); }
134 size_t GetSize() const;
136 bool Ok() const { return m_file
->IsOpened(); }
139 wxFFileOutputStream();
141 size_t OnSysWrite(const void *buffer
, size_t size
);
142 off_t
OnSysSeek(off_t pos
, wxSeekMode mode
);
143 off_t
OnSysTell() const;
149 DECLARE_NO_COPY_CLASS(wxFFileOutputStream
)
152 class WXDLLIMPEXP_BASE wxFFileStream
: public wxFFileInputStream
, public wxFFileOutputStream
{
154 wxFFileStream(const wxString
& fileName
);
157 // wxUSE_STREAMS && wxUSE_FILE