]> git.saurik.com Git - wxWidgets.git/blame - include/wx/wfstream.h
Avoid error message when closing message
[wxWidgets.git] / include / wx / wfstream.h
CommitLineData
32fc4afb 1/////////////////////////////////////////////////////////////////////////////
bd5e2346 2// Name: wfstream.h
32fc4afb
GL
3// Purpose: File stream classes
4// Author: Guilhem Lavaux
5// Modified by:
6// Created: 11/07/98
7// RCS-ID: $Id$
8// Copyright: (c) Guilhem Lavaux
65571936 9// Licence: wxWindows licence
32fc4afb 10/////////////////////////////////////////////////////////////////////////////
0c32066b 11
34138703
JS
12#ifndef _WX_WXFSTREAM_H__
13#define _WX_WXFSTREAM_H__
32fc4afb 14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
bd5e2346 16#pragma interface "wfstream.h"
0c32066b
JS
17#endif
18
2df98b23 19#include "wx/defs.h"
ce4169a4
RR
20
21#if wxUSE_STREAMS && wxUSE_FILE
22
ed58dbea
RR
23#include "wx/object.h"
24#include "wx/string.h"
25#include "wx/stream.h"
26#include "wx/file.h"
65045edd
RR
27#include "wx/ffile.h"
28
29// ----------------------------------------------------------------------------
30// wxFileStream using wxFile
31// ----------------------------------------------------------------------------
32fc4afb 32
bddd7a8d 33class WXDLLIMPEXP_BASE wxFileInputStream: public wxInputStream {
32fc4afb 34 public:
75ed1d15
GL
35 wxFileInputStream(const wxString& ifileName);
36 wxFileInputStream(wxFile& file);
37 wxFileInputStream(int fd);
84b46c35 38 ~wxFileInputStream();
32fc4afb 39
588066b7 40 wxFileOffset GetLength() const;
32fc4afb 41
25c70b07 42 bool Ok() const { return m_file->IsOpened(); }
79c3e0e1
GL
43
44 protected:
25c70b07 45 wxFileInputStream();
79c3e0e1 46
75ed1d15 47 size_t OnSysRead(void *buffer, size_t size);
4004775e
RL
48 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
49 wxFileOffset OnSysTell() const;
75ed1d15
GL
50
51 protected:
52 wxFile *m_file;
53 bool m_file_destroy;
22f3361e
VZ
54
55 DECLARE_NO_COPY_CLASS(wxFileInputStream)
79c3e0e1
GL
56};
57
bddd7a8d 58class WXDLLIMPEXP_BASE wxFileOutputStream: public wxOutputStream {
79c3e0e1
GL
59 public:
60 wxFileOutputStream(const wxString& fileName);
75ed1d15
GL
61 wxFileOutputStream(wxFile& file);
62 wxFileOutputStream(int fd);
79c3e0e1
GL
63 virtual ~wxFileOutputStream();
64
1678ad78 65 // To solve an ambiguity on GCC
a737331d
GL
66// inline wxOutputStream& Write(const void *buffer, size_t size)
67// { return wxOutputStream::Write(buffer, size); }
32fc4afb
GL
68
69 void Sync();
8f0ff178 70 bool Close() { return m_file_destroy ? m_file->Close() : true; }
588066b7 71 wxFileOffset GetLength() const;
32fc4afb 72
25c70b07 73 bool Ok() const { return m_file->IsOpened(); }
32fc4afb 74
79c3e0e1 75 protected:
25c70b07 76 wxFileOutputStream();
32fc4afb 77
75ed1d15 78 size_t OnSysWrite(const void *buffer, size_t size);
4004775e
RL
79 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
80 wxFileOffset OnSysTell() const;
32fc4afb 81
75ed1d15
GL
82 protected:
83 wxFile *m_file;
84 bool m_file_destroy;
22f3361e
VZ
85
86 DECLARE_NO_COPY_CLASS(wxFileOutputStream)
32fc4afb
GL
87};
88
fc7a2a60
VZ
89class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream,
90 public wxFileOutputStream
91{
92public:
93 wxFileStream(const wxString& fileName);
94
95private:
96 DECLARE_NO_COPY_CLASS(wxFileStream)
84b46c35
GL
97};
98
65045edd
RR
99// ----------------------------------------------------------------------------
100// wxFFileStream using wxFFile
101// ----------------------------------------------------------------------------
102
bddd7a8d 103class WXDLLIMPEXP_BASE wxFFileInputStream: public wxInputStream {
65045edd
RR
104 public:
105 wxFFileInputStream(const wxString& ifileName);
106 wxFFileInputStream(wxFFile& file);
107 wxFFileInputStream(FILE *file);
108 ~wxFFileInputStream();
109
588066b7 110 wxFileOffset GetLength() const;
65045edd
RR
111
112 bool Ok() const { return m_file->IsOpened(); }
113
114 protected:
115 wxFFileInputStream();
116
117 size_t OnSysRead(void *buffer, size_t size);
4004775e
RL
118 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
119 wxFileOffset OnSysTell() const;
65045edd
RR
120
121 protected:
122 wxFFile *m_file;
123 bool m_file_destroy;
22f3361e
VZ
124
125 DECLARE_NO_COPY_CLASS(wxFFileInputStream)
65045edd
RR
126};
127
bddd7a8d 128class WXDLLIMPEXP_BASE wxFFileOutputStream: public wxOutputStream {
65045edd
RR
129 public:
130 wxFFileOutputStream(const wxString& fileName);
131 wxFFileOutputStream(wxFFile& file);
132 wxFFileOutputStream(FILE *file);
133 virtual ~wxFFileOutputStream();
134
135 // To solve an ambiguity on GCC
136// inline wxOutputStream& Write(const void *buffer, size_t size)
137// { return wxOutputStream::Write(buffer, size); }
138
139 void Sync();
8f0ff178 140 bool Close() { return m_file_destroy ? m_file->Close() : true; }
588066b7 141 wxFileOffset GetLength() const;
65045edd
RR
142
143 bool Ok() const { return m_file->IsOpened(); }
144
145 protected:
146 wxFFileOutputStream();
147
148 size_t OnSysWrite(const void *buffer, size_t size);
4004775e
RL
149 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
150 wxFileOffset OnSysTell() const;
65045edd
RR
151
152 protected:
153 wxFFile *m_file;
154 bool m_file_destroy;
22f3361e
VZ
155
156 DECLARE_NO_COPY_CLASS(wxFFileOutputStream)
65045edd
RR
157};
158
fc7a2a60
VZ
159class WXDLLIMPEXP_BASE wxFFileStream : public wxFFileInputStream,
160 public wxFFileOutputStream
161{
162public:
163 wxFFileStream(const wxString& fileName);
164
165private:
166 DECLARE_NO_COPY_CLASS(wxFFileStream)
65045edd 167};
fc7a2a60 168
32fc4afb 169#endif
ce4169a4
RR
170 // wxUSE_STREAMS && wxUSE_FILE
171
172#endif
cc985fac
PA
173 // _WX_WXFSTREAM_H__
174
a0250ba3
RD
175
176
177
178
179
180
181