| package body FILO.FS.NullFS is |
| |
| Global_NullFS : NullFS_Type := ( |
| State => Unmounted |
| ); |
| |
| procedure Mount |
| (Item : in out NullFS_Type; |
| Success : out Boolean) |
| is |
| begin |
| Success := True; |
| Item.State := Mounted; |
| end Mount; |
| |
| procedure Open |
| (Item : in out NullFS_Type; |
| Path : in String; |
| Success : out Boolean) |
| is |
| begin |
| Success := True; |
| Item.State := File_Open; |
| end Open; |
| |
| procedure Read |
| (Item : in out NullFS_Type; |
| Buffer : in out Buffer_Type; |
| Offset : in Natural; |
| Success : out Boolean) |
| is |
| begin |
| Success := True; |
| null; |
| end Read; |
| |
| procedure Close |
| (Item : in out NullFS_Type; |
| Success : out Boolean) |
| is |
| begin |
| Success := True; |
| Item.State := Mounted; |
| end Close; |
| |
| ---------------------------------------------------------------------A |
| |
| function To_Int (Success : Boolean) return Interfaces.C.int is |
| (if Success then 1 else 0); |
| |
| function C_Mount return Interfaces.C.int |
| is |
| Success : Boolean; |
| begin |
| Mount(Global_NullFS, Success); |
| return To_Int (Success); |
| end C_Mount; |
| |
| function C_Read |
| (buf : System.Address; |
| len : Interfaces.C.int) |
| return Interfaces.C.int |
| with SPARK_Mode => Off |
| is |
| use FILO.FS; |
| Buffer : Buffer_Type (0 .. Integer(len) - 1) with Address => buf; |
| Offset : constant Natural := Natural(File_Pos); |
| Success : Boolean; |
| begin |
| Read (Global_NullFS, Buffer, Offset, Success); |
| if Success then |
| Set_File_Pos (File_Length (Offset + Buffer'Length)); |
| end if; |
| return To_Int (Success); |
| |
| end C_Read; |
| |
| function C_Dir |
| (Path : Interfaces.C.Strings.chars_ptr) |
| return Interfaces.C.int |
| with SPARK_Mode => Off |
| is |
| use Interfaces.C.Strings; |
| Success : Boolean; |
| begin |
| Open (Global_NullFS, Value (Path), Success); |
| return To_Int (Success); |
| end C_Dir; |
| |
| function C_Close return Interfaces.C.int |
| with SPARK_Mode => Off |
| is |
| Success : Boolean; |
| begin |
| Close (Global_NullFS, Success); |
| return To_Int (Success); |
| end C_Close; |
| |
| end FILO.FS.NullFS; |