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