allocated and used as receive buffer, respectively.</dd>
</dl>
<aname="num_hashfails"></a><dlclass="docutils">
<dt>num_hashfails</dt>
<dd>the number of pieces this peer has participated in
sending us that turned out to fail the hash check.</dd>
</dl>
<aname="country[2]"></a><dlclass="docutils">
<dt>country[2]</dt>
<dd>the two letter <aclass="reference external"href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166 country code</a> for the country the peer
is connected from. If the country hasn't been resolved yet, both chars are set
to 0. If the resolution failed for some reason, the field is set to "--". If the
resolution service returns an invalid country code, it is set to "!!".
The <ttclass="docutils literal">countries.nerd.dk</tt> service is used to look up countries. This field will
remain set to 0 unless the torrent is set to resolve countries, see <aclass="reference internal"href="#resolve-countries">resolve_countries()</a>.</dd>
</dl>
<aname="inet_as_name"></a><dlclass="docutils">
<dt>inet_as_name</dt>
<dd>the name of the AS this peer is located in. This might be
an empty string if there is no name in the geo ip database.</dd>
</dl>
<aname="inet_as"></a><dlclass="docutils">
<dt>inet_as</dt>
<dd>the AS number the peer is located in.</dd>
</dl>
<aname="load_balancing"></a><dlclass="docutils">
<dt>load_balancing</dt>
<dd>a measurement of the balancing of free download (that we get)
and free upload that we give. Every peer gets a certain amount of free upload, but
this member says how much <em>extra</em> free upload this peer has got. If it is a negative
number it means that this was a peer from which we have got this amount of free
<dd>the index of the piece in which the range starts.</dd>
</dl>
<aname="start"></a><dlclass="docutils">
<dt>start</dt>
<dd>the offset within that piece where the range starts.</dd>
</dl>
<aname="length"></a><dlclass="docutils">
<dt>length</dt>
<dd>the size of the range, in bytes.</dd>
</dl>
<aname="piece_block_progress"></a></div>
<divclass="section"id="piece-block-progress">
<h1>piece_block_progress</h1>
<p>Declared in "<aclass="reference external"href="../include/libtorrent/piece_block_progress.hpp">libtorrent/piece_block_progress.hpp</a>"</p>
<p>Declared in "<aclass="reference external"href="../include/libtorrent/torrent_handle.hpp">libtorrent/torrent_handle.hpp</a>"</p>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="29%"/>
<colwidth="25%"/>
<colwidth="46%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">name</th>
<thclass="head">value</th>
<thclass="head">description</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>none</td>
<td>0</td>
<td> </td>
</tr>
<tr><td>slow</td>
<td>1</td>
<td> </td>
</tr>
<tr><td>medium</td>
<td>2</td>
<td> </td>
</tr>
<tr><td>fast</td>
<td>3</td>
<td> </td>
</tr>
</tbody>
</table>
<aname="piece_index"></a><dlclass="docutils">
<dt>piece_index</dt>
<dd>the index of the piece in question. <ttclass="docutils literal">blocks_in_piece</tt> is the
number of blocks in this particular piece. This number will be the same for most pieces, but
the last piece may have fewer blocks than the standard pieces.</dd>
</dl>
<aname="finished"></a><dlclass="docutils">
<dt>finished</dt>
<dd>the number of blocks in the finished state</dd>
</dl>
<aname="writing"></a><dlclass="docutils">
<dt>writing</dt>
<dd>the number of blocks in the writing state</dd>
</dl>
<aname="requested"></a><dlclass="docutils">
<dt>requested</dt>
<dd>the number of blocks in the requested state</dd>
</dl>
<aname="blocks"></a><dlclass="docutils">
<dt>blocks</dt>
<dd><pclass="first">this is an array of <ttclass="docutils literal">blocks_in_piece</tt> number of
items. One for each block in the piece.</p>
<divclass="warning last">
<pclass="first admonition-title">Warning</p>
<pclass="last">This is a pointer that points to an array
that's owned by the <aclass="reference external"href="reference-Session.html#session">session</a> object. The next time
<aclass="reference external"href="reference-Core.html#get_download_queue()">get_download_queue()</a> is called, it will be invalidated.</p>
</div>
</dd>
</dl>
<aname="piece_state"></a><dlclass="docutils">
<dt>piece_state</dt>
<dd><pclass="first">the download speed class this piece falls into.
this is used internally to cluster peers of the same
speed class together when requesting blocks.</p>
<pclass="last">set to either <ttclass="docutils literal">fast</tt>, <ttclass="docutils literal">medium</tt>, <ttclass="docutils literal">slow</tt> or <ttclass="docutils literal">none</tt>. It tells which
download rate category the peers downloading this piece falls into. <ttclass="docutils literal">none</tt> means that no
peer is currently downloading any part of the piece. Peers prefer picking pieces from
the same category as themselves. The reason for this is to keep the number of partially
downloaded pieces down. Pieces set to <ttclass="docutils literal">none</tt> can be converted into any of <ttclass="docutils literal">fast</tt>,
<ttclass="docutils literal">medium</tt> or <ttclass="docutils literal">slow</tt> as soon as a peer want to download from it.</p>
</dd>
</dl>
<aname="torrent_handle"></a></div>
</div>
<divclass="section"id="torrent-handle">
<h1>torrent_handle</h1>
<p>Declared in "<aclass="reference external"href="../include/libtorrent/torrent_handle.hpp">libtorrent/torrent_handle.hpp</a>"</p>
<p>You will usually have to store your torrent handles somewhere, since it's the
object through which you retrieve information about the torrent and aborts the torrent.</p>
<divclass="warning">
<pclass="first admonition-title">Warning</p>
<pclass="last">Any member function that returns a value or fills in a value has to
be made synchronously. This means it has to wait for the main thread
to complete the query before it can return. This might potentially be
expensive if done from within a GUI thread that needs to stay responsive.
Try to avoid quering for information you don't need, and try to do it
in as few calls as possible. You can get most of the interesting information
about a torrent from the torrent_handle::status() call.</p>
</div>
<p>The default constructor will initialize the handle to an invalid state. Which
means you cannot perform any operation on it, unless you first assign it a
valid handle. If you try to perform any operation on an uninitialized handle,
it will throw <ttclass="docutils literal">invalid_handle</tt>.</p>
<divclass="warning">
<pclass="first admonition-title">Warning</p>
<pclass="last">All operations on a <aclass="reference external"href="reference-Core.html#torrent_handle">torrent_handle</a> may throw <aclass="reference external"href="reference-Error_Codes.html#libtorrent_exception">libtorrent_exception</a>
exception, in case the handle is no longer refering to a torrent. There is
one exception <aclass="reference external"href="reference-Core.html#is_valid()">is_valid()</a> will never throw.
Since the torrents are processed by a background thread, there is no
guarantee that a handle will remain valid between two calls.</p>
<p>This function will write <ttclass="docutils literal">data</tt> to the storage as piece <ttclass="docutils literal">piece</tt>, as if it had
been downloaded from a peer. <ttclass="docutils literal">data</tt> is expected to point to a buffer of as many
bytes as the size of the specified piece. The data in the buffer is copied and
passed on to the disk IO thread to be written at a later point.</p>
<p>By default, data that's already been downloaded is not overwritten by this buffer. If
you trust this data to be correct (and pass the piece hash check) you may pass the
overwrite_existing flag. This will instruct libtorrent to overwrite any data that
may already have been downloaded with this data.</p>
<p>Since the data is written asynchronously, you may know that is passed or failed the
hash check by waiting for <aclass="reference external"href="reference-Alerts.html#piece_finished_alert">piece_finished_alert</a> or <aclass="reference external"href="reference-Alerts.html#hash_failed_alert">hash_failed_alert</a>.</p>
<p>This function starts an asynchronous read operation of the specified piece from
this torrent. You must have completed the download of the specified piece before
calling this function.</p>
<p>When the read operation is completed, it is passed back through an <aclass="reference external"href="reference-Alerts.html#alert">alert</a>,
<aclass="reference external"href="reference-Alerts.html#read_piece_alert">read_piece_alert</a>. Since this <aclass="reference external"href="reference-Alerts.html#alert">alert</a> is a reponse to an explicit call, it will
always be posted, regardless of the <aclass="reference external"href="reference-Alerts.html#alert">alert</a> mask.</p>
<p>Note that if you read multiple pieces, the read operations are not guaranteed to
finish in the same order as you initiated them.</p>
<p>takes a reference to a vector that will be cleared and filled
with one <aclass="reference external"href="reference-Bencoding.html#entry">entry</a> for each peer connected to this torrent, given the handle is valid. If the
<aclass="reference external"href="reference-Core.html#torrent_handle">torrent_handle</a> is invalid, it will throw <aclass="reference external"href="reference-Error_Codes.html#libtorrent_exception">libtorrent_exception</a> exception. Each <aclass="reference external"href="reference-Bencoding.html#entry">entry</a> in
the vector contains information about that particular peer. See <aclass="reference external"href="reference-Core.html#peer_info">peer_info</a>.</p>
<p><ttclass="docutils literal">status()</tt> will return a structure with information about the status of this
torrent. If the <aclass="reference external"href="reference-Core.html#torrent_handle">torrent_handle</a> is invalid, it will throw <aclass="reference external"href="reference-Error_Codes.html#libtorrent_exception">libtorrent_exception</a> exception.
See <aclass="reference external"href="reference-Core.html#torrent_status">torrent_status</a>. The <ttclass="docutils literal">flags</tt> argument filters what information is returned
in the <aclass="reference external"href="reference-Core.html#torrent_status">torrent_status</a>. Some information in there is relatively expensive to calculate, and
if you're not interested in it (and see performance issues), you can filter them out.</p>
<p>By default everything is included. The flags you can use to decide what to <em>include</em> are
defined in the <aclass="reference external"href="reference-Core.html#status_flags_t">status_flags_t</a> enum.</p>
<p><ttclass="docutils literal">get_download_queue()</tt> takes a non-const reference to a vector which it will fill with
information about pieces that are partially downloaded or not downloaded at all but partially
requested. See <aclass="reference external"href="reference-Core.html#partial_piece_info">partial_piece_info</a> for the fields in the returned vector.</p>
void <strong>set_piece_deadline</strong> (int index, int deadline, int flags = 0) const;
</pre>
<p>This function sets or resets the deadline associated with a specific piece
index (<ttclass="docutils literal">index</tt>). libtorrent will attempt to download this entire piece before
the deadline expires. This is not necessarily possible, but pieces with a more
recent deadline will always be prioritized over pieces with a deadline further
ahead in time. The deadline (and flags) of a piece can be changed by calling this
function again.</p>
<p>The <ttclass="docutils literal">flags</tt> parameter can be used to ask libtorrent to send an <aclass="reference external"href="reference-Alerts.html#alert">alert</a> once the
piece has been downloaded, by passing alert_when_available. When set, the
<aclass="reference external"href="reference-Alerts.html#read_piece_alert">read_piece_alert</a><aclass="reference external"href="reference-Alerts.html#alert">alert</a> will be delivered, with the piece data, when it's downloaded.</p>
<p>If the piece is already downloaded when this call is made, nothing happens, unless
the alert_when_available flag is set, in which case it will do the same thing
as calling <aclass="reference external"href="reference-Core.html#read_piece()">read_piece()</a> for <ttclass="docutils literal">index</tt>.</p>
<p><ttclass="docutils literal">deadline</tt> is the number of milliseconds until this piece should be completed.</p>
<p><ttclass="docutils literal">reset_piece_deadline</tt> removes the deadline from the piece. If it hasn't already
been downloaded, it will no longer be considered a priority.</p>
<p>This sets the bandwidth priority of this torrent. The priority of a torrent determines
how much bandwidth its peers are assigned when distributing upload and download rate quotas.
A high number gives more bandwidth. The priority must be within the range [0, 255].</p>
<p>The default priority is 0, which is the lowest priority.</p>
<p>To query the priority of a torrent, use the <ttclass="docutils literal"><spanclass="pre">torrent_handle::status()</span></tt> call.</p>
<p>Torrents with higher priority will not nececcarily get as much bandwidth as they can
consume, even if there's is more quota. Other peers will still be weighed in when
bandwidth is being distributed. With other words, bandwidth is not distributed strictly
in order of priority, but the priority is used as a weight.</p>
<p>Peers whose Torrent has a higher priority will take precedence when distributing unchoke slots.
This is a strict prioritization where every interested peer on a high priority torrent will
be unchoked before any other, lower priority, torrents have any peers unchoked.</p>
<aname="file_progress()"></a></div>
<divclass="section"id="file-progress">
<h2>file_progress()</h2>
<preclass="literal-block">
void <strong>file_progress</strong> (std::vector<size_type>& progress, int flags = 0) const;
</pre>
<p>This function fills in the supplied vector with the the number of bytes downloaded
of each file in this torrent. The progress values are ordered the same as the files
in the <aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a>. This operation is not very cheap. Its complexity is <em>O(n + mj)</em>.
Where <em>n</em> is the number of files, <em>m</em> is the number of downloading pieces and <em>j</em>
is the number of blocks in a piece.</p>
<p>The <ttclass="docutils literal">flags</tt> parameter can be used to specify the granularity of the file progress. If
left at the default value of 0, the progress will be as accurate as possible, but also
more expensive to calculate. If <ttclass="docutils literal"><spanclass="pre">torrent_handle::piece_granularity</span></tt> is specified,
the progress will be specified in piece granularity. i.e. only pieces that have been
fully downloaded and passed the hash check count. When specifying piece granularity,
the operation is a lot cheaper, since libtorrent already keeps track of this internally
and no calculation is required.</p>
<aname="clear_error()"></a></div>
<divclass="section"id="clear-error">
<h2>clear_error()</h2>
<preclass="literal-block">
void <strong>clear_error</strong> () const;
</pre>
<p>If the torrent is in an error state (i.e. <ttclass="docutils literal"><spanclass="pre">torrent_status::error</span></tt> is non-empty), this
will clear the error and start the torrent again.</p>
<p><ttclass="docutils literal">trackers()</tt> will return the list of trackers for this torrent. The
announce <aclass="reference external"href="reference-Bencoding.html#entry">entry</a> contains both a string <ttclass="docutils literal">url</tt> which specify the announce url
for the tracker as well as an int <ttclass="docutils literal">tier</tt>, which is specifies the order in
which this tracker is tried. If you want libtorrent to use another list of
trackers for this torrent, you can use <ttclass="docutils literal">replace_trackers()</tt> which takes
a list of the same form as the one returned from <ttclass="docutils literal">trackers()</tt> and will
replace it. If you want an immediate effect, you have to call
<aclass="reference external"href="reference-Core.html#force_reannounce()">force_reannounce()</a>. See <aclass="reference external"href="reference-Core.html#announce_entry">announce_entry</a>.</p>
<p><ttclass="docutils literal">add_tracker()</tt> will look if the specified tracker is already in the set.
If it is, it doesn't do anything. If it's not in the current set of trackers,
it will insert it in the tier specified in the <aclass="reference external"href="reference-Core.html#announce_entry">announce_entry</a>.</p>
<p>The updated set of trackers will be saved in the resume data, and when a torrent
is started with resume data, the trackers from the resume data will replace the
<p>These functions are identical as the <ttclass="docutils literal">*_url_seed()</tt> variants, but they
operate on <aclass="reference external"href="http://bittorrent.org/beps/bep_0017.html">BEP 17</a> web seeds instead of <aclass="reference external"href="http://bittorrent.org/beps/bep_0019.html">BEP 19</a>.</p>
<p>See <aclass="reference external"href="manual-ref.html#http-seeding">http seeding</a> for more information.</p>
<p>add the specified extension to this torrent. The <ttclass="docutils literal">ext</tt> argument is
a function that will be called from within libtorrent's context
passing in the internal torrent object and the specified userdata
pointer. The function is expected to return a shared pointer to
a <aclass="reference external"href="reference-Plugins.html#torrent_plugin">torrent_plugin</a> instance.</p>
<aname="set_metadata()"></a></div>
<divclass="section"id="set-metadata">
<h2>set_metadata()</h2>
<preclass="literal-block">
bool <strong>set_metadata</strong> (char const* metadata, int size) const;
</pre>
<p><ttclass="docutils literal">set_metadata</tt> expects the <em>info</em> section of metadata. i.e. The buffer passed in will be
hashed and verified against the info-hash. If it fails, a <ttclass="docutils literal">metadata_failed_alert</tt> will be
generated. If it passes, a <ttclass="docutils literal">metadata_received_alert</tt> is generated. The function returns
true if the metadata is successfully set on the torrent, and false otherwise. If the torrent
already has metadata, this function will not affect the torrent, and false will be returned.</p>
<aname="is_valid()"></a></div>
<divclass="section"id="is-valid">
<h2>is_valid()</h2>
<preclass="literal-block">
bool <strong>is_valid</strong> () const;
</pre>
<p>Returns true if this handle refers to a valid torrent and false if it hasn't been initialized
or if the torrent it refers to has been aborted. Note that a handle may become invalid after
it has been added to the <aclass="reference external"href="reference-Session.html#session">session</a>. Usually this is because the storage for the torrent is
somehow invalid or if the filenames are not allowed (and hence cannot be opened/created) on
your filesystem. If such an error occurs, a <aclass="reference external"href="reference-Alerts.html#file_error_alert">file_error_alert</a> is generated and all handles
that refers to that torrent will become invalid.</p>
<p><ttclass="docutils literal">pause()</tt>, and <ttclass="docutils literal">resume()</tt> will disconnect all peers and reconnect all peers respectively.
When a torrent is paused, it will however remember all share ratios to all peers and remember
all potential (not connected) peers. Torrents may be paused automatically if there is a file
error (e.g. disk full) or something similar. See <aclass="reference external"href="reference-Alerts.html#file_error_alert">file_error_alert</a>.</p>
<p>To know if a torrent is paused or not, call <ttclass="docutils literal"><spanclass="pre">torrent_handle::status()</span></tt> and inspect
<p>The <ttclass="docutils literal">flags</tt> argument to pause can be set to <ttclass="docutils literal"><spanclass="pre">torrent_handle::graceful_pause</span></tt> which will
delay the disconnect of peers that we're still downloading outstanding requests from. The torrent
will not accept any more requests and will disconnect all idle peers. As soon as a peer is
done transferring the blocks that were requested from it, it is disconnected. This is a graceful
shut down of the torrent in the sense that no downloaded bytes are wasted.</p>
<p>torrents that are auto-managed may be automatically resumed again. It does not make sense to
pause an auto-managed torrent without making it not automanaged first. Torrents are auto-managed
by default when added to the <aclass="reference external"href="reference-Session.html#session">session</a>. For more information, see <aclass="reference external"href="manual-ref.html#queuing">queuing</a>.</p>
<aname="set_upload_mode()"></a></div>
<divclass="section"id="set-upload-mode">
<h2>set_upload_mode()</h2>
<preclass="literal-block">
void <strong>set_upload_mode</strong> (bool b) const;
</pre>
<p>Explicitly sets the upload mode of the torrent. In upload mode, the torrent will not
request any pieces. If the torrent is auto managed, it will automatically be taken out
of upload mode periodically (see <ttclass="docutils literal"><spanclass="pre">session_settings::optimistic_disk_retry</span></tt>). Torrents
are automatically put in upload mode whenever they encounter a disk write error.</p>
<p><ttclass="docutils literal">m</tt> should be true to enter upload mode, and false to leave it.</p>
<p>To test if a torrent is in upload mode, call <ttclass="docutils literal"><spanclass="pre">torrent_handle::status()</span></tt> and inspect
void <strong>set_share_mode</strong> (bool b) const;
</pre>
<p>Enable or disable share mode for this torrent. When in share mode, the torrent will
not necessarily be downloaded, especially not the whole of it. Only parts that are likely
to be distributed to more than 2 other peers are downloaded, and only if the previous
prediction was correct.</p>
<aname="flush_cache()"></a></div>
<divclass="section"id="flush-cache">
<h2>flush_cache()</h2>
<preclass="literal-block">
void <strong>flush_cache</strong> () const;
</pre>
<p>Instructs libtorrent to flush all the disk caches for this torrent and close all
file handles. This is done asynchronously and you will be notified that it's complete
through <aclass="reference external"href="reference-Alerts.html#cache_flushed_alert">cache_flushed_alert</a>.</p>
<p>Note that by the time you get the <aclass="reference external"href="reference-Alerts.html#alert">alert</a>, libtorrent may have cached more data for the
torrent, but you are guaranteed that whatever cached data libtorrent had by the time
you called <ttclass="docutils literal"><spanclass="pre">torrent_handle::flush_cache()</span></tt> has been written to disk.</p>
<aname="apply_ip_filter()"></a></div>
<divclass="section"id="apply-ip-filter">
<h2>apply_ip_filter()</h2>
<preclass="literal-block">
void <strong>apply_ip_filter</strong> (bool b) const;
</pre>
<p>Set to true to apply the <aclass="reference external"href="reference-Session.html#session">session</a> global IP filter to this torrent (which is the
default). Set to false to make this torrent ignore the IP filter.</p>
<aname="force_recheck()"></a></div>
<divclass="section"id="force-recheck">
<h2>force_recheck()</h2>
<preclass="literal-block">
void <strong>force_recheck</strong> () const;
</pre>
<p><ttclass="docutils literal">force_recheck</tt> puts the torrent back in a state where it assumes to have no resume data.
All peers will be disconnected and the torrent will stop announcing to the tracker. The torrent
will be added to the checking queue, and will be checked (all the files will be read and
compared to the piece hashes). Once the check is complete, the torrent will start connecting
<p><ttclass="docutils literal">save_resume_data()</tt> generates fast-resume data and returns it as an <aclass="reference external"href="reference-Bencoding.html#entry">entry</a>. This <aclass="reference external"href="reference-Bencoding.html#entry">entry</a>
is suitable for being bencoded. For more information about how fast-resume works, see <aclass="reference external"href="manual-ref.html#fast-resume">fast resume</a>.</p>
<p>The <ttclass="docutils literal">flags</tt> argument is a bitmask of flags ORed together. see <aclass="reference external"href="reference-Core.html#save_resume_flags_t">save_resume_flags_t</a></p>
<p>This operation is asynchronous, <ttclass="docutils literal">save_resume_data</tt> will return immediately. The resume data
is delivered when it's done through an <aclass="reference external"href="reference-Alerts.html#save_resume_data_alert">save_resume_data_alert</a>.</p>
<p>The fast resume data will be empty in the following cases:</p>
<blockquote>
<olclass="arabic simple">
<li>The torrent handle is invalid.</li>
<li>The torrent is checking (or is queued for checking) its storage, it will obviously
not be ready to write resume data.</li>
<li>The torrent hasn't received valid metadata and was started without metadata
(see libtorrent's <aclass="reference external"href="manual-ref.html#metadata-from-peers">metadata from peers</a> extension)</li>
</ol>
</blockquote>
<p>Note that by the time you receive the fast resume data, it may already be invalid if the torrent
is still downloading! The recommended practice is to first pause the <aclass="reference external"href="reference-Session.html#session">session</a>, then generate the
fast resume data, and then close it down. Make sure to not <aclass="reference external"href="reference-Session.html#remove_torrent()">remove_torrent()</a> before you receive
the <aclass="reference external"href="reference-Alerts.html#save_resume_data_alert">save_resume_data_alert</a> though. There's no need to pause when saving intermittent resume data.</p>
<divclass="warning">
<pclass="first admonition-title">Warning</p>
<pclass="last">If you pause every torrent individually instead of pausing the <aclass="reference external"href="reference-Session.html#session">session</a>, every torrent
will have its paused state saved in the resume data!</p>
</div>
<divclass="warning">
<pclass="first admonition-title">Warning</p>
<pclass="last">The resume data contains the modification timestamps for all files. If one file has
been modified when the torrent is added again, the will be rechecked. When shutting down, make
sure to flush the disk cache before saving the resume data. This will make sure that the file
timestamps are up to date and won't be modified after saving the resume data. The recommended way
to do this is to pause the torrent, which will flush the cache and disconnect all peers.</p>
</div>
<divclass="note">
<pclass="first admonition-title">Note</p>
<p>It is typically a good idea to save resume data whenever a torrent is completed or paused. In those
cases you don't need to pause the torrent or the <aclass="reference external"href="reference-Session.html#session">session</a>, since the torrent will do no more writing
to its files. If you save resume data for torrents when they are paused, you can accelerate the
shutdown process by not saving resume data again for paused torrents. Completed torrents should
have their resume data saved when they complete and on exit, since their statistics might be updated.</p>
<pclass="last">In full allocation mode the reume data is never invalidated by subsequent
writes to the files, since pieces won't move around. This means that you don't need to
pause before writing resume data in full or sparse mode. If you don't, however, any data written to
disk after you saved resume data and before the <aclass="reference external"href="reference-Session.html#session">session</a> closed is lost.</p>
</div>
<p>It also means that if the resume data is out dated, libtorrent will not re-check the files, but assume
that it is fairly recent. The assumption is that it's better to loose a little bit than to re-check
the entire file.</p>
<p>It is still a good idea to save resume data periodically during download as well as when
closing down.</p>
<p>Example code to pause and save resume data for all torrents and wait for the alerts:</p>
<preclass="literal-block">
extern int outstanding_resume_data; // global counter of outstanding resume data
<p>Every torrent that is added is assigned a queue position exactly one greater than
the greatest queue position of all existing torrents. Torrents that are being
seeded have -1 as their queue position, since they're no longer in line to be downloaded.</p>
<p>When a torrent is removed or turns into a seed, all torrents with greater queue positions
have their positions decreased to fill in the space in the sequence.</p>
<p><ttclass="docutils literal">queue_position()</tt> returns the torrent's position in the download queue. The torrents
with the smallest numbers are the ones that are being downloaded. The smaller number,
the closer the torrent is to the front of the line to be started.</p>
<p>The queue position is also available in the <aclass="reference external"href="reference-Core.html#torrent_status">torrent_status</a>.</p>
<p>The <ttclass="docutils literal"><spanclass="pre">queue_position_*()</span></tt> functions adjust the torrents position in the queue. Up means
closer to the front and down means closer to the back of the queue. Top and bottom refers
to the front and the back of the queue respectively.</p>
<aname="resolve_countries()"></a></div>
<divclass="section"id="resolve-countries">
<h2>resolve_countries()</h2>
<preclass="literal-block">
void <strong>resolve_countries</strong> (bool r);
bool <strong>resolve_countries</strong> () const;
</pre>
<p>Sets or gets the flag that derermines if countries should be resolved for the peers of this
torrent. It defaults to false. If it is set to true, the <aclass="reference external"href="reference-Core.html#peer_info">peer_info</a> structure for the peers
in this torrent will have their <ttclass="docutils literal">country</tt> member set. See <aclass="reference external"href="reference-Core.html#peer_info">peer_info</a> for more information
<p><ttclass="docutils literal">passphrase</tt> may be specified if the private key is encrypted and requires a passphrase to
be decrypted.</p>
<p>Note that when a torrent first starts up, and it needs a certificate, it will suspend connecting
to any peers until it has one. It's typically desirable to resume the torrent after setting the
ssl certificate.</p>
<p>If you receive a <aclass="reference external"href="reference-Alerts.html#torrent_need_cert_alert">torrent_need_cert_alert</a>, you need to call this to provide a valid cert. If you
don't have a cert you won't be allowed to connect to any peers.</p>
<p>Returns a pointer to the <aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a> object associated with this torrent. The
<aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a> object is a copy of the internal object. If the torrent doesn't
have metadata, the object being returned will not be fully filled in.
The torrent may be in a state without metadata only if
it was started without a .torrent file, e.g. by using the libtorrent extension of
<p><ttclass="docutils literal">use_interface()</tt> sets the network interface this torrent will use when it opens outgoing
connections. By default, it uses the same interface as the <aclass="reference external"href="reference-Session.html#session">session</a> uses to listen on. The
parameter must be a string containing one or more, comma separated, ip-address (either an
IPv4 or IPv6 address). When specifying multiple interfaces, the torrent will round-robin
which interface to use for each outgoing conneciton. This is useful for clients that are
<p><ttclass="docutils literal">index</tt> must be in the range [0, number_of_files).</p>
<p><ttclass="docutils literal">file_priority()</tt> queries or sets the priority of file <ttclass="docutils literal">index</tt>.</p>
<p><ttclass="docutils literal">prioritize_files()</tt> takes a vector that has at as many elements as there are
files in the torrent. Each <aclass="reference external"href="reference-Bencoding.html#entry">entry</a> is the priority of that file. The function
sets the priorities of all the pieces in the torrent based on the vector.</p>
<p><ttclass="docutils literal">file_priorities()</tt> returns a vector with the priorities of all files.</p>
<p>The priority values are the same as for <aclass="reference external"href="reference-Core.html#piece_priority()">piece_priority()</a>.</p>
<p>Whenever a file priority is changed, all other piece priorities are reset
to match the file priorities. In order to maintain sepcial priorities for
particular pieces, <aclass="reference external"href="reference-Core.html#piece_priority()">piece_priority()</a> has to be called again for those pieces.</p>
<p>You cannot set the file priorities on a torrent that does not yet
have metadata or a torrent that is a seed. <ttclass="docutils literal">file_priority(int, int)</tt> and
<aclass="reference external"href="reference-Core.html#prioritize_files()">prioritize_files()</a> are both no-ops for such torrents.</p>
<p>forces a reannounce in the specified amount of time.
This overrides the default announce interval, and no
announce will take place until the given time has
timed out.</p>
<aname="scrape_tracker()"></a></div>
<divclass="section"id="scrape-tracker">
<h2>scrape_tracker()</h2>
<preclass="literal-block">
void <strong>scrape_tracker</strong> () const;
</pre>
<p><ttclass="docutils literal">scrape_tracker()</tt> will send a scrape request to the tracker. A scrape request queries the
tracker for statistics such as total number of incomplete peers, complete peers, number of
downloads etc.</p>
<p>This request will specifically update the <ttclass="docutils literal">num_complete</tt> and <ttclass="docutils literal">num_incomplete</tt> fields in
the <aclass="reference external"href="reference-Core.html#torrent_status">torrent_status</a> struct once it completes. When it completes, it will generate a
<aclass="reference external"href="reference-Alerts.html#scrape_reply_alert">scrape_reply_alert</a>. If it fails, it will generate a <aclass="reference external"href="reference-Alerts.html#scrape_failed_alert">scrape_failed_alert</a>.</p>
<p><ttclass="docutils literal">set_upload_limit</tt> will limit the upload bandwidth used by this particular torrent to the
limit you set. It is given as the number of bytes per second the torrent is allowed to upload.
<ttclass="docutils literal">set_download_limit</tt> works the same way but for download bandwidth instead of upload bandwidth.
Note that setting a higher limit on a torrent then the global limit (<ttclass="docutils literal"><spanclass="pre">session_settings::upload_rate_limit</span></tt>)
will not override the global rate limit. The torrent can never upload more than the global rate
limit.</p>
<p><ttclass="docutils literal">upload_limit</tt> and <ttclass="docutils literal">download_limit</tt> will return the current limit setting, for upload and
<p><ttclass="docutils literal">connect_peer()</tt> is a way to manually connect to peers that one believe is a part of the
torrent. If the peer does not respond, or is not a member of this torrent, it will simply
be disconnected. No harm can be done by using this other than an unnecessary connection
attempt is made. If the torrent is uninitialized or in queued or checking mode, this
will throw <aclass="reference external"href="reference-Error_Codes.html#libtorrent_exception">libtorrent_exception</a>. The second (optional) argument will be bitwised ORed into
the source mask of this peer. Typically this is one of the source flags in <aclass="reference external"href="reference-Core.html#peer_info">peer_info</a>.
i.e. <ttclass="docutils literal">tracker</tt>, <ttclass="docutils literal">pex</tt>, <ttclass="docutils literal">dht</tt> etc.</p>
<p><ttclass="docutils literal">set_max_connections()</tt> sets the maximum number of connection this torrent will open. If all
connections are used up, incoming connections may be refused or poor connections may be closed.
This must be at least 2. The default is unlimited number of connections. If -1 is given to the
function, it means unlimited. There is also a global limit of the number of connections, set
by <ttclass="docutils literal">connections_limit</tt> in <aclass="reference external"href="reference-Settings.html#session_settings">session_settings</a>.</p>
<p><ttclass="docutils literal">max_connections()</tt> returns the current settings.</p>
<aname="set_tracker_login()"></a></div>
<divclass="section"id="set-tracker-login">
<h2>set_tracker_login()</h2>
<preclass="literal-block">
void <strong>set_tracker_login</strong> (std::string const& name
, std::string const& password) const;
</pre>
<p>sets a username and password that will be sent along in the HTTP-request
of the tracker announce. Set this if the tracker requires authorization.</p>
<aname="move_storage()"></a></div>
<divclass="section"id="move-storage">
<h2>move_storage()</h2>
<preclass="literal-block">
void <strong>move_storage</strong> (std::string const& save_path, int flags = 0) const;
</pre>
<p>Moves the file(s) that this torrent are currently seeding from or downloading to. If
the given <ttclass="docutils literal">save_path</tt> is not located on the same drive as the original save path,
the files will be copied to the new drive and removed from their original location.
This will block all other disk IO, and other torrents download and upload rates may
drop while copying the file.</p>
<p>Since disk IO is performed in a separate thread, this operation is also asynchronous.
Once the operation completes, the <ttclass="docutils literal">storage_moved_alert</tt> is generated, with the new
path as the message. If the move fails for some reason, <ttclass="docutils literal">storage_moved_failed_alert</tt>
is generated instead, containing the error message.</p>
<p>The <ttclass="docutils literal">flags</tt> argument determines the behavior of the copying/moving of the files
in the torrent. see <aclass="reference external"href="reference-Custom_Storage.html#move_flags_t">move_flags_t</a>.</p>
<blockquote>
<ulclass="simple">
<li>always_replace_files = 0</li>
<li>fail_if_exist = 1</li>
<li>dont_replace = 2</li>
</ul>
</blockquote>
<p><ttclass="docutils literal">always_replace_files</tt> is the default and replaces any file that exist in both the
source directory and the target directory.</p>
<p><ttclass="docutils literal">fail_if_exist</tt> first check to see that none of the copy operations would cause an
overwrite. If it would, it will fail. Otherwise it will proceed as if it was in
<ttclass="docutils literal">always_replace_files</tt> mode. Note that there is an inherent race condition here.
If the files in the target directory appear after the check but before the copy
or move completes, they will be overwritten. When failing because of files already
existing in the target path, the <ttclass="docutils literal">error</tt> of <ttclass="docutils literal">move_storage_failed_alert</tt> is set
to <ttclass="docutils literal"><spanclass="pre">boost::system::errc::file_exists</span></tt>.</p>
<p>The intention is that a client may use this as a probe, and if it fails, ask the user
which mode to use. The client may then re-issue the <ttclass="docutils literal">move_storage</tt> call with one
of the other modes.</p>
<p><ttclass="docutils literal">dont_replace</tt> always takes the existing file in the target directory, if there is
one. The source files will still be removed in that case.</p>
<p>Files that have been renamed to have absolute pahts are not moved by this function.
Keep in mind that files that don't belong to the torrent but are stored in the torrent's
directory may be moved as well. This goes for files that have been renamed to
absolute paths that still end up inside the save path.</p>
<p>Renames the file with the given index asynchronously. The rename operation is complete
when either a <aclass="reference external"href="reference-Alerts.html#file_renamed_alert">file_renamed_alert</a> or <aclass="reference external"href="reference-Alerts.html#file_rename_failed_alert">file_rename_failed_alert</a> is posted.</p>
<p>This function is intended only for use by plugins and the <aclass="reference external"href="reference-Alerts.html#alert">alert</a> dispatch function. Any code
that runs in libtorrent's network thread may not use the public API of <aclass="reference external"href="reference-Core.html#torrent_handle">torrent_handle</a>.
Doing so results in a dead-lock. For such routines, the <ttclass="docutils literal">native_handle</tt> gives access to the
underlying type representing the torrent. This type does not have a stable API and should
be relied on as little as possible.</p>
<aname="flags_t"></a></div>
<divclass="section"id="id109">
<h2>enum flags_t</h2>
<p>Declared in "<aclass="reference external"href="../include/libtorrent/torrent_handle.hpp">libtorrent/torrent_handle.hpp</a>"</p>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="50%"/>
<colwidth="18%"/>
<colwidth="33%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">name</th>
<thclass="head">value</th>
<thclass="head">description</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>overwrite_existing</td>
<td>1</td>
<td> </td>
</tr>
</tbody>
</table>
<aname="status_flags_t"></a></div>
<divclass="section"id="enum-status-flags-t">
<h2>enum status_flags_t</h2>
<p>Declared in "<aclass="reference external"href="../include/libtorrent/torrent_handle.hpp">libtorrent/torrent_handle.hpp</a>"</p>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="25%"/>
<colwidth="5%"/>
<colwidth="70%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">name</th>
<thclass="head">value</th>
<thclass="head">description</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>query_distributed_copies</td>
<td>1</td>
<td>calculates <ttclass="docutils literal">distributed_copies</tt>, <ttclass="docutils literal">distributed_full_copies</tt> and <ttclass="docutils literal">distributed_fraction</tt>.</td>
</tr>
<tr><td>query_accurate_download_counters</td>
<td>2</td>
<td>includes partial downloaded blocks in <ttclass="docutils literal">total_done</tt> and <ttclass="docutils literal">total_wanted_done</tt>.</td>
<p>Declared in "<aclass="reference external"href="../include/libtorrent/torrent_handle.hpp">libtorrent/torrent_handle.hpp</a>"</p>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="49%"/>
<colwidth="18%"/>
<colwidth="33%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">name</th>
<thclass="head">value</th>
<thclass="head">description</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>piece_granularity</td>
<td>1</td>
<td> </td>
</tr>
</tbody>
</table>
<aname="pause_flags_t"></a></div>
<divclass="section"id="enum-pause-flags-t">
<h2>enum pause_flags_t</h2>
<p>Declared in "<aclass="reference external"href="../include/libtorrent/torrent_handle.hpp">libtorrent/torrent_handle.hpp</a>"</p>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="44%"/>
<colwidth="19%"/>
<colwidth="36%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">name</th>
<thclass="head">value</th>
<thclass="head">description</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>graceful_pause</td>
<td>1</td>
<td> </td>
</tr>
</tbody>
</table>
<aname="save_resume_flags_t"></a></div>
<divclass="section"id="enum-save-resume-flags-t">
<h2>enum save_resume_flags_t</h2>
<p>Declared in "<aclass="reference external"href="../include/libtorrent/torrent_handle.hpp">libtorrent/torrent_handle.hpp</a>"</p>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="15%"/>
<colwidth="6%"/>
<colwidth="79%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">name</th>
<thclass="head">value</th>
<thclass="head">description</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>flush_disk_cache</td>
<td>1</td>
<td>the disk cache will be flushed before creating the resume data. This avoids a problem with
file timestamps in the resume data in case the cache hasn't been flushed yet.</td>
</tr>
<tr><td>save_info_dict</td>
<td>2</td>
<td>the resume data will contain the metadata
from the torrent file as well. This is default for any torrent that's added without a torrent
file (such as a magnet link or a URL).</td>
</tr>
</tbody>
</table>
<aname="torrent_status"></a></div>
</div>
<divclass="section"id="torrent-status">
<h1>torrent_status</h1>
<p>Declared in "<aclass="reference external"href="../include/libtorrent/torrent_handle.hpp">libtorrent/torrent_handle.hpp</a>"</p>
<p>holds a snapshot of the status of a torrent, as queried by <aclass="reference external"href="reference-Core.html#status()">torrent_handle::status()</a>.</p>
<dd>the name of the torrent. Typically this is derived from the
.torrent file. In case the torrent was started without metadata,
and hasn't completely received it yet, it returns the name given
to it when added to the <aclass="reference external"href="reference-Session.html#session">session</a>. See <ttclass="docutils literal"><spanclass="pre">session::add_torrent</span></tt>.
This field is only included if the torrent status is queried
with <ttclass="docutils literal"><spanclass="pre">torrent_handle::query_name</span></tt>.</dd>
</dl>
<aname="torrent_file"></a><dlclass="docutils">
<dt>torrent_file</dt>
<dd>set to point to the <ttclass="docutils literal">torrent_info</tt> object for this torrent. It's
only included if the torrent status is queried with
<dd>the time the tracker want us to wait until we announce ourself
again the next time.</dd>
</dl>
<aname="current_tracker"></a><dlclass="docutils">
<dt>current_tracker</dt>
<dd>the URL of the last working tracker. If no tracker request has
been successful yet, it's set to an empty string.</dd>
</dl>
<aname="total_download"></a>
<aname="total_upload"></a><dlclass="docutils">
<dt>total_download total_upload</dt>
<dd>the number of bytes downloaded and
uploaded to all peers, accumulated, <em>this session</em> only. The <aclass="reference external"href="reference-Session.html#session">session</a> is considered
to restart when a torrent is paused and restarted again. When a torrent is paused,
these counters are reset to 0. If you want complete, persistent, stats, see
<ttclass="docutils literal">all_time_upload</tt> and <ttclass="docutils literal">all_time_download</tt>.</dd>
send and received this <aclass="reference external"href="reference-Session.html#session">session</a>, but only the actual payload data (i.e the interesting
data), these counters ignore any protocol overhead.</dd>
<dd>The allocation mode for the torrent. See <aclass="reference external"href="reference-Storage.html#storage_mode_t">storage_mode_t</a> for the options.
For more information, see <aclass="reference external"href="manual-ref.html#storage-allocation">storage allocation</a>.</dd>
</dl>
<aname="progress"></a><dlclass="docutils">
<dt>progress</dt>
<dd>a value in the range [0, 1], that represents the progress of the
torrent's current task. It may be checking files or downloading.</dd>
</dl>
<aname="progress_ppm"></a><dlclass="docutils">
<dt>progress_ppm</dt>
<dd>reflects the same value as <ttclass="docutils literal">progress</tt>, but instead in a range
[0, 1000000] (ppm = parts per million). When floating point operations are disabled,
this is the only alternative to the floating point value in progress.</dd>
</dl>
<aname="queue_position"></a><dlclass="docutils">
<dt>queue_position</dt>
<dd>the position this torrent has in the download
queue. If the torrent is a seed or finished, this is -1.</dd>
</dl>
<aname="download_rate"></a>
<aname="upload_rate"></a><dlclass="docutils">
<dt>download_rate upload_rate</dt>
<dd>the total rates for all peers for this
torrent. These will usually have better precision than summing the rates from
all peers. The rates are given as the number of bytes per second.</dd>
<dd>the number of peers in this torrent's peer list
that is a candidate to be connected to. i.e. It has fewer connect attempts
than the max fail count, it is not a seed if we are a seed, it is not banned
etc. If this is 0, it means we don't know of any more peers that we can try.</dd>
</dl>
<aname="num_pieces"></a><dlclass="docutils">
<dt>num_pieces</dt>
<dd>the number of pieces that has been downloaded. It is equivalent
to: <ttclass="docutils literal"><spanclass="pre">std::accumulate(pieces->begin(),</span><spanclass="pre">pieces->end())</span></tt>. So you don't have to
count yourself. This can be used to see if anything has updated since last time
if you want to keep a graph of the pieces up to date.</dd>
<dd>true if the <aclass="reference external"href="reference-Session.html#session">session</a> global IP filter applies
to this torrent. This defaults to true.</dd>
</dl>
<aname="upload_mode"></a><dlclass="docutils">
<dt>upload_mode</dt>
<dd>true if the torrent is blocked from downloading. This
typically happens when a disk write operation fails. If the torrent is
auto-managed, it will periodically be taken out of this state, in the
hope that the disk condition (be it disk full or permission errors) has
been resolved. If the torrent is not auto-managed, you have to explicitly
take it out of the upload mode by calling <aclass="reference external"href="reference-Core.html#set_upload_mode()">set_upload_mode()</a> on the
torrent_handle.</dd>
</dl>
<aname="share_mode"></a><dlclass="docutils">
<dt>share_mode</dt>
<dd>true if the torrent is currently in share-mode, i.e.
not downloading the torrent, but just helping the swarm out.</dd>
</dl>
<aname="super_seeding"></a><dlclass="docutils">
<dt>super_seeding</dt>
<dd>true if the torrent is in super seeding mode</dd>
</dl>
<aname="paused"></a><dlclass="docutils">
<dt>paused</dt>
<dd>set to true if the torrent is paused and false otherwise. It's only true
if the torrent itself is paused. If the torrent is not running because the <aclass="reference external"href="reference-Session.html#session">session</a> is
paused, this is still false. To know if a torrent is active or not, you need to inspect
both <ttclass="docutils literal"><spanclass="pre">torrent_status::paused</span></tt> and <ttclass="docutils literal"><spanclass="pre">session::is_paused()</span></tt>.</dd>
</dl>
<aname="auto_managed"></a><dlclass="docutils">
<dt>auto_managed</dt>
<dd>set to true if the torrent is auto managed, i.e. libtorrent is
responsible for determining whether it should be started or queued. For more info
see <aclass="reference external"href="manual-ref.html#queuing">queuing</a></dd>
<p>constructs a tracker announce <aclass="reference external"href="reference-Bencoding.html#entry">entry</a> with <ttclass="docutils literal">u</tt> as the URL.</p>
<strong>torrent_info</strong> (std::string const& filename, int flags = 0);
<strong>torrent_info</strong> (char const* buffer, int size, error_code& ec, int flags = 0);
<strong>torrent_info</strong> (sha1_hash const& info_hash, int flags = 0);
<strong>torrent_info</strong> (lazy_entry const& torrent_file, int flags = 0);
<strong>torrent_info</strong> (char const* buffer, int size, int flags = 0);
<strong>torrent_info</strong> (lazy_entry const& torrent_file, error_code& ec, int flags = 0);
<strong>torrent_info</strong> (torrent_info const& t, int flags = 0);
<strong>torrent_info</strong> (std::string const& filename, error_code& ec, int flags = 0);
</pre>
<p>The constructor that takes an info-hash will initialize the info-hash to the given value,
but leave all other fields empty. This is used internally when downloading torrents without
the metadata. The metadata will be created by libtorrent as soon as it has been downloaded
from the swarm.</p>
<p>The constructor that takes a <aclass="reference external"href="reference-Bencoding.html#lazy_entry">lazy_entry</a> will create a <aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a> object from the
information found in the given torrent_file. The <aclass="reference external"href="reference-Bencoding.html#lazy_entry">lazy_entry</a> represents a tree node in
an bencoded file. To load an ordinary .torrent file
into a <aclass="reference external"href="reference-Bencoding.html#lazy_entry">lazy_entry</a>, use <aclass="reference external"href="reference-Bencoding.html#lazy_bdecode()">lazy_bdecode()</a>.</p>
<p>The version that takes a buffer pointer and a size will decode it as a .torrent file and
initialize the <aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a> object for you.</p>
<p>The version that takes a filename will simply load the torrent file and decode it inside
the constructor, for convenience. This might not be the most suitable for applications that
want to be able to report detailed errors on what might go wrong.</p>
<p>The overloads that takes an <ttclass="docutils literal">error_code const&</tt> never throws if an error occur, they
will simply set the error code to describe what went wrong and not fully initialize the
<aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a> object. The overloads that do not take the extra error_code parameter will
always throw if an error occurs. These overloads are not available when building without
exception support.</p>
<p>The <ttclass="docutils literal">flags</tt> argument is currently unused.</p>
<aname="~torrent_info()"></a></div>
<divclass="section"id="id150">
<h2>~torrent_info()</h2>
<preclass="literal-block">
<strong>~torrent_info</strong> ();
</pre>
<p>frees all storage associated with this <aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a> object</p>
<p>The <aclass="reference external"href="reference-Storage.html#file_storage">file_storage</a> object contains the information on how to map the pieces to
files. It is separated from the <aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a> object because when creating torrents
a storage object needs to be created without having a torrent file. When renaming files
in a storage, the storage needs to make its own copy of the <aclass="reference external"href="reference-Storage.html#file_storage">file_storage</a> in order
to make its mapping differ from the one in the torrent file.</p>
<p><ttclass="docutils literal">orig_files()</tt> returns the original (unmodified) file storage for this torrent. This
is used by the web server connection, which needs to request files with the original
names. Filename may be chaged using <ttclass="docutils literal"><spanclass="pre">torrent_info::rename_file()</span></tt>.</p>
<p>For more information on the <aclass="reference external"href="reference-Storage.html#file_storage">file_storage</a> object, see the separate document on how
<p>Renames a the file with the specified index to the new name. The new filename is
reflected by the <ttclass="docutils literal">file_storage</tt> returned by <ttclass="docutils literal">files()</tt> but not by the one
returned by <ttclass="docutils literal">orig_files()</tt>.</p>
<p>If you want to rename the base name of the torrent (for a multifile torrent), you
can copy the <ttclass="docutils literal">file_storage</tt> (see <aclass="reference external"href="reference-Core.html#files()">files()</a> and <aclass="reference external"href="reference-Core.html#orig_files()">orig_files()</a> ), change the name, and
then use <aclass="reference internal"href="#remap-files">remap_files()</a>.</p>
<p>The <ttclass="docutils literal">new_filename</tt> can both be a relative path, in which case the file name
is relative to the <ttclass="docutils literal">save_path</tt> of the torrent. If the <ttclass="docutils literal">new_filename</tt> is
an absolute path (i.e. <ttclass="docutils literal">is_complete(new_filename) == true</tt>), then the file
is detached from the <ttclass="docutils literal">save_path</tt> of the torrent. In this case the file is
not moved when <aclass="reference external"href="reference-Core.html#move_storage()">move_storage()</a> is invoked.</p>
void <strong>add_tracker</strong> (std::string const& url, int tier = 0);
</pre>
<p><ttclass="docutils literal">add_tracker()</tt> adds a tracker to the announce-list. The <ttclass="docutils literal">tier</tt> determines the order in
which the trackers are to be tried.</p>
<p>The <ttclass="docutils literal">trackers()</tt> function will return a sorted vector of <ttclass="docutils literal">announce_entry</tt>.
Each announce <aclass="reference external"href="reference-Bencoding.html#entry">entry</a> contains a string, which is the tracker url, and a tier index. The
tier index is the high-level priority. No matter which trackers that works or not, the
ones with lower tier will always be tried before the one with higher tier number.
For more information, see <aclass="reference internal"href="#announce-entry">announce_entry</a>.</p>
<p><ttclass="docutils literal">web_seeds()</tt> returns all url seeds and http seeds in the torrent. Each <aclass="reference external"href="reference-Bencoding.html#entry">entry</a>
is a <ttclass="docutils literal">web_seed_entry</tt> and may refer to either a url seed or http seed.</p>
<p><ttclass="docutils literal">add_url_seed()</tt> and <ttclass="docutils literal">add_http_seed()</tt> adds one url to the list of
url/http seeds. Currently, the only transport protocol supported for the url
is http.</p>
<p>The <ttclass="docutils literal">extern_auth</tt> argument can be used for other athorization schemese than
basic HTTP authorization. If set, it will override any username and password
found in the URL itself. The string will be sent as the HTTP authorization header's
value (without specifying "Basic").</p>
<p>The <ttclass="docutils literal">extra_headers</tt> argument defaults to an empty list, but can be used to
insert custom HTTP headers in the requests to a specific web seed.</p>
<p>See <aclass="reference external"href="manual-ref.html#http-seeding">http seeding</a> for more information.</p>
<p><ttclass="docutils literal">total_size()</tt>, <ttclass="docutils literal">piece_length()</tt> and <ttclass="docutils literal">num_pieces()</tt> returns the total
number of bytes the torrent-file represents (all the files in it), the number of byte for
each piece and the total number of pieces, respectively. The difference between
<ttclass="docutils literal">piece_size()</tt> and <ttclass="docutils literal">piece_length()</tt> is that <ttclass="docutils literal">piece_size()</tt> takes
the piece index as argument and gives you the exact size of that piece. It will always
be the same as <ttclass="docutils literal">piece_length()</tt> except in the case of the last piece, which may
<p><ttclass="docutils literal">merkle_tree()</tt> returns a reference to the merkle tree for this torrent, if any.</p>
<p><ttclass="docutils literal">set_merkle_tree()</tt> moves the passed in merkle tree into the <aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a> object.
i.e. <ttclass="docutils literal">h</tt> will not be identical after the call. You need to set the merkle tree for
a torrent that you've just created (as a merkle torrent). The merkle tree is retrieved
from the <ttclass="docutils literal"><spanclass="pre">create_torrent::merkle_tree()</span></tt> function, and need to be saved separately
from the torrent file itself. Once it's added to libtorrent, the merkle tree will be
<p><ttclass="docutils literal">name()</tt> returns the name of the torrent.</p>
<p><ttclass="docutils literal">comment()</tt> returns the comment associated with the torrent. If there's no comment,
it will return an empty string. <ttclass="docutils literal">creation_date()</tt> returns the creation date of
the torrent as time_t (<aclass="reference external"href="http://www.opengroup.org/onlinepubs/009695399/functions/time.html">posix time</a>). If there's no time stamp in the torrent file,
the optional object will be uninitialized.</p>
<p>Both the name and the comment is UTF-8 encoded strings.</p>
<p><ttclass="docutils literal">creator()</tt> returns the creator string in the torrent. If there is no creator string
<p>This is used when creating torrent. Use this to add a known DHT node. It may
be used, by the client, to bootstrap into the DHT network.</p>
<aname="parse_info_section()"></a></div>
<divclass="section"id="parse-info-section">
<h2>parse_info_section()</h2>
<preclass="literal-block">
bool <strong>parse_info_section</strong> (lazy_entry const& e, error_code& ec, int flags);
</pre>
<p>populates the <aclass="reference external"href="reference-Core.html#torrent_info">torrent_info</a> by providing just the info-dict buffer. This is used when
loading a torrent from a magnet link for instance, where we only have the info-dict.
The <aclass="reference external"href="reference-Bencoding.html#lazy_entry">lazy_entry</a><ttclass="docutils literal">e</tt> points to a parsed info-dictionary. <ttclass="docutils literal">ec</tt> returns an error code
if something fails (typically if the info dictionary is malformed). <ttclass="docutils literal">flags</tt> are currently