1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:37:35 +00:00

LibCompress: Switch DeflateCompressor to a fallible constructor

This commit is contained in:
Tim Schumacher 2023-01-03 18:59:27 +01:00 committed by Andreas Kling
parent 8cd2cf2b77
commit f4afee4278
4 changed files with 19 additions and 10 deletions

View file

@ -194,9 +194,9 @@ ErrorOr<size_t> GzipCompressor::write(ReadonlyBytes bytes)
header.extra_flags = 3; // DEFLATE sets 2 for maximum compression and 4 for minimum compression
header.operating_system = 3; // unix
TRY(m_output_stream->write_entire_buffer({ &header, sizeof(header) }));
DeflateCompressor compressed_stream { Core::Stream::Handle(*m_output_stream) };
TRY(compressed_stream.write_entire_buffer(bytes));
TRY(compressed_stream.final_flush());
auto compressed_stream = TRY(DeflateCompressor::construct(Core::Stream::Handle(*m_output_stream)));
TRY(compressed_stream->write_entire_buffer(bytes));
TRY(compressed_stream->final_flush());
Crypto::Checksum::CRC32 crc32;
crc32.update(bytes);
LittleEndian<u32> digest = crc32.digest();