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