From: Ted Dennison<dennison@telepath.com>
Subject: Re: Binary Data File - PLEASE HELP
Date: Mon, 26 Mar 2001 14:56:18 GMT
Date: 2001-03-26T14:56:18+00:00 [thread overview]
Message-ID: <mMIv6.2825$fy.4168@www.newsranger.com> (raw)
In-Reply-To: J3Iv6.56705$CL6.1997020@telenews.teleline.es
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1475 bytes --]
In article <J3Iv6.56705$CL6.1997020@telenews.teleline.es>, 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" <alguien@microsoft.com> 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
next prev parent reply other threads:[~2001-03-26 14:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <n5su6.24687$CL6.767652@telenews.teleline.es>
2001-03-26 14:08 ` Binary Data File - PLEASE HELP Sergio
2001-03-26 14:49 ` chris.danx
2001-03-26 14:56 ` Marin David Condic
2001-03-26 14:55 ` Marin David Condic
2001-03-26 19:51 ` Ted Dennison
2001-03-26 20:55 ` Marin David Condic
2001-03-26 21:16 ` tmoran
2001-03-26 22:16 ` Marin David Condic
2001-03-26 22:41 ` Ted Dennison
2001-03-26 14:56 ` Ted Dennison [this message]
2001-03-26 15:09 ` Marin David Condic
2001-03-26 15:21 ` Martin Dowie
2001-04-05 5:08 ` David Thompson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox