add write_torrent_file_buf() overload for generating .torrent files
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
* add write_torrent_file_buf() overload for generating .torrent files
|
||||
* add create_torrent::generate_buf() function to generate into a buffer
|
||||
* fix copy_file when the file ends with a sparse region
|
||||
* uTP performance, fix packet loss when sending is stalled
|
||||
|
@ -1325,6 +1325,7 @@ void bind_session()
|
||||
|
||||
entry (*write_torrent_file0)(add_torrent_params const&, write_torrent_flags_t) = &write_torrent_file;
|
||||
def("write_torrent_file", write_torrent_file0, (arg("atp"), arg("flags") = 0));
|
||||
def("write_torrent_file_buf", write_torrent_file_buf, (arg("atp"), arg("flags") = 0));
|
||||
|
||||
{
|
||||
scope s = class_<dummy17>("write_flags");
|
||||
|
@ -71,8 +71,14 @@ namespace libtorrent {
|
||||
// * The add_torrent_params object passed to this function does not contain the
|
||||
// info dictionary (the ``ti`` field)
|
||||
// * The piece layers are not complete for all files that need them
|
||||
//
|
||||
// The ``write_torrent_file_buf()`` overload returns the torrent file in
|
||||
// bencoded buffer form. This overload may be faster at the expense of lost
|
||||
// flexibility to add custom fields.
|
||||
TORRENT_EXPORT entry write_torrent_file(add_torrent_params const& atp);
|
||||
TORRENT_EXPORT entry write_torrent_file(add_torrent_params const& atp, write_torrent_flags_t flags);
|
||||
TORRENT_EXPORT std::vector<char> write_torrent_file_buf(add_torrent_params const& atp
|
||||
, write_torrent_flags_t flags);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -418,6 +418,15 @@ namespace {
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<char> write_torrent_file_buf(add_torrent_params const& atp
|
||||
, write_torrent_flags_t flags)
|
||||
{
|
||||
std::vector<char> ret;
|
||||
entry e = write_torrent_file(atp, flags);
|
||||
bencode(std::back_inserter(ret), e);
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<char> write_resume_data_buf(add_torrent_params const& atp)
|
||||
{
|
||||
std::vector<char> ret;
|
||||
|
@ -1472,6 +1472,8 @@ TORRENT_TEST(write_torrent_file_session_roundtrip)
|
||||
std::vector<char> out_buffer;
|
||||
bencode(std::back_inserter(out_buffer), e);
|
||||
|
||||
TEST_CHECK(out_buffer == write_torrent_file_buf(p, write_flags::include_dht_nodes));
|
||||
|
||||
if (out_buffer != data)
|
||||
{
|
||||
std::cout << "GOT:\n";
|
||||
@ -1493,6 +1495,8 @@ TORRENT_TEST(write_torrent_file_session_roundtrip)
|
||||
std::vector<char> out_buffer;
|
||||
bencode(std::back_inserter(out_buffer), e);
|
||||
|
||||
TEST_CHECK(out_buffer == write_torrent_file_buf(p, write_flags::include_dht_nodes));
|
||||
|
||||
if (out_buffer != data)
|
||||
{
|
||||
std::cout << "GOT:\n";
|
||||
|
Reference in New Issue
Block a user