home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / a-direio.ads < prev    next >
Text File  |  2000-07-19  |  6KB  |  159 lines

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