From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.8 required=3.0 tests=BAYES_00,PLING_QUERY autolearn=no autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 27 Jun 2021 20:36:29 -0500 From: Dennis Lee Bieber Newsgroups: comp.lang.ada Subject: Re: Hi! How I can make _indexed_ stream file Input/Output ? Thanks. Date: Sun, 27 Jun 2021 21:36:29 -0400 Organization: IISS Elusive Unicorn Message-ID: References: <68f867d3-2b83-4092-a33e-0fcc78f5a24bn@googlegroups.com> User-Agent: ForteAgent/8.00.32.1272 X-No-Archive: YES MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-yoi71hk6UH8LpLvGA9wquv0mI4P5LSZpqUkW/T5LVN1SjVDb5NL+kYUN9+mFGhQQVKtUGEBaIPh/TEF!RAQcj7WnnFj3kDM1jdGY2VWXs+T2NtTEy/4o1qQ2iF84XM9NM+ZBlt/L8ruVD+SUqln2G0mC X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 4202 Xref: reader02.eternal-september.org comp.lang.ada:62293 List-Id: On Sun, 27 Jun 2021 12:33:27 -0700 (PDT), Daniel Norte Moraes declaimed the following: >How I can make _indexed_ stream file Input/Output ? > >For 'indexed' i mean manually setting file position: > => 'from' in $type'input() and >=> 'to' in $type'output() > >Actually I use Ada.Streams.Stream_IO. > >My main need is examples. > What part of https://www.adaic.org/resources/add_content/standards/05aarm/html/AA-A-12-1.html is lacking? """ 21 -- Operations on position within file 22 procedure Set_Index(File : in File_Type; To : in Positive_Count); 23 function Index(File : in File_Type) return Positive_Count; function Size (File : in File_Type) return Count; """ """ 31/1 {8652/0055} {AI95-00026-01} The Index function returns the current file index, as a count (in stream elements) from the beginning of the file. The position of the first element in the file is 1. 31.a/1 This paragraph was deleted.Ramification: The notion of Index for Stream_IO is analogous to that of Index in Direct_IO, except that the former is measured in Stream_Element units, whereas the latter is in terms of Element_Type values. 32 The Set_Index procedure sets the current index to the specified value. 32.1/1 {8652/0055} {AI95-00026-01} If positioning is supported for the external file, the current index is maintained as follows: 32.2/1 {8652/0055} {AI95-00026-01} For Open and Create, if the Mode parameter is Append_File, the current index is set to the current size of the file plus one; otherwise, the current index is set to one. 32.3/1 {8652/0055} {AI95-00026-01} For Reset, if the Mode parameter is Append_File, or no Mode parameter is given and the current mode is Append_File, the current index is set to the current size of the file plus one; otherwise, the current index is set to one. """ """ 33 If positioning is not supported for the given file, then a call of Index or Set_Index propagates Use_Error. Similarly, a call of Read or Write with a Positive_Count parameter propagates Use_Error. 33.a/2 Implementation Note: {AI95-00085-01} It is permissible for an implementation to implement mode Append_File using the Unix append mode (the O_APPEND bit). Such an implementation does not support positioning when the mode is Append_File, and therefore the operations listed above must raise Use_Error. This is acceptable as there is no requirement that any particular file support positioning; therefore it is acceptable that a file support positioning when opened with mode Out_File, and the same file not support positioning when opened with mode Append_File. But it is not acceptable for a file to support positioning (by allowing the above operations), but to do something other than the defined semantics (that is, always write at the end, even when explicitly commanded to write somewhere else). """ -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/