Index

Package: Headers

Description

package Zip.Headers is
Change log: ========== 16-Nov-2009: GdM: Replaced Ada.Calendar.Time by Zip.Time in headers, due to perf. issues in some run-times' Ada.Calendar.Time_Of

Types

Data_descriptor

type Data_descriptor is record
    -- PK78                           --  1.. 4
    crc_32             : Unsigned_32; --  5.. 8
    compressed_size,
    uncompressed_size  : Unsigned_32;
  end record;

Local_File_Header

type Local_File_Header is record
    -- PK34                                --  1.. 4
    needed_extract_version : Unsigned_16;  --  5.. 6
    bit_flag,
    zip_type               : Unsigned_16;
    file_timedate          : Time;
    dd                     : Data_descriptor;
    filename_length,
    extra_field_length     : Unsigned_16;
  end record;

Central_File_Header

type Central_File_Header is record
    -- PK12                                  --  1.. 4
    made_by_version     : Unsigned_16;       --  5.. 6
    short_info          : Local_File_Header; --  7..32
    comment_length      : Unsigned_16;       -- 33..34
    disk_number_start   : Unsigned_16;
    internal_attributes : Unsigned_16; -- internal properties of data
    external_attributes : Unsigned_32; -- 1st byte if MS-DOS: see below
    local_header_offset : Unsigned_32;
  end record;

End_of_Central_Dir

type End_of_Central_Dir is record
    -- PK56                           --  1.. 4
    disknum            : Unsigned_16; --  5.. 6
    disknum_with_start : Unsigned_16;
    disk_total_entries : Unsigned_16;
    total_entries      : Unsigned_16;
    central_dir_size   : Unsigned_32;
    central_dir_offset : Unsigned_32;
    main_comment_length: Unsigned_16;
  end record;

Constants & Global variables

data_descriptor_length

data_descriptor_length : constant:= 16;

bad_data_descriptor

bad_data_descriptor: exception;

local_header_length

local_header_length: constant:= 30;

bad_local_header

bad_local_header: exception;

central_header_length

central_header_length: constant:= 46;

bad_central_header

bad_central_header: exception;

end_of_central_dir_length

end_of_central_dir_length : constant:= 22;

bad_end

bad_end: exception;

Subprograms & Entries

Copy_and_check

procedure Copy_and_check
( buffer: in Byte_Buffer;
the_data_desc: out Data_descriptor );
This header needs to be read in continuation of the compressed data -> access to a buffer

Read_and_check

procedure Read_and_check
( stream: in Zipstream_Class;
the_data_desc: out Data_descriptor );

Write

procedure Write
( stream: in Zipstream_Class;
the_data_desc: in Data_descriptor );
--------------------------------------------------------------------- PKZIP local file header, in front of every file in archive - PK34 -- ---------------------------------------------------------------------

Read_and_check

procedure Read_and_check
( stream: in Zipstream_Class;
header: out Local_File_Header );

Write

procedure Write
( stream: in Zipstream_Class;
header: in Local_File_Header );
----------------------------------------------------- PKZIP file header, as in central directory - PK12 -- ----------------------------------------------------- NB: a central header contains a local header in the middle

Read_and_check

procedure Read_and_check
( stream: in Zipstream_Class;
header: out Central_File_Header );

Write

procedure Write
( stream: in Zipstream_Class;
header: in Central_File_Header );
----------------------------------------- PKZIP end-of-central-directory - PK56 -- -----------------------------------------

Copy_and_check

procedure Copy_and_check
( buffer: in Byte_Buffer;
the_end: out End_of_Central_Dir );
This header needs to be read in special ways (see Load) -> access to a buffer

Read_and_check

procedure Read_and_check
( stream: in Zipstream_Class;
the_end: out End_of_Central_Dir );

Load

procedure Load
( stream: in Zipstream_Class;
the_end: out End_of_Central_Dir );
A bit more elaborated: from an open file (not a stream), find the End-of-Central-dir and load it; keep the file open.

Write

procedure Write
( stream: in Zipstream_Class;
the_end: in End_of_Central_Dir );