text stringlengths 0 234 |
|---|
bit_flag => Intel_nb (lhb (7 .. 8)), |
zip_type => Intel_nb (lhb (9 .. 10)), |
file_timedate => Zip_Streams.Calendar.Convert (Unsigned_32'(Intel_nb (lhb (11 .. 14)))), |
dd => |
(crc_32 => Intel_nb (lhb (15 .. 18)), |
compressed_size => Intel_nb (lhb (19 .. 22)), |
uncompressed_size => Intel_nb (lhb (23 .. 26))), |
filename_length => Intel_nb (lhb (27 .. 28)), |
extra_field_length => Intel_nb (lhb (29 .. 30))); |
end Read_and_check; |
procedure Write (stream : Zipstream_Class; |
header : Local_File_Header) is |
lhb : Byte_Buffer (1 .. 30); |
begin |
PK_signature (lhb, 3); |
lhb (5 .. 6) := Intel_bf (header.needed_extract_version); |
lhb (7 .. 8) := Intel_bf (header.bit_flag); |
lhb (9 .. 10) := Intel_bf (header.zip_type); |
lhb (11 .. 14) := Intel_bf (Zip_Streams.Calendar.Convert (header.file_timedate)); |
lhb (15 .. 18) := Intel_bf (header.dd.crc_32); |
lhb (19 .. 22) := Intel_bf (header.dd.compressed_size); |
lhb (23 .. 26) := Intel_bf (header.dd.uncompressed_size); |
lhb (27 .. 28) := Intel_bf (header.filename_length); |
lhb (29 .. 30) := Intel_bf (header.extra_field_length); |
BlockWrite (stream.all, lhb); |
end Write; |
------------------------------------------- |
-- PKZIP end - of - central - directory - PK56 -- |
------------------------------------------- |
procedure Copy_and_check (buffer : Byte_Buffer; |
the_end : out End_of_Central_Dir) is |
begin |
if not PK_signature (buffer, 5) then |
raise bad_end; |
end if; |
the_end := |
(disknum => Intel_nb (buffer (5 .. 6)), |
disknum_with_start => Intel_nb (buffer (7 .. 8)), |
disk_total_entries => Intel_nb (buffer (9 .. 10)), |
total_entries => Intel_nb (buffer (11 .. 12)), |
central_dir_size => Intel_nb (buffer (13 .. 16)), |
central_dir_offset => Intel_nb (buffer (17 .. 20)), |
main_comment_length => Intel_nb (buffer (21 .. 22)), |
offset_shifting => 0); -- Assuming single zip archive here |
end Copy_and_check; |
procedure Read_and_check (stream : Zipstream_Class; |
the_end : out End_of_Central_Dir) is |
eb : Byte_Buffer (1 .. 22); |
begin |
BlockRead (stream, eb); |
Copy_and_check (eb, the_end); |
end Read_and_check; |
-- Some explanations - GdM 2001 |
-- The idea is that the .ZIP can be appended to an .EXE, for |
-- self - extracting purposes. So, the most general infos are |
-- at the end, and we crawl back for more precise infos: |
-- 1) end - of - central directory |
-- 2) central directory |
-- 3) zipped files |
procedure Load (stream : Zipstream_Class; |
the_end : out End_of_Central_Dir) is |
end_buffer : Byte_Buffer (1 .. 22); |
min_end_start : Ada.Streams.Stream_IO.Count; |
use Ada.Streams.Stream_IO; |
max_comment : constant := 65_535; |
begin |
-- 20 - Jun - 2001 : abandon search below min_end_start |
-- - read about max comment length in appnote |
if Size (stream) <= max_comment then |
min_end_start := 1; |
else |
min_end_start := Ada.Streams.Stream_IO.Count (Size (stream)) - max_comment; |
end if; |
-- Yes, we must _search_ for it .. . |
-- because PKWARE put a variable - size comment _after_ it 8 - ( |
for i in reverse min_end_start .. Ada.Streams.Stream_IO.Count (Size (stream)) - 21 loop |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.