]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fstream.h
wxWave class for wxGTK (linux)
[wxWidgets.git] / include / wx / fstream.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fstream.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 "fstream.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 virtual ~wxFileInputStream();
30
31 virtual char Peek();
32
33 bool Ok() const { return m_file->IsOpened(); }
34
35 protected:
36 wxFileInputStream();
37
38 size_t OnSysRead(void *buffer, size_t size);
39 off_t OnSysSeek(off_t pos, wxSeekMode mode);
40 off_t OnSysTell() const;
41
42 protected:
43 wxFile *m_file;
44 bool m_file_destroy;
45 };
46
47 class wxFileOutputStream: public wxOutputStream {
48 public:
49 wxFileOutputStream(const wxString& fileName);
50 wxFileOutputStream(wxFile& file);
51 wxFileOutputStream(int fd);
52 virtual ~wxFileOutputStream();
53
54 // To solve an ambiguity on GCC
55 inline wxOutputStream& Write(const void *buffer, size_t size)
56 { return wxOutputStream::Write(buffer, size); }
57
58 void Sync();
59
60 bool Ok() const { return m_file->IsOpened(); }
61
62 protected:
63 wxFileOutputStream();
64
65 size_t OnSysWrite(const void *buffer, size_t size);
66 off_t OnSysSeek(off_t pos, wxSeekMode mode);
67 off_t OnSysTell() const;
68
69 protected:
70 wxFile *m_file;
71 bool m_file_destroy;
72 };
73
74 #endif