]>
Commit | Line | Data |
---|---|---|
cacbc350 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3084fecd | 3 | -- GNAT RUN-TIME COMPONENTS -- |
cacbc350 RK |
4 | -- -- |
5 | -- S Y S T E M . D I R E C T _ I O -- | |
6 | -- -- | |
7 | -- S p e c -- | |
8 | -- -- | |
0ae9f22f | 9 | -- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- |
cacbc350 RK |
10 | -- -- |
11 | -- GNAT is free software; you can redistribute it and/or modify it under -- | |
12 | -- terms of the GNU General Public License as published by the Free Soft- -- | |
13 | -- ware Foundation; either version 2, or (at your option) any later ver- -- | |
14 | -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | |
15 | -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | |
16 | -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- | |
17 | -- for more details. You should have received a copy of the GNU General -- | |
18 | -- Public License distributed with GNAT; see file COPYING. If not, write -- | |
cb5fee25 KC |
19 | -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- |
20 | -- Boston, MA 02110-1301, USA. -- | |
cacbc350 RK |
21 | -- -- |
22 | -- As a special exception, if other files instantiate generics from this -- | |
23 | -- unit, or you link this unit with other files to produce an executable, -- | |
24 | -- this unit does not by itself cause the resulting executable to be -- | |
25 | -- covered by the GNU General Public License. This exception does not -- | |
26 | -- however invalidate any other reasons why the executable file might be -- | |
27 | -- covered by the GNU Public License. -- | |
28 | -- -- | |
29 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 30 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
cacbc350 RK |
31 | -- -- |
32 | ------------------------------------------------------------------------------ | |
33 | ||
34 | -- This package contains the declaration of the control block used for | |
35 | -- Direct_IO. This must be declared at the outer library level. It also | |
36 | -- contains code that is shared between instances of Direct_IO. | |
37 | ||
38 | with Interfaces.C_Streams; | |
39 | with Ada.Streams; | |
40 | with System.File_Control_Block; | |
41 | with System.Storage_Elements; | |
42 | ||
43 | package System.Direct_IO is | |
44 | ||
45 | package FCB renames System.File_Control_Block; | |
46 | ||
47 | type Operation is (Op_Read, Op_Write, Op_Other); | |
48 | -- Type used to record last operation (to optimize sequential operations) | |
49 | ||
50 | subtype Count is Interfaces.C_Streams.long; | |
51 | -- The Count type in each instantiation is derived from this type | |
52 | ||
53 | subtype Positive_Count is Count range 1 .. Count'Last; | |
54 | ||
55 | type Direct_AFCB is new FCB.AFCB with record | |
56 | Index : Count := 1; | |
57 | -- Current Index value | |
58 | ||
59 | Bytes : Interfaces.C_Streams.size_t; | |
60 | -- Length of item in bytes (set from inside generic template) | |
61 | ||
62 | Last_Op : Operation := Op_Other; | |
63 | -- Last operation performed on file, used to avoid unnecessary | |
64 | -- repositioning between successive read or write operations. | |
65 | end record; | |
66 | ||
67 | function AFCB_Allocate (Control_Block : Direct_AFCB) return FCB.AFCB_Ptr; | |
68 | ||
69 | procedure AFCB_Close (File : access Direct_AFCB); | |
70 | procedure AFCB_Free (File : access Direct_AFCB); | |
71 | ||
72 | procedure Read | |
73 | (File : in out Direct_AFCB; | |
74 | Item : out Ada.Streams.Stream_Element_Array; | |
75 | Last : out Ada.Streams.Stream_Element_Offset); | |
76 | -- Required overriding of Read, not actually used for Direct_IO | |
77 | ||
78 | procedure Write | |
79 | (File : in out Direct_AFCB; | |
0ae9f22f | 80 | Item : Ada.Streams.Stream_Element_Array); |
cacbc350 RK |
81 | -- Required overriding of Write, not actually used for Direct_IO |
82 | ||
83 | type File_Type is access all Direct_AFCB; | |
84 | -- File_Type in individual instantiations is derived from this type | |
85 | ||
86 | procedure Create | |
87 | (File : in out File_Type; | |
0ae9f22f RD |
88 | Mode : FCB.File_Mode := FCB.Inout_File; |
89 | Name : String := ""; | |
90 | Form : String := ""); | |
cacbc350 | 91 | |
0ae9f22f | 92 | function End_Of_File (File : File_Type) return Boolean; |
cacbc350 | 93 | |
0ae9f22f | 94 | function Index (File : File_Type) return Positive_Count; |
cacbc350 RK |
95 | |
96 | procedure Open | |
97 | (File : in out File_Type; | |
0ae9f22f RD |
98 | Mode : FCB.File_Mode; |
99 | Name : String; | |
100 | Form : String := ""); | |
cacbc350 RK |
101 | |
102 | procedure Read | |
0ae9f22f | 103 | (File : File_Type; |
cacbc350 | 104 | Item : System.Address; |
0ae9f22f RD |
105 | Size : Interfaces.C_Streams.size_t; |
106 | From : Positive_Count); | |
cacbc350 RK |
107 | |
108 | procedure Read | |
0ae9f22f | 109 | (File : File_Type; |
cacbc350 | 110 | Item : System.Address; |
0ae9f22f | 111 | Size : Interfaces.C_Streams.size_t); |
cacbc350 | 112 | |
0ae9f22f | 113 | procedure Reset (File : in out File_Type; Mode : FCB.File_Mode); |
cacbc350 RK |
114 | |
115 | procedure Reset (File : in out File_Type); | |
116 | ||
0ae9f22f | 117 | procedure Set_Index (File : File_Type; To : Positive_Count); |
cacbc350 | 118 | |
0ae9f22f | 119 | function Size (File : File_Type) return Count; |
cacbc350 RK |
120 | |
121 | procedure Write | |
0ae9f22f | 122 | (File : File_Type; |
cacbc350 | 123 | Item : System.Address; |
0ae9f22f | 124 | Size : Interfaces.C_Streams.size_t; |
cacbc350 RK |
125 | Zeroes : System.Storage_Elements.Storage_Array); |
126 | -- Note: Zeroes is the buffer of zeroes used to fill out partial records | |
127 | ||
128 | end System.Direct_IO; |