|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 11264 (0x2c00) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Generic_File_Table, seg_021205
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« └─⟦this⟧
with Io; with Log; with Profile; package body Generic_File_Table is package Naming renames Directory.Naming; package Pio renames Polymorphic_Io; package Sop is new Pio.Sequential_Operations (Element_Type); Null_File_Position : constant Pio.File_Position := Pio.Nil; function Get_Pio_Mode (The_Mode : Mode) return Pio.File_Mode is -- Converts given mode to a polymorphic io mode begin case The_Mode is when Read => return Pio.Read_Only; when Write => return Pio.Write_Only; when Read_Write => return Pio.Read_Write; end case; end Get_Pio_Mode; procedure Open (The_Handle : in out Handle; Name : String; The_Mode : Mode) is Status : Pio.Error_Status; File : Io.File_Type; Pio_Mode : Pio.File_Mode; begin Pio_Mode := Get_Pio_Mode (The_Mode); -- Convert mode appropriately Pio.Open (The_Handle => Pio.Handle (The_Handle), Mode => Pio_Mode, File_Name => Name, Status => Status); -- Try opening the file if Directory."=" (Status, Directory.Name_Error) then -- If file does not exist Io.Create (File => File, Name => Name); Io.Close (File); -- Create it Pio.Open (The_Handle => Pio.Handle (The_Handle), Mode => Pio.Read_Write, File_Name => Name, Status => Status); -- Open the newly created file end if; if Directory."/=" (Status, Directory.Successful) then Log.Put_Line ("Open failed due to " & Directory.Error_Status'Image (Status), Profile.Warning_Msg); raise Open_Error; end if; exception when others => raise Open_Error; end Open; function First return File_Position is begin return File_Position (Pio.First); end First; function Get_Next_Free (Next_Free : Pio.File_Position; The_Handle : Pio.Handle) return File_Position is begin if Pio."=" (Next_Free, Null_File_Position) then return File_Position (Pio.First_Free_Position (The_Handle)); else return File_Position (Next_Free); end if; -- If next free is null then return the first file position as the -- free position end Get_Next_Free; procedure Lookup (The_Handle : Handle; Element_To_Match : Element_Type; Element_From_File : out Element_Type; Element_Position : out File_Position; Next_Free_Position : out File_Position) is The_File_Position : Pio.File_Position := Pio.First; Next_Free : Pio.File_Position := Null_File_Position; Element : Element_Type; begin while not Pio.End_Of_File (Pio.Handle (The_Handle), The_File_Position) loop Element := Sop.Read (From_File => Pio.Handle (The_Handle), At_Position => The_File_Position); -- Read each element in the file if Is_Empty (Element) then Next_Free := The_File_Position; -- If the element is an empty entry record it elsif Match (Element, Element_To_Match) then Element_Position := File_Position (The_File_Position); -- Pass back position at which a match occurred Next_Free_Position := Get_Next_Free (Next_Free, Pio.Handle (The_Handle)); -- Get the next free position Element_From_File := Element; return; end if; The_File_Position := Sop.Next (In_File => Pio.Handle (The_Handle), After => The_File_Position); end loop; Element_Position := File_Position (Null_File_Position); -- Element not found. Next_Free_Position := Get_Next_Free (Next_Free, Pio.Handle (The_Handle)); -- Next available position exception when Pio.End_Error => Log.Put_Line ("Unexpected end of file : lookup", Profile.Warning_Msg); Element_Position := File_Position (Null_File_Position); when others => Log.Put_Line ("Unexpected exception : lookup", Profile.Warning_Msg); Element_Position := File_Position (Null_File_Position); end Lookup; procedure Update (The_Handle : Handle; The_Element : Element_Type; The_Position : File_Position) is begin Sop.Write (To_File => Pio.Handle (The_Handle), At_Position => Pio.File_Position (The_Position), Value => The_Element); exception when others => Log.Put_Line ("Unexpected exception : update", Profile.Warning_Msg); end Update; function Is_Nil (The_Position : File_Position) return Boolean is begin return Pio.Is_Nil (Pio.File_Position (The_Position)); end Is_Nil; procedure Close (File : in out Handle) is Status : Pio.Error_Status; begin Pio.Close (File => Pio.Handle (File), Status => Status); if Directory."/=" (Status, Directory.Successful) then Log.Put_Line ("Close failed due to " & Directory.Error_Status'Image (Status), Profile.Warning_Msg); raise Close_Error; end if; end Close; procedure Dump (The_Handle : Handle) is The_File_Position : Pio.File_Position := Pio.First; Element : Element_Type; Null_File_Position : constant Pio.File_Position := Pio.Nil; begin while not Pio.End_Of_File (Pio.Handle (The_Handle), The_File_Position) loop Element := Sop.Read (From_File => Pio.Handle (The_Handle), At_Position => The_File_Position); Print_Element (Element); The_File_Position := Sop.Next (In_File => Pio.Handle (The_Handle), After => The_File_Position); end loop; exception when Pio.End_Error => Log.Put_Line ("Unexpected end of file : dump", Profile.Warning_Msg); when others => Log.Put_Line ("Unexpected exception : dump", Profile.Warning_Msg); end Dump; end Generic_File_Table;
nblk1=a nid=0 hdr6=14 [0x00] rec0=21 rec1=00 rec2=01 rec3=006 [0x01] rec0=00 rec1=00 rec2=0a rec3=012 [0x02] rec0=1b rec1=00 rec2=02 rec3=006 [0x03] rec0=1e rec1=00 rec2=03 rec3=044 [0x04] rec0=15 rec1=00 rec2=04 rec3=092 [0x05] rec0=01 rec1=00 rec2=09 rec3=014 [0x06] rec0=1b rec1=00 rec2=05 rec3=00a [0x07] rec0=19 rec1=00 rec2=06 rec3=010 [0x08] rec0=18 rec1=00 rec2=07 rec3=032 [0x09] rec0=04 rec1=00 rec2=08 rec3=000 tail 0x2171d58de838d6b54a9fe 0x42a00088462065003