comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: Advanced file manipulation (multiple question)
Date: Thu, 3 Mar 2005 18:49:12 -0800
Date: 2005-03-03T18:49:12-08:00	[thread overview]
Message-ID: <BfmdnSAqbOIHUbrfRVn-sA@comcast.com> (raw)
In-Reply-To: 74a78c42.0503030056.5995d08c@posting.google.com

Here is a (partial) example of binding to the Win32 copy file:

WITH Win32;
WITH Win32.WinBase;
WITH Win32.WinNT;
WITH Interfaces.C;

PACKAGE BODY DFUdiskFileUtils IS

  PACKAGE WinBase RENAMES Win32.WinBase;
  PACKAGE WinNT RENAMES Win32.WinNT;
  PACKAGE C RENAMES Interfaces.C;

  USE TYPE Win32.BOOL;
  USE TYPE Win32.DWORD;
  USE TYPE WinNT.HANDLE;

  PROCEDURE CopyFileDFU( sourceFileNameDFU,
                         destFileNameDFU : STRING;
                         copiedDFU : out BOOLEAN ) IS
    result     : Win32.BOOL;
    sourceName : ALIASED C.Char_Array := C.To_C( sourceFileNameDFU );
    destName   : ALIASED C.Char_Array := C.To_C( destFileNameDFU );
  BEGIN
    result := WinBase.CopyFile( sourceName(0)'UNCHECKED_ACCESS,
                                destName(0)'UNCHECKED_ACCESS,
                                Win32.FALSE );
    copiedDFU := result /= Win32.FALSE;
  END CopyFileDFU;

It's part of a package I made to wrap a number of OS dependent system calls.

Also... when Ada 2005 becomes available you will be able to use the 
Copy_File function in the package Ada.Directories.  There is a preliminary 
implementation at:

http://www.martin.dowie.btinternet.co.uk/

I haven't tried it, but I appears that you can add the implementation to 
your GNAT installation and have the Ada.Directories package with GNAT 3.15p.

In any case it is a good idea to at least be aware of what it takes to make 
OS calls, for those cases where you need to do something that isn't built 
into the standard libraries.

Steve
(The Duck)





      parent reply	other threads:[~2005-03-04  2: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
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 [this message]
replies disabled

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