]>
Commit | Line | Data |
---|---|---|
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 | |
9 | // Licence: wxWindows licence | |
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 | 33 | class 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 | |
cd25b18c | 40 | size_t GetSize() const; |
32fc4afb | 41 | |
25c70b07 | 42 | bool Ok() const { return m_file->IsOpened(); } |
79c3e0e1 GL |
43 | |
44 | protected: | |
25c70b07 | 45 | wxFileInputStream(); |
79c3e0e1 | 46 | |
75ed1d15 GL |
47 | size_t OnSysRead(void *buffer, size_t size); |
48 | off_t OnSysSeek(off_t pos, wxSeekMode mode); | |
49 | off_t OnSysTell() const; | |
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 | 58 | class 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(); | |
cd25b18c | 70 | size_t GetSize() const; |
32fc4afb | 71 | |
25c70b07 | 72 | bool Ok() const { return m_file->IsOpened(); } |
32fc4afb | 73 | |
79c3e0e1 | 74 | protected: |
25c70b07 | 75 | wxFileOutputStream(); |
32fc4afb | 76 | |
75ed1d15 GL |
77 | size_t OnSysWrite(const void *buffer, size_t size); |
78 | off_t OnSysSeek(off_t pos, wxSeekMode mode); | |
79 | off_t OnSysTell() const; | |
32fc4afb | 80 | |
75ed1d15 GL |
81 | protected: |
82 | wxFile *m_file; | |
83 | bool m_file_destroy; | |
22f3361e VZ |
84 | |
85 | DECLARE_NO_COPY_CLASS(wxFileOutputStream) | |
32fc4afb GL |
86 | }; |
87 | ||
fc7a2a60 VZ |
88 | class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream, |
89 | public wxFileOutputStream | |
90 | { | |
91 | public: | |
92 | wxFileStream(const wxString& fileName); | |
93 | ||
94 | private: | |
95 | DECLARE_NO_COPY_CLASS(wxFileStream) | |
84b46c35 GL |
96 | }; |
97 | ||
65045edd RR |
98 | // ---------------------------------------------------------------------------- |
99 | // wxFFileStream using wxFFile | |
100 | // ---------------------------------------------------------------------------- | |
101 | ||
bddd7a8d | 102 | class WXDLLIMPEXP_BASE wxFFileInputStream: public wxInputStream { |
65045edd RR |
103 | public: |
104 | wxFFileInputStream(const wxString& ifileName); | |
105 | wxFFileInputStream(wxFFile& file); | |
106 | wxFFileInputStream(FILE *file); | |
107 | ~wxFFileInputStream(); | |
108 | ||
109 | size_t GetSize() const; | |
110 | ||
111 | bool Ok() const { return m_file->IsOpened(); } | |
112 | ||
113 | protected: | |
114 | wxFFileInputStream(); | |
115 | ||
116 | size_t OnSysRead(void *buffer, size_t size); | |
117 | off_t OnSysSeek(off_t pos, wxSeekMode mode); | |
118 | off_t OnSysTell() const; | |
119 | ||
120 | protected: | |
121 | wxFFile *m_file; | |
122 | bool m_file_destroy; | |
22f3361e VZ |
123 | |
124 | DECLARE_NO_COPY_CLASS(wxFFileInputStream) | |
65045edd RR |
125 | }; |
126 | ||
bddd7a8d | 127 | class WXDLLIMPEXP_BASE wxFFileOutputStream: public wxOutputStream { |
65045edd RR |
128 | public: |
129 | wxFFileOutputStream(const wxString& fileName); | |
130 | wxFFileOutputStream(wxFFile& file); | |
131 | wxFFileOutputStream(FILE *file); | |
132 | virtual ~wxFFileOutputStream(); | |
133 | ||
134 | // To solve an ambiguity on GCC | |
135 | // inline wxOutputStream& Write(const void *buffer, size_t size) | |
136 | // { return wxOutputStream::Write(buffer, size); } | |
137 | ||
138 | void Sync(); | |
139 | size_t GetSize() const; | |
140 | ||
141 | bool Ok() const { return m_file->IsOpened(); } | |
142 | ||
143 | protected: | |
144 | wxFFileOutputStream(); | |
145 | ||
146 | size_t OnSysWrite(const void *buffer, size_t size); | |
147 | off_t OnSysSeek(off_t pos, wxSeekMode mode); | |
148 | off_t OnSysTell() const; | |
149 | ||
150 | protected: | |
151 | wxFFile *m_file; | |
152 | bool m_file_destroy; | |
22f3361e VZ |
153 | |
154 | DECLARE_NO_COPY_CLASS(wxFFileOutputStream) | |
65045edd RR |
155 | }; |
156 | ||
fc7a2a60 VZ |
157 | class WXDLLIMPEXP_BASE wxFFileStream : public wxFFileInputStream, |
158 | public wxFFileOutputStream | |
159 | { | |
160 | public: | |
161 | wxFFileStream(const wxString& fileName); | |
162 | ||
163 | private: | |
164 | DECLARE_NO_COPY_CLASS(wxFFileStream) | |
65045edd | 165 | }; |
fc7a2a60 | 166 | |
32fc4afb | 167 | #endif |
ce4169a4 RR |
168 | // wxUSE_STREAMS && wxUSE_FILE |
169 | ||
170 | #endif | |
cc985fac PA |
171 | // _WX_WXFSTREAM_H__ |
172 | ||
a0250ba3 RD |
173 | |
174 | ||
175 | ||
176 | ||
177 | ||
178 | ||
179 |