]> git.saurik.com Git - wxWidgets.git/blob - include/wx/wfstream.h
implemented wxStackWalker for Unix (using glibc-specific methods); moved wxUSE_STACKW...
[wxWidgets.git] / include / wx / wfstream.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/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(NO_GCC_PRAGMA)
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 WXDLLIMPEXP_BASE wxFileInputStream : public wxInputStream
34 {
35 public:
36 wxFileInputStream(const wxString& ifileName);
37 wxFileInputStream(wxFile& file);
38 wxFileInputStream(int fd);
39 ~wxFileInputStream();
40
41 wxFileOffset GetLength() const;
42
43 bool Ok() const { return m_file->IsOpened(); }
44
45 protected:
46 wxFileInputStream();
47
48 size_t OnSysRead(void *buffer, size_t size);
49 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
50 wxFileOffset OnSysTell() const;
51
52 protected:
53 wxFile *m_file;
54 bool m_file_destroy;
55
56 DECLARE_NO_COPY_CLASS(wxFileInputStream)
57 };
58
59 class WXDLLIMPEXP_BASE wxFileOutputStream : public wxOutputStream
60 {
61 public:
62 wxFileOutputStream(const wxString& fileName);
63 wxFileOutputStream(wxFile& file);
64 wxFileOutputStream(int fd);
65 virtual ~wxFileOutputStream();
66
67 void Sync();
68 bool Close() { return m_file_destroy ? m_file->Close() : true; }
69 wxFileOffset GetLength() const;
70
71 bool Ok() const { return m_file->IsOpened(); }
72
73 protected:
74 wxFileOutputStream();
75
76 size_t OnSysWrite(const void *buffer, size_t size);
77 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
78 wxFileOffset OnSysTell() const;
79
80 protected:
81 wxFile *m_file;
82 bool m_file_destroy;
83
84 DECLARE_NO_COPY_CLASS(wxFileOutputStream)
85 };
86
87 class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream,
88 public wxFileOutputStream
89 {
90 public:
91 wxFileStream(const wxString& fileName);
92
93 private:
94 DECLARE_NO_COPY_CLASS(wxFileStream)
95 };
96
97 // ----------------------------------------------------------------------------
98 // wxFFileStream using wxFFile
99 // ----------------------------------------------------------------------------
100
101 class WXDLLIMPEXP_BASE wxFFileInputStream : public wxInputStream
102 {
103 public:
104 wxFFileInputStream(const wxString& fileName, const wxChar *mode = _T("rb"));
105 wxFFileInputStream(wxFFile& file);
106 wxFFileInputStream(FILE *file);
107 ~wxFFileInputStream();
108
109 wxFileOffset GetLength() 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 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
118 wxFileOffset OnSysTell() const;
119
120 protected:
121 wxFFile *m_file;
122 bool m_file_destroy;
123
124 DECLARE_NO_COPY_CLASS(wxFFileInputStream)
125 };
126
127 class WXDLLIMPEXP_BASE wxFFileOutputStream : public wxOutputStream
128 {
129 public:
130 wxFFileOutputStream(const wxString& fileName, const wxChar *mode = _T("w+b"));
131 wxFFileOutputStream(wxFFile& file);
132 wxFFileOutputStream(FILE *file);
133 virtual ~wxFFileOutputStream();
134
135 void Sync();
136 bool Close() { return m_file_destroy ? m_file->Close() : true; }
137 wxFileOffset GetLength() const;
138
139 bool Ok() const { return m_file->IsOpened(); }
140
141 protected:
142 wxFFileOutputStream();
143
144 size_t OnSysWrite(const void *buffer, size_t size);
145 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
146 wxFileOffset OnSysTell() const;
147
148 protected:
149 wxFFile *m_file;
150 bool m_file_destroy;
151
152 DECLARE_NO_COPY_CLASS(wxFFileOutputStream)
153 };
154
155 class WXDLLIMPEXP_BASE wxFFileStream : public wxFFileInputStream,
156 public wxFFileOutputStream
157 {
158 public:
159 wxFFileStream(const wxString& fileName);
160
161 private:
162 DECLARE_NO_COPY_CLASS(wxFFileStream)
163 };
164
165 #endif // wxUSE_STREAMS && wxUSE_FILE
166
167 #endif // _WX_WXFSTREAM_H__