Exemple #1
0
//! translate handle status to P2Pstatus
P2P::FileStatus TorrentWrapper::getP2PStatusFromHandle( const libtorrent::torrent_handle& handle ) const
{
	if ( !handle.is_valid() )
		return P2P::not_stored;
	if ( handle.is_seed() )
		return P2P::complete;
	if ( handle.is_paused() )
		return P2P::paused;
	if ( handle.queue_position() > m_torr->settings().active_downloads )
		return P2P::queued;
	return P2P::leeching;
}
void TorrentManager::createTorrent(lt::torrent_handle & handle)
{
    if (handle.is_valid()) {
        boost::shared_ptr<const lt::torrent_info> info = handle.torrent_file();
        
        lt::create_torrent createTorrent(*info);
        lt::entry entry = createTorrent.generate();

        string path = m_torrentsPath + "/" + lt::to_hex(info->info_hash().to_string()) + ".torrent";
        writeBencodedTree(path, entry);
    }
}