Merge pull request #6842 from Chocobo1/countPieces

[TorrentCreator] Show total number of pieces. Closes #6774.
This commit is contained in:
sledgehammer999
2017-06-02 08:56:10 +03:00
committed by GitHub
5 changed files with 36 additions and 0 deletions

View File

@@ -160,3 +160,13 @@ void TorrentCreatorThread::run()
emit creationFailure(QString::fromStdString(e.what()));
}
}
int TorrentCreatorThread::calculateTotalPieces(const QString &inputPath, const int pieceSize)
{
if (inputPath.isEmpty())
return 0;
libt::file_storage fs;
libt::add_files(fs, Utils::Fs::toNativePath(inputPath).toStdString(), fileFilter);
return libt::create_torrent(fs, pieceSize).num_pieces();
}

View File

@@ -47,6 +47,8 @@ namespace BitTorrent
void create(const QString &inputPath, const QString &savePath, const QStringList &trackers,
const QStringList &urlSeeds, const QString &comment, bool isPrivate, int pieceSize);
static int calculateTotalPieces(const QString &inputPath, const int pieceSize);
protected:
void run();