Allow specifying the compression level for package creation
* Introduce BPackageWriterParameters which comprises all parameters for package creation, currently flags and compression level. Such an object can be passed to BPackageWriter::Init() and is passed on to PackageWriterImpl and WriterImplBase. * PackageFileHeapWriter: Add compressionLevel property and pass the value on to ZlibCompressor. * package add/create: Add options -0 ... -9 to specify the compression level to be used.
This commit is contained in:
@@ -166,6 +166,13 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
B_HPKG_COMPRESSION_LEVEL_NONE = 0,
|
||||
B_HPKG_COMPRESSION_LEVEL_FASTEST = 1,
|
||||
B_HPKG_COMPRESSION_LEVEL_BEST = 9
|
||||
};
|
||||
|
||||
|
||||
} // namespace BHPKG
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
@@ -41,13 +41,32 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class BPackageWriterParameters {
|
||||
public:
|
||||
BPackageWriterParameters();
|
||||
~BPackageWriterParameters();
|
||||
|
||||
uint32 Flags() const;
|
||||
void SetFlags(uint32 flags);
|
||||
|
||||
int32 CompressionLevel() const;
|
||||
void SetCompressionLevel(int32 compressionLevel);
|
||||
|
||||
private:
|
||||
uint32 fFlags;
|
||||
int32 fCompressionLevel;
|
||||
};
|
||||
|
||||
|
||||
class BPackageWriter {
|
||||
public:
|
||||
BPackageWriter(
|
||||
BPackageWriterListener* listener);
|
||||
~BPackageWriter();
|
||||
|
||||
status_t Init(const char* fileName, uint32 flags = 0);
|
||||
status_t Init(const char* fileName,
|
||||
const BPackageWriterParameters* parameters
|
||||
= NULL);
|
||||
status_t SetInstallPath(const char* installPath);
|
||||
void SetCheckLicenses(bool checkLicenses);
|
||||
status_t AddEntry(const char* fileName, int fd = -1);
|
||||
|
||||
@@ -35,7 +35,8 @@ class PackageFileHeapWriter : public PackageFileHeapAccessorBase,
|
||||
private AbstractDataWriter {
|
||||
public:
|
||||
PackageFileHeapWriter(BErrorOutput* errorOutput,
|
||||
int fd, off_t heapOffset);
|
||||
int fd, off_t heapOffset,
|
||||
int32 compressionLevel);
|
||||
~PackageFileHeapWriter();
|
||||
|
||||
void Init();
|
||||
@@ -86,6 +87,7 @@ private:
|
||||
void* fCompressedDataBuffer;
|
||||
size_t fPendingDataSize;
|
||||
Array<uint64> fOffsets;
|
||||
int32 fCompressionLevel;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace BHPKG {
|
||||
|
||||
class BDataReader;
|
||||
class BErrorOutput;
|
||||
class BPackageWriterParameters;
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
@@ -46,7 +47,8 @@ public:
|
||||
BPackageWriterListener* listener);
|
||||
~PackageWriterImpl();
|
||||
|
||||
status_t Init(const char* fileName, uint32 flags);
|
||||
status_t Init(const char* fileName,
|
||||
const BPackageWriterParameters& parameters);
|
||||
status_t SetInstallPath(const char* installPath);
|
||||
void SetCheckLicenses(bool checkLicenses);
|
||||
status_t AddEntry(const char* fileName, int fd = -1);
|
||||
@@ -62,7 +64,8 @@ private:
|
||||
typedef DoublyLinkedList<Entry> EntryList;
|
||||
|
||||
private:
|
||||
status_t _Init(const char* fileName, uint32 flags);
|
||||
status_t _Init(const char* fileName,
|
||||
const BPackageWriterParameters& parameters);
|
||||
status_t _Finish();
|
||||
|
||||
status_t _RegisterEntry(const char* fileName, int fd);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <package/hpkg/DataOutput.h>
|
||||
#include <package/hpkg/DataWriters.h>
|
||||
#include <package/hpkg/PackageWriter.h>
|
||||
#include <package/hpkg/Strings.h>
|
||||
#include <package/hpkg/ZlibCompressor.h>
|
||||
|
||||
@@ -99,7 +100,8 @@ protected:
|
||||
typedef DoublyLinkedList<PackageAttribute> PackageAttributeList;
|
||||
|
||||
protected:
|
||||
status_t Init(const char* fileName, uint32 flags);
|
||||
status_t Init(const char* fileName,
|
||||
const BPackageWriterParameters& parameters);
|
||||
|
||||
void RegisterPackageInfo(
|
||||
PackageAttributeList& attributeList,
|
||||
@@ -168,7 +170,7 @@ private:
|
||||
const char* fFileType;
|
||||
BErrorOutput* fErrorOutput;
|
||||
const char* fFileName;
|
||||
uint32 fFlags;
|
||||
BPackageWriterParameters fParameters;
|
||||
int fFD;
|
||||
bool fFinished;
|
||||
|
||||
@@ -211,7 +213,7 @@ WriterImplBase::FD() const
|
||||
inline uint32
|
||||
WriterImplBase::Flags() const
|
||||
{
|
||||
return fFlags;
|
||||
return fParameters.Flags();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user