text stringlengths 0 234 |
|---|
return N; |
end if; |
while N mod X = N loop |
X := X / 2; |
end loop; |
return N mod X; |
end Remove_Leading_Binary_1; |
begin -- Vine_to_tree |
Leaf_Count := Remove_Leading_Binary_1 (Size + 1); |
Compression (Root, Leaf_Count); -- create deepest leaves |
-- Use Perfect_leaves instead for a perfectly balanced tree |
Size := Size - Leaf_Count; |
while Size > 1 loop |
Compression (Root, Size / 2); |
Size := Size / 2; |
end loop; |
end Vine_To_Tree; |
procedure Rebalance (Root : in out P_Dir_Node) is |
-- Rebalance the binary search tree with root "root.all", |
-- with the result also rooted at "root.all". |
-- Uses the Tree_to_vine and Vine_to_tree procedures |
Pseudo_Root : P_Dir_Node; |
Size : Integer; |
begin |
Pseudo_Root := new Dir_Node (Name_Len => 0); |
Pseudo_Root.Right := Root; |
Tree_To_Vine (Pseudo_Root, Size); |
Vine_To_Tree (Pseudo_Root, Size); |
Root := Pseudo_Root.Right; |
Dispose (Pseudo_Root); |
end Rebalance; |
end Binary_Tree_Rebalancing; |
-- 19-Jun-2001: Enhanced file name identification |
-- a) when case insensitive -> all UPPER (current) |
-- b) '\' and '/' identified -> all '/' (new) |
function Normalize (S : String; Case_Sensitive : Boolean) return String is |
Sn : String := (if Case_Sensitive then S else Ada.Characters.Handling.To_Upper (S)); |
begin |
for I in Sn'Range loop |
if Sn (I) = '\' then |
Sn (I) := '/'; |
end if; |
end loop; |
return Sn; |
end Normalize; |
function Get_Node (Info : in Zip_Info; Name : in String) return P_Dir_Node is |
Aux : P_Dir_Node := Info.Dir_Binary_Tree; |
Up_Name : constant String := Normalize (Name, Info.Case_Sensitive); |
begin |
while Aux /= null loop |
if Up_Name > Aux.Dico_Name then |
Aux := Aux.Right; |
elsif Up_Name < Aux.Dico_Name then |
Aux := Aux.Left; |
else -- entry found ! |
return Aux; |
end if; |
end loop; |
return null; |
end Get_Node; |
Boolean_To_Encoding : constant array (Boolean) of Zip_Name_Encoding := |
(False => IBM_437, True => UTF_8); |
------------------------------------------------------------- |
-- Load Zip_info from a stream containing the .zip archive -- |
------------------------------------------------------------- |
procedure Load |
(Info : out Zip_Info; |
From : in out DCF.Streams.Root_Zipstream_Type'Class; |
Case_Sensitive : in Boolean := False) |
is |
procedure Insert |
(Dico_Name : String; -- UPPER if case-insensitive search |
File_Name : String; |
File_Index : DCF.Streams.Zs_Index_Type; |
Comp_Size, Uncomp_Size : File_Size_Type; |
Crc_32 : Unsigned_32; |
Date_Time : Time; |
Method : Pkzip_Method; |
Name_Encoding : Zip_Name_Encoding; |
Read_Only : Boolean; |
Encrypted_2_X : Boolean; |
Root_Node : in out P_Dir_Node) |
is |
procedure Insert_Into_Tree (Node : in out P_Dir_Node) is |
begin |
if Node = null then |
Node := |
new Dir_Node' |
((Name_Len => File_Name'Length, |
Left => null, |
Right => null, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.