blob: 105e98548ea67c63d5d2ce18c2b59a7c9a306104 [file] [log] [blame]
Thomas Heijligen51820372023-12-11 15:29:17 +00001package body FILO.FS.NullFS is
2
3 Global_NullFS : NullFS_Type := (
4 State => Unmounted
5 );
6
7 procedure Mount
8 (Item : in out NullFS_Type;
9 Success : out Boolean)
10 is
11 begin
12 Success := True;
13 Item.State := Mounted;
14 end Mount;
15
16 procedure Open
17 (Item : in out NullFS_Type;
18 Path : in String;
19 Success : out Boolean)
20 is
21 begin
22 Success := True;
23 Item.State := File_Open;
24 end Open;
25
26 procedure Read
27 (Item : in out NullFS_Type;
28 Buffer : in out Buffer_Type;
29 Offset : in Natural;
30 Success : out Boolean)
31 is
32 begin
33 Success := True;
34 null;
35 end Read;
36
37 procedure Close
38 (Item : in out NullFS_Type;
39 Success : out Boolean)
40 is
41 begin
42 Success := True;
43 Item.State := Mounted;
44 end Close;
45
46 ---------------------------------------------------------------------A
47
48 function To_Int (Success : Boolean) return Interfaces.C.int is
49 (if Success then 1 else 0);
50
51 function C_Mount return Interfaces.C.int
52 is
53 Success : Boolean;
54 begin
55 Mount(Global_NullFS, Success);
56 return To_Int (Success);
57 end C_Mount;
58
59 function C_Read
60 (buf : System.Address;
61 len : Interfaces.C.int)
62 return Interfaces.C.int
63 with SPARK_Mode => Off
64 is
65 use FILO.FS;
66 Buffer : Buffer_Type (0 .. Integer(len) - 1) with Address => buf;
67 Offset : Natural := Natural(File_Pos);
68 Success : Boolean;
69 begin
70 Read (Global_NullFS, Buffer, Offset, Success);
71 if Success then
72 Set_File_Pos (File_Length (Offset + Buffer'Length));
73 end if;
74 return To_Int (Success);
75
76 end C_Read;
77
78 function C_Dir
79 (Path : Interfaces.C.Strings.chars_ptr)
80 return Interfaces.C.int
81 with SPARK_Mode => Off
82 is
83 use Interfaces.C.Strings;
84 Success : Boolean;
85 begin
86 Open (Global_NullFS, Value (Path), Success);
87 return To_Int (Success);
88 end C_Dir;
89
90 function C_Close return Interfaces.C.int
91 with SPARK_Mode => Off
92 is
93 Success : Boolean;
94 begin
95 Close (Global_NullFS, Success);
96 return To_Int (Success);
97 end C_Close;
98
99end FILO.FS.NullFS;