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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,374196e3581ef3b8,start X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Binary File Manip. - Possibly a stupid question Date: 1999/07/20 Message-ID: <7n2167$td9$1@nnrp1.deja.com>#1/1 X-Deja-AN: 503122034 References: <3795BF16.BCF418D6@Think.So.Com> X-Http-Proxy: 1.0 x37.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Tue Jul 20 14:30:30 1999 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 1999-07-20T00:00:00+00:00 List-Id: In article <3795BF16.BCF418D6@Think.So.Com>, Matthew wrote: > book with no mention of binary files) I came to the conclusion that I > have to use some kind of Stream (since Stream_IO's End_Of_File > references the file's size instead of a special character), but I have > no idea how to use them properly. > .. > My compression alg. is currently running on the assumption that the > stuff read in from the source file can be accessed in 8-bit-byte chunks > that can be mapped to character representations. Streams wil work. However it is best to use them if both the writer and the eventual reader are using the Ada stream packages. Its possible, if rather unlikely, that the stream you are using could be playing tricks on your data (eg: compressing it, reading in bizzarely sized chunks at a time, byte swapping, etc). You *can* use streams to do this, you just have to be careful. If you have an *exact* representation that you want to see on disk (minus what the file-system does to it, of course), then you should probably use either Ada.Sequential_IO or Ada.Direct_IO. They are generics, so you instantiate them with the data type you want to write to the file. Another wrinkle to throw on this is that your particular application may be a good candidate for implemenation *as* a custom stream. :-) -- T.E.D. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.