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(); }
44 bool IsSeekable() const { return m_file
->GetFileType() == wxFILE_TYPE_DISK
; }
49 size_t OnSysRead(void *buffer
, size_t size
);
50 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
51 wxFileOffset
OnSysTell() const;
57 DECLARE_NO_COPY_CLASS(wxFileInputStream
)
60 class WXDLLIMPEXP_BASE wxFileOutputStream
: public wxOutputStream
63 wxFileOutputStream(const wxString
& fileName
);
64 wxFileOutputStream(wxFile
& file
);
65 wxFileOutputStream(int fd
);
66 virtual ~wxFileOutputStream();
69 bool Close() { return m_file_destroy
? m_file
->Close() : true; }
70 wxFileOffset
GetLength() const;
72 bool Ok() const { return m_file
->IsOpened(); }
73 bool IsSeekable() const { return m_file
->GetFileType() == wxFILE_TYPE_DISK
; }
78 size_t OnSysWrite(const void *buffer
, size_t size
);
79 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
80 wxFileOffset
OnSysTell() const;
86 DECLARE_NO_COPY_CLASS(wxFileOutputStream
)
89 class WXDLLIMPEXP_BASE wxFileStream
: public wxFileInputStream
,
90 public wxFileOutputStream
93 wxFileStream(const wxString
& fileName
);
96 DECLARE_NO_COPY_CLASS(wxFileStream
)
99 // ----------------------------------------------------------------------------
100 // wxFFileStream using wxFFile
101 // ----------------------------------------------------------------------------
103 class WXDLLIMPEXP_BASE wxFFileInputStream
: public wxInputStream
106 wxFFileInputStream(const wxString
& fileName
, const wxChar
*mode
= _T("rb"));
107 wxFFileInputStream(wxFFile
& file
);
108 wxFFileInputStream(FILE *file
);
109 ~wxFFileInputStream();
111 wxFileOffset
GetLength() const;
113 bool Ok() const { return m_file
->IsOpened(); }
114 bool IsSeekable() const { return m_file
->GetFileType() == wxFILE_TYPE_DISK
; }
117 wxFFileInputStream();
119 size_t OnSysRead(void *buffer
, size_t size
);
120 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
121 wxFileOffset
OnSysTell() const;
127 DECLARE_NO_COPY_CLASS(wxFFileInputStream
)
130 class WXDLLIMPEXP_BASE wxFFileOutputStream
: public wxOutputStream
133 wxFFileOutputStream(const wxString
& fileName
, const wxChar
*mode
= _T("w+b"));
134 wxFFileOutputStream(wxFFile
& file
);
135 wxFFileOutputStream(FILE *file
);
136 virtual ~wxFFileOutputStream();
139 bool Close() { return m_file_destroy
? m_file
->Close() : true; }
140 wxFileOffset
GetLength() const;
142 bool Ok() const { return m_file
->IsOpened(); }
143 bool IsSeekable() const { return m_file
->GetFileType() == wxFILE_TYPE_DISK
; }
146 wxFFileOutputStream();
148 size_t OnSysWrite(const void *buffer
, size_t size
);
149 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
150 wxFileOffset
OnSysTell() const;
156 DECLARE_NO_COPY_CLASS(wxFFileOutputStream
)
159 class WXDLLIMPEXP_BASE wxFFileStream
: public wxFFileInputStream
,
160 public wxFFileOutputStream
163 wxFFileStream(const wxString
& fileName
);
166 DECLARE_NO_COPY_CLASS(wxFFileStream
)
169 #endif // wxUSE_STREAMS && wxUSE_FILE
171 #endif // _WX_WXFSTREAM_H__