2020-08-01 17:01:39 -03:00
|
|
|
/*
|
2021-04-28 17:46:44 -03:00
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
2025-03-01 13:37:59 -03:00
|
|
|
* Copyright (c) 2025, Altomani Gianluca <altomanigianluca@gmail.com>
|
2020-08-01 17:01:39 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-01 17:01:39 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-08-26 09:22:25 -03:00
|
|
|
#include <AK/ByteBuffer.h>
|
2023-01-22 00:24:18 -03:00
|
|
|
#include <AK/MaybeOwned.h>
|
2023-02-08 23:11:50 -03:00
|
|
|
#include <AK/Stream.h>
|
2025-03-01 13:37:59 -03:00
|
|
|
#include <LibCompress/GenericZlib.h>
|
2020-08-01 17:01:39 -03:00
|
|
|
|
|
|
|
|
namespace Compress {
|
2020-08-26 09:22:25 -03:00
|
|
|
|
2025-03-01 13:37:59 -03:00
|
|
|
class ZlibDecompressor final : public GenericZlibDecompressor {
|
2020-08-01 17:01:39 -03:00
|
|
|
public:
|
2023-06-08 14:35:44 -03:00
|
|
|
static ErrorOr<NonnullOwnPtr<ZlibDecompressor>> create(MaybeOwned<Stream>);
|
2025-03-01 13:37:59 -03:00
|
|
|
static ErrorOr<ByteBuffer> decompress_all(ReadonlyBytes);
|
2020-08-26 09:22:25 -03:00
|
|
|
|
2020-08-01 17:01:39 -03:00
|
|
|
private:
|
2025-03-01 13:37:59 -03:00
|
|
|
ZlibDecompressor(AK::FixedArray<u8> buffer, MaybeOwned<Stream> stream, z_stream* zstream)
|
|
|
|
|
: GenericZlibDecompressor(move(buffer), move(stream), zstream)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-08-01 17:01:39 -03:00
|
|
|
};
|
2020-08-18 15:49:59 -03:00
|
|
|
|
2025-03-01 13:37:59 -03:00
|
|
|
class ZlibCompressor final : public GenericZlibCompressor {
|
2022-06-17 04:26:35 -03:00
|
|
|
public:
|
2025-03-01 13:37:59 -03:00
|
|
|
static ErrorOr<NonnullOwnPtr<ZlibCompressor>> create(MaybeOwned<Stream>, GenericZlibCompressionLevel = GenericZlibCompressionLevel::Default);
|
|
|
|
|
static ErrorOr<ByteBuffer> compress_all(ReadonlyBytes, GenericZlibCompressionLevel = GenericZlibCompressionLevel::Default);
|
2022-06-17 04:26:35 -03:00
|
|
|
|
|
|
|
|
private:
|
2025-03-01 13:37:59 -03:00
|
|
|
ZlibCompressor(AK::FixedArray<u8> buffer, MaybeOwned<Stream> stream, z_stream* zstream)
|
|
|
|
|
: GenericZlibCompressor(move(buffer), move(stream), zstream)
|
|
|
|
|
{
|
|
|
|
|
}
|
2022-06-17 04:26:35 -03:00
|
|
|
};
|
|
|
|
|
|
2020-08-01 17:01:39 -03:00
|
|
|
}
|