Switch package kit to BZlibCompressionAlgorithm
... and remove the Zlib{Compressor,Decompressor} API.
This commit is contained in:
@@ -6,8 +6,11 @@
|
||||
#define _PACKAGE__HPKG__PRIVATE__PACKAGE_FILE_HEAP_ACCESSOR_BASE_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <new>
|
||||
|
||||
#include <Referenceable.h>
|
||||
|
||||
#include <CompressionAlgorithm.h>
|
||||
#include <package/hpkg/DataReader.h>
|
||||
|
||||
|
||||
@@ -22,6 +25,46 @@ class BErrorOutput;
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
template<typename Parameters>
|
||||
struct GenericCompressionAlgorithmOwner : BReferenceable {
|
||||
BCompressionAlgorithm* algorithm;
|
||||
Parameters* parameters;
|
||||
|
||||
GenericCompressionAlgorithmOwner(BCompressionAlgorithm* algorithm,
|
||||
Parameters* parameters)
|
||||
:
|
||||
algorithm(algorithm),
|
||||
parameters(parameters)
|
||||
{
|
||||
}
|
||||
|
||||
~GenericCompressionAlgorithmOwner()
|
||||
{
|
||||
delete algorithm;
|
||||
delete parameters;
|
||||
}
|
||||
|
||||
static GenericCompressionAlgorithmOwner* Create(
|
||||
BCompressionAlgorithm* algorithm, Parameters* parameters)
|
||||
{
|
||||
GenericCompressionAlgorithmOwner* owner
|
||||
= new(std::nothrow) GenericCompressionAlgorithmOwner(algorithm,
|
||||
parameters);
|
||||
if (owner == NULL) {
|
||||
delete algorithm;
|
||||
delete parameters;
|
||||
}
|
||||
|
||||
return owner;
|
||||
}
|
||||
};
|
||||
|
||||
typedef GenericCompressionAlgorithmOwner<BCompressionParameters>
|
||||
CompressionAlgorithmOwner;
|
||||
typedef GenericCompressionAlgorithmOwner<BDecompressionParameters>
|
||||
DecompressionAlgorithmOwner;
|
||||
|
||||
|
||||
class PackageFileHeapAccessorBase : public BAbstractBufferedDataReader {
|
||||
public:
|
||||
class OffsetArray;
|
||||
@@ -29,7 +72,9 @@ public:
|
||||
public:
|
||||
PackageFileHeapAccessorBase(
|
||||
BErrorOutput* errorOutput, int fd,
|
||||
off_t heapOffset);
|
||||
off_t heapOffset,
|
||||
DecompressionAlgorithmOwner*
|
||||
decompressionAlgorithm);
|
||||
virtual ~PackageFileHeapAccessorBase();
|
||||
|
||||
off_t HeapOffset() const
|
||||
@@ -77,6 +122,7 @@ protected:
|
||||
off_t fHeapOffset;
|
||||
uint64 fCompressedHeapSize;
|
||||
uint64 fUncompressedHeapSize;
|
||||
DecompressionAlgorithmOwner* fDecompressionAlgorithm;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@ public:
|
||||
PackageFileHeapReader(BErrorOutput* errorOutput,
|
||||
int fd, off_t heapOffset,
|
||||
off_t compressedHeapSize,
|
||||
uint64 uncompressedHeapSize);
|
||||
uint64 uncompressedHeapSize,
|
||||
DecompressionAlgorithmOwner*
|
||||
decompressionAlgorithm);
|
||||
~PackageFileHeapReader();
|
||||
|
||||
status_t Init();
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <package/hpkg/PackageFileHeapAccessorBase.h>
|
||||
|
||||
|
||||
class BCompressionParameters;
|
||||
|
||||
namespace BPrivate {
|
||||
template<typename Value> class RangeArray;
|
||||
}
|
||||
@@ -34,7 +36,10 @@ class PackageFileHeapWriter : public PackageFileHeapAccessorBase {
|
||||
public:
|
||||
PackageFileHeapWriter(BErrorOutput* errorOutput,
|
||||
int fd, off_t heapOffset,
|
||||
int32 compressionLevel);
|
||||
CompressionAlgorithmOwner*
|
||||
compressionAlgorithm,
|
||||
DecompressionAlgorithmOwner*
|
||||
decompressionAlgorithm);
|
||||
~PackageFileHeapWriter();
|
||||
|
||||
void Init();
|
||||
@@ -81,7 +86,7 @@ private:
|
||||
void* fCompressedDataBuffer;
|
||||
size_t fPendingDataSize;
|
||||
Array<uint64> fOffsets;
|
||||
int32 fCompressionLevel;
|
||||
CompressionAlgorithmOwner* fCompressionAlgorithm;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
#include <package/hpkg/PackageInfoAttributeValue.h>
|
||||
|
||||
|
||||
class BCompressionAlgorithm;
|
||||
class BDecompressionParameters;
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
namespace BHPKG {
|
||||
|
||||
@@ -10,12 +10,18 @@
|
||||
|
||||
#include <package/hpkg/HPKGDefsPrivate.h>
|
||||
|
||||
#include <package/hpkg/PackageFileHeapWriter.h>
|
||||
#include <package/hpkg/PackageWriter.h>
|
||||
#include <package/hpkg/Strings.h>
|
||||
|
||||
#include <package/PackageInfo.h>
|
||||
|
||||
#include <package/hpkg/PackageFileHeapWriter.h>
|
||||
|
||||
|
||||
class BCompressionAlgorithm;
|
||||
class BCompressionParameters;
|
||||
class BDecompressionParameters;
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
@@ -156,6 +162,10 @@ protected:
|
||||
|
||||
protected:
|
||||
PackageFileHeapWriter* fHeapWriter;
|
||||
BCompressionAlgorithm* fCompressionAlgorithm;
|
||||
BCompressionParameters* fCompressionParameters;
|
||||
BCompressionAlgorithm* fDecompressionAlgorithm;
|
||||
BDecompressionParameters* fDecompressionParameters;
|
||||
|
||||
private:
|
||||
static const BHPKGAttributeID kDefaultVersionAttributeID
|
||||
|
||||
Reference in New Issue
Block a user