add have_piece function to torrent_handle

This commit is contained in:
Arvid Norberg 2011-11-27 00:01:13 +00:00
parent c279870516
commit c3695d9fbb
4 changed files with 19 additions and 0 deletions

View File

@ -332,6 +332,7 @@ void bind_torrent_handle()
#endif
.def("add_piece", add_piece)
.def("read_piece", _(&torrent_handle::read_piece))
.def("have_piece", _(&torrent_handle::have_piece))
.def("set_piece_deadline", _(&torrent_handle::set_piece_deadline)
, (arg("index"), arg("deadline"), arg("flags") = 0))
.def("reset_piece_deadline", _(&torrent_handle::reset_piece_deadline), (arg("index")))

View File

@ -2363,6 +2363,7 @@ Its declaration looks like this::
enum flags_t { overwrite_existing = 1 };
void add_piece(int piece, char const* data, int flags = 0) const;
void read_piece(int piece) const;
bool have_piece(int piece) const;
sha1_hash info_hash() const;
@ -2629,6 +2630,15 @@ read_piece_alert_. In order to receive this alert, you must enable
Note that if you read multiple pieces, the read operations are not guaranteed to
finish in the same order as you initiated them.
have_piece()
------------
::
bool have_piece(int piece) const;
Returns true if this piece has been completely downloaded, and false otherwise.
force_reannounce() force_dht_announce()
---------------------------------------

View File

@ -161,6 +161,7 @@ namespace libtorrent
enum flags_t { overwrite_existing = 1 };
void add_piece(int piece, char const* data, int flags = 0) const;
void read_piece(int piece) const;
bool have_piece(int piece) const;
void get_full_peer_list(std::vector<peer_list_entry>& v) const;
void get_peer_info(std::vector<peer_info>& v) const;

View File

@ -724,6 +724,13 @@ namespace libtorrent
TORRENT_ASYNC_CALL1(read_piece, piece);
}
bool torrent_handle::have_piece(int piece) const
{
INVARIANT_CHECK;
TORRENT_SYNC_CALL_RET1(bool, false, have_piece, piece);
return r;
}
storage_interface* torrent_handle::get_storage_impl() const
{
INVARIANT_CHECK;