From 24781de8bedb3bf4d12d7ec1d0307842e59a3f94 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Tue, 10 Dec 2024 20:47:53 +1300 Subject: Binding for filename.H added --- test/compare.adb | 45 +++++++++++++++++++++++++++ test/dirlist.adb | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 test/compare.adb create mode 100644 test/dirlist.adb (limited to 'test') diff --git a/test/compare.adb b/test/compare.adb new file mode 100644 index 0000000..2273414 --- /dev/null +++ b/test/compare.adb @@ -0,0 +1,45 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Ada.Text_IO, + FLTK.Filenames; + + +procedure Compare is + + package TIO renames Ada.Text_IO; + package FFN renames FLTK.Filenames; + + Aardvark : String := "aardvark"; + Zebra : String := "Zebra"; + Two : String := "item_2"; + Ten : String := "item_10"; + Cap_Ten : String := "Item_10"; + +begin + + TIO.Put_Line ("Alphabetic comparison of " & Aardvark & " and " & Zebra & ": " & + FFN.Comparison'Image (FFN.Alpha_Sort (Aardvark, Zebra))); + TIO.Put_Line ("Case insensitive comparison of " & Aardvark & " and " & Zebra & ": " & + FFN.Comparison'Image (FFN.Case_Alpha_Sort (Aardvark, Zebra))); + TIO.New_Line; + + TIO.Put_Line ("Alphabetic comparison of " & Two & " and " & Ten & ": " & + FFN.Comparison'Image (FFN.Alpha_Sort (Two, Ten))); + TIO.Put_Line ("Numeric comparison of " & Two & " and " & Ten & ": " & + FFN.Comparison'Image (FFN.Numeric_Sort (Two, Ten))); + TIO.New_Line; + + TIO.Put_Line ("Numeric comparison of " & Two & " and " & Cap_Ten & ": " & + FFN.Comparison'Image (FFN.Numeric_Sort (Two, Cap_Ten))); + TIO.Put_Line ("Case insensitive comparison of " & Two & " and " & Cap_Ten & ": " & + FFN.Comparison'Image (FFN.Case_Numeric_Sort (Two, Cap_Ten))); + +end Compare; + + 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; + + -- cgit