1. with Allegro.Files;                     use Allegro.Files; 
  2.  
  3. -- This package is a high-level API for streaming to and from standard Allegro 
  4. -- packfiles using standard Ada streams. 
  5.  
  6. package Streams.Packfiles is 
  7.  
  8.     type Packfile_Stream is new Root_Stream_Type with private; 
  9.     type A_Packfile_Stream is access all Packfile_Stream'Class; 
  10.  
  11.     ---------------------------------------------------------------------------- 
  12.  
  13.     -- Opens a packfile on disk for streaming operations. 
  14.     function Open_Stream( filename, mode : String ) return A_Packfile_Stream; 
  15.  
  16.     -- Creates a stream using an open packfile. 
  17.     function Stream( f : not null A_Packfile ) return A_Packfile_Stream; 
  18.  
  19.     -- Closes the stream and its internal packfile if it opened one. 
  20.     procedure Close( stream : in out A_Packfile_Stream ); 
  21.  
  22.     -- Returns True of the stream has reached end-of-file. 
  23.     function EOF( stream : access Packfile_Stream ) return Boolean; 
  24.  
  25.     -- Returns True if the stream encountered an error. 
  26.     function Error( stream : access Packfile_Stream ) return Boolean; 
  27.  
  28. private 
  29.  
  30.     type Packfile_Stream is new Root_Stream_Type with record 
  31.         packfile : A_Packfile := null; 
  32.         doClose  : Boolean := False;  -- True if the stream's underlying 
  33.                                       -- packfile was opened by the packfile 
  34.                                       -- stream (Open_Stream) and should be 
  35.                                       -- closed when the stream is closed. 
  36.     end record; 
  37.  
  38.     procedure Read( stream : in out Packfile_Stream; 
  39.                     item   : out Stream_Element_Array; 
  40.                     last   : out Stream_Element_Offset ); 
  41.  
  42.     procedure Write( stream : in out Packfile_Stream; 
  43.                      item   : Stream_Element_Array ); 
  44.  
  45. end Streams.Packfiles;