flush underlying streams on close()/sync()

This commit is contained in:
Guenter Obiltschnig 2014-12-02 09:08:07 +01:00
parent c455631e45
commit 9af6b5b2db
3 changed files with 11 additions and 0 deletions

View File

@ -85,6 +85,7 @@ public:
protected:
int readFromDevice(char* buffer, std::streamsize length);
int writeToDevice(const char* buffer, std::streamsize length);
int sync();
private:
enum

View File

@ -159,6 +159,7 @@ int DeflatingStreamBuf::close()
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
}
}
_pOstr->flush();
_pOstr = 0;
}
return 0;
@ -188,6 +189,7 @@ int DeflatingStreamBuf::sync()
_zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
}
_pOstr->flush();
return 0;
}

View File

@ -253,6 +253,14 @@ int InflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length
}
int InflatingStreamBuf::sync()
{
int n = BufferedStreamBuf::sync();
if (!n && _pOstr) _pOstr->flush();
return n;
}
InflatingIOS::InflatingIOS(std::ostream& ostr, InflatingStreamBuf::StreamType type):
_buf(ostr, type)
{