-- lwa_dir.adb -- -- This simple test program does the equivalent of an ls or dir command -- for each directory argument (if none, the current working directory). -- It creates a directory stream, reading each bucket (filename) and -- outputs it to STDOUT. -- -- Created in 1997 by Roy T. Fielding -- with Ada.Command_Line; with Onions.Buckets; with Onions.OS; with Onions.Instreams.Dir; use Onions.Instreams; use Onions.Instreams.Dir; with Onions.Outstreams.File; use Onions.Outstreams; use Onions.Outstreams.File; procedure Lwa_Dir is Arg_Count : Natural; Arg_Pos : Natural := 1; Spin : Input_Pipe; Spout : Output_Pipe; Sperr : Output_Pipe; Blist : Onions.Buckets.Bucket_List; begin Sperr := Open (new File_Output_Stream, Stderr); Spout := Open (new File_Output_Stream); Arg_Count := Ada.Command_Line.Argument_Count; loop if Arg_Count = 0 then Spin := Open (new Dir_Input_Stream, "."); else Spin := Open (new Dir_Input_Stream, Ada.Command_Line.Argument (Arg_Pos)); Write (Spout, Ada.Command_Line.Argument (Arg_Pos) & ":" & Onions.OS.New_Line); end if; loop begin Read (Spin, Blist); Write (Spout, Blist); Write (Spout, Onions.OS.New_Line); exception when Onions.Instreams.End_Error => exit; end; end loop; Close (Spin); Arg_Pos := Arg_Pos + 1; exit when Arg_Pos > Arg_Count; Write (Spout, Onions.OS.New_Line); end loop; Close (Spout); Close (Sperr); end Lwa_Dir;