.. include:: header.rst

`home`__

__ reference.html

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

.. raw:: html

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

.. raw:: html

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



write_resume_data_buf() write_resume_data()
-------------------------------------------

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


__ include/libtorrent/write_resume_data.hpp

.. parsed-literal::
	
	std::vector<char> **write_resume_data_buf** (add\_torrent\_params const& atp);
	entry **write_resume_data** (add\_torrent\_params const& atp);
	

this function turns the resume data in an ``add_torrent_params`` object
into a bencoded structure



.. raw:: html

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

.. raw:: html

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



write_torrent_file() write_torrent_file_buf()
---------------------------------------------

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


__ include/libtorrent/write_resume_data.hpp

.. parsed-literal::
	
	entry **write_torrent_file** (add\_torrent\_params const& atp);
	entry **write_torrent_file** (add\_torrent\_params const& atp, write\_torrent\_flags\_t flags);
	std::vector<char> **write_torrent_file_buf** (add\_torrent\_params const& atp
	   , write\_torrent\_flags\_t flags);
	

writes only the fields to create a .torrent file. This function may fail
with a ``std::system_error`` exception if:

* The `add_torrent_params`__ object passed to this function does not contain the
  info dictionary (the ``ti`` field)
* The piece layers are not complete for all files that need them

The ``write_torrent_file_buf()`` overload returns the torrent file in
bencoded buffer form. This overload may be faster at the expense of lost
flexibility to add custom fields.


__ reference-Add_Torrent.html#add_torrent_params

.. raw:: html

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

.. raw:: html

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



read_resume_data()
------------------

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


__ include/libtorrent/read_resume_data.hpp

.. parsed-literal::
	
	add_torrent_params **read_resume_data** (bdecode\_node const& rd
	   , int piece\_limit = 0x200000);
	add_torrent_params **read_resume_data** (bdecode\_node const& rd
	   , error\_code& ec, int piece\_limit = 0x200000);
	add_torrent_params **read_resume_data** (span<char const> buffer
	   , error\_code& ec, load\_torrent\_limits const& cfg = {});
	add_torrent_params **read_resume_data** (span<char const> buffer
	   , load\_torrent\_limits const& cfg = {});
	

these functions are used to parse resume data and populate the appropriate
fields in an `add_torrent_params`__ object. This object can then be used to add
the actual `torrent_info`__ object to and pass to session::add_torrent() or
session::async_add_torrent().

If the client wants to override any field that was loaded from the resume
data, e.g. save_path, those fields must be changed after loading resume
data but before adding the torrent.

The ``piece_limit`` parameter determines the largest number of pieces
allowed in the torrent that may be loaded as part of the resume data, if
it contains an ``info`` field. The overloads that take a flat buffer are
instead configured with limits on torrent sizes via load_torrent limits.

In order to support large torrents, it may also be necessary to raise the
`settings_pack::max_piece_count`__ setting and pass a higher limit to calls
to `torrent_info::parse_info_section()`__.


__ reference-Add_Torrent.html#add_torrent_params
__ reference-Torrent_Info.html#torrent_info
__ reference-Settings.html#max_piece_count
__ reference-Torrent_Info.html#parse_info_section()

.. raw:: html

	<a name="write_torrent_flags_t"></a>

.. raw:: html

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



write_torrent_flags_t
---------------------

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


__ include/libtorrent/write_resume_data.hpp

.. raw:: html

	<a name="write_torrent_flags_t::allow_missing_piece_layer"></a>

allow_missing_piece_layer
	this makes `write_torrent_file()`__ not fail when attempting to write a
	v2 torrent file that does not have all the piece layers
	

	__ reference-Resume_Data.html#write_torrent_file()

.. raw:: html

	<a name="write_torrent_flags_t::no_http_seeds"></a>

no_http_seeds
	don't include http seeds in the torrent file, even if some are
	present in the `add_torrent_params`__ object
	

	__ reference-Add_Torrent.html#add_torrent_params

.. raw:: html

	<a name="write_torrent_flags_t::include_dht_nodes"></a>

include_dht_nodes
	When set, DHT nodes from the `add_torrent_params`__ objects are included
	in the resulting .torrent file
	

	__ reference-Add_Torrent.html#add_torrent_params




.. _`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
