utilada_unit_2.5.0_f65f9ba9/samples/realpath.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
with Ada.Command_Line;
with Ada.Text_IO;
with Ada.Directories;
with Util.Files;

procedure Realpath is
   Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
   for I in 1 .. Count loop
      declare
         Path : constant String := Ada.Command_Line.Argument (I);
      begin
         Ada.Text_IO.Put_Line (Util.Files.Realpath (Path));

      exception
         when Ada.Directories.Use_Error =>
            Ada.Text_IO.Put_Line ("Invalid path: " & Path);
      end;
   end loop;
end Realpath;