1 |
12 |
jlechner |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT RUN-TIME COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- A D A . D I R E C T _ I O --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
|
10 |
|
|
-- --
|
11 |
|
|
-- This specification is derived from the Ada Reference Manual for use with --
|
12 |
|
|
-- GNAT. The copyright notice above, and the license provisions that follow --
|
13 |
|
|
-- apply solely to the contents of the part following the private keyword. --
|
14 |
|
|
-- --
|
15 |
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
16 |
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
17 |
|
|
-- ware Foundation; either version 2, or (at your option) any later ver- --
|
18 |
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
19 |
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
20 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
21 |
|
|
-- for more details. You should have received a copy of the GNU General --
|
22 |
|
|
-- Public License distributed with GNAT; see file COPYING. If not, write --
|
23 |
|
|
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
|
24 |
|
|
-- Boston, MA 02110-1301, USA. --
|
25 |
|
|
-- --
|
26 |
|
|
-- As a special exception, if other files instantiate generics from this --
|
27 |
|
|
-- unit, or you link this unit with other files to produce an executable, --
|
28 |
|
|
-- this unit does not by itself cause the resulting executable to be --
|
29 |
|
|
-- covered by the GNU General Public License. This exception does not --
|
30 |
|
|
-- however invalidate any other reasons why the executable file might be --
|
31 |
|
|
-- covered by the GNU Public License. --
|
32 |
|
|
-- --
|
33 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
34 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
35 |
|
|
-- --
|
36 |
|
|
------------------------------------------------------------------------------
|
37 |
|
|
|
38 |
|
|
with Ada.IO_Exceptions;
|
39 |
|
|
with System.Direct_IO;
|
40 |
|
|
with Interfaces.C_Streams;
|
41 |
|
|
|
42 |
|
|
generic
|
43 |
|
|
type Element_Type is private;
|
44 |
|
|
|
45 |
|
|
package Ada.Direct_IO is
|
46 |
|
|
|
47 |
|
|
pragma Compile_Time_Warning
|
48 |
|
|
(Element_Type'Has_Access_Values,
|
49 |
|
|
"?Element_Type for Direct_'I'O instance has access values");
|
50 |
|
|
|
51 |
|
|
type File_Type is limited private;
|
52 |
|
|
|
53 |
|
|
type File_Mode is (In_File, Inout_File, Out_File);
|
54 |
|
|
|
55 |
|
|
-- The following representation clause allows the use of unchecked
|
56 |
|
|
-- conversion for rapid translation between the File_Mode type
|
57 |
|
|
-- used in this package and System.File_IO.
|
58 |
|
|
|
59 |
|
|
for File_Mode use
|
60 |
|
|
(In_File => 0, -- System.File_IO.File_Mode'Pos (In_File)
|
61 |
|
|
Inout_File => 1, -- System.File_IO.File_Mode'Pos (Inout_File);
|
62 |
|
|
Out_File => 2); -- System.File_IO.File_Mode'Pos (Out_File)
|
63 |
|
|
|
64 |
|
|
type Count is range 0 .. System.Direct_IO.Count'Last;
|
65 |
|
|
|
66 |
|
|
subtype Positive_Count is Count range 1 .. Count'Last;
|
67 |
|
|
|
68 |
|
|
---------------------
|
69 |
|
|
-- File Management --
|
70 |
|
|
---------------------
|
71 |
|
|
|
72 |
|
|
procedure Create
|
73 |
|
|
(File : in out File_Type;
|
74 |
|
|
Mode : in File_Mode := Inout_File;
|
75 |
|
|
Name : in String := "";
|
76 |
|
|
Form : in String := "");
|
77 |
|
|
|
78 |
|
|
procedure Open
|
79 |
|
|
(File : in out File_Type;
|
80 |
|
|
Mode : in File_Mode;
|
81 |
|
|
Name : in String;
|
82 |
|
|
Form : in String := "");
|
83 |
|
|
|
84 |
|
|
procedure Close (File : in out File_Type);
|
85 |
|
|
procedure Delete (File : in out File_Type);
|
86 |
|
|
procedure Reset (File : in out File_Type; Mode : in File_Mode);
|
87 |
|
|
procedure Reset (File : in out File_Type);
|
88 |
|
|
|
89 |
|
|
function Mode (File : in File_Type) return File_Mode;
|
90 |
|
|
function Name (File : in File_Type) return String;
|
91 |
|
|
function Form (File : in File_Type) return String;
|
92 |
|
|
|
93 |
|
|
function Is_Open (File : in File_Type) return Boolean;
|
94 |
|
|
|
95 |
|
|
---------------------------------
|
96 |
|
|
-- Input and Output Operations --
|
97 |
|
|
---------------------------------
|
98 |
|
|
|
99 |
|
|
procedure Read
|
100 |
|
|
(File : in File_Type;
|
101 |
|
|
Item : out Element_Type;
|
102 |
|
|
From : in Positive_Count);
|
103 |
|
|
|
104 |
|
|
procedure Read
|
105 |
|
|
(File : in File_Type;
|
106 |
|
|
Item : out Element_Type);
|
107 |
|
|
|
108 |
|
|
procedure Write
|
109 |
|
|
(File : in File_Type;
|
110 |
|
|
Item : in Element_Type;
|
111 |
|
|
To : in Positive_Count);
|
112 |
|
|
|
113 |
|
|
procedure Write
|
114 |
|
|
(File : in File_Type;
|
115 |
|
|
Item : in Element_Type);
|
116 |
|
|
|
117 |
|
|
procedure Set_Index (File : in File_Type; To : in Positive_Count);
|
118 |
|
|
|
119 |
|
|
function Index (File : in File_Type) return Positive_Count;
|
120 |
|
|
function Size (File : in File_Type) return Count;
|
121 |
|
|
|
122 |
|
|
function End_Of_File (File : in File_Type) return Boolean;
|
123 |
|
|
|
124 |
|
|
----------------
|
125 |
|
|
-- Exceptions --
|
126 |
|
|
----------------
|
127 |
|
|
|
128 |
|
|
Status_Error : exception renames IO_Exceptions.Status_Error;
|
129 |
|
|
Mode_Error : exception renames IO_Exceptions.Mode_Error;
|
130 |
|
|
Name_Error : exception renames IO_Exceptions.Name_Error;
|
131 |
|
|
Use_Error : exception renames IO_Exceptions.Use_Error;
|
132 |
|
|
Device_Error : exception renames IO_Exceptions.Device_Error;
|
133 |
|
|
End_Error : exception renames IO_Exceptions.End_Error;
|
134 |
|
|
Data_Error : exception renames IO_Exceptions.Data_Error;
|
135 |
|
|
|
136 |
|
|
private
|
137 |
|
|
type File_Type is new System.Direct_IO.File_Type;
|
138 |
|
|
|
139 |
|
|
Bytes : constant Interfaces.C_Streams.size_t :=
|
140 |
|
|
Element_Type'Max_Size_In_Storage_Elements;
|
141 |
|
|
-- Size of an element in storage units
|
142 |
|
|
|
143 |
|
|
pragma Inline (Close);
|
144 |
|
|
pragma Inline (Create);
|
145 |
|
|
pragma Inline (Delete);
|
146 |
|
|
pragma Inline (End_Of_File);
|
147 |
|
|
pragma Inline (Form);
|
148 |
|
|
pragma Inline (Index);
|
149 |
|
|
pragma Inline (Is_Open);
|
150 |
|
|
pragma Inline (Mode);
|
151 |
|
|
pragma Inline (Name);
|
152 |
|
|
pragma Inline (Open);
|
153 |
|
|
pragma Inline (Read);
|
154 |
|
|
pragma Inline (Reset);
|
155 |
|
|
pragma Inline (Set_Index);
|
156 |
|
|
pragma Inline (Size);
|
157 |
|
|
pragma Inline (Write);
|
158 |
|
|
|
159 |
|
|
end Ada.Direct_IO;
|