1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: File stream classes
4 // Author: Guilhem Lavaux
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_WXFSTREAM_H__
13 #define _WX_WXFSTREAM_H__
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "wfstream.h"
21 #if wxUSE_STREAMS && wxUSE_FILE
23 #include "wx/object.h"
24 #include "wx/string.h"
25 #include "wx/stream.h"
29 // ----------------------------------------------------------------------------
30 // wxFileStream using wxFile
31 // ----------------------------------------------------------------------------
33 class WXDLLIMPEXP_BASE wxFileInputStream
: public wxInputStream
36 wxFileInputStream(const wxString
& ifileName
);
37 wxFileInputStream(wxFile
& file
);
38 wxFileInputStream(int fd
);
41 wxFileOffset
GetLength() const;
43 bool Ok() const { return m_file
->IsOpened(); }
48 size_t OnSysRead(void *buffer
, size_t size
);
49 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
50 wxFileOffset
OnSysTell() const;
56 DECLARE_NO_COPY_CLASS(wxFileInputStream
)
59 class WXDLLIMPEXP_BASE wxFileOutputStream
: public wxOutputStream
62 wxFileOutputStream(const wxString
& fileName
);
63 wxFileOutputStream(wxFile
& file
);
64 wxFileOutputStream(int fd
);
65 virtual ~wxFileOutputStream();
68 bool Close() { return m_file_destroy
? m_file
->Close() : true; }
69 wxFileOffset
GetLength() const;
71 bool Ok() const { return m_file
->IsOpened(); }
76 size_t OnSysWrite(const void *buffer
, size_t size
);
77 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
78 wxFileOffset
OnSysTell() const;
84 DECLARE_NO_COPY_CLASS(wxFileOutputStream
)
87 class WXDLLIMPEXP_BASE wxFileStream
: public wxFileInputStream
,
88 public wxFileOutputStream
91 wxFileStream(const wxString
& fileName
);
94 DECLARE_NO_COPY_CLASS(wxFileStream
)
97 // ----------------------------------------------------------------------------
98 // wxFFileStream using wxFFile
99 // ----------------------------------------------------------------------------
101 class WXDLLIMPEXP_BASE wxFFileInputStream
: public wxInputStream
104 wxFFileInputStream(const wxString
& fileName
, const wxChar
*mode
= _T("rb"));
105 wxFFileInputStream(wxFFile
& file
);
106 wxFFileInputStream(FILE *file
);
107 ~wxFFileInputStream();
109 wxFileOffset
GetLength() const;
111 bool Ok() const { return m_file
->IsOpened(); }
114 wxFFileInputStream();
116 size_t OnSysRead(void *buffer
, size_t size
);
117 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
118 wxFileOffset
OnSysTell() const;
124 DECLARE_NO_COPY_CLASS(wxFFileInputStream
)
127 class WXDLLIMPEXP_BASE wxFFileOutputStream
: public wxOutputStream
130 wxFFileOutputStream(const wxString
& fileName
, const wxChar
*mode
= _T("w+b"));
131 wxFFileOutputStream(wxFFile
& file
);
132 wxFFileOutputStream(FILE *file
);
133 virtual ~wxFFileOutputStream();
136 bool Close() { return m_file_destroy
? m_file
->Close() : true; }
137 wxFileOffset
GetLength() const;
139 bool Ok() const { return m_file
->IsOpened(); }
142 wxFFileOutputStream();
144 size_t OnSysWrite(const void *buffer
, size_t size
);
145 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
146 wxFileOffset
OnSysTell() const;
152 DECLARE_NO_COPY_CLASS(wxFFileOutputStream
)
155 class WXDLLIMPEXP_BASE wxFFileStream
: public wxFFileInputStream
,
156 public wxFFileOutputStream
159 wxFFileStream(const wxString
& fileName
);
162 DECLARE_NO_COPY_CLASS(wxFFileStream
)
165 #endif // wxUSE_STREAMS && wxUSE_FILE
167 #endif // _WX_WXFSTREAM_H__