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(NO_GCC_PRAGMA)
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 wxFileOffset
GetLength() const;
42 bool Ok() const { return m_file
->IsOpened(); }
47 size_t OnSysRead(void *buffer
, size_t size
);
48 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
49 wxFileOffset
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 bool Close() { return m_file_destroy
? m_file
->Close() : true; }
71 wxFileOffset
GetLength() const;
73 bool Ok() const { return m_file
->IsOpened(); }
78 size_t OnSysWrite(const void *buffer
, size_t size
);
79 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
80 wxFileOffset
OnSysTell() const;
86 DECLARE_NO_COPY_CLASS(wxFileOutputStream
)
89 class WXDLLIMPEXP_BASE wxFileStream
: public wxFileInputStream
,
90 public wxFileOutputStream
93 wxFileStream(const wxString
& fileName
);
96 DECLARE_NO_COPY_CLASS(wxFileStream
)
99 // ----------------------------------------------------------------------------
100 // wxFFileStream using wxFFile
101 // ----------------------------------------------------------------------------
103 class WXDLLIMPEXP_BASE wxFFileInputStream
: public wxInputStream
{
105 wxFFileInputStream(const wxString
& ifileName
);
106 wxFFileInputStream(wxFFile
& file
);
107 wxFFileInputStream(FILE *file
);
108 ~wxFFileInputStream();
110 wxFileOffset
GetLength() const;
112 bool Ok() const { return m_file
->IsOpened(); }
115 wxFFileInputStream();
117 size_t OnSysRead(void *buffer
, size_t size
);
118 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
119 wxFileOffset
OnSysTell() const;
125 DECLARE_NO_COPY_CLASS(wxFFileInputStream
)
128 class WXDLLIMPEXP_BASE wxFFileOutputStream
: public wxOutputStream
{
130 wxFFileOutputStream(const wxString
& fileName
);
131 wxFFileOutputStream(wxFFile
& file
);
132 wxFFileOutputStream(FILE *file
);
133 virtual ~wxFFileOutputStream();
135 // To solve an ambiguity on GCC
136 // inline wxOutputStream& Write(const void *buffer, size_t size)
137 // { return wxOutputStream::Write(buffer, size); }
140 bool Close() { return m_file_destroy
? m_file
->Close() : true; }
141 wxFileOffset
GetLength() const;
143 bool Ok() const { return m_file
->IsOpened(); }
146 wxFFileOutputStream();
148 size_t OnSysWrite(const void *buffer
, size_t size
);
149 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
150 wxFileOffset
OnSysTell() const;
156 DECLARE_NO_COPY_CLASS(wxFFileOutputStream
)
159 class WXDLLIMPEXP_BASE wxFFileStream
: public wxFFileInputStream
,
160 public wxFFileOutputStream
163 wxFFileStream(const wxString
& fileName
);
166 DECLARE_NO_COPY_CLASS(wxFFileStream
)
170 // wxUSE_STREAMS && wxUSE_FILE