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