replace use of add_torrent_params::url in some examples (#1866)

replace use of add_torrent_params::url in some examples
This commit is contained in:
Arvid Norberg 2017-03-29 19:19:23 -04:00 committed by GitHub
parent 02bb1251d2
commit d896e9bab3
3 changed files with 19 additions and 3 deletions

View File

@ -29,6 +29,7 @@ For example:
#include <libtorrent/session.hpp>
#include <libtorrent/add_torrent_params.hpp>
#include <libtorrent/torrent_handle.hpp>
#include <libtorrent/magnet_uri.hpp>
namespace lt = libtorrent;
int main(int argc, char const* argv[])
@ -40,7 +41,8 @@ For example:
lt::session ses;
lt::add_torrent_params atp;
atp.url = argv[1];
lt::error_code ec;
lt::parse_magnet_uri(argv[1], atp, ec);
atp.save_path = "."; // save in current dir
lt::torrent_handle h = ses.add_torrent(atp);

View File

@ -38,6 +38,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/add_torrent_params.hpp>
#include <libtorrent/torrent_handle.hpp>
#include <libtorrent/alert_types.hpp>
#include <libtorrent/magnet_uri.hpp>
#include <libtorrent/error_code.hpp>
namespace lt = libtorrent;
int main(int argc, char const* argv[])
@ -49,7 +51,12 @@ int main(int argc, char const* argv[])
lt::session ses;
lt::add_torrent_params atp;
atp.url = argv[1];
lt::error_code ec;
lt::parse_magnet_uri(argv[1], atp, ec);
if (ec) {
std::cerr << "invalid magnet URI: " << ec.message() << std::endl;
return 1;
}
atp.save_path = "."; // save in current dir
lt::torrent_handle h = ses.add_torrent(atp);

View File

@ -41,6 +41,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/alert_types.hpp>
#include <libtorrent/bencode.hpp>
#include <libtorrent/torrent_status.hpp>
#include <libtorrent/magnet_uri.hpp>
#include <libtorrent/error_code.hpp>
namespace lt = libtorrent;
using clk = std::chrono::steady_clock;
@ -82,7 +84,12 @@ int main(int argc, char const* argv[])
ifs.unsetf(std::ios_base::skipws);
atp.resume_data.assign(std::istream_iterator<char>(ifs)
, std::istream_iterator<char>());
atp.url = argv[1];
lt::error_code ec;
lt::parse_magnet_uri(argv[1], atp, ec);
if (ec) {
std::cerr << "invalid magnet URI: " << ec.message() << std::endl;
return 1;
}
atp.save_path = "."; // save in current dir
ses.async_add_torrent(atp);