*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-07-18 00:39:58 +00:00
parent feebf4bbb3
commit 1148a5574c
11 changed files with 216 additions and 137 deletions

View File

@ -47,71 +47,72 @@
</li>
<li><a class="reference" href="#torrent-handle" id="id41" name="id41">torrent_handle</a><ul>
<li><a class="reference" href="#save-path" id="id42" name="id42">save_path()</a></li>
<li><a class="reference" href="#force-reannounce" id="id43" name="id43">force_reannounce()</a></li>
<li><a class="reference" href="#connect-peer" id="id44" name="id44">connect_peer()</a></li>
<li><a class="reference" href="#set-ratio" id="id45" name="id45">set_ratio()</a></li>
<li><a class="reference" href="#set-upload-limit-set-download-limit" id="id46" name="id46">set_upload_limit() set_download_limit()</a></li>
<li><a class="reference" href="#pause-resume-is-paused" id="id47" name="id47">pause() resume() is_paused()</a></li>
<li><a class="reference" href="#set-tracker-login" id="id48" name="id48">set_tracker_login()</a></li>
<li><a class="reference" href="#use-interface" id="id49" name="id49">use_interface()</a></li>
<li><a class="reference" href="#info-hash" id="id50" name="id50">info_hash()</a></li>
<li><a class="reference" href="#set-max-uploads-set-max-connections" id="id51" name="id51">set_max_uploads() set_max_connections()</a></li>
<li><a class="reference" href="#write-resume-data" id="id52" name="id52">write_resume_data()</a></li>
<li><a class="reference" href="#id11" id="id53" name="id53">status()</a></li>
<li><a class="reference" href="#get-download-queue" id="id54" name="id54">get_download_queue()</a></li>
<li><a class="reference" href="#get-peer-info" id="id55" name="id55">get_peer_info()</a></li>
<li><a class="reference" href="#get-torrent-info" id="id56" name="id56">get_torrent_info()</a></li>
<li><a class="reference" href="#is-valid" id="id57" name="id57">is_valid()</a></li>
<li><a class="reference" href="#move-storage" id="id43" name="id43">move_storage()</a></li>
<li><a class="reference" href="#force-reannounce" id="id44" name="id44">force_reannounce()</a></li>
<li><a class="reference" href="#connect-peer" id="id45" name="id45">connect_peer()</a></li>
<li><a class="reference" href="#set-ratio" id="id46" name="id46">set_ratio()</a></li>
<li><a class="reference" href="#set-upload-limit-set-download-limit" id="id47" name="id47">set_upload_limit() set_download_limit()</a></li>
<li><a class="reference" href="#pause-resume-is-paused" id="id48" name="id48">pause() resume() is_paused()</a></li>
<li><a class="reference" href="#set-tracker-login" id="id49" name="id49">set_tracker_login()</a></li>
<li><a class="reference" href="#use-interface" id="id50" name="id50">use_interface()</a></li>
<li><a class="reference" href="#info-hash" id="id51" name="id51">info_hash()</a></li>
<li><a class="reference" href="#set-max-uploads-set-max-connections" id="id52" name="id52">set_max_uploads() set_max_connections()</a></li>
<li><a class="reference" href="#write-resume-data" id="id53" name="id53">write_resume_data()</a></li>
<li><a class="reference" href="#id11" id="id54" name="id54">status()</a></li>
<li><a class="reference" href="#get-download-queue" id="id55" name="id55">get_download_queue()</a></li>
<li><a class="reference" href="#get-peer-info" id="id56" name="id56">get_peer_info()</a></li>
<li><a class="reference" href="#get-torrent-info" id="id57" name="id57">get_torrent_info()</a></li>
<li><a class="reference" href="#is-valid" id="id58" name="id58">is_valid()</a></li>
</ul>
</li>
<li><a class="reference" href="#torrent-status" id="id58" name="id58">torrent_status</a></li>
<li><a class="reference" href="#peer-info" id="id59" name="id59">peer_info</a></li>
<li><a class="reference" href="#address" id="id60" name="id60">address</a></li>
<li><a class="reference" href="#http-settings" id="id61" name="id61">http_settings</a></li>
<li><a class="reference" href="#big-number" id="id62" name="id62">big_number</a></li>
<li><a class="reference" href="#hasher" id="id63" name="id63">hasher</a></li>
<li><a class="reference" href="#fingerprint" id="id64" name="id64">fingerprint</a></li>
<li><a class="reference" href="#free-functions" id="id65" name="id65">free functions</a><ul>
<li><a class="reference" href="#identify-client" id="id66" name="id66">identify_client()</a></li>
<li><a class="reference" href="#bdecode-bencode" id="id67" name="id67">bdecode() bencode()</a></li>
<li><a class="reference" href="#torrent-status" id="id59" name="id59">torrent_status</a></li>
<li><a class="reference" href="#peer-info" id="id60" name="id60">peer_info</a></li>
<li><a class="reference" href="#address" id="id61" name="id61">address</a></li>
<li><a class="reference" href="#http-settings" id="id62" name="id62">http_settings</a></li>
<li><a class="reference" href="#big-number" id="id63" name="id63">big_number</a></li>
<li><a class="reference" href="#hasher" id="id64" name="id64">hasher</a></li>
<li><a class="reference" href="#fingerprint" id="id65" name="id65">fingerprint</a></li>
<li><a class="reference" href="#free-functions" id="id66" name="id66">free functions</a><ul>
<li><a class="reference" href="#identify-client" id="id67" name="id67">identify_client()</a></li>
<li><a class="reference" href="#bdecode-bencode" id="id68" name="id68">bdecode() bencode()</a></li>
</ul>
</li>
<li><a class="reference" href="#alerts" id="id68" name="id68">alerts</a><ul>
<li><a class="reference" href="#listen-failed-alert" id="id69" name="id69">listen_failed_alert</a></li>
<li><a class="reference" href="#file-error-alert" id="id70" name="id70">file_error_alert</a></li>
<li><a class="reference" href="#tracker-alert" id="id71" name="id71">tracker_alert</a></li>
<li><a class="reference" href="#hash-failed-alert" id="id72" name="id72">hash_failed_alert</a></li>
<li><a class="reference" href="#peer-ban-alert" id="id73" name="id73">peer_ban_alert</a></li>
<li><a class="reference" href="#peer-error-alert" id="id74" name="id74">peer_error_alert</a></li>
<li><a class="reference" href="#invalid-request-alert" id="id75" name="id75">invalid_request_alert</a></li>
<li><a class="reference" href="#torrent-finished-alert" id="id76" name="id76">torrent_finished_alert</a></li>
<li><a class="reference" href="#dispatcher" id="id77" name="id77">dispatcher</a></li>
<li><a class="reference" href="#alerts" id="id69" name="id69">alerts</a><ul>
<li><a class="reference" href="#listen-failed-alert" id="id70" name="id70">listen_failed_alert</a></li>
<li><a class="reference" href="#file-error-alert" id="id71" name="id71">file_error_alert</a></li>
<li><a class="reference" href="#tracker-alert" id="id72" name="id72">tracker_alert</a></li>
<li><a class="reference" href="#hash-failed-alert" id="id73" name="id73">hash_failed_alert</a></li>
<li><a class="reference" href="#peer-ban-alert" id="id74" name="id74">peer_ban_alert</a></li>
<li><a class="reference" href="#peer-error-alert" id="id75" name="id75">peer_error_alert</a></li>
<li><a class="reference" href="#invalid-request-alert" id="id76" name="id76">invalid_request_alert</a></li>
<li><a class="reference" href="#torrent-finished-alert" id="id77" name="id77">torrent_finished_alert</a></li>
<li><a class="reference" href="#dispatcher" id="id78" name="id78">dispatcher</a></li>
</ul>
</li>
<li><a class="reference" href="#exceptions" id="id78" name="id78">exceptions</a><ul>
<li><a class="reference" href="#invalid-handle" id="id79" name="id79">invalid_handle</a></li>
<li><a class="reference" href="#duplicate-torrent" id="id80" name="id80">duplicate_torrent</a></li>
<li><a class="reference" href="#invalid-encoding" id="id81" name="id81">invalid_encoding</a></li>
<li><a class="reference" href="#type-error" id="id82" name="id82">type_error</a></li>
<li><a class="reference" href="#invalid-torrent-file" id="id83" name="id83">invalid_torrent_file</a></li>
<li><a class="reference" href="#exceptions" id="id79" name="id79">exceptions</a><ul>
<li><a class="reference" href="#invalid-handle" id="id80" name="id80">invalid_handle</a></li>
<li><a class="reference" href="#duplicate-torrent" id="id81" name="id81">duplicate_torrent</a></li>
<li><a class="reference" href="#invalid-encoding" id="id82" name="id82">invalid_encoding</a></li>
<li><a class="reference" href="#type-error" id="id83" name="id83">type_error</a></li>
<li><a class="reference" href="#invalid-torrent-file" id="id84" name="id84">invalid_torrent_file</a></li>
</ul>
</li>
<li><a class="reference" href="#examples" id="id84" name="id84">examples</a><ul>
<li><a class="reference" href="#dump-torrent" id="id85" name="id85">dump_torrent</a></li>
<li><a class="reference" href="#simple-client" id="id86" name="id86">simple client</a></li>
<li><a class="reference" href="#examples" id="id85" name="id85">examples</a><ul>
<li><a class="reference" href="#dump-torrent" id="id86" name="id86">dump_torrent</a></li>
<li><a class="reference" href="#simple-client" id="id87" name="id87">simple client</a></li>
</ul>
</li>
<li><a class="reference" href="#fast-resume" id="id87" name="id87">fast resume</a><ul>
<li><a class="reference" href="#file-format" id="id88" name="id88">file format</a></li>
<li><a class="reference" href="#fast-resume" id="id88" name="id88">fast resume</a><ul>
<li><a class="reference" href="#file-format" id="id89" name="id89">file format</a></li>
</ul>
</li>
<li><a class="reference" href="#extensions" id="id89" name="id89">extensions</a><ul>
<li><a class="reference" href="#chat-messages" id="id90" name="id90">chat messages</a></li>
<li><a class="reference" href="#metadata-from-peers" id="id91" name="id91">metadata from peers</a></li>
<li><a class="reference" href="#extensions" id="id90" name="id90">extensions</a><ul>
<li><a class="reference" href="#chat-messages" id="id91" name="id91">chat messages</a></li>
<li><a class="reference" href="#metadata-from-peers" id="id92" name="id92">metadata from peers</a></li>
</ul>
</li>
<li><a class="reference" href="#filename-checks" id="id92" name="id92">filename checks</a></li>
<li><a class="reference" href="#aknowledgements" id="id93" name="id93">aknowledgements</a></li>
<li><a class="reference" href="#filename-checks" id="id93" name="id93">filename checks</a></li>
<li><a class="reference" href="#aknowledgements" id="id94" name="id94">aknowledgements</a></li>
</ul>
</div>
<div class="section" id="introduction">
@ -821,6 +822,7 @@ struct torrent_handle
bool is_paused() const;
boost::filsystem::path save_path() const;
bool move_storage(boost::filesystem::path const&amp; save_path);
sha1_hash info_hash() const;
@ -842,6 +844,19 @@ boost::filsystem::path save_path() const;
<p><tt class="literal"><span class="pre">save_path()</span></tt> returns the path that was given to <a class="reference" href="#add-torrent">add_torrent()</a> when this torrent
was started.</p>
</div>
<div class="section" id="move-storage">
<h2><a name="move-storage">move_storage()</a></h2>
<blockquote>
<pre class="literal-block">
bool move_storage(boost::filsystem::path const&amp; save_path);
</pre>
</blockquote>
<p>Moves the file(s) that this torrent are currently seeding from or downloading to. This
operation will only have the desired effect if the given <tt class="literal"><span class="pre">save_path</span></tt> is located on
the same drive as the original save path. If the move operation fails, this function
returns false, otherwise true. Post condition for successful operation is:
<tt class="literal"><span class="pre">save_path()</span> <span class="pre">==</span> <span class="pre">save_path</span></tt>.</p>
</div>
<div class="section" id="force-reannounce">
<h2><a name="force-reannounce">force_reannounce()</a></h2>
<blockquote>

View File

@ -768,6 +768,7 @@ Its declaration looks like this::
bool is_paused() const;
boost::filsystem::path save_path() const;
bool move_storage(boost::filesystem::path const& save_path);
sha1_hash info_hash() const;
@ -791,6 +792,19 @@ save_path()
``save_path()`` returns the path that was given to `add_torrent()`_ when this torrent
was started.
move_storage()
--------------
::
bool move_storage(boost::filsystem::path const& save_path);
Moves the file(s) that this torrent are currently seeding from or downloading to. This
operation will only have the desired effect if the given ``save_path`` is located on
the same drive as the original save path. If the move operation fails, this function
returns false, otherwise true. Post condition for successful operation is:
``save_path() == save_path``.
force_reannounce()
------------------

View File

@ -39,7 +39,6 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma warning(push, 1)
#endif
#include <boost/format.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/exception.hpp>
@ -244,7 +243,7 @@ int main(int argc, char* argv[])
session ses(fingerprint("LT", 0, 1, 0, 0));
ses.listen_on(std::make_pair(6881, 6889));
ses.set_upload_rate_limit(1000);
// ses.set_upload_rate_limit(1000);
// ses.set_download_rate_limit(50000);
ses.set_http_settings(settings);
ses.set_severity_level(alert::debug);
@ -369,6 +368,10 @@ int main(int argc, char* argv[])
p->handle.set_max_connections(10);
p->handle.set_max_uploads(5);
p->handle.set_upload_limit(10000);
// all finished downloades are
// moved into this directory
p->handle.move_storage("finished");
events.push_back(
p->handle.get_torrent_info().name() + ": " + a->msg());
}
@ -445,42 +448,40 @@ int main(int argc, char* argv[])
out << "next announce: " << boost::posix_time::to_simple_string(t) << "\n";
out << "tracker: " << s.current_tracker << "\n";
// out << "___________________________________\n";
out << "___________________________________\n";
out << " down up q r flags block\n";
for (std::vector<peer_info>::iterator i = peers.begin();
i != peers.end();
++i)
{
out << "d:" << add_suffix(i->down_speed) << "/s "
out.fill(' ');
out.width(2);
out << add_suffix(i->down_speed) << "/s "
// << "(" << add_suffix(i->total_download) << ") "
<< "u:" << add_suffix(i->up_speed) << "/s "
<< add_suffix(i->up_speed) << "/s "
// << "(" << add_suffix(i->total_upload) << ") "
// << "ul:" << add_suffix(i->upload_limit) << "/s "
// << "uc:" << add_suffix(i->upload_ceiling) << "/s "
// << "df:" << ratio(i->total_download, i->total_upload) << " "
<< "q:" << i->download_queue_length << " "
<< "r:" << i->upload_queue_length << " "
<< "f:"
<< i->download_queue_length << " "
<< i->upload_queue_length << " "
<< static_cast<const char*>((i->flags & peer_info::interesting)?"I":"_")
<< static_cast<const char*>((i->flags & peer_info::choked)?"C":"_")
<< static_cast<const char*>((i->flags & peer_info::remote_interested)?"i":"_")
<< static_cast<const char*>((i->flags & peer_info::remote_choked)?"c":"_")
<< static_cast<const char*>((i->flags & peer_info::supports_extensions)?"e":"_")
<< static_cast<const char*>((i->flags & peer_info::local_connection)?"l":"r")
<< "\n";
<< static_cast<const char*>((i->flags & peer_info::local_connection)?"l":"r");
if (i->downloading_piece_index >= 0)
{
out.width(5);
out.fill('0');
out << i->downloading_piece_index << ";"
<< i->downloading_block_index << ": ";
out << progress_bar(
out << " " << progress_bar(
i->downloading_progress / static_cast<float>(i->downloading_total)
, 50);
out << "\n";
, 15);
}
out << "\n";
}
out << "___________________________________\n";

View File

@ -93,6 +93,8 @@ namespace libtorrent
// may throw file_error if storage for slot hasn't been allocated
void write(const char* buf, int slot, int offset, int size);
bool move_storage(boost::filesystem::path const& save_path);
#ifndef NDEBUG
// overwrites some slots with the
// contents of others
@ -140,7 +142,8 @@ namespace libtorrent
, int offset
, int size);
const boost::filesystem::path& save_path() const;
boost::filesystem::path const& save_path() const;
bool move_storage(boost::filesystem::path const&);
// fills the vector that maps all allocated
// slots to the piece that is stored (or

View File

@ -324,6 +324,7 @@ namespace libtorrent
void set_upload_limit(int limit);
void set_download_limit(int limit);
bool move_storage(boost::filesystem::path const& save_path);
bool valid_metadata() const { return m_storage.get() != 0; }
std::vector<char> const& metadata() const { return m_metadata; }

View File

@ -207,6 +207,9 @@ namespace libtorrent
void set_tracker_login(std::string const& name, std::string const& password);
// post condition: save_path() == save_path if true is returned
bool move_storage(boost::filesystem::path const& save_path);
const sha1_hash& info_hash() const
{ return m_info_hash; }

View File

@ -58,6 +58,12 @@ namespace
using namespace libtorrent;
int decode_digit(char c)
{
if (std::isdigit(c)) return c - '0';
return std::toupper(c) - 'A' + 10;
}
// takes a peer id and returns a valid boost::optional
// object if the peer id matched the azureus style encoding
// the returned fingerprint contains information about the
@ -77,20 +83,20 @@ namespace
++i;
}
if (*i < '0') return boost::optional<fingerprint>();
ret.major_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.major_version = decode_digit(*i);
++i;
if (*i < '0') return boost::optional<fingerprint>();
ret.minor_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.minor_version = decode_digit(*i);
++i;
if (*i < '0') return boost::optional<fingerprint>();
ret.revision_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.revision_version = decode_digit(*i);
++i;
if (*i < '0') return boost::optional<fingerprint>();
ret.tag_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.tag_version = decode_digit(*i);
++i;
if (*i != '-') return boost::optional<fingerprint>();
@ -105,23 +111,23 @@ namespace
fingerprint ret("..", 0, 0, 0, 0);
peer_id::const_iterator i = id.begin();
if (*i < '0') return boost::optional<fingerprint>();
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.id[0] = *i;
ret.id[1] = 0;
++i;
if (std::equal(id.begin()+4, id.begin()+8, "----"))
{
if (*i < '0') return boost::optional<fingerprint>();
ret.major_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.major_version = decode_digit(*i);
++i;
if (*i < '0') return boost::optional<fingerprint>();
ret.minor_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.minor_version = decode_digit(*i);
++i;
if (*i < '0') return boost::optional<fingerprint>();
ret.revision_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.revision_version = decode_digit(*i);
}
else if (id[8] == 0)
{
@ -139,7 +145,6 @@ namespace
else
return boost::optional<fingerprint>();
ret.tag_version = 0;
return boost::optional<fingerprint>(ret);
}
@ -156,22 +161,22 @@ namespace
ret.id[1] = 0;
++i;
if (*i < '0') return boost::optional<fingerprint>();
ret.major_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.major_version = decode_digit(*i);
++i;
if (*i != '-') return boost::optional<fingerprint>();
++i;
if (*i < '0') return boost::optional<fingerprint>();
ret.minor_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.minor_version = decode_digit(*i);
++i;
if (*i != '-') return boost::optional<fingerprint>();
++i;
if (*i < '0') return boost::optional<fingerprint>();
ret.revision_version = *i - '0';
if (!std::isalnum(*i)) return boost::optional<fingerprint>();
ret.revision_version = decode_digit(*i);
++i;
if (!std::equal(i, i+1, "--")) return boost::optional<fingerprint>();
@ -190,7 +195,7 @@ namespace libtorrent
peer_id::const_iterator PID = p.begin();
boost::optional<fingerprint> f;
if (p.is_all_zeros()) return "Unkown";
if (p.is_all_zeros()) return "Unknown";
// look for azureus style id
f = parse_az_style(p);
@ -338,7 +343,10 @@ namespace libtorrent
return "SimpleBT";
}
if (std::equal(PID, PID + 7, "turbobt"))
if (std::equal(PID, PID + 7, "turbobt")
&& std::isalnum(PID[8])
&& std::isalnum(PID[10])
&& std::isalnum(PID[12]))
{
std::stringstream s;
s << "TurboBT " << PID[8] << "." << PID[10] << "." << PID[12];

View File

@ -127,6 +127,12 @@ namespace libtorrent { namespace detail
m_ses.m_torrents.insert(
std::make_pair(t->info_hash, t->torrent_ptr)).first;
if (t->torrent_ptr->is_seed() && m_ses.m_alerts.should_post(alert::info))
{
m_ses.m_alerts.post_alert(torrent_finished_alert(
t->torrent_ptr->get_handle()
, "torrent is complete"));
}
peer_id id;
std::fill(id.begin(), id.end(), 0);
@ -197,7 +203,7 @@ namespace libtorrent { namespace detail
m_key = rand() + (rand() << 15) + (rand() << 30);
std::string print = cl_fprint.to_string();
assert(print.length() == 8);
assert(print.length() <= 20);
// the client's fingerprint
std::copy(

View File

@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <ios>
#include <ctime>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <iterator>
@ -68,39 +69,6 @@ namespace std
}
#endif
/*
namespace
{
struct lazy_hash
{
mutable libtorrent::sha1_hash digest;
mutable libtorrent::hasher h;
mutable const char* data;
std::size_t size;
lazy_hash(const char* data_, std::size_t size_)
: data(data_)
, size(size_)
{
assert(data_ != 0);
assert(size_ > 0);
}
const libtorrent::sha1_hash& get() const
{
if (data)
{
h.update(data, size);
digest = h.final();
data = 0;
}
return digest;
}
};
} // namespace unnamed
*/
namespace fs = boost::filesystem;
namespace
@ -113,9 +81,9 @@ namespace
log.flush();
}
boost::filesystem::path get_filename(
fs::path get_filename(
libtorrent::torrent_info const& t
, boost::filesystem::path const& p)
, fs::path const& p)
{
assert(t.num_files() > 0);
if (t.num_files() == 1)
@ -130,7 +98,7 @@ namespace libtorrent
std::vector<size_type> get_filesizes(
const torrent_info& t
, const boost::filesystem::path& p)
, const fs::path& p)
{
std::vector<size_type> sizes;
for (torrent_info::file_iterator i = t.begin_files();
@ -155,7 +123,7 @@ namespace libtorrent
bool match_filesizes(
const torrent_info& t
, const boost::filesystem::path& p
, const fs::path& p
, const std::vector<size_type>& sizes)
{
if ((int)sizes.size() != t.num_files()) return false;
@ -232,7 +200,7 @@ namespace libtorrent
{}
torrent_info const& info;
const boost::filesystem::path save_path;
fs::path save_path;
};
storage::storage(const torrent_info& info, const fs::path& path)
@ -246,6 +214,38 @@ namespace libtorrent
m_pimpl.swap(other.m_pimpl);
}
// returns true on success
bool storage::move_storage(fs::path const& save_path)
{
std::string old_path;
std::string new_path;
if (m_pimpl->info.num_files() == 1)
{
old_path = (m_pimpl->save_path / m_pimpl->info.begin_files()->path)
.native_file_string();
new_path = (save_path / m_pimpl->info.begin_files()->path)
.native_file_string();
}
else
{
assert(m_pimpl->info.num_files() > 1);
old_path = (m_pimpl->save_path / m_pimpl->info.name())
.native_directory_string();
new_path = (save_path / m_pimpl->info.name())
.native_directory_string();
}
fs::create_directory(save_path);
int ret = std::rename(old_path.c_str(), new_path.c_str());
if (ret == 0)
{
m_pimpl->save_path = save_path;
return true;
}
return false;
}
#ifndef NDEBUG
void storage::shuffle()
@ -489,7 +489,7 @@ namespace libtorrent
impl(
const torrent_info& info
, const boost::filesystem::path& path);
, const fs::path& path);
void check_pieces(
boost::mutex& mutex
@ -517,9 +517,19 @@ namespace libtorrent
, int offset
, int size);
const boost::filesystem::path& save_path() const
fs::path const& save_path() const
{ return m_save_path; }
bool move_storage(fs::path const& save_path)
{
if (m_storage.move_storage(save_path))
{
m_save_path = save_path;
return true;
}
return false;
}
void export_piece_map(std::vector<int>& p) const;
private:
@ -570,7 +580,7 @@ namespace libtorrent
// it can either be 'unassigned' or 'unallocated'
std::vector<int> m_slot_to_piece;
boost::filesystem::path m_save_path;
fs::path m_save_path;
mutable boost::recursive_mutex m_mutex;
@ -1397,7 +1407,7 @@ namespace libtorrent
INVARIANT_CHECK;
namespace fs = boost::filesystem;
namespace fs = fs;
assert(!m_unallocated_slots.empty());
@ -1436,11 +1446,16 @@ namespace libtorrent
m_pimpl->allocate_slots(num_slots);
}
const boost::filesystem::path& piece_manager::save_path() const
fs::path const& piece_manager::save_path() const
{
return m_pimpl->save_path();
}
bool piece_manager::move_storage(fs::path const& save_path)
{
return m_pimpl->move_storage(save_path);
}
#ifndef NDEBUG
void piece_manager::impl::check_invariant() const
{

View File

@ -665,6 +665,11 @@ namespace libtorrent
return m_storage->save_path();
}
bool torrent::move_storage(boost::filesystem::path const& save_path)
{
return m_storage->move_storage(save_path);
}
piece_manager& torrent::filesystem()
{
assert(m_storage.get());

View File

@ -222,6 +222,14 @@ namespace libtorrent
, boost::bind(&torrent::set_download_limit, _1, limit));
}
bool torrent_handle::move_storage(boost::filesystem::path const& save_path)
{
INVARIANT_CHECK;
return call_member<bool>(m_ses, m_chk, m_info_hash
, boost::bind(&torrent::move_storage, _1, save_path));
}
bool torrent_handle::is_paused() const
{
INVARIANT_CHECK;