Nico Huber | fdfa2e2 | 2023-11-27 16:26:03 +0100 | [diff] [blame] | 1 | with System; |
| 2 | with Interfaces.C; |
| 3 | with Interfaces.C.Strings; |
| 4 | |
| 5 | use Interfaces.C; |
| 6 | |
| 7 | generic |
| 8 | |
Nico Huber | 51f6041 | 2023-12-04 14:48:11 +0100 | [diff] [blame] | 9 | type T (<>) is private; |
Nico Huber | fdfa2e2 | 2023-11-27 16:26:03 +0100 | [diff] [blame] | 10 | |
Thomas Heijligen | 2f4d597 | 2023-12-04 15:36:56 +0000 | [diff] [blame] | 11 | with function Is_Mounted (State : T) return Boolean is <>; |
| 12 | with function Is_Open (State : T) return Boolean is <> |
Nico Huber | 51f6041 | 2023-12-04 14:48:11 +0100 | [diff] [blame] | 13 | with |
| 14 | Post => (if Is_Open'Result then Is_Mounted (State)); |
Nico Huber | fdfa2e2 | 2023-11-27 16:26:03 +0100 | [diff] [blame] | 15 | |
Nico Huber | 51f6041 | 2023-12-04 14:48:11 +0100 | [diff] [blame] | 16 | Initial : T; |
| 17 | |
| 18 | with procedure Mount |
| 19 | (State : in out T; |
| 20 | Part_Len : in Partition_Length; |
| 21 | Success : out Boolean) |
Thomas Heijligen | 2f4d597 | 2023-12-04 15:36:56 +0000 | [diff] [blame] | 22 | is <> |
Nico Huber | 51f6041 | 2023-12-04 14:48:11 +0100 | [diff] [blame] | 23 | with |
| 24 | Pre => not Is_Mounted (State), |
| 25 | Post => Success = Is_Mounted (State); |
| 26 | |
| 27 | with procedure Open |
| 28 | (State : in out T; |
| 29 | File_Len : out File_Length; |
| 30 | File_Path : in String; |
| 31 | Success : out Boolean) |
Thomas Heijligen | 2f4d597 | 2023-12-04 15:36:56 +0000 | [diff] [blame] | 32 | is <> |
Nico Huber | 51f6041 | 2023-12-04 14:48:11 +0100 | [diff] [blame] | 33 | with |
| 34 | Pre => Is_Mounted (State) and not Is_Open (State), |
| 35 | Post => Success = Is_Open (State); |
| 36 | |
| 37 | with procedure Close (State : in out T) |
Thomas Heijligen | 2f4d597 | 2023-12-04 15:36:56 +0000 | [diff] [blame] | 38 | is <> |
Nico Huber | 51f6041 | 2023-12-04 14:48:11 +0100 | [diff] [blame] | 39 | with |
| 40 | Pre => Is_Open (State), |
| 41 | Post => Is_Mounted (State); |
| 42 | |
| 43 | with procedure Read |
| 44 | (State : in out T; |
| 45 | File_Len : in File_Length; |
| 46 | File_Pos : in out File_Offset; |
| 47 | Buf : out Buffer_Type; |
| 48 | Len : out Natural) |
Thomas Heijligen | 2f4d597 | 2023-12-04 15:36:56 +0000 | [diff] [blame] | 49 | is <> |
Nico Huber | 51f6041 | 2023-12-04 14:48:11 +0100 | [diff] [blame] | 50 | with |
| 51 | Pre => Is_Open (State), |
| 52 | Post => Is_Open (State); |
Nico Huber | fdfa2e2 | 2023-11-27 16:26:03 +0100 | [diff] [blame] | 53 | |
Thomas Heijligen | 5c43abc | 2023-12-11 15:24:36 +0000 | [diff] [blame^] | 54 | package FILO.FS.VFS |
Nico Huber | 691220d | 2023-12-04 14:54:01 +0100 | [diff] [blame] | 55 | with |
| 56 | Convention => C |
| 57 | is |
Nico Huber | fdfa2e2 | 2023-11-27 16:26:03 +0100 | [diff] [blame] | 58 | |
Nico Huber | 0a9591e | 2023-11-27 16:59:11 +0100 | [diff] [blame] | 59 | function C_Mount return int; |
Nico Huber | fdfa2e2 | 2023-11-27 16:26:03 +0100 | [diff] [blame] | 60 | |
Nico Huber | 0a9591e | 2023-11-27 16:59:11 +0100 | [diff] [blame] | 61 | function C_Open (File_Path : Strings.chars_ptr) return int; |
Nico Huber | 51f6041 | 2023-12-04 14:48:11 +0100 | [diff] [blame] | 62 | procedure C_Close; |
Nico Huber | fdfa2e2 | 2023-11-27 16:26:03 +0100 | [diff] [blame] | 63 | |
Nico Huber | 0a9591e | 2023-11-27 16:59:11 +0100 | [diff] [blame] | 64 | function C_Read (Buf : System.Address; Len : int) return int; |
Nico Huber | fdfa2e2 | 2023-11-27 16:26:03 +0100 | [diff] [blame] | 65 | |
Thomas Heijligen | 5c43abc | 2023-12-11 15:24:36 +0000 | [diff] [blame^] | 66 | end FILO.FS.VFS; |