A.8.5 Direct Input-Output Operations
Static Semantics
1
The operations available for direct input and output
are described in this subclause. The exception Status_Error is propagated
if any of these operations is attempted for a file that is not open.
2
procedure Read(File : in File_Type; Item : out Element_Type;
From : in Positive_Count);
procedure Read(File : in File_Type; Item : out Element_Type);
3
Operates on a file of mode In_File or Inout_File.
In the case of the first form, sets the current index of the given file
to the index value given by the parameter From. Then (for both forms)
returns, in the parameter Item, the value of the element whose position
in the given file is specified by the current index of the file; finally,
increases the current index by one.
4
The exception Mode_Error
is propagated if the mode of the given file is Out_File. The exception
End_Error is propagated if the index to be used exceeds the size of the
external file. The exception Data_Error can be propagated if the element
read cannot be interpreted as a value of the subtype Element_Type (see
A.13).
5
procedure Write(File : in File_Type; Item : in Element_Type;
To : in Positive_Count);
procedure Write(File : in File_Type; Item : in Element_Type);
6
Operates on a file of mode Inout_File or Out_File.
In the case of the first form, sets the index of the given file to the
index value given by the parameter To. Then (for both forms) gives the
value of the parameter Item to the element whose position in the given
file is specified by the current index of the file; finally, increases
the current index by one.
7
The exception Mode_Error
is propagated if the mode of the given file is In_File. The exception
Use_Error is propagated if the capacity of the external file is exceeded.
8
procedure Set_Index(File : in File_Type; To : in Positive_Count);
9
Operates on a file
of any mode. Sets the current index of the given file to the given index
value (which may exceed the current size of the file).
10
function Index(File : in File_Type) return Positive_Count;
11
Operates on a file
of any mode. Returns the current index of the given file.
12
function Size(File : in File_Type) return Count;
13
Operates on a file
of any mode. Returns the current size of the external file that is associated
with the given file.
14
function End_Of_File(File : in File_Type) return Boolean;
15/3
{
AI05-0264-1}
Operates on a file of mode In_File or Inout_File. Returns True if the
current index exceeds the size of the external file; otherwise
,
returns False.
16
The exception Mode_Error is propagated if the
mode of the given file is Out_File.
17
24 Append_File mode is not supported for
the generic package Direct_IO.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe