mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-03 06:02:29 -06:00
Get rid of libboost-filesystem dependency if libtorrent >= v0.16.x is used
This commit is contained in:
@@ -71,9 +71,11 @@
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
#include <libtorrent/upnp.hpp>
|
||||
#include <libtorrent/natpmp.hpp>
|
||||
#if LIBTORRENT_VERSION_MINOR < 16
|
||||
#include <boost/filesystem/exception.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#endif
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
#include "libtorrent/error_code.hpp"
|
||||
#endif
|
||||
@@ -105,8 +107,10 @@ QBtSession::QBtSession()
|
||||
BigRatioTimer->setInterval(10000);
|
||||
connect(BigRatioTimer, SIGNAL(timeout()), SLOT(processBigRatios()));
|
||||
Preferences pref;
|
||||
#if LIBTORRENT_VERSION_MINOR < 16
|
||||
// To avoid some exceptions
|
||||
boost::filesystem::path::default_name_check(boost::filesystem::no_check);
|
||||
#endif
|
||||
// Creating Bittorrent session
|
||||
QList<int> version;
|
||||
version << VERSION_MAJOR;
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
#include <libtorrent/bencode.hpp>
|
||||
#include <libtorrent/entry.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#include <Windows.h>
|
||||
@@ -638,18 +637,22 @@ void QTorrentHandle::move_storage(QString new_path) const {
|
||||
|
||||
bool QTorrentHandle::save_torrent_file(QString path) const {
|
||||
if(!has_metadata()) return false;
|
||||
QFile met_file(path);
|
||||
if(met_file.open(QIODevice::WriteOnly)) {
|
||||
entry meta = bdecode(torrent_handle::get_torrent_info().metadata().get(), torrent_handle::get_torrent_info().metadata().get()+torrent_handle::get_torrent_info().metadata_size());
|
||||
entry torrent_file(entry::dictionary_t);
|
||||
torrent_file["info"] = meta;
|
||||
if(!torrent_handle::trackers().empty())
|
||||
torrent_file["announce"] = torrent_handle::trackers().front().url;
|
||||
boost::filesystem::ofstream out(path.toLocal8Bit().constData(), std::ios_base::binary);
|
||||
out.unsetf(std::ios_base::skipws);
|
||||
bencode(std::ostream_iterator<char>(out), torrent_file);
|
||||
|
||||
entry meta = bdecode(torrent_handle::get_torrent_info().metadata().get(), torrent_handle::get_torrent_info().metadata().get()+torrent_handle::get_torrent_info().metadata_size());
|
||||
entry torrent_entry(entry::dictionary_t);
|
||||
torrent_entry["info"] = meta;
|
||||
if(!torrent_handle::trackers().empty())
|
||||
torrent_entry["announce"] = torrent_handle::trackers().front().url;
|
||||
|
||||
vector<char> out;
|
||||
bencode(back_inserter(out), torrent_entry);
|
||||
QFile torrent_file(path);
|
||||
if (!out.empty() && torrent_file.open(QIODevice::WriteOnly)) {
|
||||
torrent_file.write(&out[0], out.size());
|
||||
torrent_file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user