Nico Huber | 1d7727f | 2023-11-30 15:58:46 +0100 | [diff] [blame] | 1 | package FS.FILO.Ext2 is |
| 2 | |
Nico Huber | 57d3a85 | 2023-12-04 15:42:40 +0100 | [diff] [blame^] | 3 | type T is private; |
Nico Huber | 1d7727f | 2023-11-30 15:58:46 +0100 | [diff] [blame] | 4 | |
Nico Huber | 57d3a85 | 2023-12-04 15:42:40 +0100 | [diff] [blame^] | 5 | function Is_Mounted (State : T) return Boolean; |
| 6 | function Is_Open (State : T) return Boolean |
Nico Huber | 1d7727f | 2023-11-30 15:58:46 +0100 | [diff] [blame] | 7 | with |
Nico Huber | 57d3a85 | 2023-12-04 15:42:40 +0100 | [diff] [blame^] | 8 | Post => (if Is_Open'Result then Is_Mounted (State)); |
Nico Huber | 1d7727f | 2023-11-30 15:58:46 +0100 | [diff] [blame] | 9 | |
Nico Huber | 57d3a85 | 2023-12-04 15:42:40 +0100 | [diff] [blame^] | 10 | procedure Mount |
| 11 | (State : in out T; |
| 12 | Part_Len : in Partition_Length; |
| 13 | Success : out Boolean) |
Nico Huber | 1d7727f | 2023-11-30 15:58:46 +0100 | [diff] [blame] | 14 | with |
Nico Huber | 57d3a85 | 2023-12-04 15:42:40 +0100 | [diff] [blame^] | 15 | Pre => not Is_Mounted (State), |
| 16 | Post => Success = Is_Mounted (State); |
Nico Huber | 1d7727f | 2023-11-30 15:58:46 +0100 | [diff] [blame] | 17 | |
Nico Huber | 57d3a85 | 2023-12-04 15:42:40 +0100 | [diff] [blame^] | 18 | procedure Open |
| 19 | (State : in out T; |
| 20 | File_Len : out File_Length; |
| 21 | File_Path : in String; |
| 22 | Success : out Boolean) |
Nico Huber | 1d7727f | 2023-11-30 15:58:46 +0100 | [diff] [blame] | 23 | with |
Nico Huber | 57d3a85 | 2023-12-04 15:42:40 +0100 | [diff] [blame^] | 24 | Pre => Is_Mounted (State) and not Is_Open (State), |
| 25 | Post => Success = Is_Open (State); |
| 26 | |
| 27 | procedure Close (State : in out T) |
| 28 | with |
| 29 | Pre => Is_Open (State), |
| 30 | Post => Is_Mounted (State); |
| 31 | |
| 32 | procedure Read |
| 33 | (State : in out T; |
| 34 | File_Len : in File_Length; |
| 35 | File_Pos : in out File_Offset; |
| 36 | Buf : out Buffer_Type; |
| 37 | Len : out Natural) |
| 38 | with |
| 39 | Pre => Is_Open (State), |
| 40 | Post => Is_Open (State); |
| 41 | |
| 42 | private |
| 43 | type State is (Unmounted, Mounted, File_Opened); |
| 44 | |
| 45 | type T is record |
| 46 | S : State; |
| 47 | end record; |
Nico Huber | 1d7727f | 2023-11-30 15:58:46 +0100 | [diff] [blame] | 48 | |
| 49 | end FS.FILO.Ext2; |