[ 1070686 ] wxOutputStream::Close()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30731 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
95662a8379
commit
8f0ff17851
@ -33,6 +33,19 @@ Creates a dummy wxOutputStream object.
|
||||
Destructor.
|
||||
|
||||
|
||||
\membersection{wxOutputStream::Close}\label{wxoutputstreamclose}
|
||||
|
||||
\func{bool}{Close}{\void}
|
||||
|
||||
Closes the stream, returning {\tt false} if an error occurs. The
|
||||
stream is closed implicitly in the destructor if Close() is not
|
||||
called explicitly.
|
||||
|
||||
If this stream wraps another stream or some other resource such
|
||||
as a file, then the underlying resource is closed too if it is owned
|
||||
by this stream, or left open otherwise.
|
||||
|
||||
|
||||
\membersection{wxOutputStream::LastWrite}\label{wxoutputstreamlastwrite}
|
||||
|
||||
\constfunc{size\_t}{LastWrite}{\void}
|
||||
|
@ -149,7 +149,6 @@ public:
|
||||
virtual bool CopyArchiveMetaData(wxArchiveInputStream& stream) = 0;
|
||||
|
||||
virtual bool CloseEntry() = 0;
|
||||
virtual bool Close() = 0;
|
||||
|
||||
protected:
|
||||
wxArchiveOutputStream(wxOutputStream& stream, wxMBConv& conv);
|
||||
|
@ -257,6 +257,7 @@ public:
|
||||
virtual size_t LastWrite() const { return wxStreamBase::m_lastcount; }
|
||||
|
||||
virtual void Sync();
|
||||
virtual bool Close() { return true; }
|
||||
|
||||
wxOutputStream& operator<<(wxInputStream& out) { return Write(out); }
|
||||
wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); }
|
||||
@ -515,6 +516,7 @@ public:
|
||||
wxFileOffset TellO() const;
|
||||
|
||||
void Sync();
|
||||
bool Close();
|
||||
|
||||
wxFileOffset GetLength() const;
|
||||
|
||||
|
@ -67,6 +67,7 @@ class WXDLLIMPEXP_BASE wxFileOutputStream: public wxOutputStream {
|
||||
// { return wxOutputStream::Write(buffer, size); }
|
||||
|
||||
void Sync();
|
||||
bool Close() { return m_file_destroy ? m_file->Close() : true; }
|
||||
wxFileOffset GetLength() const;
|
||||
|
||||
bool Ok() const { return m_file->IsOpened(); }
|
||||
@ -136,6 +137,7 @@ class WXDLLIMPEXP_BASE wxFFileOutputStream: public wxOutputStream {
|
||||
// { return wxOutputStream::Write(buffer, size); }
|
||||
|
||||
void Sync();
|
||||
bool Close() { return m_file_destroy ? m_file->Close() : true; }
|
||||
wxFileOffset GetLength() const;
|
||||
|
||||
bool Ok() const { return m_file->IsOpened(); }
|
||||
|
@ -69,9 +69,10 @@ class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
|
||||
class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
|
||||
public:
|
||||
wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
|
||||
virtual ~wxZlibOutputStream();
|
||||
virtual ~wxZlibOutputStream() { Close(); }
|
||||
|
||||
void Sync() { DoFlush(false); }
|
||||
bool Close();
|
||||
wxFileOffset GetLength() const { return m_pos; }
|
||||
|
||||
static bool CanHandleGZip();
|
||||
|
@ -1185,6 +1185,13 @@ wxBufferedOutputStream::~wxBufferedOutputStream()
|
||||
delete m_o_streambuf;
|
||||
}
|
||||
|
||||
bool wxBufferedOutputStream::Close()
|
||||
{
|
||||
Sync();
|
||||
return IsOk();
|
||||
}
|
||||
|
||||
|
||||
wxOutputStream& wxBufferedOutputStream::Write(const void *buffer, size_t size)
|
||||
{
|
||||
m_lastcount = 0;
|
||||
|
@ -238,20 +238,20 @@ wxZlibOutputStream::wxZlibOutputStream(wxOutputStream& stream,
|
||||
m_lasterror = wxSTREAM_WRITE_ERROR;
|
||||
}
|
||||
|
||||
wxZlibOutputStream::~wxZlibOutputStream()
|
||||
{
|
||||
if (m_deflate && m_z_buffer)
|
||||
DoFlush(true);
|
||||
deflateEnd(m_deflate);
|
||||
delete m_deflate;
|
||||
bool wxZlibOutputStream::Close()
|
||||
{
|
||||
DoFlush(true);
|
||||
deflateEnd(m_deflate);
|
||||
delete m_deflate;
|
||||
|
||||
delete[] m_z_buffer;
|
||||
}
|
||||
m_deflate = NULL;
|
||||
delete[] m_z_buffer;
|
||||
m_z_buffer = NULL;
|
||||
return IsOk();
|
||||
}
|
||||
|
||||
void wxZlibOutputStream::DoFlush(bool final)
|
||||
{
|
||||
wxASSERT_MSG(m_deflate && m_z_buffer, wxT("Deflate stream not open"));
|
||||
|
||||
if (!m_deflate || !m_z_buffer)
|
||||
m_lasterror = wxSTREAM_WRITE_ERROR;
|
||||
if (!IsOk())
|
||||
|
@ -179,7 +179,8 @@ class wxPipeOutputStream: public wxOutputStream
|
||||
{
|
||||
public:
|
||||
wxPipeOutputStream(HANDLE hOutput);
|
||||
virtual ~wxPipeOutputStream();
|
||||
virtual ~wxPipeOutputStream() { Close(); }
|
||||
bool Close();
|
||||
|
||||
protected:
|
||||
size_t OnSysWrite(const void *buffer, size_t len);
|
||||
@ -444,11 +445,12 @@ wxPipeOutputStream::wxPipeOutputStream(HANDLE hOutput)
|
||||
}
|
||||
}
|
||||
|
||||
wxPipeOutputStream::~wxPipeOutputStream()
|
||||
bool wxPipeOutputStream::Close()
|
||||
{
|
||||
::CloseHandle(m_hOutput);
|
||||
return ::CloseHandle(m_hOutput) != 0;
|
||||
}
|
||||
|
||||
|
||||
size_t wxPipeOutputStream::OnSysWrite(const void *buffer, size_t len)
|
||||
{
|
||||
m_lasterror = wxSTREAM_NO_ERROR;
|
||||
|
@ -400,9 +400,12 @@ protected:
|
||||
DoDeleteInStream();
|
||||
}
|
||||
void DeleteOutStream()
|
||||
{
|
||||
{
|
||||
if (m_pCurrentOut == NULL)
|
||||
return;
|
||||
|
||||
CPPUNIT_ASSERT(m_pCurrentOut->Close());
|
||||
|
||||
delete m_pCurrentOut;
|
||||
m_pCurrentOut = NULL;
|
||||
// Incase something extra needs to be done.
|
||||
|
Loading…
Reference in New Issue
Block a user