- Remove old folders after renaming

This commit is contained in:
Christophe Dumez 2009-12-19 16:53:27 +00:00
parent 28ecb2fe1d
commit 7d66c07cef
3 changed files with 181 additions and 159 deletions

View file

@ -269,6 +269,19 @@ public:
list.insert(i, value);
}
static bool removeEmptyTree(QString path) {
QDir dir(path);
foreach(QString child, dir.entryList(QDir::AllDirs)) {
if(child == "." || child == "..") continue;
return removeEmptyTree(dir.absoluteFilePath(child));
}
QString dir_name = dir.dirName();
if(dir.cdUp()) {
return dir.rmdir(dir_name);
}
return false;
}
static QString magnetUriToHash(QString magnet_uri) {
QString hash = "";
QRegExp regHex("urn:btih:([0-9A-Za-z]+)");