2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wfstream.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxTempFileOutputStream
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxTempFileOutputStream
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
wxTempFileOutputStream is an output stream based on wxTempFile.
|
|
|
|
It provides a relatively safe way to replace the contents of the
|
2008-03-08 08:52:38 -05:00
|
|
|
existing file.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{streams}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxTempFile
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxTempFileOutputStream : public wxOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Associates wxTempFileOutputStream with the file to be replaced and opens it.
|
2009-01-08 13:26:35 -05:00
|
|
|
|
|
|
|
@warning
|
2008-09-25 17:31:45 -04:00
|
|
|
You should use wxStreamBase::IsOk() to verify if the constructor succeeded.
|
|
|
|
|
|
|
|
Call Commit() or wxOutputStream::Close() to replace the old file and close
|
|
|
|
this one. Calling Discard() (or allowing the destructor to do it) will
|
|
|
|
discard the changes.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxTempFileOutputStream(const wxString& fileName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Validate changes: deletes the old file of the given name and renames the new
|
2008-09-25 17:31:45 -04:00
|
|
|
file to the old name. Returns @true if both actions succeeded.
|
|
|
|
|
|
|
|
If @false is returned it may unfortunately mean two quite different things: either that
|
2008-03-08 08:52:38 -05:00
|
|
|
either the old file couldn't be deleted or that the new file couldn't be renamed
|
|
|
|
to the old name.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool Commit();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Discard changes: the old file contents are not changed, the temporary file is
|
|
|
|
deleted.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void Discard();
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFFileOutputStream
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
This class represents data written to a file.
|
|
|
|
There are actually two such groups of classes: this one is based on wxFFile
|
|
|
|
whereas wxFileInputStream is based in the wxFile class.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
Note that wxOutputStream::SeekO() can seek beyond the end of the stream
|
|
|
|
(file) and will thus not return ::wxInvalidOffset for that.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{streams}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxBufferedOutputStream, wxFFileInputStream, wxFileInputStream
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFFileOutputStream : public wxOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2009-01-08 13:26:35 -05:00
|
|
|
Open the given file @a filename with mode @a mode.
|
|
|
|
|
|
|
|
@warning
|
|
|
|
You should use wxStreamBase::IsOk() to verify if the constructor succeeded.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxFFileOutputStream(const wxString& filename,
|
2008-09-27 16:26:28 -04:00
|
|
|
const wxString& mode = "wb");
|
2008-09-25 17:31:45 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes a file stream in write-only mode using the file I/O object file.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxFFileOutputStream(wxFFile& file);
|
2008-09-25 17:31:45 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes a file stream in write-only mode using the file descriptor fp.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFFileOutputStream(FILE* fp);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxFFileOutputStream();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the stream is initialized and ready.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFileOutputStream
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
This class represents data written to a file.
|
|
|
|
There are actually two such groups of classes: this one is based on wxFile
|
|
|
|
whereas wxFFileInputStream is based in the wxFFile class.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
Note that wxOutputStream::SeekO() can seek beyond the end of the stream
|
|
|
|
(file) and will thus not return ::wxInvalidOffset for that.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{streams}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxBufferedOutputStream, wxFileInputStream, wxFFileInputStream
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFileOutputStream : public wxOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2009-01-08 13:26:35 -05:00
|
|
|
Creates a new file with @a ofileName name and initializes the stream in write-only mode.
|
|
|
|
|
|
|
|
@warning
|
|
|
|
You should use wxStreamBase::IsOk() to verify if the constructor succeeded.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxFileOutputStream(const wxString& ofileName);
|
2008-09-25 17:31:45 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes a file stream in write-only mode using the file I/O object file.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxFileOutputStream(wxFile& file);
|
2008-09-25 17:31:45 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes a file stream in write-only mode using the file descriptor @e fd.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxFileOutputStream(int fd);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxFileOutputStream();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the stream is initialized and ready.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFileInputStream
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
This class represents data read in from a file.
|
|
|
|
There are actually two such groups of classes: this one is based on wxFile
|
|
|
|
whereas wxFFileInputStream is based in the wxFFile class.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
Note that wxInputStream::SeekI() can seek beyond the end of the stream (file)
|
|
|
|
and will thus not return ::wxInvalidOffset for that.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{streams}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxBufferedInputStream, wxFileOutputStream, wxFFileOutputStream
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFileInputStream : public wxInputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2009-01-08 13:26:35 -05:00
|
|
|
Opens the specified file using its @a ifileName name in read-only mode.
|
|
|
|
|
|
|
|
@warning
|
|
|
|
You should use wxStreamBase::IsOk() to verify if the constructor succeeded.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxFileInputStream(const wxString& ifileName);
|
2008-09-25 17:31:45 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes a file stream in read-only mode using the file I/O object file.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxFileInputStream(wxFile& file);
|
2008-09-25 17:31:45 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes a file stream in read-only mode using the specified file descriptor.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxFileInputStream(int fd);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxFileInputStream();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the stream is initialized and ready.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFFileInputStream
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
This class represents data read in from a file.
|
|
|
|
There are actually two such groups of classes: this one is based on wxFFile
|
|
|
|
whereas wxFileInputStream is based in the wxFile class.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
Note that wxInputStream::SeekI() can seek beyond the end of the stream (file)
|
|
|
|
and will thus not return ::wxInvalidOffset for that.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{streams}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxBufferedInputStream, wxFFileOutputStream, wxFileOutputStream
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFFileInputStream : public wxInputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2009-01-08 13:26:35 -05:00
|
|
|
Opens the specified file using its @a filename name using the specified @a mode.
|
|
|
|
|
|
|
|
@warning
|
|
|
|
You should use wxStreamBase::IsOk() to verify if the constructor succeeded.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxFFileInputStream(const wxString& filename,
|
|
|
|
const wxString& mode = "rb");
|
2008-09-25 17:31:45 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes a file stream in read-only mode using the file I/O object file.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxFFileInputStream(wxFFile& file);
|
2008-09-25 17:31:45 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes a file stream in read-only mode using the specified file pointer @a fp.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFFileInputStream(FILE* fp);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxFFileInputStream();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the stream is initialized and ready.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFFileStream
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
@todo describe this class.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
2008-09-25 17:31:45 -04:00
|
|
|
@category{streams}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxStreamBuffer
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFFileStream : public wxFFileOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2009-01-08 13:26:35 -05:00
|
|
|
Initializes a new file stream in the given @a mode using the specified
|
|
|
|
@a iofileName name.
|
|
|
|
|
|
|
|
@warning
|
|
|
|
You should use wxStreamBase::IsOk() to verify if the constructor succeeded.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-06-15 13:34:50 -04:00
|
|
|
wxFFileStream(const wxString& iofileName, const wxString& mode = "w+b");
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFileStream
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 17:31:45 -04:00
|
|
|
@todo describe this class.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
2008-09-25 17:31:45 -04:00
|
|
|
@category{streams}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxStreamBuffer
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFileStream : public wxFileOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Initializes a new file stream in read-write mode using the specified
|
2009-01-08 13:26:35 -05:00
|
|
|
@a iofileName name.
|
|
|
|
|
|
|
|
@warning
|
|
|
|
You should use wxStreamBase::IsOk() to verify if the constructor succeeded.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxFileStream(const wxString& iofileName);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|