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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6353697ffeb79d16 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 17 Nov 2010 06:25:31 -0600 Date: Wed, 17 Nov 2010 07:25:18 -0500 From: "Peter C. Chapin" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101027 Lightning/1.0b2 Thunderbird/3.1.6 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Encapsulating Ada.Direct_IO References: <5ba4147a-6099-4a05-b548-09544f58247a@j18g2000yqd.googlegroups.com> In-Reply-To: <5ba4147a-6099-4a05-b548-09544f58247a@j18g2000yqd.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-XWQE1aGDL7jU50YWRt2sSQmIP9z0cqpyhHVXTYtbkl2aO69b96P7/+6ryzXiDzGQlTfn4+oAmAatR9l!e7NRSQgFVZeb35+GrRWs/JLEd4qiU2Hy4UiAmCzVZ0EnsaFvOBFo2rFoyQA2T+8= 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: 2629 Xref: g2news2.google.com comp.lang.ada:16513 Date: 2010-11-17T07:25:18-05:00 List-Id: On 2010-11-16 23:44, Bryan wrote: > Spec file: > ====================== > with Ada.Direct_IO; > package Big5_Text_IO is > type File_Type is limited private; > procedure Close( File : in out File_Type ); > private > package Byte_IO is new Ada.Direct_IO(Character); > type File_Type is new Byte_IO.File_Type; > end Big5_Text_IO; > ====================== Direct_IO allows random access. There is nothing wrong with that, of course, but if your intention is to read the file sequentially you might prefer using Sequential_IO. Something I wonder about (I don't have the answer) is if it necessary to use a representation clause to force the size of the objects being read to be 8 bits. I'm a little unclear if the standard requires Character to be stored in a file in 8 bit units. That is, the language might treat the type Character rather more abstractly than you want. Again I'm not sure of this and I'd love to get some insights from others myself. Thus you might want to do something like package Big5_Text_IO is ... type Byte is mod 2**8; for Byte'Size use 8; ... private package Byte_IO is new Ada.Direct_IO(Byte); ... end Big5_Text_IO; This approach has the advantage of creating a separate type to represent the raw data from the file. Thus C : Character; B : Big5_Text_IO.Byte; C := B; -- Compile error. You haven't decoded B yet. Peter