1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - File Management</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-A-8-1.html">Previous</A> <A HREF="AA-A-8-3.html">Next</A></P>
<HR>
<H1> A.8.2 File Management</H1>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> The procedures and functions described in this
subclause provide for the control of external files; their declarations
are repeated in each of the packages for sequential, direct, text, and
stream input-output. For text input-output, the procedures Create, Open,
and Reset have additional effects described in subclause <A HREF="AA-A-10-2.html">A.10.2</A>.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B> Create(File : <B>in</B> <B>out</B> File_Type;<BR>
Mode : <B>in</B> File_Mode := <I>default_mode</I>;<BR>
Name : <B>in</B> String := "";<BR>
Form : <B>in</B> String := "");</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="CodeIndented">Establishes a new external file, with the given
name and form, and associates this external file with the given file.
The given file is left open. The current mode of the given file is set
to the given access mode. The default access mode is the mode Out_File
for sequential and text input-output; it is the mode Inout_File for direct
input-output. For direct access, the size of the created file is implementation
defined.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="CodeIndented">A null string for Name specifies an external
file that is not accessible after the completion of the main program
(a temporary file). A null string for Form specifies the use of the default
options of the implementation for the external file.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The exception
Status_Error is propagated if the given file is already open. The exception
Name_Error is propagated if the string given as Name does not allow the
identification of an external file. The exception Use_Error is propagated
if, for the specified mode, the external environment does not support
creation of an external file with the given name (in the absence of Name_Error)
and form.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B> Open(File : <B>in</B> <B>out</B> File_Type;<BR>
Mode : <B>in</B> File_Mode;<BR>
Name : <B>in</B> String;<BR>
Form : <B>in</B> String := "");</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="CodeIndented">Associates the given file with an existing
external file having the given name and form, and sets the current mode
of the given file to the given mode. The given file is left open.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The exception
Status_Error is propagated if the given file is already open. The exception
Name_Error is propagated if the string given as Name does not allow the
identification of an external file; in particular, this exception is
propagated if no external file with the given name exists. The exception
Use_Error is propagated if, for the specified mode, the external environment
does not support opening for an external file with the given name (in
the absence of Name_Error) and form.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B> Close(File : <B>in</B> <B>out</B> File_Type);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="CodeIndented">Severs the association between the given file
and its associated external file. The given file is left closed. In addition,
for sequential files, if the file being closed has mode Out_File or Append_File,
then the last element written since the most recent open or reset is
the last element that can be read from the file. If no elements have
been written and the file mode is Out_File, then the closed file is empty.
If no elements have been written and the file mode is Append_File, then
the closed file is unchanged.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The exception
Status_Error is propagated if the given file is not open.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B> Delete(File : <B>in</B> <B>out</B> File_Type);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="CodeIndented">Deletes the external file associated with the
given file. The given file is closed, and the external file ceases to
exist.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The exception
Status_Error is propagated if the given file is not open. The exception
Use_Error is propagated if deletion of the external file is not supported
by the external environment.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B> Reset(File : <B>in</B> <B>out</B> File_Type; Mode : <B>in</B> File_Mode);<BR>
<B>procedure</B> Reset(File : <B>in</B> <B>out</B> File_Type);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="CodeIndented">Resets the given file so that reading from
its elements can be restarted from the beginning of the file (for modes
In_File and Inout_File), and so that writing to its elements can be restarted
at the beginning of the file (for modes Out_File and Inout_File) or after
the last element of the file (for mode Append_File). In particular, for
direct access this means that the current index is set to one. If a Mode
parameter is supplied, the current mode of the given file is set to the
given mode. In addition, for sequential files, if the given file has
mode Out_File or Append_File when Reset is called, the last element written
since the most recent open or reset is the last element that can be read
from the file. If no elements have been written and the file mode is
Out_File, the reset file is empty. If no elements have been written and
the file mode is Append_File, then the reset file is unchanged.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The exception
Status_Error is propagated if the file is not open. The exception Use_Error
is propagated if the external environment does not support resetting
for the external file and, also, if the external environment does not
support resetting to the specified mode for the external file.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Mode(File : <B>in</B> File_Type) <B>return</B> File_Mode;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="CodeIndented">Returns the current mode of the given file.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The exception
Status_Error is propagated if the file is not open.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Name(File : <B>in</B> File_Type) <B>return</B> String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="CodeIndented">Returns a string which uniquely identifies
the external file currently associated with the given file (and may thus
be used in an Open operation). If an external environment allows alternative
specifications of the name (for example, abbreviations), the string returned
by the function should correspond to a full specification of the name.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The exception
Status_Error is propagated if the given file is not open. The exception
Use_Error is propagated if the associated external file is a temporary
file that cannot be opened by any name.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Form(File : <B>in</B> File_Type) <B>return</B> String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="CodeIndented">Returns the form string for the external file
currently associated with the given file. If an external environment
allows alternative specifications of the form (for example, abbreviations
using default options), the string returned by the function should correspond
to a full specification (that is, it should indicate explicitly all options
selected, including default options).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The exception
Status_Error is propagated if the given file is not open.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Is_Open(File : <B>in</B> File_Type) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="CodeIndented">Returns True if the file is open (that is,
if it is associated with an external file), otherwise returns False.
</DIV>
<H4 ALIGN=CENTER>Implementation Permissions</H4>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Normal"> An implementation may propagate Name_Error or
Use_Error if an attempt is made to use an I/O feature that cannot be
supported by the implementation due to limitations in the external environment.
Any such restriction should be documented. </DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-A-8-1.html">Previous</A> <A HREF="AA-A-8-3.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|