BPackageWriter: Add Recompress()
Allows rewriting an existing package file with a different compression.
This commit is contained in:
@@ -24,6 +24,7 @@ class BAbstractBufferedDataReader;
|
||||
class BErrorOutput;
|
||||
class BLowLevelPackageContentHandler;
|
||||
class BPackageContentHandler;
|
||||
class BPackageWriter;
|
||||
|
||||
|
||||
class BPackageReader {
|
||||
@@ -43,6 +44,9 @@ public:
|
||||
BAbstractBufferedDataReader* HeapReader() const;
|
||||
// Only valid as long as the reader lives.
|
||||
|
||||
private:
|
||||
friend class BPackageWriter;
|
||||
|
||||
private:
|
||||
PackageReaderImpl* fImpl;
|
||||
};
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace BPackageKit {
|
||||
namespace BHPKG {
|
||||
|
||||
|
||||
class BPackageReader;
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
class PackageWriterImpl;
|
||||
}
|
||||
@@ -72,6 +75,9 @@ public:
|
||||
status_t AddEntry(const char* fileName, int fd = -1);
|
||||
status_t Finish();
|
||||
|
||||
status_t Recompress(BPackageReader* reader);
|
||||
// to be called after Init(); no Finish()
|
||||
|
||||
private:
|
||||
PackageWriterImpl* fImpl;
|
||||
};
|
||||
|
||||
@@ -92,6 +92,10 @@ public:
|
||||
void SetFD(int fd)
|
||||
{ fFD = fd; }
|
||||
|
||||
uint64 HeapOverhead(uint64 uncompressedSize) const;
|
||||
// additional bytes needed when storing
|
||||
// the given amount of data
|
||||
|
||||
// BAbstractBufferedDataReader
|
||||
virtual status_t ReadDataToOutput(off_t offset,
|
||||
size_t size, BDataIO* output);
|
||||
|
||||
@@ -22,6 +22,9 @@ class BPackageEntryAttribute;
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class PackageWriterImpl;
|
||||
|
||||
|
||||
class PackageReaderImpl : public ReaderImplBase {
|
||||
typedef ReaderImplBase inherited;
|
||||
public:
|
||||
@@ -58,6 +61,8 @@ private:
|
||||
struct EntryAttributeHandler;
|
||||
struct RootAttributeHandler;
|
||||
|
||||
friend class PackageWriterImpl;
|
||||
|
||||
private:
|
||||
status_t _ParseTOC(AttributeHandlerContext* context,
|
||||
AttributeHandler* rootAttributeHandler);
|
||||
|
||||
@@ -35,6 +35,7 @@ class BPackageWriterParameters;
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class PackageReaderImpl;
|
||||
struct hpkg_header;
|
||||
|
||||
|
||||
@@ -53,6 +54,9 @@ public:
|
||||
status_t AddEntry(const char* fileName, int fd = -1);
|
||||
status_t Finish();
|
||||
|
||||
status_t Recompress(PackageReaderImpl* reader);
|
||||
// to be called after Init(); no Finish()
|
||||
|
||||
private:
|
||||
struct Attribute;
|
||||
struct PackageContentHandler;
|
||||
@@ -67,6 +71,8 @@ private:
|
||||
const BPackageWriterParameters& parameters);
|
||||
status_t _Finish();
|
||||
|
||||
status_t _Recompress(PackageReaderImpl* reader);
|
||||
|
||||
status_t _RegisterEntry(const char* fileName, int fd);
|
||||
Entry* _RegisterEntry(Entry* parent,
|
||||
const char* name, size_t nameLength, int fd,
|
||||
|
||||
@@ -151,6 +151,7 @@ protected:
|
||||
|
||||
inline int FD() const;
|
||||
inline uint32 Flags() const;
|
||||
inline const BPackageWriterParameters& Parameters() const;
|
||||
|
||||
inline const PackageAttributeList& PackageAttributes() const;
|
||||
inline PackageAttributeList& PackageAttributes();
|
||||
@@ -230,6 +231,13 @@ WriterImplBase::Flags() const
|
||||
}
|
||||
|
||||
|
||||
inline const BPackageWriterParameters&
|
||||
WriterImplBase::Parameters() const
|
||||
{
|
||||
return fParameters;
|
||||
}
|
||||
|
||||
|
||||
inline const WriterImplBase::PackageAttributeList&
|
||||
WriterImplBase::PackageAttributes() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user