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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c01667c07f51ded5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Advanced file manipulation (multiple question) References: <74a78c42.0503010130.785f178f@posting.google.com> In-Reply-To: <74a78c42.0503010130.785f178f@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4X1Vd.8385$MY6.7541@newsread1.news.pas.earthlink.net> Date: Tue, 01 Mar 2005 17:49:52 GMT NNTP-Posting-Host: 4.240.21.249 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1109699392 4.240.21.249 (Tue, 01 Mar 2005 09:49:52 PST) NNTP-Posting-Date: Tue, 01 Mar 2005 09:49:52 PST Xref: g2news1.google.com comp.lang.ada:8572 Date: 2005-03-01T17:49:52+00:00 List-Id: 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