added torrent_handle::read_piece(). #441
This commit is contained in:
@@ -97,6 +97,33 @@ namespace libtorrent
|
||||
std::string url;
|
||||
};
|
||||
|
||||
struct TORRENT_EXPORT read_piece_alert: torrent_alert
|
||||
{
|
||||
read_piece_alert(torrent_handle const& h
|
||||
, int p, boost::shared_array<char> d, int s)
|
||||
: torrent_alert(h)
|
||||
, buffer(d)
|
||||
, piece(p)
|
||||
, size(s)
|
||||
{}
|
||||
|
||||
virtual std::auto_ptr<alert> clone() const
|
||||
{ return std::auto_ptr<alert>(new read_piece_alert(*this)); }
|
||||
const static int static_category = alert::storage_notification;
|
||||
virtual int category() const { return static_category; }
|
||||
virtual char const* what() const { return "read piece"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << torrent_alert::message() << ": piece " << (buffer ? "successful " : "failed ") << piece;
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
boost::shared_array<char> buffer;
|
||||
int piece;
|
||||
int size;
|
||||
};
|
||||
|
||||
struct TORRENT_EXPORT file_renamed_alert: torrent_alert
|
||||
{
|
||||
file_renamed_alert(torrent_handle const& h
|
||||
|
@@ -174,6 +174,15 @@ namespace libtorrent
|
||||
void on_disk_write_complete(int ret, disk_io_job const& j
|
||||
, peer_request p);
|
||||
|
||||
struct read_piece_struct
|
||||
{
|
||||
boost::shared_array<char> piece_data;
|
||||
int blocks_left;
|
||||
bool fail;
|
||||
};
|
||||
void read_piece(int piece);
|
||||
void on_disk_read_complete(int ret, disk_io_job const& j, peer_request r, read_piece_struct* rp);
|
||||
|
||||
storage_mode_t storage_mode() const { return m_storage_mode; }
|
||||
storage_interface* get_storage()
|
||||
{
|
||||
|
@@ -316,6 +316,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;
|
||||
|
||||
void get_full_peer_list(std::vector<peer_list_entry>& v) const;
|
||||
void get_peer_info(std::vector<peer_info>& v) const;
|
||||
|
Reference in New Issue
Block a user