make use of QDir::NoDotAndDotDot

Change-Id: Ib4bdc0d4051fed25dec7dc030658b4d0822a37bd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
Joerg Bornemann 2014-04-29 12:42:54 +02:00 committed by The Qt Project
parent 159465536f
commit 818eae42cb
2 changed files with 12 additions and 16 deletions

View File

@ -370,7 +370,8 @@ MakefileGenerator::findFilesInVPATH(ProStringList l, uchar flags, const QString
regex.remove(0, dir.length());
}
if(real_dir.isEmpty() || exists(real_dir)) {
QStringList files = QDir(real_dir).entryList(QStringList(regex));
QStringList files = QDir(real_dir).entryList(QStringList(regex),
QDir::NoDotAndDotDot | QDir::AllEntries);
if(files.isEmpty()) {
debug_msg(1, "%s:%d Failure to find %s in vpath (%s)",
__FILE__, __LINE__,
@ -383,8 +384,6 @@ MakefileGenerator::findFilesInVPATH(ProStringList l, uchar flags, const QString
l.removeAt(val_it);
QString a;
for(int i = (int)files.count()-1; i >= 0; i--) {
if(files[i] == "." || files[i] == "..")
continue;
a = real_dir + files[i];
if(!(flags & VPATH_NoFixify))
a = fileFixify(a);
@ -1324,7 +1323,8 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
continue;
}
QString local_dirstr = Option::fixPathToLocalOS(dirstr, true);
QStringList files = QDir(local_dirstr).entryList(QStringList(filestr));
QStringList files = QDir(local_dirstr).entryList(QStringList(filestr),
QDir::NoDotAndDotDot | QDir::AllEntries);
if (installConfigValues.contains("no_check_exist") && files.isEmpty()) {
QString dst_file = filePrefixRoot(root, dst_dir);
QString cmd;
@ -1346,8 +1346,6 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
}
for(int x = 0; x < files.count(); x++) {
QString file = files[x];
if(file == "." || file == "..") //blah
continue;
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + file, FileFixifyAbsolute, false))));
QFileInfo fi(fileInfo(dirstr + file));
QString dst_file = filePrefixRoot(root, fileFixify(dst_dir, FileFixifyAbsolute, false));

View File

@ -137,12 +137,9 @@ ProjectGenerator::init()
regex = regex.right(regex.length() - (s+1));
}
if (Option::recursive) {
QStringList entries = QDir(dir).entryList(QDir::Dirs);
for(int i = 0; i < (int)entries.count(); i++) {
if(entries[i] != "." && entries[i] != "..") {
dirs.append(dir + entries[i] + QDir::separator() + regex);
}
}
QStringList entries = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i = 0; i < entries.count(); i++)
dirs.append(dir + entries[i] + QDir::separator() + regex);
}
QStringList files = QDir(dir).entryList(QDir::nameFiltersFromString(regex));
for(int i = 0; i < (int)files.count(); i++) {
@ -192,10 +189,10 @@ ProjectGenerator::init()
}
}
if (Option::recursive) {
QStringList dirs = QDir(newdir).entryList(QDir::Dirs);
QStringList dirs = QDir(newdir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for(int i = 0; i < (int)dirs.count(); i++) {
QString nd = fileFixify(newdir + QDir::separator() + dirs[i]);
if(dirs[i] != "." && dirs[i] != ".." && !knownDirs.contains(nd, Qt::CaseInsensitive))
if (!knownDirs.contains(nd, Qt::CaseInsensitive))
knownDirs.append(nd);
}
}
@ -207,12 +204,13 @@ ProjectGenerator::init()
dir = regx.left(s+1);
regx = regx.right(regx.length() - (s+1));
}
QStringList files = QDir(dir).entryList(QDir::nameFiltersFromString(regx), QDir::Dirs);
QStringList files = QDir(dir).entryList(QDir::nameFiltersFromString(regx),
QDir::Dirs | QDir::NoDotAndDotDot);
ProStringList &subdirs = v["SUBDIRS"];
for(int i = 0; i < (int)files.count(); i++) {
QString newdir(dir + files[i]);
QFileInfo fi(fileInfo(newdir));
if(fi.fileName() != "." && fi.fileName() != "..") {
{
newdir = fileFixify(newdir);
if(exists(fi.filePath() + QDir::separator() + fi.fileName() + Option::pro_ext) &&
!subdirs.contains(newdir)) {