--
-- Copyright (c) 2012 Kevin Wellwood
-- All rights reserved.
--
-- This source code is distributed under the Modified BSD License. For terms and
-- conditions, see license.txt.
--
private with Zip;
private with Zip_Streams.Array_Streams;
package Resources.Archives.Zip_Archives is
private
use Zip;
use Zip_Streams.Array_Streams;
-- Implements an Archive class for .zip compressed files with .zip and
-- .gfx (tile library) extensions.
type Zip_Archive is new Archive with
record
zipArray : A_Array_Stream;
zipInfo : Zip_info;
end record;
-- 'resource' will be copied and not consumed. Raises an exception on error.
procedure Construct( this : access Zip_Archive;
resource : not null A_Resource_File );
procedure Delete( this : in out Zip_Archive );
-- Returns true if 'filename' exists in the Archive.
function Exists( this : access Zip_Archive;
filename : String ) return Boolean;
-- Reads 'filename' from the Archive and returns it as a raw in-memory
-- buffer. The caller takes ownership of the returned buffer; closing the
-- Archive does not affect it. An exception is raised on error.
function Load_Raw( this : access Zip_Archive;
filename : String ) return access Stream_Element_Array;
pragma Postcondition( Load_Raw'Result /= null );
pragma Postcondition( Load_Raw'Result'First = 0 );
-- Reads 'filename' from the Archive as a resource file. The caller takes
-- ownership of the returned object; closing the archive does not affect it.
-- An exception will be raised on error.
function Load_Resource( this : access Zip_Archive;
filename : String ) return A_Resource_File;
pragma Postcondition( Load_Resource'Result /= null );
end Resources.Archives.Zip_Archives;