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 Resources.Archives.Zip_Archives is 
  13.  
  14. private 
  15.  
  16.     use Zip; 
  17.     use Zip_Streams.Array_Streams; 
  18.  
  19.     -- Implements an Archive class for .zip compressed files with .zip and 
  20.     -- .gfx (tile library) extensions. 
  21.     type Zip_Archive is new Archive with 
  22.         record 
  23.             zipArray : A_Array_Stream; 
  24.             zipInfo  : Zip_info; 
  25.         end record; 
  26.  
  27.     -- 'resource' will be copied and not consumed. Raises an exception on error. 
  28.     procedure Construct( this     : access Zip_Archive; 
  29.                          resource : not null A_Resource_File ); 
  30.  
  31.     procedure Delete( this : in out Zip_Archive ); 
  32.  
  33.     -- Returns true if 'filename' exists in the Archive. 
  34.     function Exists( this     : access Zip_Archive; 
  35.                      filename : String ) return Boolean; 
  36.  
  37.     -- Reads 'filename' from the Archive and returns it as a raw in-memory 
  38.     -- buffer. The caller takes ownership of the returned buffer; closing the 
  39.     -- Archive does not affect it. An exception is raised on error. 
  40.     function Load_Raw( this     : access Zip_Archive; 
  41.                        filename : String ) return access Stream_Element_Array; 
  42.     pragma Postcondition( Load_Raw'Result /= null ); 
  43.     pragma Postcondition( Load_Raw'Result'First = 0 ); 
  44.  
  45.     -- Reads 'filename' from the Archive as a resource file. The caller takes 
  46.     -- ownership of the returned object; closing the archive does not affect it. 
  47.     -- An exception will be raised on error. 
  48.     function Load_Resource( this     : access Zip_Archive; 
  49.                             filename : String ) return A_Resource_File; 
  50.     pragma Postcondition( Load_Resource'Result /= null ); 
  51.  
  52. end Resources.Archives.Zip_Archives;