comp.lang.ada
 help / color / mirror / Atom feed
* Re: Binary File Manip. - Possibly a stupid question
  1999-07-21  0:00 Binary File Manip. - Possibly a stupid question Matthew
@ 1999-07-20  0:00 ` Ted Dennison
  1999-07-21  0:00   ` Gautier
  0 siblings, 1 reply; 3+ messages in thread
From: Ted Dennison @ 1999-07-20  0:00 UTC (permalink / raw)


In article <3795BF16.BCF418D6@Think.So.Com>,
  Matthew <I.Dont@Think.So.Com> 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.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Binary File Manip. - Possibly a stupid question
@ 1999-07-21  0:00 Matthew
  1999-07-20  0:00 ` Ted Dennison
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew @ 1999-07-21  0:00 UTC (permalink / raw)


Greetings,

<NOTE - if this is a double posting I'm sorry - I'm having some problems
with my system clock.>

Sorry if this is a stupid question, but I'm writing a simple huffman
compression program (just to see if it works) and I want it to work on
all types of files (binary as well as text).

After much head-scratching (I'm working with some basic 2nd year Uni
knowledge, the On-Line Ada95 reference manual and a first-level text
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.

What I want to do is read in a file in 32K chunks, compress each chunk
(the code for which I've already written), and then write the compressed
chunks and header info back to disk.

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.

So is there anywhere I can look to get some detailed info on
reading/writing binary files?

If you prefer you can email me at ua.ten.qu@okolom (backwards obviously
:)

TIA,
MB

-- 
How am I supposed to hallucinate with all of these coloured lights
distracting me?




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Binary File Manip. - Possibly a stupid question
  1999-07-20  0:00 ` Ted Dennison
@ 1999-07-21  0:00   ` Gautier
  0 siblings, 0 replies; 3+ messages in thread
From: Gautier @ 1999-07-21  0:00 UTC (permalink / raw)


> Another wrinkle to throw on this is that your particular application may
> be a good candidate for implemenation *as* a custom stream. :-)

Mmmmh... like a "Zip-Ada" with streaming ?...

-- 
Gautier




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-07-21  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-21  0:00 Binary File Manip. - Possibly a stupid question Matthew
1999-07-20  0:00 ` Ted Dennison
1999-07-21  0:00   ` Gautier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox