]>
Commit | Line | Data |
---|---|---|
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: virtual public wxInputStream, | |
26 | virtual public wxFileStreamBase { | |
27 | public: | |
28 | wxFileInputStream(const wxString& fileName); | |
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 DoRead(void *buffer, size_t size); | |
39 | off_t DoSeekInput(off_t pos, wxSeekMode mode); | |
40 | off_t DoTellInput() const; | |
41 | }; | |
42 | ||
43 | class wxFileOutputStream: virtual public wxOutputStream, | |
44 | virtual public wxFileStreamBase { | |
45 | public: | |
46 | wxFileOutputStream(const wxString& fileName); | |
47 | virtual ~wxFileOutputStream(); | |
48 | ||
49 | // To solve an ambiguity on GCC | |
50 | inline wxOutputStream& Write(const void *buffer, size_t size) | |
51 | { return wxOutputStream::Write(buffer, size); } | |
52 | ||
53 | void Sync(); | |
54 | ||
55 | bool Ok() const { return m_file->IsOpened(); } | |
56 | ||
57 | protected: | |
58 | wxFileOutputStream(); | |
59 | ||
60 | size_t DoWrite(const void *buffer, size_t size); | |
61 | off_t DoSeekOutput(off_t pos, wxSeekMode mode); | |
62 | off_t DoTellOutput() const; | |
63 | }; | |
64 | ||
65 | class wxFileStream: public wxStream, | |
66 | public wxFileInputStream, public wxFileOutputStream { | |
67 | public: | |
68 | wxFileStream(const wxString& fileName); | |
69 | virtual ~wxFileStream(); | |
70 | }; | |
71 | ||
72 | #endif |