torrent.cpp

This commit is contained in:
spyhole 2005-07-02 08:47:46 +00:00
parent bd05d7e4bf
commit 6410cac43c
2 changed files with 33 additions and 1 deletions

View File

@ -632,6 +632,29 @@ namespace libtorrent
m_picker->filtered_pieces(bitmask); m_picker->filtered_pieces(bitmask);
} }
//idea from Arvid and MooPolice
//todo refactoring and improving the function body
void torrent::filter_file(int index, bool filter)
{
__int64 start_position = 0;
int start_piece_index = 0;
int end_piece_index = 0;
for(int i=0;i<index;i++)
{
start_position += m_torrent_file.file_at(i).size;
}
start_position = start_position+1;
start_piece_index = start_position/(m_torrent_file.piece_length());
end_piece_index = start_piece_index + m_torrent_file.file_at(index).size/(m_torrent_file.piece_length());
for(int filter_piece_index= start_piece_index;filter_piece_index<end_piece_index;filter_piece_index++)
{
filter_piece(filter_piece_index, filter);
}
}
void torrent::replace_trackers(std::vector<announce_entry> const& urls) void torrent::replace_trackers(std::vector<announce_entry> const& urls)
{ {
assert(!urls.empty()); assert(!urls.empty());

View File

@ -286,6 +286,15 @@ namespace libtorrent
return ret; return ret;
} }
//idea from Arvid and MooPolice
//todo refactoring and improving the function body
void torrent_handle::filter_file(int index, bool filter)
{
INVARIANT_CHECK;
call_member<void>(m_ses, m_chk, m_info_hash
, bind(&torrent::filter_file, _1, index, filter));
}
std::vector<announce_entry> const& torrent_handle::trackers() const std::vector<announce_entry> const& torrent_handle::trackers() const
{ {
INVARIANT_CHECK; INVARIANT_CHECK;