2020-08-28 17:53:57 +02:00
|
|
|
/*
|
2022-02-26 09:06:40 -07:00
|
|
|
* Copyright (c) 2020-2022, the SerenityOS developers.
|
2021-04-22 23:40:43 +03:00
|
|
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
2025-03-01 17:38:52 +01:00
|
|
|
* Copyright (c) 2025, Altomani Gianluca <altomanigianluca@gmail.com>
|
2020-08-28 17:53:57 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-28 17:53:57 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2025-03-01 17:38:52 +01:00
|
|
|
#include <LibCompress/Zlib.h>
|
2020-08-28 17:53:57 +02:00
|
|
|
|
|
|
|
namespace Compress {
|
|
|
|
|
2025-03-01 17:38:52 +01:00
|
|
|
class GzipDecompressor final : public GenericZlibDecompressor {
|
2020-08-28 17:53:57 +02:00
|
|
|
public:
|
2025-03-01 17:38:52 +01:00
|
|
|
bool is_likely_compressed(ReadonlyBytes bytes);
|
2020-09-13 12:24:17 +02:00
|
|
|
|
2025-03-01 17:38:52 +01:00
|
|
|
static ErrorOr<NonnullOwnPtr<GzipDecompressor>> create(MaybeOwned<Stream>);
|
2022-11-29 15:43:31 +01:00
|
|
|
static ErrorOr<ByteBuffer> decompress_all(ReadonlyBytes);
|
2023-03-31 19:01:39 -04:00
|
|
|
|
2020-08-28 17:53:57 +02:00
|
|
|
private:
|
2025-03-01 17:38:52 +01:00
|
|
|
GzipDecompressor(AK::FixedArray<u8> buffer, MaybeOwned<Stream> stream, z_stream* zstream)
|
|
|
|
: GenericZlibDecompressor(move(buffer), move(stream), zstream)
|
|
|
|
{
|
|
|
|
}
|
2020-08-28 17:53:57 +02:00
|
|
|
};
|
|
|
|
|
2025-03-01 17:38:52 +01:00
|
|
|
class GzipCompressor final : public GenericZlibCompressor {
|
2021-03-13 01:26:44 +02:00
|
|
|
public:
|
2025-03-01 17:38:52 +01:00
|
|
|
static ErrorOr<NonnullOwnPtr<GzipCompressor>> create(MaybeOwned<Stream>, GenericZlibCompressionLevel = GenericZlibCompressionLevel::Default);
|
|
|
|
static ErrorOr<ByteBuffer> compress_all(ReadonlyBytes, GenericZlibCompressionLevel = GenericZlibCompressionLevel::Default);
|
2024-11-15 15:39:02 -05:00
|
|
|
|
2021-03-13 01:26:44 +02:00
|
|
|
private:
|
2025-03-01 17:38:52 +01:00
|
|
|
GzipCompressor(AK::FixedArray<u8> buffer, MaybeOwned<Stream> stream, z_stream* zstream)
|
|
|
|
: GenericZlibCompressor(move(buffer), move(stream), zstream)
|
|
|
|
{
|
|
|
|
}
|
2021-03-13 01:26:44 +02:00
|
|
|
};
|
|
|
|
|
2020-08-28 17:53:57 +02:00
|
|
|
}
|