[Mono-list] [Fwd: [Mono-cvs-list] Mono CVS: mcs gonzalo]

Martin Baulig martin@gnome.org
03 Jul 2002 02:17:01 +0200

Gonzalo Paniagua Javier <gonzalo@gnome-db.org> writes:

> > If the stream is not seekable, there is no way to back up from the peek,
> > and peek is not supposed to consume. Besides, the MS docs on the method
> > explicitly state that -1 is supposed to be returned if Peek is called on
> > a non-seekable stream.

I'm not 100% sure what you're talking about since Mike forgot to quote
the change in his mail.

However, from the context I assume that you changed the stream's Peek()
function to make it "work" on a nonseekable stream.  This'd be wrong.

> I was getting an error in a StreamReader that wraps a NetworkStream.
> I got a "\r" from StreamReader.ReadLine cause Peek always returned -1
> cause you cannot seek a NetworkStream.

Well, IMO StreamReader.ReadLine() must not call Peek() on a nonseekable
stream.  The correct way to do it is to change the StreamReader to do a
read and then to cache the value.

On the other hand, the StreamReader's Peek() function may return a value
on a nonseekable stream since it can cache the data from the non-seekable

I can't look at the docs since I've already shut down my Windows box and
everything so I may be wrong ...

Martin Baulig