* added support for compressing the package attributes section to

PackageWriterImpl
* added my own copyright

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40358 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe 2011-02-04 22:40:10 +00:00
parent 70d5966963
commit fd9c0b3361
2 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__HPKG__PRIVATE__PACKAGE_WRITER_IMPL_H_

View File

@ -1,5 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
@ -1006,10 +1007,12 @@ PackageWriterImpl::_WriteAttributeChildren(Attribute* attribute)
void
PackageWriterImpl::_WritePackageAttributes(hpkg_header& header)
{
// write the package attributes
// write the package attributes (zlib writer on top of a file writer)
off_t startOffset = fHeapEnd;
FDDataWriter realWriter(fFD, startOffset, fListener);
fDataWriter = &realWriter;
ZlibDataWriter zlibWriter(&realWriter);
fDataWriter = &zlibWriter;
zlibWriter.Init();
// name
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
@ -1114,21 +1117,22 @@ PackageWriterImpl::_WritePackageAttributes(hpkg_header& header)
}
_Write<uint8>(0);
zlibWriter.Finish();
fHeapEnd = realWriter.Offset();
fDataWriter = NULL;
off_t endOffset = fHeapEnd;
fListener->OnPackageAttributesSizeInfo(endOffset - startOffset);
fListener->OnPackageAttributesSizeInfo(zlibWriter.BytesWritten());
// update the header
header.attributes_compression = B_HOST_TO_BENDIAN_INT32(
B_HPKG_COMPRESSION_NONE);
header.attributes_compression
= B_HOST_TO_BENDIAN_INT32(B_HPKG_COMPRESSION_ZLIB);
header.attributes_length_compressed
= B_HOST_TO_BENDIAN_INT32(endOffset - startOffset);
header.attributes_length_uncompressed
= header.attributes_length_compressed;
// TODO: Support compression!
= B_HOST_TO_BENDIAN_INT32(zlibWriter.BytesWritten());
}