Ada.Directories.Exists 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);
 
   if D.Exists (Name => "some_file") then
      IO.Put_Line (Item => "some_file exists");
   end if;
 
   if D.Exists (Name => "/home/thomas/wiki_examples/aDir/some_dir") then
      IO.Put_Line (Item => "/home/thomas/wiki_examples/aDir/some_dir exists");
   end if;
 
   if not D.Exists (Name => "nonexistant_file") then
      IO.Put_Line (Item => "nonexistant_file does not exist");
   end if;
 
   if D.Exists (Name => "") then
      IO.Put_Line (Item => "This is impossible!");
   end if;
 
exception
   when D.Name_Error =>
      IO.Put_Line (Item => "Name_Error raised");
end aDir;

Go back


Navigation