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"
23 #include "wx/object.h"
24 #include "wx/string.h"
25 #include "wx/stream.h"
31 // ----------------------------------------------------------------------------
32 // wxFileStream using wxFile
33 // ----------------------------------------------------------------------------
35 class WXDLLIMPEXP_BASE wxFileInputStream
: public wxInputStream
38 wxFileInputStream(const wxString
& ifileName
);
39 wxFileInputStream(wxFile
& file
);
40 wxFileInputStream(int fd
);
43 wxFileOffset
GetLength() const;
45 bool Ok() const { return m_file
->IsOpened(); }
46 bool IsSeekable() const { return m_file
->GetKind() == wxFILE_KIND_DISK
; }
51 size_t OnSysRead(void *buffer
, size_t size
);
52 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
53 wxFileOffset
OnSysTell() const;
59 DECLARE_NO_COPY_CLASS(wxFileInputStream
)
62 class WXDLLIMPEXP_BASE wxFileOutputStream
: public wxOutputStream
65 wxFileOutputStream(const wxString
& fileName
);
66 wxFileOutputStream(wxFile
& file
);
67 wxFileOutputStream(int fd
);
68 virtual ~wxFileOutputStream();
71 bool Close() { return m_file_destroy
? m_file
->Close() : true; }
72 wxFileOffset
GetLength() const;
74 bool Ok() const { return m_file
->IsOpened(); }
75 bool IsSeekable() const { return m_file
->GetKind() == wxFILE_KIND_DISK
; }
80 size_t OnSysWrite(const void *buffer
, size_t size
);
81 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
82 wxFileOffset
OnSysTell() const;
88 DECLARE_NO_COPY_CLASS(wxFileOutputStream
)
91 class WXDLLIMPEXP_BASE wxFileStream
: public wxFileInputStream
,
92 public wxFileOutputStream
95 wxFileStream(const wxString
& fileName
);
98 DECLARE_NO_COPY_CLASS(wxFileStream
)
105 // ----------------------------------------------------------------------------
106 // wxFFileStream using wxFFile
107 // ----------------------------------------------------------------------------
109 class WXDLLIMPEXP_BASE wxFFileInputStream
: public wxInputStream
112 wxFFileInputStream(const wxString
& fileName
, const wxChar
*mode
= _T("rb"));
113 wxFFileInputStream(wxFFile
& file
);
114 wxFFileInputStream(FILE *file
);
115 ~wxFFileInputStream();
117 wxFileOffset
GetLength() const;
119 bool Ok() const { return m_file
->IsOpened(); }
120 bool IsSeekable() const { return m_file
->GetKind() == wxFILE_KIND_DISK
; }
123 wxFFileInputStream();
125 size_t OnSysRead(void *buffer
, size_t size
);
126 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
127 wxFileOffset
OnSysTell() const;
133 DECLARE_NO_COPY_CLASS(wxFFileInputStream
)
136 class WXDLLIMPEXP_BASE wxFFileOutputStream
: public wxOutputStream
139 wxFFileOutputStream(const wxString
& fileName
, const wxChar
*mode
= _T("w+b"));
140 wxFFileOutputStream(wxFFile
& file
);
141 wxFFileOutputStream(FILE *file
);
142 virtual ~wxFFileOutputStream();
145 bool Close() { return m_file_destroy
? m_file
->Close() : true; }
146 wxFileOffset
GetLength() const;
148 bool Ok() const { return m_file
->IsOpened(); }
149 bool IsSeekable() const { return m_file
->GetKind() == wxFILE_KIND_DISK
; }
152 wxFFileOutputStream();
154 size_t OnSysWrite(const void *buffer
, size_t size
);
155 wxFileOffset
OnSysSeek(wxFileOffset pos
, wxSeekMode mode
);
156 wxFileOffset
OnSysTell() const;
162 DECLARE_NO_COPY_CLASS(wxFFileOutputStream
)
165 class WXDLLIMPEXP_BASE wxFFileStream
: public wxFFileInputStream
,
166 public wxFFileOutputStream
169 wxFFileStream(const wxString
& fileName
);
172 DECLARE_NO_COPY_CLASS(wxFFileStream
)
177 #endif // wxUSE_STREAMS
179 #endif // _WX_WXFSTREAM_H__