Applied patch [ 818336 ] Add timestamp to gzip out stream
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -134,7 +134,7 @@ The stream is not seekable, \helpref{SeekO()}{wxoutputstreamseeko} returns
|
|||||||
|
|
||||||
\membersection{wxGzipOutputStream::wxGzipOutputStream}\label{wxgzipoutputstreamwxgzipoutputstream}
|
\membersection{wxGzipOutputStream::wxGzipOutputStream}\label{wxgzipoutputstreamwxgzipoutputstream}
|
||||||
|
|
||||||
\func{}{wxGzipOutputStream}{\param{wxOutputStream\& }{stream}, \param{const wxString\& }{originalName = wxEmptyString}, \param{int }{level = -1}, \param{wxMBConv\& }{conv = wxConvFile}}
|
\func{}{wxGzipOutputStream}{\param{wxOutputStream\& }{stream}, \param{const wxString\& }{originalName = wxEmptyString}, \param{const wxDateTime\& }{originalTime = wxDateTime::Now()}, \param{int }{level = -1}, \param{wxMBConv\& }{conv = wxConvFile}}
|
||||||
|
|
||||||
If the {\it originalName} is given, then it is written to the gzip header
|
If the {\it originalName} is given, then it is written to the gzip header
|
||||||
with any directory components removed. On a Unicode build it is first
|
with any directory components removed. On a Unicode build it is first
|
||||||
@@ -144,9 +144,8 @@ use {\it wxConvFile} which more closely matches the behaviour of the gzip
|
|||||||
program. In a non-Unicode build {\it conv} is ignored. {\it conv} has no
|
program. In a non-Unicode build {\it conv} is ignored. {\it conv} has no
|
||||||
effect on the stream data.
|
effect on the stream data.
|
||||||
|
|
||||||
If {\it originalName} specifies a file that exists then it's current
|
If {\it originalTime} is given then it is also written to the gzip header
|
||||||
modification time is also written to the gzip header as the timestamp.
|
as the timestamp. If omitted the current time is used.
|
||||||
Otherwise the current time is used for the timestamp.
|
|
||||||
|
|
||||||
{\it level} is the compression level. It can be an integer between $0$ (no
|
{\it level} is the compression level. It can be an integer between $0$ (no
|
||||||
compression) and $9$ (most compression). $-1$ specifies that the default
|
compression) and $9$ (most compression). $-1$ specifies that the default
|
||||||
|
@@ -64,6 +64,9 @@ class WXDLLIMPEXP_BASE wxGzipOutputStream : public wxFilterOutputStream
|
|||||||
public:
|
public:
|
||||||
wxGzipOutputStream(wxOutputStream& stream,
|
wxGzipOutputStream(wxOutputStream& stream,
|
||||||
const wxString& originalName = wxEmptyString,
|
const wxString& originalName = wxEmptyString,
|
||||||
|
#if wxUSE_DATETIME
|
||||||
|
const wxDateTime& originalTime = wxDateTime::Now(),
|
||||||
|
#endif
|
||||||
int level = -1,
|
int level = -1,
|
||||||
wxMBConv& conv = wxConvFile);
|
wxMBConv& conv = wxConvFile);
|
||||||
virtual ~wxGzipOutputStream();
|
virtual ~wxGzipOutputStream();
|
||||||
|
@@ -175,12 +175,14 @@ size_t wxGzipInputStream::OnSysRead(void *buffer, size_t size)
|
|||||||
wxDataInputStream ds(*m_parent_i_stream);
|
wxDataInputStream ds(*m_parent_i_stream);
|
||||||
m_lasterror = wxSTREAM_READ_ERROR;
|
m_lasterror = wxSTREAM_READ_ERROR;
|
||||||
|
|
||||||
if (m_parent_i_stream->IsOk() && ds.Read32() != m_crc)
|
if (m_parent_i_stream->IsOk()) {
|
||||||
wxLogError(_("reading Gzip stream: bad crc"));
|
if (ds.Read32() != m_crc)
|
||||||
else if (m_parent_i_stream->IsOk() && ds.Read32() != (wxUint32)TellI())
|
wxLogError(_("reading Gzip stream: bad crc"));
|
||||||
wxLogError(_("reading Gzip stream: incorrect length"));
|
else if (ds.Read32() != (wxUint32)TellI())
|
||||||
else if (m_parent_i_stream->IsOk())
|
wxLogError(_("reading Gzip stream: incorrect length"));
|
||||||
m_lasterror = wxSTREAM_EOF;
|
else
|
||||||
|
m_lasterror = wxSTREAM_EOF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!*m_decomp) {
|
else if (!*m_decomp) {
|
||||||
m_lasterror = wxSTREAM_READ_ERROR;
|
m_lasterror = wxSTREAM_READ_ERROR;
|
||||||
@@ -194,10 +196,13 @@ size_t wxGzipInputStream::OnSysRead(void *buffer, size_t size)
|
|||||||
// Output stream
|
// Output stream
|
||||||
|
|
||||||
wxGzipOutputStream::wxGzipOutputStream(
|
wxGzipOutputStream::wxGzipOutputStream(
|
||||||
wxOutputStream& stream,
|
wxOutputStream& stream,
|
||||||
const wxString& originalName /*=wxEmptyString*/,
|
const wxString& originalName /*=wxEmptyString*/,
|
||||||
int level /*=-1*/,
|
#if wxUSE_DATETIME
|
||||||
wxMBConv& conv /*=wxConvFile*/)
|
const wxDateTime& originalTime /*=wxDateTime::Now()*/,
|
||||||
|
#endif
|
||||||
|
int level /*=-1*/,
|
||||||
|
wxMBConv& conv /*=wxConvFile*/)
|
||||||
: wxFilterOutputStream(stream)
|
: wxFilterOutputStream(stream)
|
||||||
{
|
{
|
||||||
m_comp = NULL;
|
m_comp = NULL;
|
||||||
@@ -205,17 +210,10 @@ wxGzipOutputStream::wxGzipOutputStream(
|
|||||||
|
|
||||||
wxFileName filename(originalName);
|
wxFileName filename(originalName);
|
||||||
|
|
||||||
#if wxUSE_DATETIME
|
|
||||||
wxDateTime datetime;
|
|
||||||
|
|
||||||
if (filename.FileExists())
|
|
||||||
datetime = filename.GetModificationTime();
|
|
||||||
else
|
|
||||||
datetime = wxDateTime::Now();
|
|
||||||
|
|
||||||
wxUint32 timestamp = (datetime.GetValue() / 1000L).GetLo();
|
|
||||||
#else
|
|
||||||
wxUint32 timestamp = 0;
|
wxUint32 timestamp = 0;
|
||||||
|
#if wxUSE_DATETIME
|
||||||
|
if (originalTime.IsValid())
|
||||||
|
timestamp = (originalTime.GetValue() / 1000L).GetLo();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// RFC-1952 specifies ISO-8859-1 for the name. Also it should be just the
|
// RFC-1952 specifies ISO-8859-1 for the name. Also it should be just the
|
||||||
|
Reference in New Issue
Block a user