text
stringlengths 0
234
|
|---|
Dico_Name => Dico_Name,
|
File_Name => File_Name,
|
File_Index => File_Index,
|
Comp_Size => Comp_Size,
|
Uncomp_Size => Uncomp_Size,
|
Crc_32 => Crc_32,
|
Date_Time => Date_Time,
|
Method => Method,
|
Name_Encoding => Name_Encoding,
|
Read_Only => Read_Only,
|
Encrypted_2_X => Encrypted_2_X));
|
elsif Dico_Name > Node.Dico_Name then
|
Insert_Into_Tree (Node.Right);
|
elsif Dico_Name < Node.Dico_Name then
|
Insert_Into_Tree (Node.Left);
|
else
|
-- Here we have a case where the entry name already exists
|
-- in the dictionary
|
raise Duplicate_Name with
|
"Entry name '" & Dico_Name & "' appears twice in archive";
|
end if;
|
end Insert_Into_Tree;
|
begin
|
Insert_Into_Tree (Root_Node);
|
end Insert;
|
The_End : Zip.Headers.End_Of_Central_Dir;
|
Header : Zip.Headers.Central_File_Header;
|
P : P_Dir_Node := null;
|
Main_Comment : P_String;
|
begin
|
if Info.Loaded then
|
raise Program_Error;
|
end if;
|
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'Access, Main_Comment.all);
|
-- Process central directory
|
From.Set_Index
|
(DCF.Streams.Zs_Index_Type (1 + The_End.Central_Dir_Offset) + The_End.Offset_Shifting);
|
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'Access, This_Name);
|
-- Skip extra field and entry comment
|
From.Set_Index
|
(From.Index +
|
DCF.Streams.Zs_Size_Type
|
(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 =>
|
DCF.Streams.Zs_Index_Type (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),
|
Name_Encoding =>
|
Boolean_To_Encoding
|
((Header.Short_Info.Bit_Flag and Zip.Headers.Language_Encoding_Flag_Bit) /= 0),
|
Read_Only =>
|
Header.Made_By_Version / 256 = 0 and -- DOS-like
|
(Header.External_Attributes and 1) = 1,
|
Encrypted_2_X =>
|
(Header.Short_Info.Bit_Flag and Zip.Headers.Encryption_Flag_Bit) /= 0,
|
Root_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 Init_Buffers;
|
Function Body: function Read_Byte_Decrypted return Unsigned_8; -- NB: reading goes on a while even if
|
pragma Inline (Read_Byte_Decrypted); -- Zip_EOF is set: just gives garbage
|
package Bit_Buffer is
|
procedure Init;
|
-- Read at least n bits into the bit buffer, returns the n first bits
|
function Read (N : Natural) return Integer;
|
pragma Inline (Read);
|
function Read_U32 (N : Natural) return Unsigned_32;
|
pragma Inline (Read_U32);
|
-- Dump n bits no longer needed from the bit buffer
|
procedure Dump (N : Natural);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.