xref: /haiku/headers/os/package/hpkg/PackageWriter.h (revision 73ad2473e7874b3702cf5b0fdf4c81b747812ed9)
1 /*
2  * Copyright 2009,2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__HPKG__PACKAGE_WRITER_H_
6 #define _PACKAGE__HPKG__PACKAGE_WRITER_H_
7 
8 
9 #include <SupportDefs.h>
10 
11 #include <package/hpkg/ErrorOutput.h>
12 
13 
14 namespace BPackageKit {
15 
16 namespace BHPKG {
17 
18 
19 namespace BPrivate {
20 	class PackageWriterImpl;
21 }
22 using BPrivate::PackageWriterImpl;
23 
24 
25 class BPackageWriterListener : public BErrorOutput {
26 public:
27 	virtual	void				PrintErrorVarArgs(const char* format,
28 									va_list args) = 0;
29 
30 	virtual	void				OnEntryAdded(const char* path) = 0;
31 
32 	virtual void				OnTOCSizeInfo(uint64 uncompressedStringsSize,
33 									uint64 uncompressedMainSize,
34 									uint64 uncompressedTOCSize) = 0;
35 	virtual void				OnPackageAttributesSizeInfo(uint32 stringCount,
36 									uint32 uncompressedSize) = 0;
37 	virtual void				OnPackageSizeInfo(uint32 headerSize,
38 									uint64 heapSize, uint64 tocSize,
39 									uint32 packageAttributesSize,
40 									uint64 totalSize) = 0;
41 };
42 
43 
44 class BPackageWriterParameters {
45 public:
46 								BPackageWriterParameters();
47 								~BPackageWriterParameters();
48 
49 			uint32				Flags() const;
50 			void				SetFlags(uint32 flags);
51 
52 			int32				CompressionLevel() const;
53 			void				SetCompressionLevel(int32 compressionLevel);
54 
55 private:
56 			uint32				fFlags;
57 			int32				fCompressionLevel;
58 };
59 
60 
61 class BPackageWriter {
62 public:
63 								BPackageWriter(
64 									BPackageWriterListener* listener);
65 								~BPackageWriter();
66 
67 			status_t			Init(const char* fileName,
68 									const BPackageWriterParameters* parameters
69 										= NULL);
70 			status_t			SetInstallPath(const char* installPath);
71 			void				SetCheckLicenses(bool checkLicenses);
72 			status_t			AddEntry(const char* fileName, int fd = -1);
73 			status_t			Finish();
74 
75 private:
76 			PackageWriterImpl*	fImpl;
77 };
78 
79 
80 }	// namespace BHPKG
81 
82 }	// namespace BPackageKit
83 
84 
85 #endif	// _PACKAGE__HPKG__PACKAGE_WRITER_H_
86