1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Update genflist tool to search recursively

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-11-10 18:50:55 +01:00
parent b1c68734d8
commit 1a8d77ccfa
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -2,6 +2,7 @@
#include <QFile>
#include <QByteArray>
#include <QDir>
#include <QStack>
#include <QCryptographicHash>
#include <sodium.h>
#include "serialize.h"
@ -15,6 +16,31 @@ using namespace std;
///
/// The generated flist is very simple and just installs everything in the working directory ...
QList<QString> scanDir(QDir dir)
{
QList<QString> files;
QStack<QString> stack;
stack.push(dir.absolutePath());
while (!stack.isEmpty()) {
QString sSubdir = stack.pop();
QDir subdir(sSubdir);
// Check for the files.
QList<QString> sublist = subdir.entryList(QDir::Files);
for (QString& file : sublist)
file = dir.relativeFilePath(sSubdir + '/' + file);
files += sublist;
QFileInfoList infoEntries = subdir.entryInfoList(QStringList(),
QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
for (int i = 0; i < infoEntries.size(); i++) {
QFileInfo& item = infoEntries[i];
stack.push(item.absoluteFilePath());
}
}
return files;
}
int main(int argc, char* argv[])
{
cout << "qTox updater flist generator" << endl;
@ -56,7 +82,7 @@ int main(int argc, char* argv[])
return 1;
}
QStringList filesListStr = sdir.entryList(QDir::Files);
QStringList filesListStr = scanDir(sdir);
/// Serialize the flist data
QByteArray flistData;