summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-06-10 11:48:16 +0200
committerQt by Nokia <qt-info@nokia.com>2011-06-22 11:17:02 +0200
commite6b744fb4be6e975f0336a86bd1a0cd5c60cd85e (patch)
tree554870eb272729306ee45fc77a110f25a19750c8 /src/tools
parent4545b212afcdeaeb4022e43260390674960fc94a (diff)
simplify relative path generation
instead of hand-crafting the logic, simply use QDir::relativeFilePath() Change-Id: I5a495ad6bdfa8ec126741180770934e7ebee0495 Reviewed-on: http://codereview.qt.nokia.com/512 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/main.cpp29
1 files changed, 1 insertions, 28 deletions
diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp
index 41a3a4fc93..eaafd0a9fd 100644
--- a/src/tools/moc/main.cpp
+++ b/src/tools/moc/main.cpp
@@ -67,34 +67,7 @@ static QByteArray combinePath(const char *infile, const char *outfile)
{
QFileInfo inFileInfo(QDir::current(), QFile::decodeName(infile));
QFileInfo outFileInfo(QDir::current(), QFile::decodeName(outfile));
- int numCommonComponents = 0;
-
- QStringList inSplitted = inFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
- QStringList outSplitted = outFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
-
- while (!inSplitted.isEmpty() && !outSplitted.isEmpty() &&
- inSplitted.first() == outSplitted.first()) {
- inSplitted.removeFirst();
- outSplitted.removeFirst();
- numCommonComponents++;
- }
-
- if (numCommonComponents < 2)
- /*
- The paths don't have the same drive, or they don't have the
- same root directory. Use an absolute path.
- */
- return QFile::encodeName(inFileInfo.absoluteFilePath());
- /*
- The paths have something in common. Use a path relative to
- the output file.
- */
- while (!outSplitted.isEmpty()) {
- outSplitted.removeFirst();
- inSplitted.prepend(QLatin1String(".."));
- }
- inSplitted.append(inFileInfo.fileName());
- return QFile::encodeName(inSplitted.join(QLatin1String("/")));
+ return QFile::encodeName(outFileInfo.dir().relativeFilePath(inFileInfo.filePath()));
}