merged python fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-03-29 02:46:12 +00:00
parent d21243dc9f
commit dfe541ecec
4 changed files with 29 additions and 15 deletions

View File

@ -20,7 +20,7 @@
* fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP
* add missing functions to python binding (flush_cache() and remap_files())
* add missing functions to python binding (flush_cache(), remap_files() and orig_files())
* improve handling of filenames that are invalid on windows
* support 'implied_port' in DHT announce_peer
* don't use pool allocator for disk blocks (cache may now return pages to the kernel)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# Copyright Daniel Wallin 2006. Use, modification and distribution is
# subject to the Boost Software License, Version 1.0. (See accompanying

View File

@ -1,8 +1,8 @@
#!/bin/python
#!/usr/bin/env python
# Copyright Arvid Norberg 2008. Use, modification and distribution is
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
from __future__ import print_function
import libtorrent as lt
import time
@ -28,4 +28,3 @@ while (not h.is_seed()):
time.sleep(1)
print(h.name(), 'complete')

View File

@ -71,6 +71,17 @@ namespace
return result;
}
list orig_files(torrent_info const& ti, bool storage) {
list result;
file_storage const& st = ti.orig_files();
for (int i = 0; i < st.num_files(); ++i)
result.append(st.at(i));
return result;
}
std::string hash_for_piece(torrent_info const& ti, int i)
{
return ti.hash_for_piece(i).to_string();
@ -111,6 +122,8 @@ namespace
size_type get_size(file_entry const& fe) { return fe.size; }
size_type get_offset(file_entry const& fe) { return fe.offset; }
size_type get_file_base(file_entry const& fe) { return fe.file_base; }
void set_file_base(file_entry& fe, int b) { fe.file_base = b; }
bool get_pad_file(file_entry const& fe) { return fe.pad_file; }
bool get_executable_attribute(file_entry const& fe) { return fe.executable_attribute; }
bool get_hidden_attribute(file_entry const& fe) { return fe.hidden_attribute; }
@ -165,6 +178,7 @@ void bind_torrent_info()
.def("file_at", &torrent_info::file_at)
.def("file_at_offset", &torrent_info::file_at_offset)
.def("files", &files, (arg("storage")=false))
.def("orig_files", &orig_files, (arg("storage")=false))
.def("rename_file", rename_file0)
#if TORRENT_USE_WSTRING
.def("rename_file", rename_file1)
@ -194,6 +208,7 @@ void bind_torrent_info()
.add_property("symlink_attribute", &get_symlink_attribute)
.add_property("offset", &get_offset)
.add_property("size", &get_size)
.add_property("file_base", &get_file_base, &set_file_base)
;
class_<announce_entry>("announce_entry", init<std::string const&>())