]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fstream.h
Shared libs now get installed correctly on 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 #ifndef _WX_WXFSTREAM_H__
12 #define _WX_WXFSTREAM_H__
13
14 #include <wx/object.h>
15 #include <wx/string.h>
16 #include <wx/stream.h>
17 #include <wx/file.h>
18
19 class wxFileStreamBase {
20 protected:
21 wxFile *m_file;
22 bool m_file_destroy;
23 };
24
25 class wxFileInputStream: public wxInputStream, virtual public wxFileStreamBase {
26 public:
27 wxFileInputStream(const wxString& fileName);
28 virtual ~wxFileInputStream();
29
30 virtual char Peek();
31
32 bool Ok() const { return m_file->IsOpened(); }
33
34 protected:
35 wxFileInputStream();
36
37 size_t DoRead(void *buffer, size_t size);
38 off_t DoSeekInput(off_t pos, wxSeekMode mode);
39 off_t DoTellInput() const;
40 };
41
42 class wxFileOutputStream: public wxOutputStream, virtual public wxFileStreamBase {
43 public:
44 wxFileOutputStream(const wxString& fileName);
45 virtual ~wxFileOutputStream();
46
47 // To solve an ambiguity on GCC
48 inline wxOutputStream& Write(const void *buffer, size_t size)
49 { return wxOutputStream::Write(buffer, size); }
50
51 void Sync();
52
53 bool Ok() const { return m_file->IsOpened(); }
54
55 protected:
56 wxFileOutputStream();
57
58 size_t DoWrite(const void *buffer, size_t size);
59 off_t DoSeekOutput(off_t pos, wxSeekMode mode);
60 off_t DoTellOutput() const;
61 };
62
63 class wxFileStream: public wxFileInputStream, public wxFileOutputStream {
64 public:
65 wxFileStream(const wxString& fileName);
66 virtual ~wxFileStream();
67 };
68
69 #endif