added torrent_info::remap_files()

This commit is contained in:
Arvid Norberg 2009-11-27 22:15:34 +00:00
parent bf107858b8
commit 5d1bfc497a
4 changed files with 29 additions and 0 deletions

View File

@ -80,6 +80,7 @@
* automatically caps files and connections by default to rlimit
* added session::is_dht_running() function
* added torrent_handle::force_dht_announce()
* added torrent_info::remap_files()
release 0.14.8

View File

@ -1408,6 +1408,8 @@ The ``torrent_info`` has the following synopsis::
file_storage const& files() const;
file_storage const& orig_files() const;
void remap_files(file_storage const& f);
void rename_file(int index, std::string const& new_filename);
void rename_file(int index, std::wstring const& new_filename);
@ -1528,6 +1530,19 @@ names. Filename may be chaged using ``torrent_info::rename_file()``.
For more information on the ``file_storage`` object, see the separate document on how
to create torrents.
remap_files()
-------------
::
void remap_files(file_storage const& f);
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.
rename_file()
-------------

View File

@ -195,6 +195,8 @@ namespace libtorrent
}
#endif // TORRENT_USE_WSTRING
void remap_files(file_storage const& f);
void add_tracker(std::string const& url, int tier = 0);
std::vector<announce_entry> const& trackers() const { return m_urls; }

View File

@ -451,6 +451,17 @@ namespace libtorrent
}
}
void torrent_info::remap_files(file_storage const& f)
{
// the new specified file storage must have the exact
// same size as the current file storage
TORRENT_ASSERT(m_files.total_size() == f.total_size());
if (m_files.total_size() != f.total_size()) return;
copy_on_write();
m_files = f;
}
#ifndef TORRENT_NO_DEPRECATE
// standard constructor that parses a torrent file
torrent_info::torrent_info(entry const& torrent_file)