.. include:: header.rst

`home`__

__ reference.html

.. contents:: Table of contents
  :depth: 2
  :backlinks: none

.. raw:: html

	<a name="web_seed_entry"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:class+web_seed_entry&labels=documentation&body=Documentation+under+heading+%22class+web_seed_entry%22+could+be+improved">report issue</a>]</span>



web_seed_entry
--------------

Declared in "`libtorrent/torrent_info.hpp`__"


__ include/libtorrent/torrent_info.hpp

the `web_seed_entry`__ holds information about a web seed (also known
as URL seed or HTTP seed). It is essentially a URL with some state
associated with it. For more information, see `BEP 17`_ and `BEP 19`_.


__ reference-Torrent_Info.html#web_seed_entry


.. parsed-literal::
	

	struct web_seed_entry
	{
	   bool **operator==** (web\_seed\_entry const& e) const;
	   bool **operator<** (web\_seed\_entry const& e) const;
	
	   enum type_t
	   {
	      url_seed,
	      http_seed,
	   };
	
	   std::string url;
	   std::string auth;
	   headers_t extra_headers;
	   std::uint8_t type;
	};

.. raw:: html

	<a name="operator==()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:web_seed_entry%3A%3A%5Boperator%3D%3D%28%29%5D&labels=documentation&body=Documentation+under+heading+%22web_seed_entry%3A%3A%5Boperator%3D%3D%28%29%5D%22+could+be+improved">report issue</a>]</span>



operator==()
............

.. parsed-literal::
	
	bool **operator==** (web\_seed\_entry const& e) const;
	

URL and type comparison



.. raw:: html

	<a name="operator<()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:web_seed_entry%3A%3A%5Boperator%3C%28%29%5D&labels=documentation&body=Documentation+under+heading+%22web_seed_entry%3A%3A%5Boperator%3C%28%29%5D%22+could+be+improved">report issue</a>]</span>



operator<()
...........

.. parsed-literal::
	
	bool **operator<** (web\_seed\_entry const& e) const;
	

URL and type less-than comparison



.. raw:: html

	<a name="type_t"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:enum+type_t&labels=documentation&body=Documentation+under+heading+%22enum+type_t%22+could+be+improved">report issue</a>]</span>



enum type_t
...........

Declared in "`libtorrent/torrent_info.hpp`__"


__ include/libtorrent/torrent_info.hpp

+-----------+-------+-------------+
| name      | value | description |
+===========+=======+=============+
| url_seed  | 0     |             |
+-----------+-------+-------------+
| http_seed | 1     |             |
+-----------+-------+-------------+



.. raw:: html

	<a name="url"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:web_seed_entry%3A%3A%5Burl%5D&labels=documentation&body=Documentation+under+heading+%22web_seed_entry%3A%3A%5Burl%5D%22+could+be+improved">report issue</a>]</span>


url
	The URL of the web seed
	


.. raw:: html

	<a name="auth"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:web_seed_entry%3A%3A%5Bauth%5D&labels=documentation&body=Documentation+under+heading+%22web_seed_entry%3A%3A%5Bauth%5D%22+could+be+improved">report issue</a>]</span>


auth
	Optional authentication. If this is set, it's passed
	in as HTTP basic auth to the web seed. The format is:
	username:password.
	


.. raw:: html

	<a name="extra_headers"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:web_seed_entry%3A%3A%5Bextra_headers%5D&labels=documentation&body=Documentation+under+heading+%22web_seed_entry%3A%3A%5Bextra_headers%5D%22+could+be+improved">report issue</a>]</span>


extra_headers
	Any extra HTTP headers that need to be passed to the web seed
	


.. raw:: html

	<a name="type"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:web_seed_entry%3A%3A%5Btype%5D&labels=documentation&body=Documentation+under+heading+%22web_seed_entry%3A%3A%5Btype%5D%22+could+be+improved">report issue</a>]</span>


type
	The type of web seed (see `type_t`__)
	

__ reference-Torrent_Info.html#type_t

.. raw:: html

	<a name="load_torrent_limits"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:class+load_torrent_limits&labels=documentation&body=Documentation+under+heading+%22class+load_torrent_limits%22+could+be+improved">report issue</a>]</span>



load_torrent_limits
-------------------

Declared in "`libtorrent/torrent_info.hpp`__"


__ include/libtorrent/torrent_info.hpp

this object holds configuration options for limits to use when loading
torrents. They are meant to prevent loading potentially malicious torrents
that cause excessive memory allocations.




.. parsed-literal::
	

	struct load_torrent_limits
	{
	   int **max_buffer_size**  = 10000000;
	   int **max_pieces**  = 0x200000;
	   int **max_decode_depth**  = 100;
	   int **max_decode_tokens**  = 3000000;
	};

.. raw:: html

	<a name="max_buffer_size"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:load_torrent_limits%3A%3A%5Bmax_buffer_size%5D&labels=documentation&body=Documentation+under+heading+%22load_torrent_limits%3A%3A%5Bmax_buffer_size%5D%22+could+be+improved">report issue</a>]</span>


max_buffer_size
	the max size of a .torrent file to load into RAM
	


.. raw:: html

	<a name="max_pieces"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:load_torrent_limits%3A%3A%5Bmax_pieces%5D&labels=documentation&body=Documentation+under+heading+%22load_torrent_limits%3A%3A%5Bmax_pieces%5D%22+could+be+improved">report issue</a>]</span>


max_pieces
	the max number of pieces allowed in the torrent
	


.. raw:: html

	<a name="max_decode_depth"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:load_torrent_limits%3A%3A%5Bmax_decode_depth%5D&labels=documentation&body=Documentation+under+heading+%22load_torrent_limits%3A%3A%5Bmax_decode_depth%5D%22+could+be+improved">report issue</a>]</span>


max_decode_depth
	the max recursion depth in the bdecoded structure
	


.. raw:: html

	<a name="max_decode_tokens"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:load_torrent_limits%3A%3A%5Bmax_decode_tokens%5D&labels=documentation&body=Documentation+under+heading+%22load_torrent_limits%3A%3A%5Bmax_decode_tokens%5D%22+could+be+improved">report issue</a>]</span>


max_decode_tokens
	the max number of bdecode tokens
	


.. raw:: html

	<a name="torrent_info"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:class+torrent_info&labels=documentation&body=Documentation+under+heading+%22class+torrent_info%22+could+be+improved">report issue</a>]</span>



torrent_info
------------

Declared in "`libtorrent/torrent_info.hpp`__"


__ include/libtorrent/torrent_info.hpp

the `torrent_info`__ class holds the information found in a .torrent file.


__ reference-Torrent_Info.html#torrent_info


.. parsed-literal::
	

	class torrent_info
	{
	   explicit **torrent_info** (bdecode\_node const& torrent\_file);
	   **torrent_info** (char const\* buffer, int size);
	   **torrent_info** (std\:\:string const& filename, load\_torrent\_limits const& cfg);
	   explicit **torrent_info** (span<char const> buffer, from\_span\_t);
	   **torrent_info** (torrent\_info const& t);
	   **torrent_info** (span<char const> buffer, error\_code& ec, from\_span\_t);
	   **torrent_info** (std\:\:string const& filename, error\_code& ec);
	   explicit **torrent_info** (std\:\:string const& filename);
	   explicit **torrent_info** (info\_hash\_t const& info\_hash);
	   **torrent_info** (bdecode\_node const& torrent\_file, error\_code& ec);
	   **torrent_info** (bdecode\_node const& torrent\_file, load\_torrent\_limits const& cfg);
	   **torrent_info** (char const\* buffer, int size, error\_code& ec);
	   **torrent_info** (span<char const> buffer, load\_torrent\_limits const& cfg, from\_span\_t);
	   **~torrent_info** ();
	   file_storage const& **files** () const;
	   file_storage const& **orig_files** () const;
	   void **rename_file** (file\_index\_t index, std\:\:string const& new\_filename);
	   void **remap_files** (file\_storage const& f);
	   std::vector<announce_entry> const& **trackers** () const;
	   void **add_tracker** (std\:\:string const& url, int tier = 0);
	   void **add_tracker** (std\:\:string const& url, int tier
	      , announce\_entry\:\:tracker\_source source);
	   void **clear_trackers** ();
	   std::vector<sha1_hash> **similar_torrents** () const;
	   std::vector<std::string> **collections** () const;
	   void **add_http_seed** (std\:\:string const& url
	      , std\:\:string const& extern\_auth = std\:\:string()
	      , web\_seed\_entry\:\:headers\_t const& extra\_headers = web\_seed\_entry\:\:headers\_t());
	   void **add_url_seed** (std\:\:string const& url
	      , std\:\:string const& ext\_auth = std\:\:string()
	      , web\_seed\_entry\:\:headers\_t const& ext\_headers = web\_seed\_entry\:\:headers\_t());
	   std::vector<web_seed_entry> const& **web_seeds** () const;
	   void **set_web_seeds** (std\:\:vector<web\_seed\_entry> seeds);
	   std::int64_t **total_size** () const;
	   int **piece_length** () const;
	   int **num_pieces** () const;
	   piece_index_t **last_piece** () const;
	   index_range<piece_index_t> **piece_range** () const;
	   piece_index_t **end_piece** () const;
	   info_hash_t const& **info_hashes** () const;
	   sha1_hash **info_hash** () const noexcept;
	   bool **v1** () const;
	   bool **v2** () const;
	   int **num_files** () const;
	   std::vector<file_slice> **map_block** (piece\_index\_t const piece
	      , std\:\:int64\_t offset, int size) const;
	   peer_request **map_file** (file\_index\_t const file, std\:\:int64\_t offset, int size) const;
	   string_view **ssl_cert** () const;
	   bool **is_valid** () const;
	   bool **priv** () const;
	   bool **is_i2p** () const;
	   int **piece_size** (piece\_index\_t index) const;
	   char const* **hash_for_piece_ptr** (piece\_index\_t const index) const;
	   sha1_hash **hash_for_piece** (piece\_index\_t index) const;
	   bool **is_loaded** () const;
	   const std::string& **name** () const;
	   std::time_t **creation_date** () const;
	   const std::string& **creator** () const;
	   const std::string& **comment** () const;
	   std::vector<std::pair<std::string, int>> const& **nodes** () const;
	   void **add_node** (std\:\:pair<std\:\:string, int> const& node);
	   bool **parse_info_section** (bdecode\_node const& info, error\_code& ec, int max\_pieces);
	   bdecode_node **info** (char const\* key) const;
	   span<char const> **info_section** () const;
	   span<char const> **piece_layer** (file\_index\_t) const;
	   void **free_piece_layers** ();
	};

.. raw:: html

	<a name="torrent_info()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Btorrent_info%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Btorrent_info%28%29%5D%22+could+be+improved">report issue</a>]</span>



torrent_info()
..............

.. parsed-literal::
	
	explicit **torrent_info** (bdecode\_node const& torrent\_file);
	**torrent_info** (char const\* buffer, int size);
	**torrent_info** (std\:\:string const& filename, load\_torrent\_limits const& cfg);
	explicit **torrent_info** (span<char const> buffer, from\_span\_t);
	**torrent_info** (torrent\_info const& t);
	**torrent_info** (span<char const> buffer, error\_code& ec, from\_span\_t);
	**torrent_info** (std\:\:string const& filename, error\_code& ec);
	explicit **torrent_info** (std\:\:string const& filename);
	explicit **torrent_info** (info\_hash\_t const& info\_hash);
	**torrent_info** (bdecode\_node const& torrent\_file, error\_code& ec);
	**torrent_info** (bdecode\_node const& torrent\_file, load\_torrent\_limits const& cfg);
	**torrent_info** (char const\* buffer, int size, error\_code& ec);
	**torrent_info** (span<char const> buffer, load\_torrent\_limits const& cfg, from\_span\_t);
	

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.

The constructor that takes a `bdecode_node`__ will create a `torrent_info`__
object from the information found in the given torrent_file. The
`bdecode_node`__ represents a tree node in an bencoded file. To load an
ordinary .torrent file into a `bdecode_node`__, use `bdecode()`__.

The version that takes a buffer pointer and a size will decode it as a
.torrent file and initialize the `torrent_info`__ object for you.

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.

There is an upper limit on the size of the torrent file that will be
loaded by the overload taking a filename. If it's important that even
very large torrent files are loaded, use one of the other overloads.

The overloads that takes an ``error_code const&`` never throws if an
error occur, they will simply set the error code to describe what went
wrong and not fully initialize the `torrent_info`__ 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.

The overload that takes a ``span`` also needs an extra parameter of
type ``from_span_t`` to disambiguate the ``std::string`` overload for
string literals. There is an object in the libtorrent namespace of this
type called ``from_span``.


__ reference-Bdecoding.html#bdecode_node
__ reference-Torrent_Info.html#torrent_info
__ reference-Bdecoding.html#bdecode_node
__ reference-Bdecoding.html#bdecode_node
__ reference-Bdecoding.html#bdecode()
__ reference-Torrent_Info.html#torrent_info
__ reference-Torrent_Info.html#torrent_info

.. raw:: html

	<a name="~torrent_info()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5B~torrent_info%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5B~torrent_info%28%29%5D%22+could+be+improved">report issue</a>]</span>



~torrent_info()
...............

.. parsed-literal::
	
	**~torrent_info** ();
	

frees all storage associated with this `torrent_info`__ object


__ reference-Torrent_Info.html#torrent_info

.. raw:: html

	<a name="orig_files()"></a>
	<a name="files()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Borig_files%28%29+files%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Borig_files%28%29+files%28%29%5D%22+could+be+improved">report issue</a>]</span>



orig_files() files()
....................

.. parsed-literal::
	
	file_storage const& **files** () const;
	file_storage const& **orig_files** () const;
	

The `file_storage`__ object contains the information on how to map the
pieces to files. It is separated from the `torrent_info`__ 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 `file_storage`__ in order to make its
mapping differ from the one in the torrent file.

``orig_files()`` 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 changed using
``torrent_info::rename_file()``.

For more information on the `file_storage`__ object, see the separate
document on how to create torrents.


__ reference-Storage.html#file_storage
__ reference-Torrent_Info.html#torrent_info
__ reference-Storage.html#file_storage
__ reference-Storage.html#file_storage

.. raw:: html

	<a name="rename_file()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Brename_file%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Brename_file%28%29%5D%22+could+be+improved">report issue</a>]</span>



rename_file()
.............

.. parsed-literal::
	
	void **rename_file** (file\_index\_t index, std\:\:string const& new\_filename);
	

Renames the file with the specified index to the new name. The new
filename is reflected by the ``file_storage`` returned by ``files()``
but not by the one returned by ``orig_files()``.

If you want to rename the base name of the torrent (for a multi file
torrent), you can copy the ``file_storage`` (see `files()`__ and
`orig_files()`__ ), change the name, and then use `remap_files()`_.

The ``new_filename`` can both be a relative path, in which case the
file name is relative to the ``save_path`` of the torrent. If the
``new_filename`` is an absolute path (i.e. ``is_complete(new_filename)
== true``), then the file is detached from the ``save_path`` of the
torrent. In this case the file is not moved when `move_storage()`__ is
invoked.


__ reference-Torrent_Info.html#files()
__ reference-Torrent_Info.html#orig_files()
__ reference-Torrent_Handle.html#move_storage()

.. raw:: html

	<a name="remap_files()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bremap_files%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bremap_files%28%29%5D%22+could+be+improved">report issue</a>]</span>



remap_files()
.............

.. parsed-literal::
	
	void **remap_files** (file\_storage const& f);
	

.. warning::
	Using `remap_files()` is discouraged as it's incompatible with v2
	torrents. This is because the piece boundaries and piece hashes in
	v2 torrents are intimately tied to the file boundaries. Instead,
	just rename individual files, or implement a custom `disk_interface`__
	to customize how to store files.

Remaps the file storage to a new file layout. This can be used to, for
instance, download all data in a torrent to a single file, or to a
number of fixed size sector aligned files, regardless of the number
and sizes of the files in the torrent.

The new specified ``file_storage`` must have the exact same size as
the current one.


__ reference-Custom_Storage.html#disk_interface

.. raw:: html

	<a name="clear_trackers()"></a>
	<a name="trackers()"></a>
	<a name="add_tracker()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bclear_trackers%28%29+trackers%28%29+add_tracker%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bclear_trackers%28%29+trackers%28%29+add_tracker%28%29%5D%22+could+be+improved">report issue</a>]</span>



clear_trackers() trackers() add_tracker()
.........................................

.. parsed-literal::
	
	std::vector<announce_entry> const& **trackers** () const;
	void **add_tracker** (std\:\:string const& url, int tier = 0);
	void **add_tracker** (std\:\:string const& url, int tier
	      , announce\_entry\:\:tracker\_source source);
	void **clear_trackers** ();
	

``add_tracker()`` adds a tracker to the announce-list. The ``tier``
determines the order in which the trackers are to be tried.
The ``trackers()`` function will return a sorted vector of
`announce_entry`__. Each announce `entry`__ 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 `announce_entry`__.

``trackers()`` returns all entries from announce-list.

``clear_trackers()`` removes all trackers from announce-list.


__ reference-Trackers.html#announce_entry
__ reference-Bencoding.html#entry
__ reference-Trackers.html#announce_entry

.. raw:: html

	<a name="similar_torrents()"></a>
	<a name="collections()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bsimilar_torrents%28%29+collections%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bsimilar_torrents%28%29+collections%28%29%5D%22+could+be+improved">report issue</a>]</span>



similar_torrents() collections()
................................

.. parsed-literal::
	
	std::vector<sha1_hash> **similar_torrents** () const;
	std::vector<std::string> **collections** () const;
	

These two functions are related to `BEP 38`_ (mutable torrents). The
vectors returned from these correspond to the "similar" and
"collections" keys in the .torrent file. Both info-hashes and
collections from within the info-dict and from outside of it are
included.



.. raw:: html

	<a name="add_http_seed()"></a>
	<a name="add_url_seed()"></a>
	<a name="web_seeds()"></a>
	<a name="set_web_seeds()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Badd_http_seed%28%29+add_url_seed%28%29+web_seeds%28%29+set_web_seeds%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Badd_http_seed%28%29+add_url_seed%28%29+web_seeds%28%29+set_web_seeds%28%29%5D%22+could+be+improved">report issue</a>]</span>



add_http_seed() add_url_seed() web_seeds() set_web_seeds()
..........................................................

.. parsed-literal::
	
	void **add_http_seed** (std\:\:string const& url
	      , std\:\:string const& extern\_auth = std\:\:string()
	      , web\_seed\_entry\:\:headers\_t const& extra\_headers = web\_seed\_entry\:\:headers\_t());
	void **add_url_seed** (std\:\:string const& url
	      , std\:\:string const& ext\_auth = std\:\:string()
	      , web\_seed\_entry\:\:headers\_t const& ext\_headers = web\_seed\_entry\:\:headers\_t());
	std::vector<web_seed_entry> const& **web_seeds** () const;
	void **set_web_seeds** (std\:\:vector<web\_seed\_entry> seeds);
	

``web_seeds()`` returns all url seeds and http seeds in the torrent.
Each `entry`__ is a ``web_seed_entry`` and may refer to either a url seed
or http seed.

``add_url_seed()`` and ``add_http_seed()`` adds one url to the list of
url/http seeds.

``set_web_seeds()`` replaces all web seeds with the ones specified in
the ``seeds`` vector.

The ``extern_auth`` argument can be used for other authorization
schemes 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").

The ``extra_headers`` argument defaults to an empty list, but can be
used to insert custom HTTP headers in the requests to a specific web
seed.

See `http seeding`__ for more information.


__ reference-Bencoding.html#entry
__ manual-ref.html#http-seeding

.. raw:: html

	<a name="total_size()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Btotal_size%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Btotal_size%28%29%5D%22+could+be+improved">report issue</a>]</span>



total_size()
............

.. parsed-literal::
	
	std::int64_t **total_size** () const;
	

``total_size()`` returns the total number of bytes the torrent-file
represents. Note that this is the number of pieces times the piece
size (modulo the last piece possibly being smaller). With pad files,
the total size will be larger than the sum of all (regular) file
sizes.



.. raw:: html

	<a name="num_pieces()"></a>
	<a name="piece_length()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bnum_pieces%28%29+piece_length%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bnum_pieces%28%29+piece_length%28%29%5D%22+could+be+improved">report issue</a>]</span>



num_pieces() piece_length()
...........................

.. parsed-literal::
	
	int **piece_length** () const;
	int **num_pieces** () const;
	

``piece_length()`` and ``num_pieces()`` returns the number of byte
for each piece and the total number of pieces, respectively. The
difference between ``piece_size()`` and ``piece_length()`` is that
``piece_size()`` takes the piece index as argument and gives you the
exact size of that piece. It will always be the same as
``piece_length()`` except in the case of the last piece, which may be
smaller.



.. raw:: html

	<a name="end_piece()"></a>
	<a name="last_piece()"></a>
	<a name="piece_range()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bend_piece%28%29+last_piece%28%29+piece_range%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bend_piece%28%29+last_piece%28%29+piece_range%28%29%5D%22+could+be+improved">report issue</a>]</span>



end_piece() last_piece() piece_range()
......................................

.. parsed-literal::
	
	piece_index_t **last_piece** () const;
	index_range<piece_index_t> **piece_range** () const;
	piece_index_t **end_piece** () const;
	

``last_piece()`` returns the index to the last piece in the torrent and
``end_piece()`` returns the index to the one-past-end piece in the
torrent
``piece_range()`` returns an implementation-defined type that can be
used as the container in a range-for loop. Where the values are the
indices of all pieces in the `file_storage`__.


__ reference-Storage.html#file_storage

.. raw:: html

	<a name="info_hashes()"></a>
	<a name="info_hash()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Binfo_hashes%28%29+info_hash%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Binfo_hashes%28%29+info_hash%28%29%5D%22+could+be+improved">report issue</a>]</span>



info_hashes() info_hash()
.........................

.. parsed-literal::
	
	info_hash_t const& **info_hashes** () const;
	sha1_hash **info_hash** () const noexcept;
	

returns the info-hash of the torrent. For BitTorrent v2 support, use
``info_hashes()`` to get an object that may hold both a v1 and v2
info-hash



.. raw:: html

	<a name="v2()"></a>
	<a name="v1()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bv2%28%29+v1%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bv2%28%29+v1%28%29%5D%22+could+be+improved">report issue</a>]</span>



v2() v1()
.........

.. parsed-literal::
	
	bool **v1** () const;
	bool **v2** () const;
	

returns whether this torrent has v1 and/or v2 metadata, respectively.
Hybrid torrents have both. These are shortcuts for
info_hashes().has_v1() and info_hashes().has_v2() calls.



.. raw:: html

	<a name="num_files()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bnum_files%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bnum_files%28%29%5D%22+could+be+improved">report issue</a>]</span>



num_files()
...........

.. parsed-literal::
	
	int **num_files** () const;
	

If you need index-access to files you can use the ``num_files()`` along
with the ``file_path()``, ``file_size()``-family of functions to access
files using indices.



.. raw:: html

	<a name="map_block()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bmap_block%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bmap_block%28%29%5D%22+could+be+improved">report issue</a>]</span>



map_block()
...........

.. parsed-literal::
	
	std::vector<file_slice> **map_block** (piece\_index\_t const piece
	      , std\:\:int64\_t offset, int size) const;
	

This function will map a piece index, a byte offset within that piece
and a size (in bytes) into the corresponding files with offsets where
that data for that piece is supposed to be stored. See `file_slice`__.


__ reference-Storage.html#file_slice

.. raw:: html

	<a name="map_file()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bmap_file%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bmap_file%28%29%5D%22+could+be+improved">report issue</a>]</span>



map_file()
..........

.. parsed-literal::
	
	peer_request **map_file** (file\_index\_t const file, std\:\:int64\_t offset, int size) const;
	

This function will map a range in a specific file into a range in the
torrent. The ``file_offset`` parameter is the offset in the file,
given in bytes, where 0 is the start of the file. See `peer_request`__.

The input range is assumed to be valid within the torrent.
``file_offset`` + ``size`` is not allowed to be greater than the file
size. ``file_index`` must refer to a valid file, i.e. it cannot be >=
``num_files()``.


__ reference-Core.html#peer_request

.. raw:: html

	<a name="ssl_cert()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bssl_cert%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bssl_cert%28%29%5D%22+could+be+improved">report issue</a>]</span>



ssl_cert()
..........

.. parsed-literal::
	
	string_view **ssl_cert** () const;
	

Returns the SSL root certificate for the torrent, if it is an SSL
torrent. Otherwise returns an empty string. The certificate is
the public certificate in x509 format.



.. raw:: html

	<a name="is_valid()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bis_valid%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bis_valid%28%29%5D%22+could+be+improved">report issue</a>]</span>



is_valid()
..........

.. parsed-literal::
	
	bool **is_valid** () const;
	

returns true if this `torrent_info`__ object has a torrent loaded.
This is primarily used to determine if a magnet link has had its
metadata resolved yet or not.


__ reference-Torrent_Info.html#torrent_info

.. raw:: html

	<a name="priv()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bpriv%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bpriv%28%29%5D%22+could+be+improved">report issue</a>]</span>



priv()
......

.. parsed-literal::
	
	bool **priv** () const;
	

returns true if this torrent is private. i.e., the client should not
advertise itself on the trackerless network (the Kademlia DHT) for this torrent.



.. raw:: html

	<a name="is_i2p()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bis_i2p%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bis_i2p%28%29%5D%22+could+be+improved">report issue</a>]</span>



is_i2p()
........

.. parsed-literal::
	
	bool **is_i2p** () const;
	

returns true if this is an i2p torrent. This is determined by whether
or not it has a tracker whose URL domain name ends with ".i2p". i2p
torrents disable the DHT and local peer discovery as well as talking
to peers over anything other than the i2p network.



.. raw:: html

	<a name="piece_size()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bpiece_size%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bpiece_size%28%29%5D%22+could+be+improved">report issue</a>]</span>



piece_size()
............

.. parsed-literal::
	
	int **piece_size** (piece\_index\_t index) const;
	

returns the piece size of file with ``index``. This will be the same as `piece_length()`__,
except for the last piece, which may be shorter.


__ reference-Torrent_Info.html#piece_length()

.. raw:: html

	<a name="hash_for_piece()"></a>
	<a name="hash_for_piece_ptr()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bhash_for_piece%28%29+hash_for_piece_ptr%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bhash_for_piece%28%29+hash_for_piece_ptr%28%29%5D%22+could+be+improved">report issue</a>]</span>



hash_for_piece() hash_for_piece_ptr()
.....................................

.. parsed-literal::
	
	char const* **hash_for_piece_ptr** (piece\_index\_t const index) const;
	sha1_hash **hash_for_piece** (piece\_index\_t index) const;
	

``hash_for_piece()`` takes a piece-index and returns the 20-bytes
sha1-hash for that piece and ``info_hash()`` returns the 20-bytes
sha1-hash for the info-section of the torrent file.
``hash_for_piece_ptr()`` returns a pointer to the 20 byte sha1 digest
for the piece. Note that the string is not 0-terminated.



.. raw:: html

	<a name="name()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bname%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bname%28%29%5D%22+could+be+improved">report issue</a>]</span>



name()
......

.. parsed-literal::
	
	const std::string& **name** () const;
	

``name()`` returns the name of the torrent.
name contains UTF-8 encoded string.



.. raw:: html

	<a name="creation_date()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bcreation_date%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bcreation_date%28%29%5D%22+could+be+improved">report issue</a>]</span>



creation_date()
...............

.. parsed-literal::
	
	std::time_t **creation_date** () const;
	

``creation_date()`` returns the creation date of the torrent as time_t
(`posix time`_). If there's no time stamp in the torrent file, 0 is
returned.
.. _`posix time`: http://www.opengroup.org/onlinepubs/009695399/functions/time.html



.. raw:: html

	<a name="creator()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bcreator%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bcreator%28%29%5D%22+could+be+improved">report issue</a>]</span>



creator()
.........

.. parsed-literal::
	
	const std::string& **creator** () const;
	

``creator()`` returns the creator string in the torrent. If there is
no creator string it will return an empty string.



.. raw:: html

	<a name="comment()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bcomment%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bcomment%28%29%5D%22+could+be+improved">report issue</a>]</span>



comment()
.........

.. parsed-literal::
	
	const std::string& **comment** () const;
	

``comment()`` returns the comment associated with the torrent. If
there's no comment, it will return an empty string.
comment contains UTF-8 encoded string.



.. raw:: html

	<a name="nodes()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bnodes%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bnodes%28%29%5D%22+could+be+improved">report issue</a>]</span>



nodes()
.......

.. parsed-literal::
	
	std::vector<std::pair<std::string, int>> const& **nodes** () const;
	

If this torrent contains any DHT nodes, they are put in this vector in
their original form (host name and port number).



.. raw:: html

	<a name="add_node()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Badd_node%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Badd_node%28%29%5D%22+could+be+improved">report issue</a>]</span>



add_node()
..........

.. parsed-literal::
	
	void **add_node** (std\:\:pair<std\:\:string, int> const& node);
	

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.



.. raw:: html

	<a name="parse_info_section()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bparse_info_section%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bparse_info_section%28%29%5D%22+could+be+improved">report issue</a>]</span>



parse_info_section()
....................

.. parsed-literal::
	
	bool **parse_info_section** (bdecode\_node const& info, error\_code& ec, int max\_pieces);
	

populates the `torrent_info`__ 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 `bdecode_node`__ ``e`` points to a
parsed info-dictionary. ``ec`` returns an error code if something
fails (typically if the info dictionary is malformed).
The `max_pieces` parameter allows limiting the amount of memory
dedicated to loading the torrent, and fails for torrents that exceed
the limit. To load large torrents, this limit may also need to be
raised in `settings_pack::max_piece_count`__ and in calls to
`read_resume_data()`__.


__ reference-Torrent_Info.html#torrent_info
__ reference-Bdecoding.html#bdecode_node
__ reference-Settings.html#max_piece_count
__ reference-Resume_Data.html#read_resume_data()

.. raw:: html

	<a name="info()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Binfo%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Binfo%28%29%5D%22+could+be+improved">report issue</a>]</span>



info()
......

.. parsed-literal::
	
	bdecode_node **info** (char const\* key) const;
	

This function looks up keys from the info-dictionary of the loaded
torrent file. It can be used to access extension values put in the
.torrent file. If the specified key cannot be found, it returns nullptr.



.. raw:: html

	<a name="info_section()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Binfo_section%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Binfo_section%28%29%5D%22+could+be+improved">report issue</a>]</span>



info_section()
..............

.. parsed-literal::
	
	span<char const> **info_section** () const;
	

returns a the raw info section of the torrent file.
The underlying buffer is still owned by the `torrent_info`__ object


__ reference-Torrent_Info.html#torrent_info

.. raw:: html

	<a name="piece_layer()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bpiece_layer%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bpiece_layer%28%29%5D%22+could+be+improved">report issue</a>]</span>



piece_layer()
.............

.. parsed-literal::
	
	span<char const> **piece_layer** (file\_index\_t) const;
	

return the bytes of the piece layer hashes for the specified file. If
the file doesn't have a piece layer, an empty span is returned.
The span size is divisible by 32, the size of a SHA-256 hash.
If the size of the file is smaller than or equal to the piece size,
the files "root hash" is the hash of the file and is not saved
separately in the "piece layers" field, but this function still
returns the root hash of the file in that case.



.. raw:: html

	<a name="free_piece_layers()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:torrent_info%3A%3A%5Bfree_piece_layers%28%29%5D&labels=documentation&body=Documentation+under+heading+%22torrent_info%3A%3A%5Bfree_piece_layers%28%29%5D%22+could+be+improved">report issue</a>]</span>



free_piece_layers()
...................

.. parsed-literal::
	
	void **free_piece_layers** ();
	

clears the piece layers from the `torrent_info`__. This is done by the
`session`__ when a torrent is added, to avoid storing it twice. The piece
layer (or other hashes part of the merkle tree) are stored in the
internal torrent object.


__ reference-Torrent_Info.html#torrent_info
__ reference-Session.html#session



.. _`BEP 3`: https://www.bittorrent.org/beps/bep_0003.html
.. _`BEP 17`: https://www.bittorrent.org/beps/bep_0017.html
.. _extensions: manual-ref.html#extensions
.. _`BEP 52`: https://www.bittorrent.org/beps/bep_0052.html
.. _`BEP 19`: https://www.bittorrent.org/beps/bep_0019.html
.. _`BEP 38`: https://www.bittorrent.org/beps/bep_0038.html
.. _`rate based choking`: manual-ref.html#rate-based-choking
.. _`BEP 42`: https://www.bittorrent.org/beps/bep_0042.html
