fixed to work with managed C++ projects.

This commit is contained in:
Arvid Norberg 2003-11-07 01:44:30 +00:00
parent 81289c9354
commit eb90660022
5 changed files with 36 additions and 20 deletions

View File

@ -118,12 +118,12 @@ bool sleep_and_input(char* c)
void set_cursor(int x, int y) void set_cursor(int x, int y)
{ {
std::cout << "\033[" << y << ";" << x << "H"; // std::cout << "\033[" << y << ";" << x << "H";
} }
void clear() void clear()
{ {
std::cout << "\033[2J"; // std::cout << "\033[2J";
} }
#endif #endif

View File

@ -105,7 +105,7 @@ namespace libtorrent
piece_checker_data(): progress(0.f), abort(false) {} piece_checker_data(): progress(0.f), abort(false) {}
boost::shared_ptr<torrent> torrent_ptr; boost::shared_ptr<torrent> torrent_ptr;
std::string save_path; boost::filesystem::path save_path;
sha1_hash info_hash; sha1_hash info_hash;
@ -197,17 +197,14 @@ namespace libtorrent
{ {
public: public:
session(int listen_port, const std::string& fingerprint = std::string()) 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(); ~session();
// all torrent_handles must be destructed before the session is destructed! // 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); void set_http_settings(const http_settings& s);

View File

@ -102,14 +102,7 @@ namespace libtorrent
void allocate_files(detail::piece_checker_data* data, void allocate_files(detail::piece_checker_data* data,
boost::mutex& mutex, boost::mutex& mutex,
const std::string& save_path) 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
}
void uploaded_bytes(int num_bytes) { assert(num_bytes > 0); m_bytes_uploaded += num_bytes; } 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; } void downloaded_bytes(int num_bytes) { assert(num_bytes > 0); m_bytes_downloaded += num_bytes; }

View File

@ -516,6 +516,7 @@ namespace libtorrent
} }
// the return value from this function is valid only as long as the // the return value from this function is valid only as long as the
// session is locked! // session is locked!
torrent* session_impl::find_torrent(const sha1_hash& info_hash) 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<void> test = boost::ref(m_impl);
assert(!test.empty());
#endif
}
// if the torrent already exists, this will throw duplicate_torrent // if the torrent already exists, this will throw duplicate_torrent
torrent_handle session::add_torrent(const torrent_info& ti, torrent_handle session::add_torrent(
const std::string& save_path) const torrent_info& ti
, const boost::filesystem::path& save_path)
{ {
{ {

View File

@ -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 torrent::status() const
{ {
torrent_status st; torrent_status st;