text
stringlengths
0
234
end if;
Length := Piece_Interval_Count'Min
(Piece_Interval_Count'Last,
Self.Current_Piece.Intervals.Last_Index);
Self.Pipelined :=
(Length => Length,
Expire => (1 .. Length => Length * Expire_Loops),
Request => (Length, others => <>));
for J in 1 .. Length loop
declare
Last : constant Interval :=
Self.Current_Piece.Intervals.Last_Element;
Index : constant Piece_Index := Self.Current_Piece.Piece;
Offset : constant Piece_Offset := Last.From;
Length : constant Piece_Offset := Last.To - Offset + 1;
begin
Self.Send_Message
((00, 00, 00, 13, 06) &
To_Int (Natural (Index - 1)) &
To_Int (Natural (Offset)) &
To_Int (Natural (Length)));
Self.Pipelined.Request.List (J) :=
(Piece => Self.Current_Piece.Piece,
Span => (Offset, Last.To));
Self.Current_Piece.Intervals.Delete_Last;
Function Definition: procedure Free is new Ada.Unchecked_Deallocation
Function Body: (Metainfo, Metainfo_Access);
--------------
-- Announce --
--------------
not overriding function Announce
(Self : Metainfo_File) return League.IRIs.IRI is
begin
return Self.Data.Announce;
end Announce;
-------------------
-- Announce_List --
-------------------
not overriding function Announce_List
(Self : Metainfo_File) return String_Vector_Array is
begin
return Self.Data.Announces;
end Announce_List;
----------------
-- File_Count --
----------------
not overriding function File_Count (Self : Metainfo_File) return Positive is
begin
return Self.Data.File_Count;
end File_Count;
-----------------
-- File_Length --
-----------------
not overriding function File_Length
(Self : Metainfo_File;
Index : Positive) return Ada.Streams.Stream_Element_Count is
begin
return Self.Data.Files (Index).Length;
end File_Length;
---------------
-- File_Path --
---------------
not overriding function File_Path
(Self : Metainfo_File;
Index : Positive) return League.String_Vectors.Universal_String_Vector
is
begin
return Self.Data.Files (Index).Path;
end File_Path;
--------------
-- Finalize --
--------------
procedure Finalize (Self : in out Metainfo_File) is
begin
Free (Self.Data);
end Finalize;
---------------
-- Info_Hash --
---------------
not overriding function Info_Hash (Self : Metainfo_File) return SHA1 is