1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. private with Zip; 
  10. private with Zip_Streams.Array_Streams; 
  11.  
  12. package Archives.Zip_Archives is 
  13.  
  14.     type Zip_Archive is new Archive with private; 
  15.  
  16.     -- Returns true if 'filename' exists in the Archive. 
  17.     function Exists( this     : access Zip_Archive; 
  18.                      filename : String ) return Boolean; 
  19.  
  20.     -- Reads 'filename' from the Archive and opens it as an Allegro bitmap. The 
  21.     -- caller takes ownership of the returned bitmap; closing the archive does 
  22.     -- not affect it. An exception is raised on error. 
  23.     function Load_Bitmap( this     : access Zip_Archive; 
  24.                           filename : String ) return A_Bitmap; 
  25.     pragma Postcondition( Load_Bitmap'Result /= null ); 
  26.  
  27.     -- Reads 'filename' from the Archive and opens it as an in-memory packfile. 
  28.     -- The caller takes ownership of the returned packfile; closing the archive 
  29.     -- does not affect it. An exception is raised on error. 
  30.     function Load_Packfile( this     : access Zip_Archive; 
  31.                             filename : String ) return A_Packfile; 
  32.     pragma Postcondition( Load_Packfile'Result /= null ); 
  33.  
  34.     -- Reads 'filename' from the Archive and returns it as a raw in-memory 
  35.     -- buffer. The caller takes ownership of the returned buffer; closing the 
  36.     -- Archive does not affect it. An exception is raised on error. 
  37.     function Load_Raw( this     : access Zip_Archive; 
  38.                        filename : String ) return access Stream_Element_Array; 
  39.     pragma Postcondition( Load_Raw'Result /= null ); 
  40.  
  41. private 
  42.  
  43.     use Zip; 
  44.     use Zip_Streams.Array_Streams; 
  45.  
  46.     -- Implements an Archive class for .zip compressed files with .zip and 
  47.     -- .gfx (tile library) extensions. 
  48.     type Zip_Archive is new Archive with 
  49.         record 
  50.             zipArray : A_Array_Stream; 
  51.             zipInfo  : Zip_info; 
  52.         end record; 
  53.  
  54.     -- 'path' is the absolute path of the archive. Raises an exception on error. 
  55.     procedure Construct( this : access Zip_Archive; path : String ); 
  56.  
  57.     -- 'resource' will be copied and not consumed. Raises an exception on error. 
  58.     procedure Construct( this     : access Zip_Archive; 
  59.                          resource : not null A_Resource_File ); 
  60.  
  61.     procedure Delete( this : in out Zip_Archive ); 
  62.  
  63. end Archives.Zip_Archives;