text stringlengths 0 234 |
|---|
else |
raise Duplicate_name; |
end if; |
end Insert; |
the_end : Zip.Headers.End_of_Central_Dir; |
header : Zip.Headers.Central_File_Header; |
p : p_Dir_node := null; |
zip_info_already_loaded : exception; |
main_comment : p_String; |
use Ada.Streams, Ada.Streams.Stream_IO; |
begin -- Load Zip_info |
if info.loaded then |
raise zip_info_already_loaded; |
end if; -- 15 - Apr - 2002 |
Zip.Headers.Load (from, the_end); |
-- We take the opportunity to read the main comment, which is right |
-- after the end - of - central - directory block. |
main_comment := new String (1 .. Integer (the_end.main_comment_length)); |
String'Read (from, main_comment.all); |
-- Process central directory: |
Zip_Streams.Set_Index ( |
from, |
Positive ( |
1 + |
the_end.offset_shifting + the_end.central_dir_offset |
) |
); |
for i in 1 .. the_end.total_entries loop |
Zip.Headers.Read_and_check (from, header); |
declare |
this_name : String (1 .. Natural (header.short_info.filename_length)); |
begin |
String'Read (from, this_name); |
-- Skip extra field and entry comment. |
Zip_Streams.Set_Index ( |
from, Positive ( |
Ada.Streams.Stream_IO.Count (Zip_Streams.Index (from)) + |
Ada.Streams.Stream_IO.Count ( |
header.short_info.extra_field_length + |
header.comment_length |
)) |
); |
-- Now the whole i_th central directory entry is behind |
Insert (dico_name => Normalize (this_name, case_sensitive), |
file_name => Normalize (this_name, True), |
file_index => Ada.Streams.Stream_IO.Count |
(1 + header.local_header_offset + the_end.offset_shifting), |
comp_size => header.short_info.dd.compressed_size, |
uncomp_size => header.short_info.dd.uncompressed_size, |
crc_32 => header.short_info.dd.crc_32, |
date_time => header.short_info.file_timedate, |
method => Method_from_code (header.short_info.zip_type), |
unicode_file_name => |
(header.short_info.bit_flag and |
Zip.Headers.Language_Encoding_Flag_Bit) /= 0, |
node => p); |
-- Since the files are usually well ordered, the tree as inserted |
-- is very unbalanced; we need to rebalance it from time to time |
-- during loading, otherwise the insertion slows down dramatically |
-- for zip files with plenty of files - converges to |
-- O (total_entries ** 2) .. . |
if i mod 256 = 0 then |
Binary_tree_rebalancing.Rebalance (p); |
end if; |
Function Definition: procedure Dispose is new |
Function Body: Ada.Unchecked_Deallocation (HufT_table, p_HufT_table); |
procedure Dispose is new |
Ada.Unchecked_Deallocation (Table_list, p_Table_list); |
current : p_Table_list; |
tcount : Natural; -- just a stat. Idea : replace table_list with an array |
begin |
if full_trace then |
pragma Warnings (Off, "this code can never be executed and has been deleted"); |
Ada.Text_IO.Put ("[HufT_Free .. . "); |
tcount := 0; |
pragma Warnings (On, "this code can never be executed and has been deleted"); |
end if; |
while tl /= null loop |
Dispose (tl.all.table); -- destroy the Huffman table |
current := tl; |
tl := tl.all.next; |
Dispose (current); -- destroy the current node |
if full_trace then |
pragma Warnings (Off, "this code can never be executed and has been deleted"); |
tcount := tcount + 1; |
pragma Warnings (On, "this code can never be executed and has been deleted"); |
end if; |
end loop; |
if full_trace then |
pragma Warnings (Off, "this code can never be executed and has been deleted"); |
Ada.Text_IO.Put_Line (Integer'Image (tcount) & " tables]"); |
pragma Warnings (On, "this code can never be executed and has been deleted"); |
end if; |
end HufT_free; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.