]>
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 | ||
25 | class wxFileInputStream: public wxInputStream, virtual public wxFileStreamBase { | |
32fc4afb | 26 | public: |
79c3e0e1 GL |
27 | wxFileInputStream(const wxString& fileName); |
28 | virtual ~wxFileInputStream(); | |
32fc4afb | 29 | |
1678ad78 | 30 | virtual char Peek(); |
32fc4afb | 31 | |
25c70b07 | 32 | bool Ok() const { return m_file->IsOpened(); } |
79c3e0e1 GL |
33 | |
34 | protected: | |
25c70b07 | 35 | wxFileInputStream(); |
79c3e0e1 | 36 | |
1678ad78 GL |
37 | size_t DoRead(void *buffer, size_t size); |
38 | off_t DoSeekInput(off_t pos, wxSeekMode mode); | |
39 | off_t DoTellInput() const; | |
79c3e0e1 GL |
40 | }; |
41 | ||
25c70b07 | 42 | class wxFileOutputStream: public wxOutputStream, virtual public wxFileStreamBase { |
79c3e0e1 GL |
43 | public: |
44 | wxFileOutputStream(const wxString& fileName); | |
45 | virtual ~wxFileOutputStream(); | |
46 | ||
1678ad78 GL |
47 | // To solve an ambiguity on GCC |
48 | inline wxOutputStream& Write(const void *buffer, size_t size) | |
49 | { return wxOutputStream::Write(buffer, size); } | |
32fc4afb GL |
50 | |
51 | void Sync(); | |
52 | ||
25c70b07 | 53 | bool Ok() const { return m_file->IsOpened(); } |
32fc4afb | 54 | |
79c3e0e1 | 55 | protected: |
25c70b07 | 56 | wxFileOutputStream(); |
32fc4afb | 57 | |
1678ad78 GL |
58 | size_t DoWrite(const void *buffer, size_t size); |
59 | off_t DoSeekOutput(off_t pos, wxSeekMode mode); | |
60 | off_t DoTellOutput() const; | |
32fc4afb GL |
61 | }; |
62 | ||
79c3e0e1 | 63 | class wxFileStream: public wxFileInputStream, public wxFileOutputStream { |
32fc4afb | 64 | public: |
79c3e0e1 GL |
65 | wxFileStream(const wxString& fileName); |
66 | virtual ~wxFileStream(); | |
32fc4afb GL |
67 | }; |
68 | ||
69 | #endif |