| Thomas Heijligen | 5c43abc | 2023-12-11 15:24:36 +0000 | [diff] [blame] | 1 | package body FILO.FS is |
| Nico Huber | 3a5cd8c | 2023-11-27 17:38:06 +0100 | [diff] [blame] | 2 | |
| 3 | C_Part_Length : unsigned_long |
| 4 | with |
| 5 | Import => True, |
| 6 | Convention => C, |
| 7 | External_Name => "part_length"; |
| 8 | |
| 9 | C_File_Max : int |
| 10 | with |
| 11 | Import => True, |
| 12 | Convention => C, |
| 13 | External_Name => "filemax"; |
| 14 | |
| 15 | C_File_Pos : int |
| 16 | with |
| 17 | Import => True, |
| 18 | Convention => C, |
| 19 | External_Name => "filepos"; |
| 20 | |
| Nico Huber | 575c6ec | 2024-09-12 16:22:25 +0200 | [diff] [blame^] | 21 | pragma Warnings |
| 22 | (GNAT, Off, "condition can only be False*", |
| 23 | Reason => "Depends on `unsigned long` size."); |
| 24 | pragma Warnings |
| 25 | (GNAT, Off, "condition is always True", |
| 26 | Reason => "Depends on `unsigned long` size."); |
| Nico Huber | f9ab868 | 2024-01-29 16:32:02 +0100 | [diff] [blame] | 27 | function Part_Len return Partition_Length |
| 28 | is |
| Nico Huber | 575c6ec | 2024-09-12 16:22:25 +0200 | [diff] [blame^] | 29 | (if Unsigned_64 (C_Part_Length) <= Unsigned_64 (Partition_Length'Last) / 512 |
| 30 | then Partition_Length (C_Part_Length) * 512 |
| 31 | else Partition_Length'Last); |
| 32 | pragma Warnings (GNAT, On, "condition can only be False*"); |
| 33 | pragma Warnings (GNAT, On, "condition is always True"); |
| Nico Huber | 3a5cd8c | 2023-11-27 17:38:06 +0100 | [diff] [blame] | 34 | |
| 35 | function File_Max return File_Length is |
| 36 | begin |
| 37 | if C_File_Max < 0 then |
| 38 | return 0; |
| 39 | end if; |
| 40 | |
| 41 | return File_Length (C_File_Max); |
| 42 | end File_Max; |
| 43 | |
| 44 | procedure Set_File_Max (Len : File_Length) is |
| 45 | begin |
| 46 | C_File_Max := int (Len); |
| 47 | end Set_File_Max; |
| 48 | |
| 49 | function File_Pos return File_Offset is |
| 50 | begin |
| 51 | if C_File_Pos < 0 then |
| 52 | return 0; |
| 53 | end if; |
| 54 | |
| 55 | return File_Offset (C_File_Pos); |
| 56 | end File_Pos; |
| 57 | |
| 58 | procedure Set_File_Pos (Off : File_Offset) is |
| 59 | begin |
| 60 | C_File_Pos := int (Off); |
| 61 | end Set_File_Pos; |
| 62 | |
| Thomas Heijligen | 5c43abc | 2023-12-11 15:24:36 +0000 | [diff] [blame] | 63 | end FILO.FS; |