* refactored PackageWriter(Impl) to no longer print anything itself,

but publish that info through a BPackageWriterListener
* adjusted 'package create' to print a package summary by default and 
  more verbose info upon request.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40332 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe
2011-01-31 15:43:33 +00:00
parent 2eb4032d55
commit 7fd711ef99
5 changed files with 261 additions and 91 deletions
+26 -1
View File
@@ -8,6 +8,8 @@
#include <SupportDefs.h>
#include <package/hpkg/ErrorOutput.h>
namespace BPackageKit {
@@ -20,9 +22,32 @@ namespace BPrivate {
using BPrivate::PackageWriterImpl;
class BPackageWriterListener : public BErrorOutput {
public:
virtual void PrintErrorVarArgs(const char* format,
va_list args) = 0;
virtual void OnEntryAdded(const char* path) = 0;
virtual void OnTOCSizeInfo(
uint64 uncompressedAttributeTypesSize,
uint64 uncompressedStringsSize,
uint64 uncompressedMainSize,
uint64 uncompressedTOCSize) = 0;
virtual void OnPackageAttributesSizeInfo(
uint32 uncompressedSize) = 0;
virtual void OnPackageSizeInfo(uint32 headerSize,
uint64 heapSize, uint64 tocSize,
uint32 packageAttributesSize,
uint64 totalSize) = 0;
};
class BPackageWriter {
public:
BPackageWriter();
public:
BPackageWriter(
BPackageWriterListener* listener);
~BPackageWriter();
status_t Init(const char* fileName);
@@ -9,19 +9,19 @@
#include <util/DoublyLinkedList.h>
#include <util/OpenHashTable.h>
#include <package/PackageInfo.h>
#include <package/hpkg/PackageWriter.h>
#include <package/hpkg/Strings.h>
namespace BPackageKit {
class BPackageInfo;
namespace BHPKG {
class BDataReader;
class BErrorOutput;
namespace BPrivate {
@@ -31,7 +31,8 @@ struct hpkg_header;
class PackageWriterImpl {
public:
PackageWriterImpl();
PackageWriterImpl(
BPackageWriterListener* listener);
~PackageWriterImpl();
status_t Init(const char* fileName);
@@ -49,6 +50,7 @@ private:
struct DataWriter;
struct DummyDataWriter;
struct FDDataWriter;
struct SubPathAdder;
struct ZlibDataWriter;
typedef BOpenHashTable<AttributeTypeHashDefinition>
@@ -86,7 +88,7 @@ private:
off_t offset);
void _AddEntry(int dirFD, Entry* entry,
const char* fileName);
const char* fileName, char* pathBuffer);
Attribute* _AddAttribute(const char* attributeName,
const AttributeValue& value);
@@ -114,6 +116,8 @@ private:
uint64& _compressedSize);
private:
BPackageWriterListener* fListener;
const char* fFileName;
int fFD;
bool fFinished;
@@ -122,6 +126,8 @@ private:
void* fDataBuffer;
size_t fDataBufferSize;
BPackageInfo fPackageInfo;
DataWriter* fDataWriter;
Entry* fRootEntry;