[fpc-devel] zstream, fpc and lazarus

Daniël Mantione daniel.mantione at freepascal.org
Sun Dec 2 13:46:40 CET 2007

Op Sun, 2 Dec 2007, schreef Sergei Gorelkin:

> 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?

It doesn't, otherwise it could not be sequentially written. As you cannot 
"unread" some bytes, this makes the bytes remaining in the buffer


More information about the fpc-devel mailing list