public void GetCompressedCopy( [NotNull] Stream stream, bool prependBlockCount )
{
if ( stream == null )
throw new ArgumentNullException( "stream" );
using ( GZipStream compressor = new GZipStream( stream, CompressionMode.Compress ) ) {
if ( prependBlockCount ) {
// convert block count to big-endian
int convertedBlockCount = IPAddress.HostToNetworkOrder( Blocks.Length );
// write block count to gzip stream
compressor.Write( BitConverter.GetBytes( convertedBlockCount ), 0, 4 );
}
compressor.Write( Blocks, 0, Blocks.Length );
}
}