[fpc-devel] zstream, fpc and lazarus

Sergei Gorelkin sergei_gorelkin at mail.ru
Sun Dec 2 12:00:45 CET 2007


Daniƫl Mantione wrote:
> 
> I agree, but I would like to be carefull about one thing: zstreams read 
> from pipes or sockets. If someone closes a socket zstream early, a seek to 
> end would result in an exception. Is there a way we can detect a stream to 
> be seekable?
> 
Probably no, and it's (sometimes) a badly needed feature.
However, two solutions come to my mind:

1) Ignore that particular exception. Not very good, because excessive 
data will still be read from the source stream.
2) Add a property, something like "MaxSourceSize", and limit 
decompression stream to read no more than that many bytes from the 
source. Of course, this size must be known beforehand, but usually 
sequential streams are arranged in a way that it is known. Or, maybe 
zlib data header already contains this size?

Sergei



More information about the fpc-devel mailing list