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;

References:

zip-headers.ads:58:8 (declaration)
unzip-streams.adb:33:34 (reference)
unzip.adb:31:34 (reference)
zip-headers.adb:133:43 (reference)
zip-headers.adb:159:30 (reference)
zip-headers.ads:72:42 (reference)
zip-headers.ads:77:29 (reference)
zip-headers.ads:87:28 (reference)

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;

References:

zip-headers.ads:84:8 (declaration)
zip-headers.adb:70:44 (reference)
zip-headers.adb:102:31 (reference)
zip-headers.ads:107:42 (reference)
zip-headers.ads:112:29 (reference)
zip.adb:188:29 (reference)
zip.adb:439:32 (reference)
zip.adb:487:29 (reference)

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;
    -- The Zip archive may be appended to another file (for instance an
    -- executable for self - extracting purposes) of size N.
    -- Then, all offsets need to be shifted by N.
    -- N=0 if the Zip archive is on its own.
    -- The real offset of the end - of - central - dir
    -- will be N + central_dir_size + central_dir_offset.
    -- This way, we have an unique chance to determine N when reading the
    -- end - of - central - dir. N is stored in the field hereafter.
    offset_shifting     : Unsigned_32;
  end record;

References:

zip-headers.ads:118:8 (declaration)
zip-headers.adb:184:44 (reference)
zip-headers.adb:204:44 (reference)
zip-headers.adb:223:34 (reference)
zip-headers.adb:285:31 (reference)
zip-headers.ads:143:43 (reference)
zip-headers.ads:146:43 (reference)
zip-headers.ads:153:33 (reference)
zip-headers.ads:156:31 (reference)
zip.adb:187:29 (reference)
zip.adb:438:32 (reference)
zip.adb:485:29 (reference)

Constants & Global variables

data_descriptor_length

data_descriptor_length  : constant := 16;

References:

zip-headers.ads:37:3 (declaration)
unzip-streams.adb:118:60 (reference)
unzip.adb:357:78 (reference)

bad_data_descriptor

bad_data_descriptor : exception;

References:

zip-headers.ads:47:3 (declaration)
zip-headers.adb:312:16 (reference)

Language_Encoding_Flag_Bit

Language_Encoding_Flag_Bit  : constant := 2**11;

References:

zip-headers.ads:56:3 (declaration)
zip.adb:238:38 (reference)

local_header_length

local_header_length : constant := 30;

References:

zip-headers.ads:69:3 (declaration)
unzip-streams.adb:64:67 (reference)
unzip-streams.adb:112:34 (reference)
unzip.adb:216:48 (reference)
unzip.adb:349:68 (reference)

bad_local_header

bad_local_header : exception;

References:

zip-headers.ads:74:3 (declaration)
unzip-streams.adb:47:27 (reference)
unzip.adb:199:27 (reference)
unzip.adb:578:24 (reference)
zip-headers.adb:141:16 (reference)

central_header_length

central_header_length : constant := 46;

References:

zip-headers.ads:104:3 (declaration)

bad_central_header

bad_central_header : exception;

References:

zip-headers.ads:109:3 (declaration)
zip-headers.adb:78:16 (reference)

end_of_central_dir_length

end_of_central_dir_length  : constant := 22;

References:

zip-headers.ads:138:3 (declaration)

bad_end

bad_end : exception;

References:

zip-headers.ads:148:3 (declaration)
zip-headers.adb:188:16 (reference)
zip-headers.adb:254:25 (reference)
zip-headers.adb:274:18 (reference)

Subprograms & Entries

Copy_and_check

procedure Copy_and_check 
(buffer: 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: Zipstream_Class;
the_data_desc: out Data_descriptor);

References:

zip-headers.ads:44:14 (declaration)
zip-headers.adb:321:14 (body)
zip-headers.adb:329:8 (label)

Copy_and_check

procedure Copy_and_check 
(buffer: 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: Zipstream_Class;
the_end: out End_of_Central_Dir);

References:

zip-headers.ads:145:13 (declaration)
zip-headers.adb:203:14 (body)
zip-headers.adb:211:8 (label)

Load

procedure Load 
(stream: 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.