]> git.saurik.com Git - wxWidgets.git/blame - include/wx/wfstream.h
reverted last commit, do this check in wx/chkconf.h instead
[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
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
5fec5bb6
VZ
33class WXDLLIMPEXP_BASE wxFileInputStream : public wxInputStream
34{
35public:
36 wxFileInputStream(const wxString& ifileName);
37 wxFileInputStream(wxFile& file);
38 wxFileInputStream(int fd);
39 ~wxFileInputStream();
32fc4afb 40
5fec5bb6 41 wxFileOffset GetLength() const;
32fc4afb 42
5fec5bb6 43 bool Ok() const { return m_file->IsOpened(); }
79c3e0e1 44
5fec5bb6
VZ
45protected:
46 wxFileInputStream();
79c3e0e1 47
5fec5bb6
VZ
48 size_t OnSysRead(void *buffer, size_t size);
49 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
50 wxFileOffset OnSysTell() const;
75ed1d15 51
5fec5bb6
VZ
52protected:
53 wxFile *m_file;
54 bool m_file_destroy;
22f3361e
VZ
55
56 DECLARE_NO_COPY_CLASS(wxFileInputStream)
79c3e0e1
GL
57};
58
5fec5bb6
VZ
59class WXDLLIMPEXP_BASE wxFileOutputStream : public wxOutputStream
60{
61public:
62 wxFileOutputStream(const wxString& fileName);
63 wxFileOutputStream(wxFile& file);
64 wxFileOutputStream(int fd);
65 virtual ~wxFileOutputStream();
32fc4afb 66
5fec5bb6
VZ
67 void Sync();
68 bool Close() { return m_file_destroy ? m_file->Close() : true; }
69 wxFileOffset GetLength() const;
32fc4afb 70
5fec5bb6 71 bool Ok() const { return m_file->IsOpened(); }
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
fc7a2a60
VZ
87class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream,
88 public wxFileOutputStream
89{
90public:
91 wxFileStream(const wxString& fileName);
92
93private:
94 DECLARE_NO_COPY_CLASS(wxFileStream)
84b46c35
GL
95};
96
65045edd
RR
97// ----------------------------------------------------------------------------
98// wxFFileStream using wxFFile
99// ----------------------------------------------------------------------------
100
5fec5bb6
VZ
101class WXDLLIMPEXP_BASE wxFFileInputStream : public wxInputStream
102{
103public:
104 wxFFileInputStream(const wxString& fileName, const wxChar *mode = _T("rb"));
105 wxFFileInputStream(wxFFile& file);
106 wxFFileInputStream(FILE *file);
107 ~wxFFileInputStream();
65045edd 108
5fec5bb6 109 wxFileOffset GetLength() const;
65045edd 110
5fec5bb6 111 bool Ok() const { return m_file->IsOpened(); }
65045edd 112
5fec5bb6
VZ
113protected:
114 wxFFileInputStream();
65045edd 115
5fec5bb6
VZ
116 size_t OnSysRead(void *buffer, size_t size);
117 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
118 wxFileOffset OnSysTell() const;
65045edd 119
5fec5bb6
VZ
120protected:
121 wxFFile *m_file;
122 bool m_file_destroy;
22f3361e
VZ
123
124 DECLARE_NO_COPY_CLASS(wxFFileInputStream)
65045edd
RR
125};
126
5fec5bb6
VZ
127class WXDLLIMPEXP_BASE wxFFileOutputStream : public wxOutputStream
128{
129public:
130 wxFFileOutputStream(const wxString& fileName, const wxChar *mode = _T("w+b"));
131 wxFFileOutputStream(wxFFile& file);
132 wxFFileOutputStream(FILE *file);
133 virtual ~wxFFileOutputStream();
65045edd 134
5fec5bb6
VZ
135 void Sync();
136 bool Close() { return m_file_destroy ? m_file->Close() : true; }
137 wxFileOffset GetLength() const;
65045edd 138
5fec5bb6 139 bool Ok() const { return m_file->IsOpened(); }
65045edd 140
5fec5bb6
VZ
141protected:
142 wxFFileOutputStream();
65045edd 143
5fec5bb6
VZ
144 size_t OnSysWrite(const void *buffer, size_t size);
145 wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
146 wxFileOffset OnSysTell() const;
65045edd 147
5fec5bb6
VZ
148protected:
149 wxFFile *m_file;
150 bool m_file_destroy;
22f3361e
VZ
151
152 DECLARE_NO_COPY_CLASS(wxFFileOutputStream)
65045edd
RR
153};
154
fc7a2a60
VZ
155class WXDLLIMPEXP_BASE wxFFileStream : public wxFFileInputStream,
156 public wxFFileOutputStream
157{
158public:
159 wxFFileStream(const wxString& fileName);
160
161private:
162 DECLARE_NO_COPY_CLASS(wxFFileStream)
65045edd 163};
fc7a2a60 164
5fec5bb6 165#endif // wxUSE_STREAMS && wxUSE_FILE
a0250ba3 166
5fec5bb6 167#endif // _WX_WXFSTREAM_H__