// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef __WXFSTREAM_H__
-#define __WXFSTREAM_H__
-#include <stdio.h>
+#ifndef _WX_WXFSTREAM_H__
+#define _WX_WXFSTREAM_H__
+
+#ifdef __GNUG__
+#pragma interface "fstream.h"
+#endif
+
#include <wx/object.h>
#include <wx/string.h>
#include <wx/stream.h>
+#include <wx/file.h>
-class wxFileStreamBase: public wxStream {
- DECLARE_CLASS(wxFileStreamBase)
+class wxFileInputStream: public wxInputStream {
public:
- wxFileStreamBase(const wxString& fileName, int iolimit);
- virtual ~wxFileStreamBase();
+ wxFileInputStream(const wxString& ifileName);
+ wxFileInputStream(wxFile& file);
+ wxFileInputStream(int fd);
+ virtual ~wxFileInputStream();
- wxInputStream& Read(void *buffer, size_t size);
- size_t SeekI(int pos, wxWhenceType whence = wxBeginPosition);
- size_t TellI() const;
+ virtual char Peek();
- bool Eof() const { return m_eof; }
- size_t LastRead() const { return m_lastread; }
+ bool Ok() const { return m_file->IsOpened(); }
- wxOutputStream& Write(const void *buffer, size_t size);
- size_t SeekO(int pos, wxWhenceType whence = wxBeginPosition);
- size_t TellO() const;
+ protected:
+ wxFileInputStream();
- bool Bad() const { return m_bad; }
- size_t LastWrite() const { return m_lastwrite; }
-
- void Sync();
+ size_t OnSysRead(void *buffer, size_t size);
+ off_t OnSysSeek(off_t pos, wxSeekMode mode);
+ off_t OnSysTell() const;
protected:
- size_t m_lastread, m_lastwrite;
- bool m_eof, m_bad;
- FILE *m_file;
+ wxFile *m_file;
+ bool m_file_destroy;
};
-class wxFileInputStream: public wxFileStreamBase {
- DECLARE_CLASS(wxFileInputStream)
+class wxFileOutputStream: public wxOutputStream {
public:
- wxFileInputStream(const wxString& fileName) : wxFileStreamBase(fileName, 1) {}
- virtual ~wxFileInputStream() {}
-};
+ wxFileOutputStream(const wxString& fileName);
+ wxFileOutputStream(wxFile& file);
+ wxFileOutputStream(int fd);
+ virtual ~wxFileOutputStream();
-class wxFileOutputStream: public wxFileStreamBase {
- DECLARE_CLASS(wxFileOutputStream)
- public:
- wxFileOutputStream(const wxString& fileName) : wxFileStreamBase(fileName, 2) {}
- virtual ~wxFileOutputStream() {}
-};
+ // To solve an ambiguity on GCC
+ inline wxOutputStream& Write(const void *buffer, size_t size)
+ { return wxOutputStream::Write(buffer, size); }
-class wxFileStream: public wxFileStreamBase {
- DECLARE_CLASS(wxFileStream)
- public:
- wxFileStream(const wxString& fileName) : wxFileStreamBase(fileName, 0) {}
- virtual ~wxFileStream() {}
+ void Sync();
+
+ bool Ok() const { return m_file->IsOpened(); }
+
+ protected:
+ wxFileOutputStream();
+
+ size_t OnSysWrite(const void *buffer, size_t size);
+ off_t OnSysSeek(off_t pos, wxSeekMode mode);
+ off_t OnSysTell() const;
+
+ protected:
+ wxFile *m_file;
+ bool m_file_destroy;
};
#endif