mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Stop using load_file from libtorrent
This commit is contained in:
parent
721fa821f7
commit
47c2f2e30a
@ -74,6 +74,7 @@
|
|||||||
#include "libtorrent/error_code.hpp"
|
#include "libtorrent/error_code.hpp"
|
||||||
#endif
|
#endif
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
@ -746,7 +747,13 @@ void QBtSession::resumeTorrent(QString hash) {
|
|||||||
bool QBtSession::loadFastResumeData(QString hash, std::vector<char> &buf) {
|
bool QBtSession::loadFastResumeData(QString hash, std::vector<char> &buf) {
|
||||||
const QString fastresume_path = QDir(misc::BTBackupLocation()).absoluteFilePath(hash+QString(".fastresume"));
|
const QString fastresume_path = QDir(misc::BTBackupLocation()).absoluteFilePath(hash+QString(".fastresume"));
|
||||||
qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path));
|
qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path));
|
||||||
return (load_file(qPrintable(fastresume_path), buf) == 0);
|
QFile fastresume_file(fastresume_path);
|
||||||
|
if(!fastresume_file.open(QIODevice::ReadOnly)) return false;
|
||||||
|
const QByteArray content = fastresume_file.readAll();
|
||||||
|
const int content_size = content.size();
|
||||||
|
buf.resize(content_size);
|
||||||
|
memcpy(&buf[0], content.data(), content_size);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::loadTorrentSettings(QTorrentHandle h) {
|
void QBtSession::loadTorrentSettings(QTorrentHandle h) {
|
||||||
@ -1299,20 +1306,17 @@ void QBtSession::loadSessionState() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if LIBTORRENT_VERSION_MINOR > 14
|
#if LIBTORRENT_VERSION_MINOR > 14
|
||||||
|
QFile state_file(state_path);
|
||||||
|
if(!state_file.open(QIODevice::ReadOnly)) return;
|
||||||
std::vector<char> in;
|
std::vector<char> in;
|
||||||
if (load_file(state_path.toUtf8().constData(), in) == 0)
|
const QByteArray content = state_file.readAll();
|
||||||
{
|
const int content_size = content.size();
|
||||||
lazy_entry e;
|
in.resize(content_size);
|
||||||
#if LIBTORRENT_VERSION_MINOR > 15
|
memcpy(&in[0], content.data(), content_size);
|
||||||
error_code ec;
|
// bdecode
|
||||||
lazy_bdecode(&in[0], &in[0] + in.size(), e, ec);
|
lazy_entry e;
|
||||||
if(!ec)
|
if (lazy_bdecode(&in[0], &in[0] + in.size(), e) == 0)
|
||||||
s->load_state(e);
|
s->load_state(e);
|
||||||
#else
|
|
||||||
if (lazy_bdecode(&in[0], &in[0] + in.size(), e) == 0)
|
|
||||||
s->load_state(e);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
boost::filesystem::ifstream ses_state_file(state_path.toUtf8().constData()
|
boost::filesystem::ifstream ses_state_file(state_path.toUtf8().constData()
|
||||||
, std::ios_base::binary);
|
, std::ios_base::binary);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user