Pregunta

I'm using TZDecompressionStream to unpack compressed data. There is a property OnProgress: TNotifyEvent in TZDecompressionStream where I can check Position property of my DecompressionStream. It gives me position in unpacked data, but I don't now size of all unpacked data to estimate progress. I know only packed data size.

Is there is a way to get position in input (unpacked) data?

¿Fue útil?

Solución

TZDecompressionStream.Size gives unpacked data size, but you must get this value before starting to read from stream (unpack). And if you try to get unpacked data size in OnProgress event handler you will get an EZDecompressionError exception with message 'buffer error'.


This error happens because TStream.Size getter retrieves a size by performing Seek forward to the end of stream and then Seek backward to the saved position. Latter operation is not supported due unidirectional nature of TZDecompressionStream see the 3rd paragraph of class description. Retrieval of size before starting an actual decompression operation is possible because Seek(0, soFromBeginning) is allowed as a special case, which effectively resets decoder to initial state.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top