2 * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef _PACKAGE__HPKG__PRIVATE__PACKAGE_FILE_HEAP_WRITER_H_
6 #define _PACKAGE__HPKG__PRIVATE__PACKAGE_FILE_HEAP_WRITER_H_
10 #include <package/hpkg/PackageFileHeapAccessorBase.h>
13 class BCompressionParameters
;
16 template<typename Value
> class RangeArray
;
20 namespace BPackageKit
{
32 class PackageFileHeapReader
;
35 class PackageFileHeapWriter
: public PackageFileHeapAccessorBase
{
37 PackageFileHeapWriter(BErrorOutput
* errorOutput
,
38 BPositionIO
* file
, off_t heapOffset
,
39 CompressionAlgorithmOwner
*
41 DecompressionAlgorithmOwner
*
42 decompressionAlgorithm
);
43 ~PackageFileHeapWriter();
46 void Reinit(PackageFileHeapReader
* heapReader
);
48 status_t
AddData(BDataReader
& dataReader
, off_t size
,
50 void AddDataThrows(const void* buffer
, size_t size
);
51 void RemoveDataRanges(
52 const ::BPrivate::RangeArray
<uint64
>&
54 // doesn't truncate the file
58 virtual status_t
ReadAndDecompressChunk(size_t chunkIndex
,
59 void* compressedDataBuffer
,
60 void* uncompressedDataBuffer
);
67 friend struct ChunkBuffer
;
72 status_t
_FlushPendingData();
73 status_t
_WriteChunk(const void* data
, size_t size
,
75 status_t
_WriteDataCompressed(const void* data
,
77 status_t
_WriteDataUncompressed(const void* data
,
80 void _PushChunks(ChunkBuffer
& chunkBuffer
,
81 uint64 startOffset
, uint64 endOffset
);
82 void _UnwriteLastPartialChunk();
85 void* fPendingDataBuffer
;
86 void* fCompressedDataBuffer
;
87 size_t fPendingDataSize
;
88 Array
<uint64
> fOffsets
;
89 CompressionAlgorithmOwner
* fCompressionAlgorithm
;
93 } // namespace BPrivate
97 } // namespace BPackageKit
100 #endif // _PACKAGE__HPKG__PRIVATE__PACKAGE_FILE_HEAP_WRITER_H_