comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: Q: Index value in case of Ada.Streams.Stream_IO.End_Error
Date: Mon, 24 Apr 2006 18:05:06 +0200
Date: 2006-04-24T18:05:06+02:00	[thread overview]
Message-ID: <hvsi2e.uhv.ln@hunter.axlog.fr> (raw)
In-Reply-To: <444ce1c1$1_5@news.bluewin.ch>

Gautier a �crit :
> Jean-Pierre Rosen:
> 
>>> Is there a RM-documented way to know the Index of a 
>>> Ada.Streams.Stream_IO.File_Type
>>> when it knocks the end of a file at reading it ?
> 
>> out parameter Last in function Read...
>>
>> This gives you the number of bytes actually read.
> 
> You mean the _procedure_ Read, from Stream_IO ?
> 
>   procedure Read (File : in File_Type;
>                   Item : out Stream_Element_Array;
>                   Last : out Stream_Element_Offset);
> 
> Nice, but for my buffer I need to use the Read _attribute_ (13.13.2).
> 
If you use 'Read, and there is not enough bytes left in the file, then 
your file is corrupted. You will get End_Error.
Now, if you want to analyze what happened, here is what you can do:
1) before calling 'Read, get the current index (function Index)
2) Do a T'Read
3) If you get End_Error, do a Set_Index to return where you were, and 
use the Read procedure to get the corresponding array of bytes.
Then it's up to you...
-- 
---------------------------------------------------------
            J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



  reply	other threads:[~2006-04-24 16:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-22  1:33 Q: Index value in case of Ada.Streams.Stream_IO.End_Error Gautier
2006-04-24  8:11 ` Jean-Pierre Rosen
2006-04-24 14:33   ` Gautier
2006-04-24 16:05     ` Jean-Pierre Rosen [this message]
2006-04-24 17:44       ` Gautier
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox