]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wfstream.h | |
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 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_WXFSTREAM_H__ | |
13 | #define _WX_WXFSTREAM_H__ | |
14 | ||
15 | #if defined(__GNUG__) && !defined(__APPLE__) | |
16 | #pragma interface "wfstream.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
21 | #if wxUSE_STREAMS && wxUSE_FILE | |
22 | ||
23 | #include "wx/object.h" | |
24 | #include "wx/string.h" | |
25 | #include "wx/stream.h" | |
26 | #include "wx/file.h" | |
27 | #include "wx/ffile.h" | |
28 | ||
29 | // ---------------------------------------------------------------------------- | |
30 | // wxFileStream using wxFile | |
31 | // ---------------------------------------------------------------------------- | |
32 | ||
33 | class WXDLLEXPORT wxFileInputStream: public wxInputStream { | |
34 | public: | |
35 | wxFileInputStream(const wxString& ifileName); | |
36 | wxFileInputStream(wxFile& file); | |
37 | wxFileInputStream(int fd); | |
38 | ~wxFileInputStream(); | |
39 | ||
40 | size_t GetSize() const; | |
41 | ||
42 | bool Ok() const { return m_file->IsOpened(); } | |
43 | ||
44 | protected: | |
45 | wxFileInputStream(); | |
46 | ||
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; | |
54 | ||
55 | DECLARE_NO_COPY_CLASS(wxFileInputStream) | |
56 | }; | |
57 | ||
58 | class WXDLLEXPORT wxFileOutputStream: public wxOutputStream { | |
59 | public: | |
60 | wxFileOutputStream(const wxString& fileName); | |
61 | wxFileOutputStream(wxFile& file); | |
62 | wxFileOutputStream(int fd); | |
63 | virtual ~wxFileOutputStream(); | |
64 | ||
65 | // To solve an ambiguity on GCC | |
66 | // inline wxOutputStream& Write(const void *buffer, size_t size) | |
67 | // { return wxOutputStream::Write(buffer, size); } | |
68 | ||
69 | void Sync(); | |
70 | size_t GetSize() const; | |
71 | ||
72 | bool Ok() const { return m_file->IsOpened(); } | |
73 | ||
74 | protected: | |
75 | wxFileOutputStream(); | |
76 | ||
77 | size_t OnSysWrite(const void *buffer, size_t size); | |
78 | off_t OnSysSeek(off_t pos, wxSeekMode mode); | |
79 | off_t OnSysTell() const; | |
80 | ||
81 | protected: | |
82 | wxFile *m_file; | |
83 | bool m_file_destroy; | |
84 | ||
85 | DECLARE_NO_COPY_CLASS(wxFileOutputStream) | |
86 | }; | |
87 | ||
88 | class WXDLLEXPORT wxFileStream: public wxFileInputStream, public wxFileOutputStream { | |
89 | public: | |
90 | wxFileStream(const wxString& fileName); | |
91 | }; | |
92 | ||
93 | // ---------------------------------------------------------------------------- | |
94 | // wxFFileStream using wxFFile | |
95 | // ---------------------------------------------------------------------------- | |
96 | ||
97 | class WXDLLEXPORT wxFFileInputStream: public wxInputStream { | |
98 | public: | |
99 | wxFFileInputStream(const wxString& ifileName); | |
100 | wxFFileInputStream(wxFFile& file); | |
101 | wxFFileInputStream(FILE *file); | |
102 | ~wxFFileInputStream(); | |
103 | ||
104 | size_t GetSize() const; | |
105 | ||
106 | bool Ok() const { return m_file->IsOpened(); } | |
107 | ||
108 | protected: | |
109 | wxFFileInputStream(); | |
110 | ||
111 | size_t OnSysRead(void *buffer, size_t size); | |
112 | off_t OnSysSeek(off_t pos, wxSeekMode mode); | |
113 | off_t OnSysTell() const; | |
114 | ||
115 | protected: | |
116 | wxFFile *m_file; | |
117 | bool m_file_destroy; | |
118 | ||
119 | DECLARE_NO_COPY_CLASS(wxFFileInputStream) | |
120 | }; | |
121 | ||
122 | class WXDLLEXPORT wxFFileOutputStream: public wxOutputStream { | |
123 | public: | |
124 | wxFFileOutputStream(const wxString& fileName); | |
125 | wxFFileOutputStream(wxFFile& file); | |
126 | wxFFileOutputStream(FILE *file); | |
127 | virtual ~wxFFileOutputStream(); | |
128 | ||
129 | // To solve an ambiguity on GCC | |
130 | // inline wxOutputStream& Write(const void *buffer, size_t size) | |
131 | // { return wxOutputStream::Write(buffer, size); } | |
132 | ||
133 | void Sync(); | |
134 | size_t GetSize() const; | |
135 | ||
136 | bool Ok() const { return m_file->IsOpened(); } | |
137 | ||
138 | protected: | |
139 | wxFFileOutputStream(); | |
140 | ||
141 | size_t OnSysWrite(const void *buffer, size_t size); | |
142 | off_t OnSysSeek(off_t pos, wxSeekMode mode); | |
143 | off_t OnSysTell() const; | |
144 | ||
145 | protected: | |
146 | wxFFile *m_file; | |
147 | bool m_file_destroy; | |
148 | ||
149 | DECLARE_NO_COPY_CLASS(wxFFileOutputStream) | |
150 | }; | |
151 | ||
152 | class WXDLLEXPORT wxFFileStream: public wxFFileInputStream, public wxFFileOutputStream { | |
153 | public: | |
154 | wxFFileStream(const wxString& fileName); | |
155 | }; | |
156 | #endif | |
157 | // wxUSE_STREAMS && wxUSE_FILE | |
158 | ||
159 | #endif | |
160 | // _WX_WXFSTREAM_H__ | |
161 | ||
162 | ||
163 | ||
164 | ||
165 | ||
166 | ||
167 | ||
168 |