default:
wxString msg(m_inflate->msg, *wxConvCurrent);
if (!msg)
- msg.Format(_("zlib error %d"), err);
+ msg = wxString::Format(_("zlib error %d"), err);
wxLogError(_("Can't read from inflate stream: %s"), msg.c_str());
m_lasterror = wxSTREAM_READ_ERROR;
}
memset(m_deflate, 0, sizeof(z_stream_s));
m_deflate->next_out = m_z_buffer;
m_deflate->avail_out = m_z_size;
-
+
// see zlib.h for documentation on windowBits
int windowBits = MAX_WBITS;
switch (flags) {
default: wxFAIL_MSG(wxT("Invalid zlib flag"));
}
- if (deflateInit2(m_deflate, level, Z_DEFLATED, windowBits,
+ if (deflateInit2(m_deflate, level, Z_DEFLATED, windowBits,
8, Z_DEFAULT_STRATEGY) == Z_OK)
return;
}
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())
m_lasterror = wxSTREAM_WRITE_ERROR;
wxString msg(m_deflate->msg, *wxConvCurrent);
if (!msg)
- msg.Format(_("zlib error %d"), err);
+ msg = wxString::Format(_("zlib error %d"), err);
wxLogError(_("Can't write to deflate stream: %s"), msg.c_str());
}
}
/* static */ bool wxZlibOutputStream::CanHandleGZip()
-{
+{
return wxZlibInputStream::CanHandleGZip();
}
#endif
// wxUSE_ZLIB && wxUSE_STREAMS
-
+