-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpathscanner.cpp
More file actions
30 lines (27 loc) · 892 Bytes
/
Copy pathpathscanner.cpp
File metadata and controls
30 lines (27 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "pathscanner.h"
PathScanner::PathScanner()
{
}
QStringList & PathScanner::scanDirectory(const QString &directoryPath, const QStringList & filters, const bool rootLevelCall)
{
if(rootLevelCall) {
foundPaths.clear();
}
QDir dir(directoryPath);
if(dir.exists()) {
if(!filters.isEmpty()) {
dir.setNameFilters(filters);
}
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks);
QStringList filesList = dir.entryList();
for(QString f : filesList) {
foundPaths.append(dir.absolutePath() + "/" + f);
}
dir.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
QStringList dirList = dir.entryList();
for(QString d : dirList) {
scanDirectory(dir.absolutePath() + "/" +d, filters, false);
}
}
return foundPaths;
}