summaryrefslogtreecommitdiffstats
path: root/torrentparser.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2016-08-20 08:31:29 +0200
committerArno <arno@disconnect.de>2016-08-20 08:31:29 +0200
commitd47427a2d51fcc7f8e1f8926a706e04ff01603ed (patch)
tree22002ee669fbce025aad1782f75733843e3581be /torrentparser.cpp
parent8ab990b7c6fb5348b09f451878a80e2c70695876 (diff)
downloadShemovCleaner-d47427a2d51fcc7f8e1f8926a706e04ff01603ed.tar.gz
ShemovCleaner-d47427a2d51fcc7f8e1f8926a706e04ff01603ed.tar.bz2
ShemovCleaner-d47427a2d51fcc7f8e1f8926a706e04ff01603ed.zip
Present torrent files as a tree
A torrent info dictionary has two modes: single and multi files. When in multi-mode, the name-entry is the directory containing the files. Represent it as a tree. During testing I discovered a fatal bug in the torrent parser: If we encounter an invalid string, we have to move mPos forward, else we will loop indefinitely until we're OOM. I also added some icons for folders, files and trackers.
Diffstat (limited to 'torrentparser.cpp')
-rw-r--r--torrentparser.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/torrentparser.cpp b/torrentparser.cpp
index fc59233..8e09681 100644
--- a/torrentparser.cpp
+++ b/torrentparser.cpp
@@ -2,7 +2,7 @@
#include "torrentparser.h"
-TorrentParser::TorrentParser(const QString file, QObject *parent) : QObject(parent), mFile(file), mPos(0), mOk(true) {}
+TorrentParser::TorrentParser(const QString file, QObject *parent) : QObject(parent), mFile(file), mPos(0) {}
const QList<QVariant> TorrentParser::parse(){
QFile f(mFile);
@@ -41,12 +41,11 @@ const QVariant TorrentParser::parseObject(){
const QByteArray TorrentParser::parseString(){
int lenlen = mData.indexOf(':', mPos) - mPos;
if(lenlen <= 0){
- mOk = false;
+ ++mPos;
return QByteArray();
}
int len = mData.mid(mPos, lenlen).toInt();
if(mPos + len > mData.size()){
- mOk = false;
return QByteArray();
}
mPos = mPos + lenlen + 1;
@@ -82,8 +81,6 @@ const QList<QVariant> TorrentParser::parseList(){
return retval;
}
-
-
const QHash<QString,QVariant> TorrentParser::parseDict(){
QHash<QString,QVariant> retval;
if(mData.at(mPos) != 'd'){