2011-01-30 18:05:38 +03:00
|
|
|
/*
|
2011-01-30 18:15:33 +03:00
|
|
|
* Copyright 2009,2011, Haiku, Inc.
|
2011-01-30 18:05:38 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _PACKAGE__HPKG__PACKAGE_WRITER_H_
|
|
|
|
#define _PACKAGE__HPKG__PACKAGE_WRITER_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
2011-01-31 18:43:33 +03:00
|
|
|
#include <package/hpkg/ErrorOutput.h>
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
|
2014-07-13 02:30:25 +04:00
|
|
|
class BPositionIO;
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
namespace BPackageKit {
|
|
|
|
|
|
|
|
namespace BHPKG {
|
|
|
|
|
|
|
|
|
2014-07-08 23:58:10 +04:00
|
|
|
class BPackageReader;
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
namespace BPrivate {
|
|
|
|
class PackageWriterImpl;
|
|
|
|
}
|
|
|
|
using BPrivate::PackageWriterImpl;
|
|
|
|
|
|
|
|
|
2011-01-31 18:43:33 +03:00
|
|
|
class BPackageWriterListener : public BErrorOutput {
|
|
|
|
public:
|
|
|
|
virtual void PrintErrorVarArgs(const char* format,
|
|
|
|
va_list args) = 0;
|
|
|
|
|
|
|
|
virtual void OnEntryAdded(const char* path) = 0;
|
|
|
|
|
2011-02-12 22:21:37 +03:00
|
|
|
virtual void OnTOCSizeInfo(uint64 uncompressedStringsSize,
|
2011-01-31 18:43:33 +03:00
|
|
|
uint64 uncompressedMainSize,
|
|
|
|
uint64 uncompressedTOCSize) = 0;
|
2011-02-08 22:50:36 +03:00
|
|
|
virtual void OnPackageAttributesSizeInfo(uint32 stringCount,
|
2011-01-31 18:43:33 +03:00
|
|
|
uint32 uncompressedSize) = 0;
|
|
|
|
virtual void OnPackageSizeInfo(uint32 headerSize,
|
|
|
|
uint64 heapSize, uint64 tocSize,
|
|
|
|
uint32 packageAttributesSize,
|
|
|
|
uint64 totalSize) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-19 03:07:08 +04:00
|
|
|
class BPackageWriterParameters {
|
|
|
|
public:
|
|
|
|
BPackageWriterParameters();
|
|
|
|
~BPackageWriterParameters();
|
|
|
|
|
|
|
|
uint32 Flags() const;
|
|
|
|
void SetFlags(uint32 flags);
|
|
|
|
|
2014-07-13 01:12:21 +04:00
|
|
|
uint32 Compression() const;
|
|
|
|
void SetCompression(uint32 compression);
|
|
|
|
|
2013-05-19 03:07:08 +04:00
|
|
|
int32 CompressionLevel() const;
|
|
|
|
void SetCompressionLevel(int32 compressionLevel);
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32 fFlags;
|
2014-07-13 01:12:21 +04:00
|
|
|
uint32 fCompression;
|
2013-05-19 03:07:08 +04:00
|
|
|
int32 fCompressionLevel;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
class BPackageWriter {
|
2011-01-31 18:43:33 +03:00
|
|
|
public:
|
|
|
|
BPackageWriter(
|
|
|
|
BPackageWriterListener* listener);
|
2011-01-30 18:05:38 +03:00
|
|
|
~BPackageWriter();
|
|
|
|
|
2013-05-19 03:07:08 +04:00
|
|
|
status_t Init(const char* fileName,
|
|
|
|
const BPackageWriterParameters* parameters
|
|
|
|
= NULL);
|
2014-07-13 02:30:25 +04:00
|
|
|
status_t Init(BPositionIO* file, bool keepFile,
|
|
|
|
const BPackageWriterParameters* parameters
|
|
|
|
= NULL);
|
2011-07-11 16:00:55 +04:00
|
|
|
status_t SetInstallPath(const char* installPath);
|
2011-07-11 15:55:35 +04:00
|
|
|
void SetCheckLicenses(bool checkLicenses);
|
2011-07-01 03:41:28 +04:00
|
|
|
status_t AddEntry(const char* fileName, int fd = -1);
|
2011-01-30 18:05:38 +03:00
|
|
|
status_t Finish();
|
|
|
|
|
2014-07-08 23:58:10 +04:00
|
|
|
status_t Recompress(BPackageReader* reader);
|
|
|
|
// to be called after Init(); no Finish()
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
private:
|
|
|
|
PackageWriterImpl* fImpl;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace BHPKG
|
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _PACKAGE__HPKG__PACKAGE_WRITER_H_
|