mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 01:33:07 -07:00
Load torrents that have big metadata file. Closes #1889.
This commit is contained in:
parent
0adb9fcbce
commit
f35e06540e
5 changed files with 115 additions and 76 deletions
13
src/misc.cpp
13
src/misc.cpp
|
@ -77,6 +77,7 @@ const int UNLEN = 256;
|
|||
#include <libtorrent/sha1_hash.hpp>
|
||||
#endif
|
||||
#include <libtorrent/escape_string.hpp>
|
||||
#include <libtorrent/lazy_entry.hpp>
|
||||
|
||||
using namespace libtorrent;
|
||||
|
||||
|
@ -655,6 +656,18 @@ bool misc::slowEquals(const QByteArray &a, const QByteArray &b)
|
|||
return (diff == 0);
|
||||
}
|
||||
|
||||
void misc::loadBencodedFile(const QString &filename, std::vector<char> &buffer, libtorrent::lazy_entry &entry, libtorrent::error_code &ec)
|
||||
{
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::ReadOnly)) return;
|
||||
const qint64 content_size = file.bytesAvailable();
|
||||
if (content_size <= 0) return;
|
||||
buffer.resize(content_size);
|
||||
file.read(&buffer[0], content_size);
|
||||
// bdecode
|
||||
lazy_bdecode(&buffer[0], &buffer[0] + buffer.size(), entry, ec);
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Trick to get a portable sleep() function
|
||||
class SleeperThread : public QThread {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue