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:
parent
6292c51306
commit
6e4ed714f1
@ -68,9 +68,9 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
static QString driveSpec(const QString &path)
|
static QString driveSpec(const QString &path)
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
if (path.size() < 2)
|
if (path.size() < 2)
|
||||||
return QString();
|
return QString();
|
||||||
char c = path.at(0).toLatin1();
|
char c = path.at(0).toLatin1();
|
||||||
@ -79,11 +79,8 @@ static QString driveSpec(const QString &path)
|
|||||||
if (path.at(1).toLatin1() != ':')
|
if (path.at(1).toLatin1() != ':')
|
||||||
return QString();
|
return QString();
|
||||||
return path.mid(0, 2);
|
return path.mid(0, 2);
|
||||||
#else
|
|
||||||
Q_UNUSED(path);
|
|
||||||
return QString();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//************* QDirPrivate
|
//************* QDirPrivate
|
||||||
QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, QDir::SortFlags sort_, QDir::Filters filters_)
|
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))
|
if (isRelativePath(file) || isRelativePath(dir))
|
||||||
return file;
|
return file;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
QString dirDrive = driveSpec(dir);
|
QString dirDrive = driveSpec(dir);
|
||||||
QString fileDrive = driveSpec(file);
|
QString fileDrive = driveSpec(file);
|
||||||
|
|
||||||
@ -732,18 +730,15 @@ QString QDir::relativeFilePath(const QString &fileName) const
|
|||||||
fileDriveMissing = true;
|
fileDriveMissing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
if (fileDrive.toLower() != dirDrive.toLower()
|
if (fileDrive.toLower() != dirDrive.toLower()
|
||||||
|| (file.startsWith(QLatin1String("//"))
|
|| (file.startsWith(QLatin1String("//"))
|
||||||
&& !dir.startsWith(QLatin1String("//"))))
|
&& !dir.startsWith(QLatin1String("//"))))
|
||||||
#else
|
|
||||||
if (fileDrive != dirDrive)
|
|
||||||
#endif
|
|
||||||
return file;
|
return file;
|
||||||
|
|
||||||
dir.remove(0, dirDrive.size());
|
dir.remove(0, dirDrive.size());
|
||||||
if (!fileDriveMissing)
|
if (!fileDriveMissing)
|
||||||
file.remove(0, fileDrive.size());
|
file.remove(0, fileDrive.size());
|
||||||
|
#endif
|
||||||
|
|
||||||
QString result;
|
QString result;
|
||||||
QStringList dirElts = dir.split(QLatin1Char('/'), QString::SkipEmptyParts);
|
QStringList dirElts = dir.split(QLatin1Char('/'), QString::SkipEmptyParts);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user