]> git.saurik.com Git - wxWidgets.git/blob - include/wx/wfstream.h
Applied Russel's changes to wxToolBarBase
[wxWidgets.git] / include / wx / wfstream.h
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 #ifdef __GNUG__
16 #pragma interface "wfstream.h"
17 #endif
18
19 #include <wx/object.h>
20 #include <wx/string.h>
21 #include <wx/stream.h>
22 #include <wx/file.h>
23
24 class wxFileInputStream: public wxInputStream {
25 public:
26 wxFileInputStream(const wxString& ifileName);
27 wxFileInputStream(wxFile& file);
28 wxFileInputStream(int fd);
29 ~wxFileInputStream();
30
31 char Peek();
32 size_t StreamSize() const;
33
34 bool Ok() const { return m_file->IsOpened(); }
35
36 protected:
37 wxFileInputStream();
38
39 size_t OnSysRead(void *buffer, size_t size);
40 off_t OnSysSeek(off_t pos, wxSeekMode mode);
41 off_t OnSysTell() const;
42
43 protected:
44 wxFile *m_file;
45 bool m_file_destroy;
46 };
47
48 class wxFileOutputStream: public wxOutputStream {
49 public:
50 wxFileOutputStream(const wxString& fileName);
51 wxFileOutputStream(wxFile& file);
52 wxFileOutputStream(int fd);
53 virtual ~wxFileOutputStream();
54
55 // To solve an ambiguity on GCC
56 inline wxOutputStream& Write(const void *buffer, size_t size)
57 { return wxOutputStream::Write(buffer, size); }
58
59 void Sync();
60 size_t StreamSize() const;
61
62 bool Ok() const { return m_file->IsOpened(); }
63
64 protected:
65 wxFileOutputStream();
66
67 size_t OnSysWrite(const void *buffer, size_t size);
68 off_t OnSysSeek(off_t pos, wxSeekMode mode);
69 off_t OnSysTell() const;
70
71 protected:
72 wxFile *m_file;
73 bool m_file_destroy;
74 };
75
76 class wxFileStream: public wxFileInputStream, public wxFileOutputStream {
77 public:
78 wxFileStream(const wxString& fileName);
79 };
80
81 #endif