1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-10 14:57:52 +00:00

Code clean up

This commit is contained in:
Christophe Dumez 2011-03-10 17:42:17 +00:00
parent 879a010c3d
commit e7abeb9bd4

View File

@ -89,16 +89,16 @@ void TorrentCreatorThread::run() {
try { try {
file_storage fs; file_storage fs;
// Adding files to the torrent // Adding files to the torrent
add_files(fs, input_path.toUtf8().constData(), file_filter); libtorrent::add_files(fs, input_path.toUtf8().constData(), file_filter);
if(abort) return; if(abort) return;
create_torrent t(fs, piece_size); create_torrent t(fs, piece_size);
// Add url seeds // Add url seeds
foreach(const QString &seed, url_seeds){ foreach(const QString &seed, url_seeds){
t.add_url_seed(seed.trimmed().toLocal8Bit().data()); t.add_url_seed(seed.trimmed().toStdString());
} }
foreach(const QString &tracker, trackers) { foreach(const QString &tracker, trackers) {
t.add_tracker(tracker.trimmed().toLocal8Bit().data()); t.add_tracker(tracker.trimmed().toStdString());
} }
if(abort) return; if(abort) return;
// calculate the hash for all pieces // calculate the hash for all pieces
@ -116,7 +116,7 @@ void TorrentCreatorThread::run() {
std::vector<char> torrent; std::vector<char> torrent;
bencode(back_inserter(torrent), t.generate()); bencode(back_inserter(torrent), t.generate());
QFile outfile(save_path); QFile outfile(save_path);
if(outfile.open(QIODevice::WriteOnly)) { if(!torrent.empty() && outfile.open(QIODevice::WriteOnly)) {
outfile.write(&torrent[0], torrent.size()); outfile.write(&torrent[0], torrent.size());
outfile.close(); outfile.close();
emit updateProgress(100); emit updateProgress(100);