moved the asio headers into the include directory, to have them installed when libtorrent is installed. improved the complexity of torrent_info::map_file(), It's now O(1).

This commit is contained in:
Arvid Norberg 2006-06-17 22:04:25 +00:00
parent 1a081561c4
commit 903e11e458
12 changed files with 173 additions and 283 deletions

View File

@ -18,153 +18,7 @@ debian/libtorrent0-dev.install \
debian/libtorrent0.dirs \ debian/libtorrent0.dirs \
debian/libtorrent0.docs \ debian/libtorrent0.docs \
debian/libtorrent0.install \ debian/libtorrent0.install \
debian/rules \ debian/rules
asio/aclocal.m4 \
asio/autogen.sh \
asio/boostify.pl \
asio/configure \
asio/configure.ac \
asio/COPYING \
asio/depcomp \
asio/include/asio/basic_datagram_socket.hpp \
asio/include/asio/basic_deadline_timer.hpp \
asio/include/asio/basic_io_object.hpp \
asio/include/asio/basic_resolver.hpp \
asio/include/asio/basic_socket.hpp \
asio/include/asio/basic_socket_acceptor.hpp \
asio/include/asio/basic_strand.hpp \
asio/include/asio/basic_stream_socket.hpp \
asio/include/asio/buffer.hpp \
asio/include/asio/buffered_read_stream.hpp \
asio/include/asio/buffered_read_stream_fwd.hpp \
asio/include/asio/buffered_stream.hpp \
asio/include/asio/buffered_stream_fwd.hpp \
asio/include/asio/buffered_write_stream.hpp \
asio/include/asio/buffered_write_stream_fwd.hpp \
asio/include/asio/completion_condition.hpp \
asio/include/asio/datagram_socket_service.hpp \
asio/include/asio/deadline_timer.hpp \
asio/include/asio/deadline_timer_service.hpp \
asio/include/asio/detail/bind_handler.hpp \
asio/include/asio/detail/buffer_resize_guard.hpp \
asio/include/asio/detail/buffered_stream_storage.hpp \
asio/include/asio/detail/call_stack.hpp \
asio/include/asio/detail/consuming_buffers.hpp \
asio/include/asio/detail/epoll_reactor.hpp \
asio/include/asio/detail/epoll_reactor_fwd.hpp \
asio/include/asio/detail/event.hpp \
asio/include/asio/detail/fd_set_adapter.hpp \
asio/include/asio/detail/handler_alloc_helpers.hpp \
asio/include/asio/detail/hash_map.hpp \
asio/include/asio/detail/io_control.hpp \
asio/include/asio/detail/kqueue_reactor.hpp \
asio/include/asio/detail/kqueue_reactor_fwd.hpp \
asio/include/asio/detail/mutex.hpp \
asio/include/asio/detail/noncopyable.hpp \
asio/include/asio/detail/null_event.hpp \
asio/include/asio/detail/null_mutex.hpp \
asio/include/asio/detail/null_signal_blocker.hpp \
asio/include/asio/detail/null_thread.hpp \
asio/include/asio/detail/null_tss_ptr.hpp \
asio/include/asio/detail/old_win_sdk_compat.hpp \
asio/include/asio/detail/pipe_select_interrupter.hpp \
asio/include/asio/detail/pop_options.hpp \
asio/include/asio/detail/posix_event.hpp \
asio/include/asio/detail/posix_mutex.hpp \
asio/include/asio/detail/posix_signal_blocker.hpp \
asio/include/asio/detail/posix_thread.hpp \
asio/include/asio/detail/posix_tss_ptr.hpp \
asio/include/asio/detail/push_options.hpp \
asio/include/asio/detail/reactive_deadline_timer_service.hpp \
asio/include/asio/detail/reactive_socket_service.hpp \
asio/include/asio/detail/reactor_op_queue.hpp \
asio/include/asio/detail/reactor_timer_queue.hpp \
asio/include/asio/detail/resolver_service.hpp \
asio/include/asio/detail/scoped_lock.hpp \
asio/include/asio/detail/select_interrupter.hpp \
asio/include/asio/detail/select_reactor.hpp \
asio/include/asio/detail/select_reactor_fwd.hpp \
asio/include/asio/detail/service_registry.hpp \
asio/include/asio/detail/signal_blocker.hpp \
asio/include/asio/detail/signal_init.hpp \
asio/include/asio/detail/socket_holder.hpp \
asio/include/asio/detail/socket_ops.hpp \
asio/include/asio/detail/socket_option.hpp \
asio/include/asio/detail/socket_select_interrupter.hpp \
asio/include/asio/detail/socket_types.hpp \
asio/include/asio/detail/strand_service.hpp \
asio/include/asio/detail/task_io_service.hpp \
asio/include/asio/detail/task_io_service_fwd.hpp \
asio/include/asio/detail/thread.hpp \
asio/include/asio/detail/tss_ptr.hpp \
asio/include/asio/detail/win_event.hpp \
asio/include/asio/detail/win_iocp_io_service.hpp \
asio/include/asio/detail/win_iocp_io_service_fwd.hpp \
asio/include/asio/detail/win_iocp_operation.hpp \
asio/include/asio/detail/win_iocp_socket_service.hpp \
asio/include/asio/detail/win_local_free_on_block_exit.hpp \
asio/include/asio/detail/win_mutex.hpp \
asio/include/asio/detail/win_signal_blocker.hpp \
asio/include/asio/detail/win_thread.hpp \
asio/include/asio/detail/win_tss_ptr.hpp \
asio/include/asio/detail/winsock_init.hpp \
asio/include/asio/detail/wrapped_handler.hpp \
asio/include/asio/error.hpp \
asio/include/asio/error_handler.hpp \
asio/include/asio/handler_alloc_hook.hpp \
asio/include/asio/impl/basic_datagram_socket.ipp \
asio/include/asio/impl/io_service.ipp \
asio/include/asio/impl/read.ipp \
asio/include/asio/impl/write.ipp \
asio/include/asio/io_service.hpp \
asio/include/asio/ip/address.hpp \
asio/include/asio/ip/address_v4.hpp \
asio/include/asio/ip/address_v6.hpp \
asio/include/asio/ip/basic_endpoint.hpp \
asio/include/asio/ip/basic_resolver_entry.hpp \
asio/include/asio/ip/basic_resolver_iterator.hpp \
asio/include/asio/ip/basic_resolver_query.hpp \
asio/include/asio/ip/detail/socket_option.hpp \
asio/include/asio/ip/host_name.hpp \
asio/include/asio/ip/multicast.hpp \
asio/include/asio/ip/resolver_query_base.hpp \
asio/include/asio/ip/tcp.hpp \
asio/include/asio/ip/udp.hpp \
asio/include/asio/is_read_buffered.hpp \
asio/include/asio/is_write_buffered.hpp \
asio/include/asio/placeholders.hpp \
asio/include/asio/read.hpp \
asio/include/asio/resolver_service.hpp \
asio/include/asio/socket_acceptor_service.hpp \
asio/include/asio/socket_base.hpp \
asio/include/asio/ssl/basic_context.hpp \
asio/include/asio/ssl/context.hpp \
asio/include/asio/ssl/context_base.hpp \
asio/include/asio/ssl/context_service.hpp \
asio/include/asio/ssl/detail/openssl_context_service.hpp \
asio/include/asio/ssl/detail/openssl_init.hpp \
asio/include/asio/ssl/detail/openssl_operation.hpp \
asio/include/asio/ssl/detail/openssl_stream_service.hpp \
asio/include/asio/ssl/detail/openssl_types.hpp \
asio/include/asio/ssl/stream.hpp \
asio/include/asio/ssl/stream_base.hpp \
asio/include/asio/ssl/stream_service.hpp \
asio/include/asio/ssl.hpp \
asio/include/asio/strand.hpp \
asio/include/asio/strand_service.hpp \
asio/include/asio/stream_socket_service.hpp \
asio/include/asio/system_exception.hpp \
asio/include/asio/thread.hpp \
asio/include/asio/time_traits.hpp \
asio/include/asio/write.hpp \
asio/include/asio.hpp \
asio/include/Makefile.am \
asio/INSTALL \
asio/install-sh \
asio/LICENSE_1_0.txt \
asio/Makefile.am \
asio/missing \
asio/README
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
@ -176,7 +30,6 @@ check: test
&& test/test_ip_filter \ && test/test_ip_filter \
&& test/test_piece_picker \ && test/test_piece_picker \
&& test/test_storage \ && test/test_storage \
&& test/test_metadata_extension \
&& test/test_buffer \ && test/test_buffer \
&& echo && echo && echo " **** all tests passed ****" && echo && echo && echo && echo && echo " **** all tests passed ****" && echo && echo

View File

@ -6,127 +6,7 @@
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
<title>libtorrent manual</title> <title>libtorrent manual</title>
<meta name="author" content="Arvid Norberg, arvid&#64;rasterbar.com" /> <meta name="author" content="Arvid Norberg, arvid&#64;rasterbar.com" />
<style type="text/css"> <link rel="stylesheet" href="rst.css" type="text/css" />
body
{
background-color: white;
color: black;
margin: 1em 2em 1em 2em;
}
h1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; text-align: left; font-size: 140%; }
h2 { font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; text-align: left; font-size: 110%; }
h3 { font-family: "courier new", courier, monospace; font-weight: bold; text-align: left; font-size: 100%; }
pre
{
border: gray 1pt solid;
padding: 2pt;
display: block;
font-family: "courier new", courier, monospace;
background-color: #eeeeee;
color: black;
font-size: small
}
code
{
white-space: pre;
border: gray 1pt solid;
padding: 2pt;
display: block;
font-family: "courier new", courier, monospace;
color: black;
font-size: small
}
tt
{
display: inline;
font-family: "Courier New", Courier, monospace;
}
p
{
text-align: justify;
font-family: Georgia, "Times New Roman", Times, serif
}
ul
{
font-family: Georgia, "Times New Roman", Times, serif
}
ol
{
font-family: Georgia, "Times New Roman", Times, serif
}
a:link
{
font-weight: bold;
color: #003366;
text-decoration: none;
}
a:visited
{
font-weight: bold;
color: #003366;
text-decoration: none;
}
table
{
border: 1px solid black;
border-collapse: collapse;
}
table td
{
padding: 6px;
}
table th
{
border: 3px solid black;
padding: 6px;
}
table.menu
{
border-style: none;
}
table.menu td
{
padding-left: 15px;
padding-right: 15px;
padding-top: 7px;
padding-bottom: 7px;
}
td
{
border: 1px solid black
}
div.warning, div.note, div.important {
width: 80%;
margin: 1.5em auto;
background: #C1E5F6;
background: #F1FFF5;
border: solid 1px #D1DFD5;
padding: 5px 10px 5px 10px;
}
</style>
</head> </head>
<body> <body>
<div class="document" id="libtorrent-manual"> <div class="document" id="libtorrent-manual">
@ -137,10 +17,12 @@ div.warning, div.note, div.important {
<tbody valign="top"> <tbody valign="top">
<tr><th class="docinfo-name">Author:</th> <tr><th class="docinfo-name">Author:</th>
<td>Arvid Norberg, <a class="last reference" href="mailto:arvid&#64;rasterbar.com">arvid&#64;rasterbar.com</a></td></tr> <td>Arvid Norberg, <a class="last reference" href="mailto:arvid&#64;rasterbar.com">arvid&#64;rasterbar.com</a></td></tr>
<tr><th class="docinfo-name">Version:</th>
<td>0.9.2</td></tr>
</tbody> </tbody>
</table> </table>
<div class="contents topic"> <div class="contents topic" id="table-of-contents">
<p class="topic-title first"><a id="table-of-contents" name="table-of-contents">Table of contents</a></p> <p class="topic-title first"><a name="table-of-contents">Table of contents</a></p>
<ul class="simple"> <ul class="simple">
<li><a class="reference" href="#introduction" id="id25" name="id25">introduction</a></li> <li><a class="reference" href="#introduction" id="id25" name="id25">introduction</a></li>
<li><a class="reference" href="#downloading-and-building" id="id26" name="id26">downloading and building</a><ul> <li><a class="reference" href="#downloading-and-building" id="id26" name="id26">downloading and building</a><ul>
@ -1328,10 +1210,14 @@ iterators with the type <tt class="docutils literal"><span class="pre">file_entr
<p>The <tt class="docutils literal"><span class="pre">path</span></tt> is the full (relative) path of each file. i.e. if it is a multi-file <p>The <tt class="docutils literal"><span class="pre">path</span></tt> is the full (relative) path of each file. i.e. if it is a multi-file
torrent, all the files starts with a directory with the same name as <tt class="docutils literal"><span class="pre">torrent_info::name()</span></tt>. torrent, all the files starts with a directory with the same name as <tt class="docutils literal"><span class="pre">torrent_info::name()</span></tt>.
The filenames are encoded with UTF-8.</p> The filenames are encoded with UTF-8.</p>
<p><tt class="docutils literal"><span class="pre">size</span></tt> is the size of the file (in bytes) and <tt class="docutils literal"><span class="pre">offset</span></tt> is the byte offset
of the file within the torrent. i.e. the sum of all the sizes of the files
before this one in the file list this one in the file list..</p>
<pre class="literal-block"> <pre class="literal-block">
struct file_entry struct file_entry
{ {
boost::filesystem::path path; boost::filesystem::path path;
size_type offset;
size_type size; size_type size;
}; };
</pre> </pre>

View File

@ -3,6 +3,7 @@ libtorrent manual
================= =================
:Author: Arvid Norberg, arvid@rasterbar.com :Author: Arvid Norberg, arvid@rasterbar.com
:Version: 0.9.2
.. contents:: Table of contents .. contents:: Table of contents
:depth: 2 :depth: 2
@ -1146,11 +1147,16 @@ The ``path`` is the full (relative) path of each file. i.e. if it is a multi-fil
torrent, all the files starts with a directory with the same name as ``torrent_info::name()``. torrent, all the files starts with a directory with the same name as ``torrent_info::name()``.
The filenames are encoded with UTF-8. The filenames are encoded with UTF-8.
``size`` is the size of the file (in bytes) and ``offset`` is the byte offset
of the file within the torrent. i.e. the sum of all the sizes of the files
before this one in the file list this one in the file list..
:: ::
struct file_entry struct file_entry
{ {
boost::filesystem::path path; boost::filesystem::path path;
size_type offset;
size_type size; size_type size;
}; };

View File

@ -14,5 +14,5 @@ make_torrent_LDADD = $(top_builddir)/src/libtorrent.la
simple_client_SOURCES = simple_client.cpp simple_client_SOURCES = simple_client.cpp
simple_client_LDADD = $(top_builddir)/src/libtorrent.la simple_client_LDADD = $(top_builddir)/src/libtorrent.la
AM_CXXFLAGS=-ftemplate-depth-50 -I$(top_srcdir)/include -I$(top_srcdir)/asio/include @DEBUGFLAGS@ @PTHREAD_CFLAGS@ AM_CXXFLAGS=-ftemplate-depth-50 -I$(top_srcdir)/include @DEBUGFLAGS@ @PTHREAD_CFLAGS@
AM_LDFLAGS= ${LDLAGS} -L./ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ AM_LDFLAGS= ${LDLAGS} -L./ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@

View File

@ -38,4 +38,144 @@ libtorrent/torrent_info.hpp \
libtorrent/tracker_manager.hpp \ libtorrent/tracker_manager.hpp \
libtorrent/udp_tracker_connection.hpp \ libtorrent/udp_tracker_connection.hpp \
libtorrent/utf8.hpp \ libtorrent/utf8.hpp \
libtorrent/version.hpp libtorrent/version.hpp \
\
asio/basic_datagram_socket.hpp \
asio/basic_deadline_timer.hpp \
asio/basic_io_object.hpp \
asio/basic_resolver.hpp \
asio/basic_socket.hpp \
asio/basic_socket_acceptor.hpp \
asio/basic_socket_iostream.hpp \
asio/basic_socketbuf.hpp \
asio/basic_strand.hpp \
asio/basic_stream_socket.hpp \
asio/basic_streambuf.hpp \
asio/buffer.hpp \
asio/buffered_read_stream.hpp \
asio/buffered_read_stream_fwd.hpp \
asio/buffered_stream.hpp \
asio/buffered_stream_fwd.hpp \
asio/buffered_write_stream.hpp \
asio/buffered_write_stream_fwd.hpp \
asio/completion_condition.hpp \
asio/datagram_socket_service.hpp \
asio/deadline_timer.hpp \
asio/deadline_timer_service.hpp \
asio/detail/bind_handler.hpp \
asio/detail/buffer_resize_guard.hpp \
asio/detail/buffered_stream_storage.hpp \
asio/detail/call_stack.hpp \
asio/detail/const_buffers_iterator.hpp \
asio/detail/consuming_buffers.hpp \
asio/detail/epoll_reactor.hpp \
asio/detail/epoll_reactor_fwd.hpp \
asio/detail/event.hpp \
asio/detail/fd_set_adapter.hpp \
asio/detail/handler_alloc_helpers.hpp \
asio/detail/hash_map.hpp \
asio/detail/io_control.hpp \
asio/detail/kqueue_reactor.hpp \
asio/detail/kqueue_reactor_fwd.hpp \
asio/detail/mutex.hpp \
asio/detail/noncopyable.hpp \
asio/detail/null_event.hpp \
asio/detail/null_mutex.hpp \
asio/detail/null_signal_blocker.hpp \
asio/detail/null_thread.hpp \
asio/detail/null_tss_ptr.hpp \
asio/detail/old_win_sdk_compat.hpp \
asio/detail/pipe_select_interrupter.hpp \
asio/detail/pop_options.hpp \
asio/detail/posix_event.hpp \
asio/detail/posix_mutex.hpp \
asio/detail/posix_signal_blocker.hpp \
asio/detail/posix_thread.hpp \
asio/detail/posix_tss_ptr.hpp \
asio/detail/push_options.hpp \
asio/detail/reactive_deadline_timer_service.hpp \
asio/detail/reactive_socket_service.hpp \
asio/detail/reactor_op_queue.hpp \
asio/detail/reactor_timer_queue.hpp \
asio/detail/resolver_service.hpp \
asio/detail/scoped_lock.hpp \
asio/detail/select_interrupter.hpp \
asio/detail/select_reactor.hpp \
asio/detail/select_reactor_fwd.hpp \
asio/detail/service_registry.hpp \
asio/detail/signal_blocker.hpp \
asio/detail/signal_init.hpp \
asio/detail/socket_holder.hpp \
asio/detail/socket_ops.hpp \
asio/detail/socket_option.hpp \
asio/detail/socket_select_interrupter.hpp \
asio/detail/socket_types.hpp \
asio/detail/strand_service.hpp \
asio/detail/task_io_service.hpp \
asio/detail/task_io_service_fwd.hpp \
asio/detail/thread.hpp \
asio/detail/tss_ptr.hpp \
asio/detail/win_event.hpp \
asio/detail/win_iocp_io_service.hpp \
asio/detail/win_iocp_io_service_fwd.hpp \
asio/detail/win_iocp_operation.hpp \
asio/detail/win_iocp_socket_service.hpp \
asio/detail/win_local_free_on_block_exit.hpp \
asio/detail/win_mutex.hpp \
asio/detail/win_signal_blocker.hpp \
asio/detail/win_thread.hpp \
asio/detail/win_tss_ptr.hpp \
asio/detail/winsock_init.hpp \
asio/detail/wrapped_handler.hpp \
asio/error.hpp \
asio/error_handler.hpp \
asio/handler_alloc_hook.hpp \
asio/impl/io_service.ipp \
asio/impl/read.ipp \
asio/impl/read_until.ipp \
asio/impl/write.ipp \
asio/io_service.hpp \
asio/ip/address.hpp \
asio/ip/address_v4.hpp \
asio/ip/address_v6.hpp \
asio/ip/basic_endpoint.hpp \
asio/ip/basic_resolver_entry.hpp \
asio/ip/basic_resolver_iterator.hpp \
asio/ip/basic_resolver_query.hpp \
asio/ip/detail/socket_option.hpp \
asio/ip/host_name.hpp \
asio/ip/multicast.hpp \
asio/ip/resolver_query_base.hpp \
asio/ip/tcp.hpp \
asio/ip/udp.hpp \
asio/is_read_buffered.hpp \
asio/is_write_buffered.hpp \
asio/placeholders.hpp \
asio/read.hpp \
asio/read_until.hpp \
asio/resolver_service.hpp \
asio/socket_acceptor_service.hpp \
asio/socket_base.hpp \
asio/ssl/basic_context.hpp \
asio/ssl/context.hpp \
asio/ssl/context_base.hpp \
asio/ssl/context_service.hpp \
asio/ssl/detail/openssl_context_service.hpp \
asio/ssl/detail/openssl_init.hpp \
asio/ssl/detail/openssl_operation.hpp \
asio/ssl/detail/openssl_stream_service.hpp \
asio/ssl/detail/openssl_types.hpp \
asio/ssl/stream.hpp \
asio/ssl/stream_base.hpp \
asio/ssl/stream_service.hpp \
asio/ssl.hpp \
asio/strand.hpp \
asio/strand_service.hpp \
asio/stream_socket_service.hpp \
asio/streambuf.hpp \
asio/system_exception.hpp \
asio/thread.hpp \
asio/time_traits.hpp \
asio/write.hpp \
asio.hpp

View File

@ -63,7 +63,8 @@ namespace libtorrent
struct TORRENT_EXPORT file_entry struct TORRENT_EXPORT file_entry
{ {
boost::filesystem::path path; boost::filesystem::path path;
size_type size; size_type offset; // the offset of this file inside the torrent
size_type size; // the size of this file
}; };
struct TORRENT_EXPORT file_slice struct TORRENT_EXPORT file_slice

View File

@ -55,5 +55,5 @@ $(top_srcdir)/include/libtorrent/version.hpp
libtorrent_la_LDFLAGS = $(LDFLAGS) -version-info 1:0:1 libtorrent_la_LDFLAGS = $(LDFLAGS) -version-info 1:0:1
libtorrent_la_LIBADD = @ZLIB@ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ libtorrent_la_LIBADD = @ZLIB@ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@
AM_CXXFLAGS= -ftemplate-depth-50 -I$(top_srcdir)/include -I$(top_srcdir)/asio/include @ZLIBINCL@ @DEBUGFLAGS@ @PTHREAD_CFLAGS@ AM_CXXFLAGS= -ftemplate-depth-50 -I$(top_srcdir)/include @ZLIBINCL@ @DEBUGFLAGS@ @PTHREAD_CFLAGS@
AM_LDFLAGS= $(LDFLAGS) -L./ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ AM_LDFLAGS= $(LDFLAGS) -L./ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@

View File

@ -375,7 +375,7 @@ namespace libtorrent
} }
#endif #endif
tcp::resolver::query q(*connect_to_host, "https"); tcp::resolver::query q(*connect_to_host, 0);
m_name_lookup.async_resolve(q m_name_lookup.async_resolve(q
, boost::bind(&http_tracker_connection::name_lookup, self(), _1, _2)); , boost::bind(&http_tracker_connection::name_lookup, self(), _1, _2));
set_timeout(m_settings.tracker_completion_timeout set_timeout(m_settings.tracker_completion_timeout

View File

@ -955,7 +955,7 @@ namespace libtorrent
= parse_url_components(url); = parse_url_components(url);
m_resolving_web_seeds.insert(url); m_resolving_web_seeds.insert(url);
tcp::resolver::query q(hostname, "http"); tcp::resolver::query q(hostname, 0);
m_host_resolver.async_resolve(q, bind(&torrent::on_name_lookup m_host_resolver.async_resolve(q, bind(&torrent::on_name_lookup
, shared_from_this(), _1, _2, port, url)); , shared_from_this(), _1, _2, port, url));

View File

@ -87,7 +87,7 @@ namespace
i != list->end(); ++i) i != list->end(); ++i)
{ {
if (i->string() != "..") if (i->string() != "..")
target.path /= i->string(); target.path /= i->string();
} }
if (target.path.is_complete()) throw std::runtime_error("torrent contains " if (target.path.is_complete()) throw std::runtime_error("torrent contains "
"a file with an absolute path: '" "a file with an absolute path: '"
@ -97,10 +97,13 @@ namespace
void extract_files(const entry::list_type& list, std::vector<file_entry>& target void extract_files(const entry::list_type& list, std::vector<file_entry>& target
, std::string const& root_dir) , std::string const& root_dir)
{ {
size_type offset = 0;
for (entry::list_type::const_iterator i = list.begin(); i != list.end(); ++i) for (entry::list_type::const_iterator i = list.begin(); i != list.end(); ++i)
{ {
target.push_back(file_entry()); target.push_back(file_entry());
extract_single_file(*i, target.back(), root_dir); extract_single_file(*i, target.back(), root_dir);
target.back().offset = offset;
offset += target.back().size;
} }
} }
@ -224,6 +227,7 @@ namespace libtorrent
// field. // field.
file_entry e; file_entry e;
e.path = m_name; e.path = m_name;
e.offset = 0;
e.size = info["length"].integer(); e.size = info["length"].integer();
m_files.push_back(e); m_files.push_back(e);
} }
@ -666,9 +670,9 @@ namespace libtorrent
peer_request torrent_info::map_file(int file_index, size_type file_offset peer_request torrent_info::map_file(int file_index, size_type file_offset
, int size) const , int size) const
{ {
size_type offset = file_offset; assert(file_index < (int)m_files.size());
for (int i = 0; i < file_index; ++i) assert(file_index >= 0);
offset += file_at(i).size; size_type offset = file_offset + m_files[file_index].offset;
peer_request ret; peer_request ret;
ret.piece = offset / piece_length(); ret.piece = offset / piece_length();

View File

@ -90,7 +90,7 @@ namespace libtorrent
, m_attempts(0) , m_attempts(0)
{ {
m_socket.reset(new datagram_socket(d)); m_socket.reset(new datagram_socket(d));
tcp::resolver::query q(hostname, "http"); tcp::resolver::query q(hostname, 0);
m_name_lookup.async_resolve(q m_name_lookup.async_resolve(q
, boost::bind(&udp_tracker_connection::name_lookup, self(), _1, _2)); , boost::bind(&udp_tracker_connection::name_lookup, self(), _1, _2));
set_timeout(m_settings.tracker_completion_timeout set_timeout(m_settings.tracker_completion_timeout

View File

@ -24,5 +24,5 @@ test_metadata_extension_LDADD = $(top_builddir)/src/libtorrent.la
noinst_HEADERS = test.hpp setup_transfer.hpp noinst_HEADERS = test.hpp setup_transfer.hpp
AM_CXXFLAGS=-ftemplate-depth-50 -I$(top_srcdir)/include -I$(top_srcdir)/asio/include @DEBUGFLAGS@ @PTHREAD_CFLAGS@ AM_CXXFLAGS=-ftemplate-depth-50 -I$(top_srcdir)/include @DEBUGFLAGS@ @PTHREAD_CFLAGS@
AM_LDFLAGS= -L./ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ AM_LDFLAGS= -L./ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@