-- Ada 2012 Implementierung von der SP2 Aufgabe "creeper", ohne -- Flag-Parsing, Festlesung einer maximalen Tiefe und Pattern -- Matching. with Ada.Text_IO; with Ada.Strings; with Ada.Command_Line; with POSIX; with POSIX_Files; procedure Creeper is package IO renames Ada.Text_Io; package File renames Posix_Files; function Join (Sub, Sup : POSIX.Pathname) return POSIX.Pathname is begin return Posix.To_Posix_String (Posix.To_String (Sub) & "/" & Posix.To_String (Sup)); end; procedure Listing (Path : POSIX.Pathname) is procedure Iterate (D_Entry : in File.Directory_Entry; Quit : in out Boolean) is File_Name : Posix.Pathname := File.Filename_Of (D_Entry); begin if not (Posix.To_String (File_Name) = "." or Posix.To_String (File_Name) = "..") then Listing (Join (Path, File_Name)); end if; end; procedure For_Every_Directory_Entry is new File.For_Every_Directory_Entry (Action => Iterate); begin if File.Is_Directory (Path) then begin For_Every_Directory_Entry (Path); exception when E : POSIX.POSIX_Error => declare Err : POSIX.Error_Code := POSIX.Get_Error_Code; Msg : String := POSIX.Image (Err); begin IO.Put_Line (IO.Standard_Error, Msg & ": " & Posix.To_String (path)); end; end; elsif File.Is_File (Path) then Io.Put_Line (Posix.To_String (Path)); end if; end; begin for i in 1 .. Ada.Command_Line.Argument_Count loop Listing (POSIX.To_POSIX_String (Ada.Command_Line.Argument (i))); end loop; end; -- Local Variables: -- tab-width: 2 -- compile-command: "gnatmake -aI/usr/share/ada/adainclude/florist -aO/usr/lib/ada/adalib/florist creeper.adb -largs -lflorist" -- End: