If the underlying object reported EOF after reading the last byte, then
ZlibCompressed would report EOF itself before giving out all data from
the buffers.
void set_eof();
public:
- /** Returns the end-of-file flag. */
+ /** Returns the end-of-file flag. Note that some types of objects won't
+ indicate end-of-file until you try to read at least one byte past the actual
+ end, while others indicate it when you've read the last byte. */
bool eof() const { return eof_flag; }
/** Returns the system-level handle for the object. Used by Console to
buffer_size(1024),
in_buffer(0),
out_buffer(0),
+ stream_end(false),
priv(0)
{
#ifdef WITH_ZLIB
{
int ret = inflate(&priv->stream, Z_NO_FLUSH);
if(ret==Z_STREAM_END)
- set_eof();
+ stream_end = true;
else if(ret!=Z_OK)
throw zlib_error("inflate", ret);
need_more_input = (priv->stream.next_out==out_buffer);
if(need_more_input)
{
- if(eof_flag)
+ if(stream_end)
break;
if(priv->stream.next_in>in_buffer)
unsigned len = below.read(reinterpret_cast<char *>(priv->stream.next_in), in_buffer+buffer_size-priv->stream.next_in);
priv->stream.avail_in += len;
if(!len && below.eof())
- set_eof();
+ stream_end = true;
}
}
+
+ if(size>0 && processed==0 && stream_end)
+ set_eof();
#else
(void)data;
(void)size;
unsigned buffer_size;
unsigned char *in_buffer;
unsigned char *out_buffer;
+ bool stream_end;
Private *priv;
public: