Add preliminary support of libtorrent v1.2

libtorrent v1.2 should be built with deprecated features enabled.
This commit is contained in:
Vladimir Golovnev (Glassez)
2019-03-06 08:58:07 +03:00
parent 20f2c86d25
commit ead078a38e
37 changed files with 646 additions and 370 deletions

View File

@@ -34,6 +34,7 @@
#include <libtorrent/create_torrent.hpp>
#include <libtorrent/storage.hpp>
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/version.hpp>
#include <QDirIterator>
#include <QFile>
@@ -47,6 +48,12 @@
namespace
{
#if (LIBTORRENT_VERSION_NUM < 10200)
using CreateFlags = int;
#else
using CreateFlags = lt::create_flags_t;
#endif
// do not include files and folders whose
// name starts with a .
bool fileFilter(const std::string &f)
@@ -131,7 +138,7 @@ void TorrentCreatorThread::run()
if (isInterruptionRequested()) return;
libt::create_torrent newTorrent(fs, m_params.pieceSize, -1
, (m_params.isAlignmentOptimized ? libt::create_torrent::optimize_alignment : 0));
, (m_params.isAlignmentOptimized ? libt::create_torrent::optimize_alignment : CreateFlags {}));
// Add url seeds
for (QString seed : asConst(m_params.urlSeeds)) {
@@ -203,5 +210,5 @@ int TorrentCreatorThread::calculateTotalPieces(const QString &inputPath, const i
libt::add_files(fs, Utils::Fs::toNativePath(inputPath).toStdString(), fileFilter);
return libt::create_torrent(fs, pieceSize, -1
, (isAlignmentOptimized ? libt::create_torrent::optimize_alignment : 0)).num_pieces();
, (isAlignmentOptimized ? libt::create_torrent::optimize_alignment : CreateFlags {})).num_pieces();
}