summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2009-08-11 16:11:30 (GMT)
committerJoerg Bornemann <joerg.bornemann@trolltech.com>2009-08-11 16:22:16 (GMT)
commit53576b4d3c3e7325d01efba6c4da80299492f2db (patch)
tree6089bb66a4a8ce6f4d62378c833604c1574a9729
parentf36fb8b2b63b3734cc2bd66b329ca4fef1204845 (diff)
downloadQt-53576b4d3c3e7325d01efba6c4da80299492f2db.zip
Qt-53576b4d3c3e7325d01efba6c4da80299492f2db.tar.gz
Qt-53576b4d3c3e7325d01efba6c4da80299492f2db.tar.bz2
QFSFileEngine must set LocalDiskFlag regardless file exists or not
LocalDiskFlag actually means "Local File Engine" and can be effectively used for testing file path for target storage type (local/network/virtual and so on) Merge-request: 1176 Reviewed-by: Joerg Bornemann <joerg.bornemann@trolltech.com>
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp5
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp26
2 files changed, 29 insertions, 2 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index c2b993b..52fe44e 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -1540,8 +1540,9 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::Fil
}
}
if (type & FlagsMask) {
- if(d->doStat()) {
- ret |= QAbstractFileEngine::FileFlags(ExistsFlag | LocalDiskFlag);
+ ret |= LocalDiskFlag;
+ if (d->doStat()) {
+ ret |= ExistsFlag;
if (d->filePath == QLatin1String("/") || (d->filePath.at(0).isLetter() && d->filePath.mid(1,d->filePath.length()) == QLatin1String(":/"))
|| isUncRoot(d->filePath)) {
ret |= RootFlag;
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index fa2bd6e..306ca49 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -147,6 +147,9 @@ private slots:
void isBundle_data();
void isBundle();
+ void isLocalFs_data();
+ void isLocalFs();
+
void refresh();
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
@@ -1024,6 +1027,29 @@ void tst_QFileInfo::isBundle()
QCOMPARE(fi.isBundle(), isBundle);
}
+void tst_QFileInfo::isLocalFs_data()
+{
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<bool>("isLocalFs");
+
+ QTest::newRow("local root") << QString::fromLatin1("/") << true;
+ QTest::newRow("local non-existent file") << QString::fromLatin1("/abrakadabra.boo") << true;
+
+ QTest::newRow("qresource root") << QString::fromLatin1(":/") << false;
+}
+
+void tst_QFileInfo::isLocalFs()
+{
+ QFETCH(QString, path);
+ QFETCH(bool, isLocalFs);
+
+ QFileInfo info(path);
+ QFileInfoPrivate *privateInfo = getPrivate(info);
+ QVERIFY(privateInfo->data->fileEngine);
+ QCOMPARE(bool(privateInfo->data->fileEngine->fileFlags(QAbstractFileEngine::LocalDiskFlag)
+ & QAbstractFileEngine::LocalDiskFlag), isLocalFs);
+}
+
void tst_QFileInfo::refresh()
{
#if defined(Q_OS_WINCE)