1998-07-12 15:24:52 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-01-15 23:06:09 +00:00
|
|
|
// Name: wx/wfstream.h
|
1998-07-12 15:24:52 +00:00
|
|
|
// Purpose: File stream classes
|
|
|
|
// Author: Guilhem Lavaux
|
|
|
|
// Modified by:
|
|
|
|
// Created: 11/07/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Guilhem Lavaux
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-07-12 15:24:52 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1998-09-10 11:41:14 +00:00
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_WXFSTREAM_H__
|
|
|
|
#define _WX_WXFSTREAM_H__
|
1998-07-12 15:24:52 +00:00
|
|
|
|
2003-08-09 12:38:21 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1998-11-22 15:59:54 +00:00
|
|
|
#pragma interface "wfstream.h"
|
1998-09-10 11:41:14 +00:00
|
|
|
#endif
|
|
|
|
|
1999-06-16 06:03:04 +00:00
|
|
|
#include "wx/defs.h"
|
1999-06-15 20:21:59 +00:00
|
|
|
|
|
|
|
#if wxUSE_STREAMS && wxUSE_FILE
|
|
|
|
|
1999-08-20 22:52:21 +00:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
#include "wx/stream.h"
|
|
|
|
#include "wx/file.h"
|
1999-08-22 16:12:48 +00:00
|
|
|
#include "wx/ffile.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFileStream using wxFile
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-07-12 15:24:52 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxFileInputStream : public wxInputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFileInputStream(const wxString& ifileName);
|
|
|
|
wxFileInputStream(wxFile& file);
|
|
|
|
wxFileInputStream(int fd);
|
|
|
|
~wxFileInputStream();
|
1998-07-12 15:24:52 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
wxFileOffset GetLength() const;
|
1998-07-12 15:24:52 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
bool Ok() const { return m_file->IsOpened(); }
|
1998-07-14 12:06:50 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
protected:
|
|
|
|
wxFileInputStream();
|
1998-07-14 12:06:50 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
size_t OnSysRead(void *buffer, size_t size);
|
|
|
|
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
|
|
|
|
wxFileOffset OnSysTell() const;
|
1998-10-14 17:36:50 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
protected:
|
|
|
|
wxFile *m_file;
|
|
|
|
bool m_file_destroy;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFileInputStream)
|
1998-07-14 12:06:50 +00:00
|
|
|
};
|
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxFileOutputStream : public wxOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFileOutputStream(const wxString& fileName);
|
|
|
|
wxFileOutputStream(wxFile& file);
|
|
|
|
wxFileOutputStream(int fd);
|
|
|
|
virtual ~wxFileOutputStream();
|
1998-07-12 15:24:52 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
void Sync();
|
|
|
|
bool Close() { return m_file_destroy ? m_file->Close() : true; }
|
|
|
|
wxFileOffset GetLength() const;
|
1998-07-12 15:24:52 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
bool Ok() const { return m_file->IsOpened(); }
|
1998-07-12 15:24:52 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
protected:
|
|
|
|
wxFileOutputStream();
|
1998-07-12 15:24:52 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
size_t OnSysWrite(const void *buffer, size_t size);
|
|
|
|
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
|
|
|
|
wxFileOffset OnSysTell() const;
|
1998-07-12 15:24:52 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
protected:
|
|
|
|
wxFile *m_file;
|
|
|
|
bool m_file_destroy;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFileOutputStream)
|
1998-07-12 15:24:52 +00:00
|
|
|
};
|
|
|
|
|
2003-07-22 00:24:07 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream,
|
|
|
|
public wxFileOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFileStream(const wxString& fileName);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFileStream)
|
1998-10-28 18:29:51 +00:00
|
|
|
};
|
|
|
|
|
1999-08-22 16:12:48 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFFileStream using wxFFile
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxFFileInputStream : public wxInputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFFileInputStream(const wxString& fileName, const wxChar *mode = _T("rb"));
|
|
|
|
wxFFileInputStream(wxFFile& file);
|
|
|
|
wxFFileInputStream(FILE *file);
|
|
|
|
~wxFFileInputStream();
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
wxFileOffset GetLength() const;
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
bool Ok() const { return m_file->IsOpened(); }
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
protected:
|
|
|
|
wxFFileInputStream();
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
size_t OnSysRead(void *buffer, size_t size);
|
|
|
|
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
|
|
|
|
wxFileOffset OnSysTell() const;
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
protected:
|
|
|
|
wxFFile *m_file;
|
|
|
|
bool m_file_destroy;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFFileInputStream)
|
1999-08-22 16:12:48 +00:00
|
|
|
};
|
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxFFileOutputStream : public wxOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFFileOutputStream(const wxString& fileName, const wxChar *mode = _T("w+b"));
|
|
|
|
wxFFileOutputStream(wxFFile& file);
|
|
|
|
wxFFileOutputStream(FILE *file);
|
|
|
|
virtual ~wxFFileOutputStream();
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
void Sync();
|
|
|
|
bool Close() { return m_file_destroy ? m_file->Close() : true; }
|
|
|
|
wxFileOffset GetLength() const;
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
bool Ok() const { return m_file->IsOpened(); }
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
protected:
|
|
|
|
wxFFileOutputStream();
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
size_t OnSysWrite(const void *buffer, size_t size);
|
|
|
|
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
|
|
|
|
wxFileOffset OnSysTell() const;
|
1999-08-22 16:12:48 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
protected:
|
|
|
|
wxFFile *m_file;
|
|
|
|
bool m_file_destroy;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFFileOutputStream)
|
1999-08-22 16:12:48 +00:00
|
|
|
};
|
|
|
|
|
2003-07-22 00:24:07 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxFFileStream : public wxFFileInputStream,
|
|
|
|
public wxFFileOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxFFileStream(const wxString& fileName);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFFileStream)
|
1999-08-22 16:12:48 +00:00
|
|
|
};
|
2003-07-22 00:24:07 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
#endif // wxUSE_STREAMS && wxUSE_FILE
|
1999-09-13 03:49:33 +00:00
|
|
|
|
2005-01-15 23:06:09 +00:00
|
|
|
#endif // _WX_WXFSTREAM_H__
|