From 4c199b1876f119c71fda4318b49e744e628f6ee7 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 28 Aug 2009 03:46:19 +0000 Subject: [PATCH] added missing functions to python binding related to torrent creation --- ChangeLog | 2 ++ bindings/python/src/create_torrent.cpp | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a0e582be8..d5a1d51d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -70,7 +70,9 @@ * improved support for sparse files on windows * added ability to give seeding torrents preference to active slots + * added missing functions to python binding related to torrent creation * fixed to add filename on web seed urls that lack it + * fixed BOOST_ASIO_HASH_MAP_BUCKETS define for boost 1.39 release 0.14.5 diff --git a/bindings/python/src/create_torrent.cpp b/bindings/python/src/create_torrent.cpp index 05a3af08a..116762e47 100644 --- a/bindings/python/src/create_torrent.cpp +++ b/bindings/python/src/create_torrent.cpp @@ -10,6 +10,14 @@ using namespace boost::python; using namespace libtorrent; +namespace +{ + void set_hash(create_torrent& c, int p, char const* hash) + { + c.set_hash(p, sha1_hash(hash)); + } +} + void bind_create_torrent() { void (file_storage::*add_file0)(file_entry const&) = &file_storage::add_file; @@ -21,6 +29,9 @@ void bind_create_torrent() void (file_storage::*set_name0)(std::string const&) = &file_storage::set_name; void (file_storage::*set_name1)(std::wstring const&) = &file_storage::set_name; + void (*set_piece_hashes0)(create_torrent&, boost::filesystem::path const&) = &set_piece_hashes; + void (*add_files0)(file_storage&, boost::filesystem::path const&) = add_files; + class_("file_storage") .def("is_valid", &file_storage::is_valid) .def("add_file", add_file0) @@ -50,7 +61,7 @@ void bind_create_torrent() .def("files", &create_torrent::files, return_internal_reference<>()) .def("set_comment", &create_torrent::set_comment) .def("set_creator", &create_torrent::set_creator) - .def("set_hash", &create_torrent::set_hash) + .def("set_hash", &set_hash) .def("add_url_seed", &create_torrent::add_url_seed) .def("add_node", &create_torrent::add_node) .def("add_tracker", &create_torrent::add_tracker) @@ -60,4 +71,8 @@ void bind_create_torrent() .def("piece_size", &create_torrent::piece_size) .def("priv", &create_torrent::priv) ; + + def("add_files", add_files0); + def("set_piece_hashes", set_piece_hashes0); + }