blob: bc4c246b698dfdaaf86d730f56dcdac112ccd7e3 [file] [log] [blame]
Thomas Heijligen5c43abc2023-12-11 15:24:36 +00001package body FILO.FS is
Nico Huber3a5cd8c2023-11-27 17:38:06 +01002
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 Huber575c6ec2024-09-12 16:22:25 +020021 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 Huberf9ab8682024-01-29 16:32:02 +010027 function Part_Len return Partition_Length
28 is
Nico Huber575c6ec2024-09-12 16:22:25 +020029 (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 Huber3a5cd8c2023-11-27 17:38:06 +010034
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 Heijligen5c43abc2023-12-11 15:24:36 +000063end FILO.FS;