• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ torrent_info类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中torrent_info的典型用法代码示例。如果您正苦于以下问题:C++ torrent_info类的具体用法?C++ torrent_info怎么用?C++ torrent_info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了torrent_info类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: make_magnet_uri

	std::string make_magnet_uri(torrent_info const& info)
	{
		std::string ret;
		sha1_hash const& ih = info.info_hash();
		ret += "magnet:?xt=urn:btih:";
		ret += aux::to_hex(ih);

		std::string const& name = info.name();

		if (!name.empty())
		{
			ret += "&dn=";
			ret += escape_string(name);
		}

		for (auto const& tr : info.trackers())
		{
			ret += "&tr=";
			ret += escape_string(tr.url);
		}

		for (auto const& s : info.web_seeds())
		{
			if (s.type != web_seed_entry::url_seed) continue;

			ret += "&ws=";
			ret += escape_string(s.url);
		}

		return ret;
	}
开发者ID:Chocobo1,项目名称:libtorrent,代码行数:31,代码来源:magnet_uri.cpp


示例2: make_magnet_uri

	std::string make_magnet_uri(torrent_info const& info)
	{
		std::string ret;
		sha1_hash const& ih = info.info_hash();
		ret += "magnet:?xt=urn:btih:";
		ret += to_hex(ih.to_string());

		std::string const& name = info.name();

		if (!name.empty())
		{
			ret += "&dn=";
			ret += escape_string(name.c_str(), name.length());
		}

		std::vector<announce_entry> const& tr = info.trackers();

		for (std::vector<announce_entry>::const_iterator i = tr.begin(), end(tr.end()); i != end; ++i)
		{
			ret += "&tr=";
			ret += escape_string(i->url.c_str(), i->url.length());
		}

		std::vector<web_seed_entry> const& seeds = info.web_seeds();
		for (std::vector<web_seed_entry>::const_iterator i = seeds.begin()
			, end(seeds.end()); i != end; ++i)
		{
			if (i->type != web_seed_entry::url_seed) continue;

			ret += "&ws=";
			ret += escape_string(i->url.c_str(), i->url.length());
		}

		return ret;
	}
开发者ID:ycopy,项目名称:libtorrent,代码行数:35,代码来源:magnet_uri.cpp


示例3: get_file_extremity_pieces

static QPair<int, int> get_file_extremity_pieces(const torrent_info& t, int file_index)
{
    const int num_pieces = t.num_pieces();
    const int piece_size = t.piece_length();
    const file_entry& file = t.file_at(file_index);

    // Determine the first and last piece of the file
    int first_piece = floor((file.offset + 1) / (float) piece_size);
    Q_ASSERT(first_piece >= 0 && first_piece < num_pieces);

    int num_pieces_in_file = ceil(file.size / (float) piece_size);
    int last_piece = first_piece + num_pieces_in_file - 1;
    Q_ASSERT(last_piece >= 0 && last_piece < num_pieces);

    return qMakePair(first_piece, last_piece);
}
开发者ID:azuwis,项目名称:debian_qbittorrent,代码行数:16,代码来源:qtorrenthandle.cpp


示例4: make_magnet_uri

	std::string make_magnet_uri(torrent_info const& info)
	{
		std::stringstream ret;
		if (!info.is_valid()) return ret.str();

		std::string name = info.name();

		ret << "magnet:?xt=urn:btih:" << base32encode(
			std::string((char*)info.info_hash().begin(), 20));
		if (!name.empty())
			ret << "&dn=" << escape_string(name.c_str(), name.length());
		std::vector<announce_entry> const& tr = info.trackers();
		if (!tr.empty())
		{
			ret << "&tr=" << escape_string(tr[0].url.c_str()
				, tr[0].url.length());
		}
		return ret.str();
	}
开发者ID:huyang819,项目名称:cdn-partner,代码行数:19,代码来源:magnet_uri.cpp


示例5: make_magnet_uri

	std::string make_magnet_uri(torrent_info const& info)
	{
		char ret[1024];
		int num_chars = snprintf(ret, sizeof(ret), "magnet:?xt=urn:btih:%s"
			, base32encode(std::string((char*)info.info_hash().begin(), 20)).c_str());

		std::string const& name = info.name();

		if (!name.empty())
			num_chars += snprintf(ret + num_chars, sizeof(ret) - num_chars, "&dn=%s"
				, escape_string(name.c_str(), name.length()).c_str());

		std::vector<announce_entry> const& tr = info.trackers();
		if (!tr.empty())
		{
			num_chars += snprintf(ret + num_chars, sizeof(ret) - num_chars, "&tr=%s"
				, escape_string(tr[0].url.c_str(), tr[0].url.length()).c_str());
		}

		return ret;
	}
开发者ID:bgyss,项目名称:libtorrent,代码行数:21,代码来源:magnet_uri.cpp


示例6: GetTorrentInfo

openmagnet_info* TorrentManager::GetTorrentInfo(const torrent_handle& handle)
{
	if (handle.is_valid())
	{
		openmagnet_info* info = new openmagnet_info;
#if LIBTORRENT_VERSION_NUM >= 10000
		boost::intrusive_ptr<torrent_info const> ti = handle.torrent_file();
		info->size = ti->total_size();
		info->name = QString::fromUtf8(ti->name().c_str());
		info->describtion = QString::fromUtf8(ti->comment().c_str());
		info->files = ti->files();
		info->infoHash = QString::fromStdString(to_hex(ti->info_hash().to_string()));
#else
		const torrent_info ti = handle.get_torrent_info();
		info->size = ti.total_size();
		info->name = QString::fromUtf8(ti.name().c_str());
		info->describtion = QString::fromUtf8(ti.comment().c_str());
		info->files = ti.files();
		info->infoHash = QString::fromStdString(to_hex(ti.info_hash().to_string()));
#endif
		info->handle = handle;
		info->baseSuffix = StaticHelpers::GetBaseSuffix(info->files);
		return info;
	}

	return NULL;
}
开发者ID:sunpeng196,项目名称:CuteTorrent,代码行数:27,代码来源:TorrentManager.cpp


示例7: switch


//.........这里部分代码省略.........

				QString infoHash = QString::fromStdString(to_hex(h.info_hash().to_string()));
				Torrent* pTorrent = m_pTorrentStorrage->getTorrent(infoHash);

				if (pTorrent != NULL)
				{
					emit Notify(NotificationSystem::TORRENT_INFO, tr("MOVE_STORRAGE_COMPLETED_TO:\n%1 %2").arg(pTorrent->GetName(), pTorrent->GetSavePath()), pTorrent->GetSavePath());
					pTorrent->CompliteMoveStorrage();
				}

				break;
			}

			case fastresume_rejected_alert::alert_type:
			{
				fastresume_rejected_alert* p = alert_cast<fastresume_rejected_alert>(a);
				torrent_handle h = p->handle;
				h.auto_managed(false);
				h.pause();
				emit Notify(NotificationSystem::TORRENT_ERROR, StaticHelpers::translateLibTorrentError(p->error), QVariant());
				break;
			}

			case metadata_received_alert::alert_type:
			{
				metadata_received_alert* p = alert_cast<metadata_received_alert>(a);
				torrent_handle h = p->handle;

				if (h.is_valid())
				{
					try
					{
#if LIBTORRENT_VERSION_NUM >= 10000
						boost::intrusive_ptr<torrent_info const> ti = h.torrent_file();

						if (ti != NULL)
						{
							create_torrent ct(*ti.get());
							QString info_hash = QString::fromStdString(to_hex(ti->info_hash().to_string()));
#else
						const torrent_info ti = h.get_torrent_info();
						{
							create_torrent ct(ti);
							QString info_hash = QString::fromStdString(to_hex(ti.info_hash().to_string()));
#endif
							std::ofstream out(StaticHelpers::CombinePathes(dataDir, "BtSessionData", info_hash + ".torrent").toStdString(), std::ios_base::binary);
							bencode(std::ostream_iterator<char>(out), ct.generate());
						}
					}
					catch (...)
					{
						qCritical() << "Exception in metadata_received_alert";
					}
				}

				break;
			}

			case portmap_alert::alert_type:
			{
				portmap_alert* alert = alert_cast<portmap_alert>(a);
				emit Notify(NotificationSystem::SYSTEM_ERROR, QString::fromUtf8(alert->message().c_str()), QVariant());
			}

			case state_update_alert::alert_type:
			{
开发者ID:sunpeng196,项目名称:CuteTorrent,代码行数:67,代码来源:TorrentManager.cpp



注:本文中的torrent_info类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ track_list_t类代码示例发布时间:2022-05-31
下一篇:
C++ torrent_handle类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap