1998-07-12 11:24:52 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1998-11-22 10:59:54 -05:00
|
|
|
// Name: wfstream.h
|
1998-07-12 11:24:52 -04:00
|
|
|
// Purpose: File stream classes
|
|
|
|
// Author: Guilhem Lavaux
|
|
|
|
// Modified by:
|
|
|
|
// Created: 11/07/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Guilhem Lavaux
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1998-09-10 07:41:14 -04:00
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_WXFSTREAM_H__
|
|
|
|
#define _WX_WXFSTREAM_H__
|
1998-07-12 11:24:52 -04:00
|
|
|
|
2003-08-09 08:38:21 -04:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1998-11-22 10:59:54 -05:00
|
|
|
#pragma interface "wfstream.h"
|
1998-09-10 07:41:14 -04:00
|
|
|
#endif
|
|
|
|
|
1999-06-16 02:03:04 -04:00
|
|
|
#include "wx/defs.h"
|
1999-06-15 16:21:59 -04:00
|
|
|
|
|
|
|
#if wxUSE_STREAMS && wxUSE_FILE
|
|
|
|
|
1999-08-20 18:52:21 -04:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
#include "wx/stream.h"
|
|
|
|
#include "wx/file.h"
|
1999-08-22 12:12:48 -04:00
|
|
|
#include "wx/ffile.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFileStream using wxFile
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-07-12 11:24:52 -04:00
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxFileInputStream: public wxInputStream {
|
1998-07-12 11:24:52 -04:00
|
|
|
public:
|
1998-10-14 13:36:50 -04:00
|
|
|
wxFileInputStream(const wxString& ifileName);
|
|
|
|
wxFileInputStream(wxFile& file);
|
|
|
|
wxFileInputStream(int fd);
|
1998-10-28 13:29:51 -05:00
|
|
|
~wxFileInputStream();
|
1998-07-12 11:24:52 -04:00
|
|
|
|
1999-07-24 06:50:13 -04:00
|
|
|
size_t GetSize() const;
|
1998-07-12 11:24:52 -04:00
|
|
|
|
1998-09-04 13:32:11 -04:00
|
|
|
bool Ok() const { return m_file->IsOpened(); }
|
1998-07-14 08:06:50 -04:00
|
|
|
|
|
|
|
protected:
|
1998-09-04 13:32:11 -04:00
|
|
|
wxFileInputStream();
|
1998-07-14 08:06:50 -04:00
|
|
|
|
1998-10-14 13:36:50 -04:00
|
|
|
size_t OnSysRead(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;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFileInputStream)
|
1998-07-14 08:06:50 -04:00
|
|
|
};
|
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxFileOutputStream: public wxOutputStream {
|
1998-07-14 08:06:50 -04:00
|
|
|
public:
|
|
|
|
wxFileOutputStream(const wxString& fileName);
|
1998-10-14 13:36:50 -04:00
|
|
|
wxFileOutputStream(wxFile& file);
|
|
|
|
wxFileOutputStream(int fd);
|
1998-07-14 08:06:50 -04:00
|
|
|
virtual ~wxFileOutputStream();
|
|
|
|
|
1998-07-24 13:13:47 -04:00
|
|
|
// To solve an ambiguity on GCC
|
1999-04-26 14:16:56 -04:00
|
|
|
// inline wxOutputStream& Write(const void *buffer, size_t size)
|
|
|
|
// { return wxOutputStream::Write(buffer, size); }
|
1998-07-12 11:24:52 -04:00
|
|
|
|
|
|
|
void Sync();
|
1999-07-24 06:50:13 -04:00
|
|
|
size_t GetSize() const;
|
1998-07-12 11:24:52 -04:00
|
|
|
|
1998-09-04 13:32:11 -04:00
|
|
|
bool Ok() const { return m_file->IsOpened(); }
|
1998-07-12 11:24:52 -04:00
|
|
|
|
1998-07-14 08:06:50 -04:00
|
|
|
protected:
|
1998-09-04 13:32:11 -04:00
|
|
|
wxFileOutputStream();
|
1998-07-12 11:24:52 -04:00
|
|
|
|
1998-10-14 13:36:50 -04:00
|
|
|
size_t OnSysWrite(const void *buffer, size_t size);
|
|
|
|
off_t OnSysSeek(off_t pos, wxSeekMode mode);
|
|
|
|
off_t OnSysTell() const;
|
1998-07-12 11:24:52 -04:00
|
|
|
|
1998-10-14 13:36:50 -04:00
|
|
|
protected:
|
|
|
|
wxFile *m_file;
|
|
|
|
bool m_file_destroy;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFileOutputStream)
|
1998-07-12 11:24:52 -04:00
|
|
|
};
|
|
|
|
|
2003-07-21 20:24:07 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream,
|
|
|
|
public wxFileOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFileStream(const wxString& fileName);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFileStream)
|
1998-10-28 13:29:51 -05:00
|
|
|
};
|
|
|
|
|
1999-08-22 12:12:48 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFFileStream using wxFFile
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxFFileInputStream: public wxInputStream {
|
1999-08-22 12:12:48 -04:00
|
|
|
public:
|
|
|
|
wxFFileInputStream(const wxString& ifileName);
|
|
|
|
wxFFileInputStream(wxFFile& file);
|
|
|
|
wxFFileInputStream(FILE *file);
|
|
|
|
~wxFFileInputStream();
|
|
|
|
|
|
|
|
size_t GetSize() const;
|
|
|
|
|
|
|
|
bool Ok() const { return m_file->IsOpened(); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxFFileInputStream();
|
|
|
|
|
|
|
|
size_t OnSysRead(void *buffer, size_t size);
|
|
|
|
off_t OnSysSeek(off_t pos, wxSeekMode mode);
|
|
|
|
off_t OnSysTell() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxFFile *m_file;
|
|
|
|
bool m_file_destroy;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFFileInputStream)
|
1999-08-22 12:12:48 -04:00
|
|
|
};
|
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxFFileOutputStream: public wxOutputStream {
|
1999-08-22 12:12:48 -04:00
|
|
|
public:
|
|
|
|
wxFFileOutputStream(const wxString& fileName);
|
|
|
|
wxFFileOutputStream(wxFFile& file);
|
|
|
|
wxFFileOutputStream(FILE *file);
|
|
|
|
virtual ~wxFFileOutputStream();
|
|
|
|
|
|
|
|
// To solve an ambiguity on GCC
|
|
|
|
// inline wxOutputStream& Write(const void *buffer, size_t size)
|
|
|
|
// { return wxOutputStream::Write(buffer, size); }
|
|
|
|
|
|
|
|
void Sync();
|
|
|
|
size_t GetSize() const;
|
|
|
|
|
|
|
|
bool Ok() const { return m_file->IsOpened(); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxFFileOutputStream();
|
|
|
|
|
|
|
|
size_t OnSysWrite(const void *buffer, size_t size);
|
|
|
|
off_t OnSysSeek(off_t pos, wxSeekMode mode);
|
|
|
|
off_t OnSysTell() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxFFile *m_file;
|
|
|
|
bool m_file_destroy;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFFileOutputStream)
|
1999-08-22 12:12:48 -04:00
|
|
|
};
|
|
|
|
|
2003-07-21 20:24:07 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxFFileStream : public wxFFileInputStream,
|
|
|
|
public wxFFileOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFFileStream(const wxString& fileName);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFFileStream)
|
1999-08-22 12:12:48 -04:00
|
|
|
};
|
2003-07-21 20:24:07 -04:00
|
|
|
|
1998-07-12 11:24:52 -04:00
|
|
|
#endif
|
1999-06-15 16:21:59 -04:00
|
|
|
// wxUSE_STREAMS && wxUSE_FILE
|
|
|
|
|
|
|
|
#endif
|
1999-07-09 11:30:31 -04:00
|
|
|
// _WX_WXFSTREAM_H__
|
|
|
|
|
1999-09-12 23:49:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|