From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,43f3f0c085aeb29d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!130.59.10.21.MISMATCH!kanaga.switch.ch!switch.ch!news.in2p3.fr!in2p3.fr!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Q: Index value in case of Ada.Streams.Stream_IO.End_Error Date: Mon, 24 Apr 2006 18:05:06 +0200 Organization: Adalog Message-ID: References: <44498820$1_7@news.bluewin.ch> <444ce1c1$1_5@news.bluewin.ch> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1145898064 17152 195.25.228.57 (24 Apr 2006 17:01:04 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Mon, 24 Apr 2006 17:01:04 +0000 (UTC) User-Agent: Thunderbird 1.5 (Windows/20051201) In-Reply-To: <444ce1c1$1_5@news.bluewin.ch> Xref: g2news2.google.com comp.lang.ada:3920 Date: 2006-04-24T18:05:06+02:00 List-Id: 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