[fpc-devel] Read from memory stream with position before start of file

Michael Van Canneyt michael at freepascal.org
Fri Jan 2 15:07:27 CET 2009



On Thu, 1 Jan 2009, Paul Ishenin wrote:

> Michael Van Canneyt wrote:
> > > If you do an exception or silent change of position it can cause
> > > incompatibilities. Maybe read operation must be fixed to ignore positions
> > > out
> > > of the range 0..Size -1?
> > >     
> >
> > What does Delphi do in such a case ?
> >   
> Tested so:
> 
> procedure TForm1.Button1Click(Sender: TObject);
> var
>  S: TMemoryStream;
>  B: Byte;
>  Count: Integer;
> begin
>  S := TMemoryStream.Create;
>  B := 1;
>  S.Write(B, SizeOf(B));
>  S.Position := -1;
>  Count := S.Read(B, SizeOf(B));
>  ShowMessage(IntToStr(Count));
>  S.Free;
> end;
> 
> Count = 0. IOW, delphi does not read if position < 0

And writing ?

Michael.



More information about the fpc-devel mailing list