Ada.Directories.Copy_File Example

with Ada.Text_IO;
with Ada.Directories;
 
procedure aDir is
   package IO renames Ada.Text_IO;
   package D renames Ada.Directories;
 
begin
   IO.Put ("Starting default directory: ");
   IO.Put_Line (Item => D.Current_Directory);
 
   D.Copy_File (Source_Name => "some_file",
                Target_Name => "some_new_file");
end aDir;
with Ada.Text_IO;
with Ada.Directories;
 
procedure aDir is
   package IO renames Ada.Text_IO;
   package D renames Ada.Directories;
 
begin
   IO.Put ("Starting default directory: ");
   IO.Put_Line (Item => D.Current_Directory);
 
   declare
   begin
      D.Copy_File (Source_Name => "some_non_existant_file",
                   Target_Name => "");
   exception
      when D.Name_Error =>
         IO.Put_Line (Item => "Source and/or Target Name_Error");
   end;
 
   declare
   begin
      D.Copy_File (Source_Name => "some_file",
                   Target_Name => "/root/illegal_file_location");
   exception
      when D.Use_Error =>
         IO.Put_Line (Item => "Source and/or Target Use_Error");
   end;
end aDir;

Go back


Navigation