Ada.Directories.Create_Directory 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.Set_Directory (Directory => "/home/thomas/wiki_examples/aDir");
   D.Create_Directory (New_Directory => "some_dir");
   --  Running the program multiple times will raise the Use_Error.
   --  Changing some_dir to a null string will raise the Name_Error.
exception
   when D.Use_Error =>
      IO.Put_Line (Item => "Directory cannot be created.");
   when D.Name_Error =>
      IO.Put_Line (Item => "Directory is not valid.");
end aDir;

Go back


Navigation