]> git.saurik.com Git - wxWidgets.git/blame - include/wx/wfstream.h
Made toolbars sticky, i.e. you need to drag them
[wxWidgets.git] / include / wx / wfstream.h
CommitLineData
32fc4afb 1/////////////////////////////////////////////////////////////////////////////
5fec5bb6 2// Name: wx/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
2df98b23 15#include "wx/defs.h"
ce4169a4 16
85990624 17#if wxUSE_STREAMS
ce4169a4 18
ed58dbea
RR
19#include "wx/object.h"
20#include "wx/string.h"
21#include "wx/stream.h"
22#include "wx/file.h"
65045edd
RR
23#include "wx/ffile.h"
24
85990624
RN
25#if wxUSE_FILE
26
65045edd
RR
27// ----------------------------------------------------------------------------
28// wxFileStream using wxFile
29// ----------------------------------------------------------------------------
32fc4afb 30
5fec5bb6
VZ
31class WXDLLIMPEXP_BASE wxFileInputStream : public wxInputStream
32{
33public:
34 wxFileInputStream(const wxString& ifileName);
35 wxFileInputStream(wxFile& file);
36 wxFileInputStream(int fd);
37 ~wxFileInputStream();
32fc4afb 38
5fec5bb6 39 wxFileOffset GetLength() const;
32fc4afb 40
5fec5bb6 41 bool Ok() const { return m_file->IsOpened(); }
0912690b 42 bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; }
79c3e0e1 43
5fec5bb6
VZ
44protected:
45 wxFileInputStream();
79c3e0e1 46
5fec5bb6
VZ
47 size_t OnSysRead(void *buffer, size_t size);
48 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
49 wxFileOffset OnSysTell() const;
75ed1d15 50
5fec5bb6
VZ
51protected:
52 wxFile *m_file;
53 bool m_file_destroy;
22f3361e
VZ
54
55 DECLARE_NO_COPY_CLASS(wxFileInputStream)
79c3e0e1
GL
56};
57
5fec5bb6
VZ
58class WXDLLIMPEXP_BASE wxFileOutputStream : public wxOutputStream
59{
60public:
61 wxFileOutputStream(const wxString& fileName);
62 wxFileOutputStream(wxFile& file);
63 wxFileOutputStream(int fd);
64 virtual ~wxFileOutputStream();
32fc4afb 65
5fec5bb6
VZ
66 void Sync();
67 bool Close() { return m_file_destroy ? m_file->Close() : true; }
68 wxFileOffset GetLength() const;
32fc4afb 69
5fec5bb6 70 bool Ok() const { return m_file->IsOpened(); }
0912690b 71 bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; }
32fc4afb 72
5fec5bb6
VZ
73protected:
74 wxFileOutputStream();
32fc4afb 75
5fec5bb6
VZ
76 size_t OnSysWrite(const void *buffer, size_t size);
77 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
78 wxFileOffset OnSysTell() const;
32fc4afb 79
5fec5bb6
VZ
80protected:
81 wxFile *m_file;
82 bool m_file_destroy;
22f3361e
VZ
83
84 DECLARE_NO_COPY_CLASS(wxFileOutputStream)
32fc4afb
GL
85};
86
e1265174
MW
87class WXDLLIMPEXP_BASE wxTempFileOutputStream : public wxOutputStream
88{
89public:
90 wxTempFileOutputStream(const wxString& fileName);
91 virtual ~wxTempFileOutputStream();
92
93 bool Close() { return Commit(); }
94 virtual bool Commit() { return m_file->Commit(); }
95 virtual void Discard() { m_file->Discard(); }
96
97 wxFileOffset GetLength() const { return m_file->Length(); }
98 bool IsSeekable() const { return true; }
99
100protected:
101 size_t OnSysWrite(const void *buffer, size_t size);
102 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode)
103 { return m_file->Seek(pos, mode); }
104 wxFileOffset OnSysTell() const { return m_file->Tell(); }
105
106private:
107 wxTempFile *m_file;
108
109 DECLARE_NO_COPY_CLASS(wxTempFileOutputStream)
110};
111
fc7a2a60
VZ
112class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream,
113 public wxFileOutputStream
114{
115public:
116 wxFileStream(const wxString& fileName);
117
118private:
119 DECLARE_NO_COPY_CLASS(wxFileStream)
84b46c35
GL
120};
121
85990624
RN
122#endif //wxUSE_FILE
123
124#if wxUSE_FFILE
125
65045edd
RR
126// ----------------------------------------------------------------------------
127// wxFFileStream using wxFFile
128// ----------------------------------------------------------------------------
129
5fec5bb6
VZ
130class WXDLLIMPEXP_BASE wxFFileInputStream : public wxInputStream
131{
132public:
133 wxFFileInputStream(const wxString& fileName, const wxChar *mode = _T("rb"));
134 wxFFileInputStream(wxFFile& file);
135 wxFFileInputStream(FILE *file);
136 ~wxFFileInputStream();
65045edd 137
5fec5bb6 138 wxFileOffset GetLength() const;
65045edd 139
5fec5bb6 140 bool Ok() const { return m_file->IsOpened(); }
0912690b 141 bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; }
65045edd 142
5fec5bb6
VZ
143protected:
144 wxFFileInputStream();
65045edd 145
5fec5bb6
VZ
146 size_t OnSysRead(void *buffer, size_t size);
147 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
148 wxFileOffset OnSysTell() const;
65045edd 149
5fec5bb6
VZ
150protected:
151 wxFFile *m_file;
152 bool m_file_destroy;
22f3361e
VZ
153
154 DECLARE_NO_COPY_CLASS(wxFFileInputStream)
65045edd
RR
155};
156
5fec5bb6
VZ
157class WXDLLIMPEXP_BASE wxFFileOutputStream : public wxOutputStream
158{
159public:
160 wxFFileOutputStream(const wxString& fileName, const wxChar *mode = _T("w+b"));
161 wxFFileOutputStream(wxFFile& file);
162 wxFFileOutputStream(FILE *file);
163 virtual ~wxFFileOutputStream();
65045edd 164
5fec5bb6
VZ
165 void Sync();
166 bool Close() { return m_file_destroy ? m_file->Close() : true; }
167 wxFileOffset GetLength() const;
65045edd 168
5fec5bb6 169 bool Ok() const { return m_file->IsOpened(); }
0912690b 170 bool IsSeekable() const { return m_file->GetKind() == wxFILE_KIND_DISK; }
65045edd 171
5fec5bb6
VZ
172protected:
173 wxFFileOutputStream();
65045edd 174
5fec5bb6
VZ
175 size_t OnSysWrite(const void *buffer, size_t size);
176 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
177 wxFileOffset OnSysTell() const;
65045edd 178
5fec5bb6
VZ
179protected:
180 wxFFile *m_file;
181 bool m_file_destroy;
22f3361e
VZ
182
183 DECLARE_NO_COPY_CLASS(wxFFileOutputStream)
65045edd
RR
184};
185
fc7a2a60
VZ
186class WXDLLIMPEXP_BASE wxFFileStream : public wxFFileInputStream,
187 public wxFFileOutputStream
188{
189public:
190 wxFFileStream(const wxString& fileName);
191
192private:
193 DECLARE_NO_COPY_CLASS(wxFFileStream)
65045edd 194};
fc7a2a60 195
85990624
RN
196#endif //wxUSE_FFILE
197
198#endif // wxUSE_STREAMS
a0250ba3 199
5fec5bb6 200#endif // _WX_WXFSTREAM_H__