Contents Up Previous Next

wxTempFileOutputStream

wxTempFileOutputStream is an output stream based on wxTempFile. It provides a relatively safe way to replace the contents of the existing file.

Derived from

wxOutputStream

Include files

<wx/wfstream.h>

See also

wxTempFile

Members

wxTempFileOutputStream::wxTempFileOutputStream
wxTempFileOutputStream::Commit
wxTempFileOutputStream::Discard


wxTempFileOutputStream::wxTempFileOutputStream

wxTempFileOutputStream(const wxString& fileName)

Associates wxTempFileOutputStream with the file to be replaced and opens it. You should use IsOk to verify if the constructor succeeded.

Call Commit() or Close() to replace the old file and close this one. Calling Discard() (or allowing the destructor to do it) will discard the changes.


wxTempFileOutputStream::Commit

bool Commit()

Validate changes: deletes the old file of the given name and renames the new 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 either the old file couldn't be deleted or that the new file couldn't be renamed to the old name.


wxTempFileOutputStream::Discard

void Discard()

Discard changes: the old file contents are not changed, the temporary file is deleted.