xref: /haiku/src/bin/package/PackageWriterListener.cpp (revision a84e14ca84d32e9469c91372d71556488bd3d48b)
1*cba1e223SIngo Weinhold /*
2*cba1e223SIngo Weinhold  * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3*cba1e223SIngo Weinhold  * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
4*cba1e223SIngo Weinhold  * Distributed under the terms of the MIT License.
5*cba1e223SIngo Weinhold  */
6*cba1e223SIngo Weinhold 
7*cba1e223SIngo Weinhold 
8*cba1e223SIngo Weinhold #include "PackageWriterListener.h"
9*cba1e223SIngo Weinhold 
10*cba1e223SIngo Weinhold #include <stdio.h>
11*cba1e223SIngo Weinhold 
12*cba1e223SIngo Weinhold 
13*cba1e223SIngo Weinhold using BPackageKit::BHPKG::BPackageWriterListener;
14*cba1e223SIngo Weinhold using BPackageKit::BHPKG::BPackageWriter;
15*cba1e223SIngo Weinhold 
16*cba1e223SIngo Weinhold 
PackageWriterListener(bool verbose,bool quiet)17*cba1e223SIngo Weinhold PackageWriterListener::PackageWriterListener(bool verbose, bool quiet)
18*cba1e223SIngo Weinhold 	:
19*cba1e223SIngo Weinhold 	fVerbose(verbose), fQuiet(quiet)
20*cba1e223SIngo Weinhold {
21*cba1e223SIngo Weinhold }
22*cba1e223SIngo Weinhold 
23*cba1e223SIngo Weinhold 
24*cba1e223SIngo Weinhold void
PrintErrorVarArgs(const char * format,va_list args)25*cba1e223SIngo Weinhold PackageWriterListener::PrintErrorVarArgs(const char* format, va_list args)
26*cba1e223SIngo Weinhold {
27*cba1e223SIngo Weinhold 	vfprintf(stderr, format, args);
28*cba1e223SIngo Weinhold }
29*cba1e223SIngo Weinhold 
30*cba1e223SIngo Weinhold 
31*cba1e223SIngo Weinhold void
OnEntryAdded(const char * path)32*cba1e223SIngo Weinhold PackageWriterListener::OnEntryAdded(const char* path)
33*cba1e223SIngo Weinhold {
34*cba1e223SIngo Weinhold 	if (fQuiet || !fVerbose)
35*cba1e223SIngo Weinhold 		return;
36*cba1e223SIngo Weinhold 
37*cba1e223SIngo Weinhold 	printf("\t%s\n", path);
38*cba1e223SIngo Weinhold }
39*cba1e223SIngo Weinhold 
40*cba1e223SIngo Weinhold 
41*cba1e223SIngo Weinhold void
OnTOCSizeInfo(uint64 uncompressedStringsSize,uint64 uncompressedMainSize,uint64 uncompressedTOCSize)42*cba1e223SIngo Weinhold PackageWriterListener::OnTOCSizeInfo(uint64 uncompressedStringsSize,
43*cba1e223SIngo Weinhold 	uint64 uncompressedMainSize, uint64 uncompressedTOCSize)
44*cba1e223SIngo Weinhold {
45*cba1e223SIngo Weinhold 	if (fQuiet || !fVerbose)
46*cba1e223SIngo Weinhold 		return;
47*cba1e223SIngo Weinhold 
48*cba1e223SIngo Weinhold 	printf("----- TOC Info -----------------------------------\n");
49*cba1e223SIngo Weinhold 	printf("cached strings size:     %10" B_PRIu64 " (uncompressed)\n",
50*cba1e223SIngo Weinhold 		uncompressedStringsSize);
51*cba1e223SIngo Weinhold 	printf("TOC main size:           %10" B_PRIu64 " (uncompressed)\n",
52*cba1e223SIngo Weinhold 		uncompressedMainSize);
53*cba1e223SIngo Weinhold 	printf("total TOC size:          %10" B_PRIu64 " (uncompressed)\n",
54*cba1e223SIngo Weinhold 		uncompressedTOCSize);
55*cba1e223SIngo Weinhold }
56*cba1e223SIngo Weinhold 
57*cba1e223SIngo Weinhold 
58*cba1e223SIngo Weinhold void
OnPackageAttributesSizeInfo(uint32 stringCount,uint32 uncompressedSize)59*cba1e223SIngo Weinhold PackageWriterListener::OnPackageAttributesSizeInfo(uint32 stringCount,
60*cba1e223SIngo Weinhold 	uint32 uncompressedSize)
61*cba1e223SIngo Weinhold {
62*cba1e223SIngo Weinhold 	if (fQuiet || !fVerbose)
63*cba1e223SIngo Weinhold 		return;
64*cba1e223SIngo Weinhold 
65*cba1e223SIngo Weinhold 	printf("----- Package Attribute Info ---------------------\n");
66*cba1e223SIngo Weinhold 	printf("string count:            %10" B_PRIu32 "\n", stringCount);
67*cba1e223SIngo Weinhold 	printf("package attributes size: %10" B_PRIu32 " (uncompressed)\n",
68*cba1e223SIngo Weinhold 		uncompressedSize);
69*cba1e223SIngo Weinhold }
70*cba1e223SIngo Weinhold 
71*cba1e223SIngo Weinhold 
72*cba1e223SIngo Weinhold void
OnPackageSizeInfo(uint32 headerSize,uint64 heapSize,uint64 tocSize,uint32 packageAttributesSize,uint64 totalSize)73*cba1e223SIngo Weinhold PackageWriterListener::OnPackageSizeInfo(uint32 headerSize, uint64 heapSize,
74*cba1e223SIngo Weinhold 	uint64 tocSize, uint32 packageAttributesSize, uint64 totalSize)
75*cba1e223SIngo Weinhold {
76*cba1e223SIngo Weinhold 	if (fQuiet)
77*cba1e223SIngo Weinhold 		return;
78*cba1e223SIngo Weinhold 
79*cba1e223SIngo Weinhold 	printf("----- Package Info ----------------\n");
80*cba1e223SIngo Weinhold 	printf("header size:             %10" B_PRIu32 "\n", headerSize);
81*cba1e223SIngo Weinhold 	printf("heap size:               %10" B_PRIu64 "\n", heapSize);
82*cba1e223SIngo Weinhold 	printf("TOC size:                %10" B_PRIu64 "\n", tocSize);
83*cba1e223SIngo Weinhold 	printf("package attributes size: %10" B_PRIu32 "\n",
84*cba1e223SIngo Weinhold 		packageAttributesSize);
85*cba1e223SIngo Weinhold 	printf("total size:              %10" B_PRIu64 "\n", totalSize);
86*cba1e223SIngo Weinhold 	printf("-----------------------------------\n");
87*cba1e223SIngo Weinhold }
88