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.1 required=5.0 tests=BAYES_00,LOTS_OF_MONEY, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,136a2b49b817b53c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-26 06:58:07 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!hammer.uoregon.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison Sender: usenet@www.newsranger.com References: Subject: Re: Binary Data File - PLEASE HELP Message-ID: Date: Mon, 26 Mar 2001 14:56:18 GMT NNTP-Posting-Host: 127.0.0.1 X-Complaints-To: abuse@newsranger.com X-Trace: www.newsranger.com 985618578 127.0.0.1 (Mon, 26 Mar 2001 09:56:18 EST) NNTP-Posting-Date: Mon, 26 Mar 2001 09:56:18 EST Organization: http://www.newsranger.com Xref: supernews.google.com comp.lang.ada:6053 Date: 2001-03-26T14:56:18+00:00 List-Id: In article , Sergio says... > >Ada simply cannot do that, sorry. BZZZT! Wrong. There are no less than 3 ways to do this (perhaps more). You can: 1) Use Ada.Streams.Stream_IO and Ada.Streams.Read (read must be called directly with the entire buffer). 2) Use Ada.Sequential_IO (it'll have to be instantiated with the whole buffer as its type). 3) Pragma interface to C and use the same calls you did below (it's a dumb way to do it rather than the other 2 options, but it works). >"Sergio" escribi� en el mensaje >news:n5su6.24687$CL6.767652@telenews.teleline.es... >> How could I do this in Ada? Could I do it at a reasonable speed? I don't >> know how, please help me. Thanks >> >> void WorkFile(char *fileName) >> { >> char Buffer[4096]; >> FILE *handle; >> >> handle = fopen(fileName, "r"); >> while (!feof(handle)) >> { >> fread(handle, 4096, 1, buffer); /* Read data from file to buffer >*/ >> Work(Buffer); /* ... do some work with such data */ >> } >> } If you'd like to see some code I have laying around that does almost exactly this, just say the word and I'll post it. About the only thing you can do with C that you can't do with Ada is have a yearly obfuscated code contest with thousands of worthy submissions. :-) --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com