diff options
Diffstat (limited to 'test/dirlist.adb')
-rw-r--r-- | test/dirlist.adb | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/test/dirlist.adb b/test/dirlist.adb new file mode 100644 index 0000000..1a07515 --- /dev/null +++ b/test/dirlist.adb @@ -0,0 +1,93 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Ada.Characters.Latin_1, + Ada.Command_Line, + Ada.Text_IO, + FLTK.Filenames; + + +procedure Dirlist is + + package Latin renames Ada.Characters.Latin_1; + package ACom renames Ada.Command_Line; + package TIO renames Ada.Text_IO; + package Fil renames FLTK.Filenames; + +begin + + TIO.Put_Line ("Test program for FLTK directory listing function."); + TIO.New_Line; + TIO.Put ("Input: "); + for Index in 1 .. ACom.Argument_Count loop + TIO.Put (ACom.Argument (Index)); + exit when Index = ACom.Argument_Count; + TIO.Put (" "); + end loop; + TIO.New_Line; + TIO.New_Line; + + if ACom.Argument_Count /= 1 then + TIO.Put_Line ("Error: Need exactly one argument to denote a directory to list."); + ACom.Set_Exit_Status (ACom.Failure); + return; + end if; + + declare + Name : Fil.Path_String := Fil.Expand (ACom.Argument (1)); + begin + if not Fil.Is_Directory (Name) then + TIO.Put_Line ("Error: " & Name & " is not a valid directory."); + ACom.Set_Exit_Status (ACom.Failure); + return; + end if; + + declare + The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Alpha_Sort'Access); + begin + TIO.Put_Line ("Alphabetical Sort:"); + for Index in 1 .. The_List.Length loop + TIO.Put_Line (Latin.HT & The_List.Item (Index)); + end loop; + TIO.New_Line; + end; + + declare + The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Case_Alpha_Sort'Access); + begin + TIO.Put_Line ("Case Insensitive Alphabetical Sort:"); + for Index in 1 .. The_List.Length loop + TIO.Put_Line (Latin.HT & The_List.Item (Index)); + end loop; + TIO.New_Line; + end; + + declare + The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Numeric_Sort'Access); + begin + TIO.Put_Line ("Numeric Sort:"); + for Index in 1 .. The_List.Length loop + TIO.Put_Line (Latin.HT & The_List.Item (Index)); + end loop; + TIO.New_Line; + end; + + declare + The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Case_Numeric_Sort'Access); + begin + TIO.Put_Line ("Case Insensitive Numeric Sort:"); + for Index in 1 .. The_List.Length loop + TIO.Put_Line (Latin.HT & The_List.Item (Index)); + end loop; + TIO.New_Line; + end; + end; + +end Dirlist; + + |