summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2009-08-11 16:11:33 (GMT)
committerJoerg Bornemann <joerg.bornemann@trolltech.com>2009-08-11 16:22:43 (GMT)
commit7fe142cfcf27632a455ce193fa57c131afea61cc (patch)
tree1f1a0b372d792569c9d542dbffe08c85ac8651c7 /src
parent53576b4d3c3e7325d01efba6c4da80299492f2db (diff)
downloadQt-7fe142cfcf27632a455ce193fa57c131afea61cc.zip
Qt-7fe142cfcf27632a455ce193fa57c131afea61cc.tar.gz
Qt-7fe142cfcf27632a455ce193fa57c131afea61cc.tar.bz2
move dubbed code into static funtion
Merge-request: 1176 Reviewed-by: Joerg Bornemann <joerg.bornemann@trolltech.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 52fe44e..2c9b977 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -337,6 +337,13 @@ static bool uncShareExists(const QString &server)
return false;
}
+static bool isDriveRoot(const QString &path)
+{
+ return (path.length() == 3
+ && path.at(0).isLetter() && path.at(1) == QLatin1Char(':')
+ && path.at(2) == QLatin1Char('/'));
+}
+
static QString nativeAbsoluteFilePathCore(const QString &path)
{
QString ret;
@@ -1217,8 +1224,8 @@ bool QFSFileEnginePrivate::doStat() const
could_stat = fileAttrib != INVALID_FILE_ATTRIBUTES;
if (!could_stat) {
#if !defined(Q_OS_WINCE)
- if (!fname.isEmpty() && fname.at(0).isLetter() && fname.mid(1, fname.length()) == QLatin1String(":/")) {
- // an empty drive ??
+ if (isDriveRoot(fname)) {
+ // a valid drive ??
DWORD drivesBitmask = ::GetLogicalDrives();
int drivebit = 1 << (fname.at(0).toUpper().unicode() - QLatin1Char('A').unicode());
if (drivesBitmask & drivebit) {
@@ -1543,8 +1550,7 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::Fil
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)) {
+ if (d->filePath == QLatin1String("/") || isDriveRoot(d->filePath) || isUncRoot(d->filePath)) {
ret |= RootFlag;
} else if (d->fileAttrib & FILE_ATTRIBUTE_HIDDEN) {
QString baseName = fileName(BaseName);