[ 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:
@@ -33,6 +33,19 @@ Creates a dummy wxOutputStream object.
|
|||||||
Destructor.
|
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}
|
\membersection{wxOutputStream::LastWrite}\label{wxoutputstreamlastwrite}
|
||||||
|
|
||||||
\constfunc{size\_t}{LastWrite}{\void}
|
\constfunc{size\_t}{LastWrite}{\void}
|
||||||
|
@@ -149,7 +149,6 @@ public:
|
|||||||
virtual bool CopyArchiveMetaData(wxArchiveInputStream& stream) = 0;
|
virtual bool CopyArchiveMetaData(wxArchiveInputStream& stream) = 0;
|
||||||
|
|
||||||
virtual bool CloseEntry() = 0;
|
virtual bool CloseEntry() = 0;
|
||||||
virtual bool Close() = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxArchiveOutputStream(wxOutputStream& stream, wxMBConv& conv);
|
wxArchiveOutputStream(wxOutputStream& stream, wxMBConv& conv);
|
||||||
|
@@ -257,6 +257,7 @@ public:
|
|||||||
virtual size_t LastWrite() const { return wxStreamBase::m_lastcount; }
|
virtual size_t LastWrite() const { return wxStreamBase::m_lastcount; }
|
||||||
|
|
||||||
virtual void Sync();
|
virtual void Sync();
|
||||||
|
virtual bool Close() { return true; }
|
||||||
|
|
||||||
wxOutputStream& operator<<(wxInputStream& out) { return Write(out); }
|
wxOutputStream& operator<<(wxInputStream& out) { return Write(out); }
|
||||||
wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); }
|
wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); }
|
||||||
@@ -515,6 +516,7 @@ public:
|
|||||||
wxFileOffset TellO() const;
|
wxFileOffset TellO() const;
|
||||||
|
|
||||||
void Sync();
|
void Sync();
|
||||||
|
bool Close();
|
||||||
|
|
||||||
wxFileOffset GetLength() const;
|
wxFileOffset GetLength() const;
|
||||||
|
|
||||||
|
@@ -67,6 +67,7 @@ class WXDLLIMPEXP_BASE wxFileOutputStream: public wxOutputStream {
|
|||||||
// { return wxOutputStream::Write(buffer, size); }
|
// { return wxOutputStream::Write(buffer, size); }
|
||||||
|
|
||||||
void Sync();
|
void Sync();
|
||||||
|
bool Close() { return m_file_destroy ? m_file->Close() : true; }
|
||||||
wxFileOffset GetLength() const;
|
wxFileOffset GetLength() const;
|
||||||
|
|
||||||
bool Ok() const { return m_file->IsOpened(); }
|
bool Ok() const { return m_file->IsOpened(); }
|
||||||
@@ -136,6 +137,7 @@ class WXDLLIMPEXP_BASE wxFFileOutputStream: public wxOutputStream {
|
|||||||
// { return wxOutputStream::Write(buffer, size); }
|
// { return wxOutputStream::Write(buffer, size); }
|
||||||
|
|
||||||
void Sync();
|
void Sync();
|
||||||
|
bool Close() { return m_file_destroy ? m_file->Close() : true; }
|
||||||
wxFileOffset GetLength() const;
|
wxFileOffset GetLength() const;
|
||||||
|
|
||||||
bool Ok() const { return m_file->IsOpened(); }
|
bool Ok() const { return m_file->IsOpened(); }
|
||||||
|
@@ -69,9 +69,10 @@ class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
|
|||||||
class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
|
class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
|
||||||
public:
|
public:
|
||||||
wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
|
wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
|
||||||
virtual ~wxZlibOutputStream();
|
virtual ~wxZlibOutputStream() { Close(); }
|
||||||
|
|
||||||
void Sync() { DoFlush(false); }
|
void Sync() { DoFlush(false); }
|
||||||
|
bool Close();
|
||||||
wxFileOffset GetLength() const { return m_pos; }
|
wxFileOffset GetLength() const { return m_pos; }
|
||||||
|
|
||||||
static bool CanHandleGZip();
|
static bool CanHandleGZip();
|
||||||
|
@@ -1185,6 +1185,13 @@ wxBufferedOutputStream::~wxBufferedOutputStream()
|
|||||||
delete m_o_streambuf;
|
delete m_o_streambuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxBufferedOutputStream::Close()
|
||||||
|
{
|
||||||
|
Sync();
|
||||||
|
return IsOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxOutputStream& wxBufferedOutputStream::Write(const void *buffer, size_t size)
|
wxOutputStream& wxBufferedOutputStream::Write(const void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
m_lastcount = 0;
|
m_lastcount = 0;
|
||||||
|
@@ -238,20 +238,20 @@ wxZlibOutputStream::wxZlibOutputStream(wxOutputStream& stream,
|
|||||||
m_lasterror = wxSTREAM_WRITE_ERROR;
|
m_lasterror = wxSTREAM_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxZlibOutputStream::~wxZlibOutputStream()
|
bool wxZlibOutputStream::Close()
|
||||||
{
|
{
|
||||||
if (m_deflate && m_z_buffer)
|
|
||||||
DoFlush(true);
|
DoFlush(true);
|
||||||
deflateEnd(m_deflate);
|
deflateEnd(m_deflate);
|
||||||
delete m_deflate;
|
delete m_deflate;
|
||||||
|
|
||||||
|
m_deflate = NULL;
|
||||||
delete[] m_z_buffer;
|
delete[] m_z_buffer;
|
||||||
|
m_z_buffer = NULL;
|
||||||
|
return IsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxZlibOutputStream::DoFlush(bool final)
|
void wxZlibOutputStream::DoFlush(bool final)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(m_deflate && m_z_buffer, wxT("Deflate stream not open"));
|
|
||||||
|
|
||||||
if (!m_deflate || !m_z_buffer)
|
if (!m_deflate || !m_z_buffer)
|
||||||
m_lasterror = wxSTREAM_WRITE_ERROR;
|
m_lasterror = wxSTREAM_WRITE_ERROR;
|
||||||
if (!IsOk())
|
if (!IsOk())
|
||||||
|
@@ -179,7 +179,8 @@ class wxPipeOutputStream: public wxOutputStream
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxPipeOutputStream(HANDLE hOutput);
|
wxPipeOutputStream(HANDLE hOutput);
|
||||||
virtual ~wxPipeOutputStream();
|
virtual ~wxPipeOutputStream() { Close(); }
|
||||||
|
bool Close();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
size_t OnSysWrite(const void *buffer, size_t len);
|
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)
|
size_t wxPipeOutputStream::OnSysWrite(const void *buffer, size_t len)
|
||||||
{
|
{
|
||||||
m_lasterror = wxSTREAM_NO_ERROR;
|
m_lasterror = wxSTREAM_NO_ERROR;
|
||||||
|
@@ -403,6 +403,9 @@ protected:
|
|||||||
{
|
{
|
||||||
if (m_pCurrentOut == NULL)
|
if (m_pCurrentOut == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(m_pCurrentOut->Close());
|
||||||
|
|
||||||
delete m_pCurrentOut;
|
delete m_pCurrentOut;
|
||||||
m_pCurrentOut = NULL;
|
m_pCurrentOut = NULL;
|
||||||
// Incase something extra needs to be done.
|
// Incase something extra needs to be done.
|
||||||
|
Reference in New Issue
Block a user