DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T V

⟦b2682fa50⟧ TextFile

    Length: 9808 (0x2650)
    Types: TextFile
    Names: »V«

Derivation

└─⟦d10a02448⟧ Bits:30000409 8mm tape, Rational 1000, ENVIRONMENT, D_12_7_3
    └─ ⟦fc9b38f02⟧ »DATA« 
        └─⟦9b46a407a⟧ 
            └─⟦12c68c704⟧ 
                └─⟦this⟧ 
└─⟦5f3412b64⟧ Bits:30000745 8mm tape, Rational 1000, ENVIRONMENT 12_6_5 TOOLS 
    └─ ⟦91c658230⟧ »DATA« 
        └─⟦458657fb6⟧ 
            └─⟦220843204⟧ 
                └─⟦this⟧ 

TextFile

with Action;
with Default;
with Directory;
with Io_Exceptions;
with System;

package Polymorphic_Io is

    pragma Subsystem (Directory);
    pragma Module_Name (4, 1706);

    -- Provides the basic file abstraction on top of the package directory
    -- and file object manager abstractions.  Understanding actions is not
    -- necessary to use this level;  parameters are always defaulted to be
    -- single, queued actions.  Intended users are the Ada LRM Chapter 14
    -- IO packages, as well as sophisticated users that require more facilities
    -- than those provided in Chapter 14.

    subtype File is Directory.Object;

    subtype Version is Directory.Version;

    function Get_Class return Directory.Class;

    subtype Error_Status is Directory.Error_Status;

    type Handle is limited private;
    -- Handle that is needed to do anything to a file.

    function Nil                    return Handle;
    function Is_Nil (File : Handle) return Boolean;

    type File_Mode is (Read_Only, Write_Only, Read_Write, None);


    type File_Position is private;
    -- Logical file pointer that is needed to input and output operations.

    function Nil                                 return File_Position;
    function First                               return File_Position;
    function Is_Nil   (Position : File_Position) return Boolean;
    function Is_First (Position : File_Position) return Boolean;

    function "<"  (Left, Right : File_Position) return Boolean;
    function "<=" (Left, Right : File_Position) return Boolean;
    function ">"  (Left, Right : File_Position) return Boolean;
    function ">=" (Left, Right : File_Position) return Boolean;

    package Naming renames Directory.Naming;

    subtype Context is Directory.Naming.Context;

    function Default_Context
                (For_Job : Default.Process_Id := Default.Process) return Context
        renames Directory.Naming.Default_Context;

    procedure Open (The_Handle     : in out Handle;
                    Mode           : File_Mode;
                    File_Name      : Naming.Name;
                    Status         : out Error_Status;
                    The_Version    : Directory.Version_Name :=
                       Directory.Default_Version;
                    The_Context    : Context := Polymorphic_Io.Default_Context;
                    Action_Id      : Action.Id := Action.Null_Id;
                    Max_Wait       : Duration := Directory.Default_Wait;
                    Prevent_Backup : Boolean := False);

    procedure Open (The_Handle     : in out Handle;
                    Mode           :        File_Mode;
                    The_Object     :        File;
                    Status         : out    Error_Status;
                    The_Version    :        Directory.Version_Name :=
                       Directory.Default_Version;
                    Action_Id      :        Action.Id := Action.Null_Id;
                    Max_Wait       :        Duration := Directory.Default_Wait;
                    Prevent_Backup :        Boolean := False);

    procedure Open (The_Handle     : in out Handle;
                    Mode           :        File_Mode;
                    The_Version    : in out Version;
                    Status         : out    Error_Status;
                    Action_Id      :        Action.Id := Action.Null_Id;
                    Max_Wait       :        Duration  := Directory.Default_Wait;
                    Prevent_Backup :        Boolean   := False);


    procedure Close (File : in out Handle; Status : out Error_Status);
    -- Close a previously opened File.

    procedure Delete (File : in out Handle; Status : out Error_Status);
    -- Delete a previously opened File.  File cannot have been opened for Read.
    -- Commit any action opened on behalf of the user

    function Is_Open   (File : Handle) return Boolean;
    function Mode      (File : Handle) return File_Mode;
    function Name      (File : Handle) return Naming.Simple_Name;
    function Full_Name (File : Handle) return Naming.Name;
    -- Extract information about an open File.

    function End_Of_File
                (File : Handle; Position : File_Position) return Boolean;
    -- TRUE => Position is past end_of_File

    function First_Free_Position (File : Handle) return File_Position;
    -- Determine the first free (ie. non-existent) position within File.

    function Size (File : Handle) return Long_Integer;
    -- size of file in bits

    generic
        type Element is private;
        -- Element must be constrained and "safe".

    package Direct_Operations is

        function Compute (In_File : Handle;
                          Index   : Positive;
                          Base    : File_Position := Polymorphic_Io.First)
                         return File_Position;
        -- Determine the File_Position of the Index'th Element past Base.

        function Read (From_File : Handle; At_Position : File_Position)
                      return Element;
        -- Yield the Element at the specified position in From_File.
        -- If At_Position >= Free (From_File), END_ERROR is raised.
        -- If the system can detect that no element has ever been
        -- written At_Position, HOLE_ERROR is raised.

        procedure Write (To_File     : Handle;
                         At_Position : File_Position;
                         Value       : Element);
        -- Store the Value at the specified position in To_File.
        -- If At_Position + Value'Size >= Free (To_File), To_File is
        -- extended so that Free (To_File) = At_Position + Value'Size.

    end Direct_Operations;

    generic
        type Element is private;
        -- must be "safe"
    package Sequential_Operations is

        function Next (In_File : Handle; After : File_Position)
                      return File_Position;
        -- Move to the next Element in the specified file beyond After.
        -- If After >= Free (In_File), END_ERROR is raised.

        function Read (From_File : Handle; At_Position : File_Position)
                      return Element;
        -- Yield the Element at the specified position in From_File.
        -- If At_Position >= Free (From_File), END_ERROR is raised.
        -- If the system can detect that no element has ever been
        -- written At_Position, HOLE_ERROR is raised.

        procedure Write (To_File     : Handle;
                         At_Position : File_Position;
                         Value       : Element);
        -- Store the Value at the specified position in To_File.
        -- If At_Position + Value'Size >= Free (To_File), To_File is
        -- extended so that Free (To_File) = At_Position + Value'Size.

    end Sequential_Operations;

    generic
        type Element         is private;
        type Element_Pointer is access Element;
        pragma Segmented_Heap (Element_Pointer);
    package Access_Operations is

        function Reference (From_File : Handle; At_Position : File_Position)
                           return Element_Pointer;
        -- return a reference to the element "at_position"

        function Position (From_File : Handle; Pointer : Element_Pointer)
                          return File_Position;

        -- return position of element referenced by Pointer.
    end Access_Operations;


    Status_Error : exception renames Io_Exceptions.Status_Error;
    Mode_Error   : exception renames Io_Exceptions.Mode_Error;
    End_Error    : exception renames Io_Exceptions.End_Error;
    Data_Error   : exception renames Io_Exceptions.Data_Error;


    ----------------------------------------------
    -- CONVERSION OPERATIONS for FILE_POSITIONS --
    ----------------------------------------------
    function Convert (Pos : File_Position) return Long_Integer;
    function Convert (Pos : Long_Integer)  return File_Position;


    procedure Save (File             : in out Handle;
                    Status           : out    Error_Status;
                    Immediate_Effect :        Boolean := False);


    function Get_Action (File : Handle) return Action.Id;

    package String_Operations is
        subtype Byte        is System.Byte;
        subtype Byte_String is System.Byte_String;

        procedure Read (File  :        Handle;
                        Pos   : in out File_Position;
                        Item  : out    Byte_String;
                        Count : out    Natural);
        procedure Read (File :        Handle;
                        Pos  : in out File_Position;
                        Item : out    Byte);
        procedure Read (File  :        Handle;
                        Pos   : in out File_Position;
                        Item  : out    String;
                        Count : out    Natural);
        procedure Read (File :        Handle;
                        Pos  : in out File_Position;
                        Item : out    Character);

        procedure Write (File :        Handle;
                         Pos  : in out File_Position;
                         Item :        Byte_String);
        procedure Write
                     (File : Handle; Pos : in out File_Position; Item : Byte);
        procedure Write
                     (File : Handle; Pos : in out File_Position; Item : String);
        procedure Write (File :        Handle;
                         Pos  : in out File_Position;
                         Item :        Character);

    end String_Operations;

    procedure Truncate (File : Handle;
                        Pos  : File_Position := Polymorphic_Io.First);
    -- Shortens the file so that Pos is the first position outside the file.
    -- Will not make the file bigger if Pos is larger than the current size of
    -- the file.

end Polymorphic_Io;