summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2009-08-11 16:11:27 (GMT)
committerJoerg Bornemann <joerg.bornemann@trolltech.com>2009-08-11 16:21:30 (GMT)
commitf36fb8b2b63b3734cc2bd66b329ca4fef1204845 (patch)
tree18f7dd3fa9d7a88abdac58d5ac3afe9773eb80f3
parent7fe0dfb80efd67886a33fe8b37e9714175925688 (diff)
downloadQt-f36fb8b2b63b3734cc2bd66b329ca4fef1204845.zip
Qt-f36fb8b2b63b3734cc2bd66b329ca4fef1204845.tar.gz
Qt-f36fb8b2b63b3734cc2bd66b329ca4fef1204845.tar.bz2
'.' and '..' must not be hidden
_unix code always sets HiddenFlag for special dirs which is wrong; also there is some inconsistence under win: * FindFirstFile sets FILE_ATTRIBUTE_HIDDEN flag for ".." of hidden dir *even* if parent dir is not hidden; * GetFileAttributes sets FILE_ATTRIBUTE_HIDDEN flag for ".." *only* if parent dir is hidden. so, _win part sets HiddenFlag wrong too; finally, we never test parent dir's flags; futhermore hidden special dirs (dotAndDotDot) makes dir iterator's filtering a bit more complex Merge-request: 1176 Reviewed-by: Joerg Bornemann <joerg.bornemann@trolltech.com>
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp18
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp7
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp13
3 files changed, 28 insertions, 10 deletions
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 4d451e6..ff10a44 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -656,15 +656,19 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const
ret |= LocalDiskFlag;
if (exists)
ret |= ExistsFlag;
- QString baseName = fileName(BaseName);
- if ((baseName.size() > 0 && baseName.at(0) == QLatin1Char('.'))
+ if (d->filePath == QLatin1String("/")) {
+ ret |= RootFlag;
+ } else {
+ QString baseName = fileName(BaseName);
+ if ((baseName.size() > 1
+ && baseName.at(0) == QLatin1Char('.') && baseName.at(1) != QLatin1Char('.'))
#if !defined(QWS) && defined(Q_OS_MAC)
- || _q_isMacHidden(d->filePath)
+ || _q_isMacHidden(d->filePath)
#endif
- )
- ret |= HiddenFlag;
- if (d->filePath == QLatin1String("/"))
- ret |= RootFlag;
+ ) {
+ ret |= HiddenFlag;
+ }
+ }
}
return ret;
}
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 25fbae8..c2b993b 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -1542,12 +1542,13 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::Fil
if (type & FlagsMask) {
if(d->doStat()) {
ret |= QAbstractFileEngine::FileFlags(ExistsFlag | LocalDiskFlag);
- if (d->fileAttrib & FILE_ATTRIBUTE_HIDDEN)
- ret |= HiddenFlag;
if (d->filePath == QLatin1String("/") || (d->filePath.at(0).isLetter() && d->filePath.mid(1,d->filePath.length()) == QLatin1String(":/"))
|| isUncRoot(d->filePath)) {
ret |= RootFlag;
- ret &= ~HiddenFlag;
+ } else if (d->fileAttrib & FILE_ATTRIBUTE_HIDDEN) {
+ QString baseName = fileName(BaseName);
+ if (baseName != QLatin1String(".") && baseName != QLatin1String(".."))
+ ret |= HiddenFlag;
}
}
}
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index e2800e5..fa2bd6e 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -974,9 +974,22 @@ void tst_QFileInfo::isHidden_data()
foreach (const QFileInfo& info, QDir::drives()) {
QTest::newRow(qPrintable("drive." + info.path())) << info.path() << false;
}
+
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ QTest::newRow("C:/RECYCLER") << QString::fromLatin1("C:/RECYCLER") << true;
+ QTest::newRow("C:/RECYCLER/.") << QString::fromLatin1("C:/RECYCLER/.") << false;
+ QTest::newRow("C:/RECYCLER/..") << QString::fromLatin1("C:/RECYCLER/..") << false;
+#endif
+#if defined(Q_OS_UNIX)
+ QTest::newRow("~/.qt") << QDir::homePath() + QString("/.qt") << true;
+ QTest::newRow("~/.qt/.") << QDir::homePath() + QString("/.qt/.") << false;
+ QTest::newRow("~/.qt/..") << QDir::homePath() + QString("/.qt/..") << false;
+#endif
+
#if !defined(Q_OS_WIN)
QTest::newRow("/bin/") << QString::fromLatin1("/bin/") << false;
#endif
+
#ifdef Q_OS_MAC
QTest::newRow("mac_etc") << QString::fromLatin1("/etc") << true;
QTest::newRow("mac_private_etc") << QString::fromLatin1("/private/etc") << false;