comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: Advanced file manipulation (multiple question)
Date: Tue, 01 Mar 2005 17:49:52 GMT
Date: 2005-03-01T17:49:52+00:00	[thread overview]
Message-ID: <4X1Vd.8385$MY6.7541@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <74a78c42.0503010130.785f178f@posting.google.com>

Steph-ADA wrote:

> I'm new on this board so please excuse my lack of habits!
> I have some question about how manipulating files in ADA. Here's a
> kind of list, if you have any informations about how solving these
> problems, it would be very kind!

It's Ada, named for Ada King, Countess Lovelace, who wrote programs for 
  Babbage's Analytical Engine.

> - If I want to copy a file, if it's a 10kb gif file or a big 100Mb avi
> one, should I consider it as binary files, and use the same
> Ada.sequential_io and Ada.direct_io packages? Or is there special
> methods to copy/edit/write in/delete large files?

Probably the best way is to make an OS call for this. That won't be 
portable at the moment, but should be when Ada 0X becomes available, you 
should be able to use Ada.Directories.Copy_File portably.

If you must do this portably in Ada, one way is to use 
Ada.Streams.Stream_IO to open the source file and obtain the size of the 
file, then read and write chunks of the file that will fit in memory. 
When there's not enough data left in the file to fill a chunk, decrease 
the chunk size by a large factor. Repeat until you're copying the last 
few (< 10) bytes byte-by-byte (technically, Stream_Elements, one-by-one).

-- 
Jeff Carter
"Ada has made you lazy and careless. You can write programs in C that
are just as safe by the simple application of super-human diligence."
E. Robert Tisdale
72



  parent reply	other threads:[~2005-03-01 17:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-01  9:30 Advanced file manipulation (multiple question) Steph-ADA
2005-03-01  9:59 ` Peter Hermann
2005-03-01 12:18 ` Larry Kilgallen
2005-03-01 17:49 ` Jeffrey Carter [this message]
2005-03-02  2:42 ` Steve
2005-03-02 10:31   ` Steph-ADA
2005-03-03  3:12     ` Steve
2005-03-02 16:56   ` Jeffrey Carter
2005-03-02 17:22     ` Larry Kilgallen
2005-03-03  0:26       ` Jeffrey Carter
2005-03-03  8:16         ` Martin Krischik
2005-03-04  9:20           ` Steph-ADA
2005-03-04 10:38             ` Jean-Pierre Rosen
2005-03-03  8:56         ` Steph-ADA
2005-03-03 19:36           ` Jeffrey Carter
2005-03-03 22:32           ` Randy Brukardt
2005-03-04  2:49           ` Steve
replies disabled

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