2009-11-15 00:08:33 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2011-01-30 18:05:38 +03:00
|
|
|
#ifndef _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSOR_H_
|
|
|
|
#define _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSOR_H_
|
2009-11-15 00:08:33 +03:00
|
|
|
|
|
|
|
|
2009-11-16 00:29:53 +03:00
|
|
|
#include <zlib.h>
|
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
#include <package/hpkg/ZlibCompressionBase.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
namespace BHPKG {
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
|
|
|
|
class BDataOutput;
|
2009-11-15 00:08:33 +03:00
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
namespace BPrivate {
|
2009-11-16 00:29:53 +03:00
|
|
|
|
|
|
|
|
2009-11-15 00:08:33 +03:00
|
|
|
class ZlibCompressor : public ZlibCompressionBase {
|
|
|
|
public:
|
2011-01-30 18:05:38 +03:00
|
|
|
ZlibCompressor(BDataOutput* output);
|
2009-11-15 00:08:33 +03:00
|
|
|
~ZlibCompressor();
|
|
|
|
|
2013-05-19 03:00:36 +04:00
|
|
|
status_t Init(int compressionLevel = Z_BEST_COMPRESSION);
|
2009-11-16 00:29:53 +03:00
|
|
|
status_t CompressNext(const void* input,
|
|
|
|
size_t inputSize);
|
|
|
|
status_t Finish();
|
|
|
|
|
|
|
|
static status_t CompressSingleBuffer(const void* input,
|
|
|
|
size_t inputSize, void* output,
|
2013-05-19 03:00:36 +04:00
|
|
|
size_t outputSize, size_t& _compressedSize,
|
|
|
|
int compressionLevel = Z_BEST_COMPRESSION);
|
2009-11-16 00:29:53 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
z_stream fStream;
|
2011-01-30 18:05:38 +03:00
|
|
|
BDataOutput* fOutput;
|
2009-11-16 00:29:53 +03:00
|
|
|
bool fStreamInitialized;
|
2009-11-15 00:08:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
} // namespace BHPKG
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
#endif // _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSOR_H_
|