ifdef drivespec handling in relativeFilePath to windows

on unix, the code wouldn't do anything except burning cycles anyway.

Change-Id: I1c28b1a7014af93ca70a17e0bd669debad8003c2
Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
This commit is contained in:
Oswald Buddenhagen 2012-08-06 20:41:18 +02:00 committed by Qt by Nokia
parent 6292c51306
commit 6e4ed714f1

View File

@ -68,9 +68,9 @@
QT_BEGIN_NAMESPACE
#if defined(Q_OS_WIN)
static QString driveSpec(const QString &path)
{
#if defined(Q_OS_WIN)
if (path.size() < 2)
return QString();
char c = path.at(0).toLatin1();
@ -79,11 +79,8 @@ static QString driveSpec(const QString &path)
if (path.at(1).toLatin1() != ':')
return QString();
return path.mid(0, 2);
#else
Q_UNUSED(path);
return QString();
#endif
}
#endif
//************* QDirPrivate
QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, QDir::SortFlags sort_, QDir::Filters filters_)
@ -723,6 +720,7 @@ QString QDir::relativeFilePath(const QString &fileName) const
if (isRelativePath(file) || isRelativePath(dir))
return file;
#ifdef Q_OS_WIN
QString dirDrive = driveSpec(dir);
QString fileDrive = driveSpec(file);
@ -732,18 +730,15 @@ QString QDir::relativeFilePath(const QString &fileName) const
fileDriveMissing = true;
}
#ifdef Q_OS_WIN
if (fileDrive.toLower() != dirDrive.toLower()
|| (file.startsWith(QLatin1String("//"))
&& !dir.startsWith(QLatin1String("//"))))
#else
if (fileDrive != dirDrive)
#endif
return file;
dir.remove(0, dirDrive.size());
if (!fileDriveMissing)
file.remove(0, fileDrive.size());
#endif
QString result;
QStringList dirElts = dir.split(QLatin1Char('/'), QString::SkipEmptyParts);