blob: 1a07515f463be80899a1f74432714ddf83d455ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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;
|