2 * Copyright 2009,2011, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
5 #ifndef _PACKAGE__HPKG__PACKAGE_WRITER_H_
6 #define _PACKAGE__HPKG__PACKAGE_WRITER_H_
9 #include <SupportDefs.h>
11 #include <package/hpkg/ErrorOutput.h>
17 namespace BPackageKit
{
22 class PackageWriterImpl
;
24 using BPrivate::PackageWriterImpl
;
27 class BPackageWriterListener
: public BErrorOutput
{
29 virtual void PrintErrorVarArgs(const char* format
,
32 virtual void OnEntryAdded(const char* path
) = 0;
34 virtual void OnTOCSizeInfo(uint64 uncompressedStringsSize
,
35 uint64 uncompressedMainSize
,
36 uint64 uncompressedTOCSize
) = 0;
37 virtual void OnPackageAttributesSizeInfo(uint32 stringCount
,
38 uint32 uncompressedSize
) = 0;
39 virtual void OnPackageSizeInfo(uint32 headerSize
,
40 uint64 heapSize
, uint64 tocSize
,
41 uint32 packageAttributesSize
,
42 uint64 totalSize
) = 0;
46 class BPackageWriterParameters
{
48 BPackageWriterParameters();
49 ~BPackageWriterParameters();
52 void SetFlags(uint32 flags
);
54 uint32
Compression() const;
55 void SetCompression(uint32 compression
);
57 int32
CompressionLevel() const;
58 void SetCompressionLevel(int32 compressionLevel
);
63 int32 fCompressionLevel
;
67 class BPackageWriter
{
70 BPackageWriterListener
* listener
);
73 status_t
Init(const char* fileName
,
74 const BPackageWriterParameters
* parameters
76 status_t
Init(BPositionIO
* file
, bool keepFile
,
77 const BPackageWriterParameters
* parameters
79 status_t
SetInstallPath(const char* installPath
);
80 void SetCheckLicenses(bool checkLicenses
);
81 status_t
AddEntry(const char* fileName
, int fd
= -1);
84 status_t
Recompress(BPositionIO
* inputFile
);
85 // to be called after Init(); no Finish()
88 PackageWriterImpl
* fImpl
;
94 } // namespace BPackageKit
97 #endif // _PACKAGE__HPKG__PACKAGE_WRITER_H_