diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 06cb821cc..91f2dd2b1 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -118,12 +118,12 @@ bool sleep_and_input(char* c) void set_cursor(int x, int y) { - std::cout << "\033[" << y << ";" << x << "H"; +// std::cout << "\033[" << y << ";" << x << "H"; } void clear() { - std::cout << "\033[2J"; +// std::cout << "\033[2J"; } #endif diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 99042a9d6..f0d4c7a2d 100755 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -105,7 +105,7 @@ namespace libtorrent piece_checker_data(): progress(0.f), abort(false) {} boost::shared_ptr torrent_ptr; - std::string save_path; + boost::filesystem::path save_path; sha1_hash info_hash; @@ -197,17 +197,14 @@ namespace libtorrent { public: - session(int listen_port, const std::string& fingerprint = std::string()) - : m_impl(listen_port, fingerprint) - , m_checker_impl(&m_impl) - , m_thread(boost::ref(m_impl)) - , m_checker_thread(boost::ref(m_checker_impl)) - {} + session(int listen_port, const std::string& fingerprint = std::string()); ~session(); // all torrent_handles must be destructed before the session is destructed! - torrent_handle add_torrent(const torrent_info& ti, const std::string& save_path); + torrent_handle add_torrent( + const torrent_info& ti + , const boost::filesystem::path& save_path); void set_http_settings(const http_settings& s); diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index e455e1b63..b1e9b1c0a 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -102,14 +102,7 @@ namespace libtorrent void allocate_files(detail::piece_checker_data* data, boost::mutex& mutex, - const std::string& save_path) - { - m_storage.initialize_pieces(this, save_path, data, mutex); - m_picker.files_checked(m_storage.pieces()); -#ifndef NDEBUG - m_picker.integrity_check(this); -#endif - } + const boost::filesystem::path& save_path); void uploaded_bytes(int num_bytes) { assert(num_bytes > 0); m_bytes_uploaded += num_bytes; } void downloaded_bytes(int num_bytes) { assert(num_bytes > 0); m_bytes_downloaded += num_bytes; } diff --git a/src/session.cpp b/src/session.cpp index ed163aadf..b28a5add8 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -516,6 +516,7 @@ namespace libtorrent } + // the return value from this function is valid only as long as the // session is locked! torrent* session_impl::find_torrent(const sha1_hash& info_hash) @@ -528,9 +529,23 @@ namespace libtorrent } + session::session(int listen_port, const std::string& fingerprint) + : m_impl(listen_port, fingerprint) + , m_checker_impl(&m_impl) + , m_thread(boost::ref(m_impl)) + , m_checker_thread(boost::ref(m_checker_impl)) + { +#ifndef NDEBUG + boost::function0 test = boost::ref(m_impl); + assert(!test.empty()); +#endif + } + + // if the torrent already exists, this will throw duplicate_torrent - torrent_handle session::add_torrent(const torrent_info& ti, - const std::string& save_path) + torrent_handle session::add_torrent( + const torrent_info& ti + , const boost::filesystem::path& save_path) { { diff --git a/src/torrent.cpp b/src/torrent.cpp index 480c5e600..831dbd1ec 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -400,6 +400,17 @@ namespace libtorrent } } + void torrent::allocate_files(detail::piece_checker_data* data, + boost::mutex& mutex, + const boost::filesystem::path& save_path) + { + m_storage.initialize_pieces(this, save_path, data, mutex); + m_picker.files_checked(m_storage.pieces()); +#ifndef NDEBUG + m_picker.integrity_check(this); +#endif + } + torrent_status torrent::status() const { torrent_status st;