forked from qt-creator/qt-creator
Utils: Move FileUtils::resolvePath to FilePath
In line with the general move toward use of FilePath nowadays. Change-Id: I1c50e1479f7d9100ff8ded3ce3c22dd82b7fe6aa Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -398,13 +398,13 @@ bool FileUtils::isRelativePath(const QString &path)
|
||||
return true;
|
||||
}
|
||||
|
||||
QString FileUtils::resolvePath(const QString &baseDir, const QString &fileName)
|
||||
FilePath FilePath::resolvePath(const QString &fileName) const
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return QString();
|
||||
if (isAbsolutePath(fileName))
|
||||
return QDir::cleanPath(fileName);
|
||||
return QDir::cleanPath(baseDir + QLatin1Char('/') + fileName);
|
||||
return {}; // FIXME: Isn't this odd?
|
||||
if (FileUtils::isAbsolutePath(fileName))
|
||||
return FilePath::fromString(QDir::cleanPath(fileName));
|
||||
return FilePath::fromString(QDir::cleanPath(toString() + QLatin1Char('/') + fileName));
|
||||
}
|
||||
|
||||
FilePath FileUtils::commonPath(const FilePath &oldCommonPath, const FilePath &filePath)
|
||||
|
||||
@@ -107,6 +107,7 @@ public:
|
||||
FilePath relativeChildPath(const FilePath &parent) const;
|
||||
FilePath pathAppended(const QString &str) const;
|
||||
FilePath stringAppended(const QString &str) const;
|
||||
FilePath resolvePath(const QString &fileName) const;
|
||||
|
||||
FilePath canonicalPath() const;
|
||||
|
||||
@@ -172,7 +173,6 @@ public:
|
||||
|
||||
static bool isRelativePath(const QString &fileName);
|
||||
static bool isAbsolutePath(const QString &fileName) { return !isRelativePath(fileName); }
|
||||
static QString resolvePath(const QString &baseDir, const QString &fileName);
|
||||
static FilePath commonPath(const FilePath &oldCommonPath, const FilePath &fileName);
|
||||
static QByteArray fileId(const FilePath &fileName);
|
||||
};
|
||||
|
||||
@@ -4700,8 +4700,8 @@ static QString findExecutableFromName(const QString &fileNameFromCore, const QSt
|
||||
absPath = fileNameFromCore;
|
||||
} else {
|
||||
QFileInfo coreInfo(coreFile);
|
||||
QDir coreDir = coreInfo.dir();
|
||||
absPath = FileUtils::resolvePath(coreDir.absolutePath(), fileNameFromCore);
|
||||
FilePath coreDir = FilePath::fromString(coreInfo.dir().absolutePath());
|
||||
absPath = coreDir.resolvePath(fileNameFromCore).toString();
|
||||
}
|
||||
if (QFileInfo(absPath).isFile() || absPath.isEmpty())
|
||||
return absPath;
|
||||
|
||||
@@ -155,7 +155,7 @@ FilePath CustomParser::absoluteFilePath(const QString &filePath) const
|
||||
if (m_workingDirectory.isEmpty())
|
||||
return FilePath::fromUserInput(filePath);
|
||||
|
||||
return FilePath::fromString(FileUtils::resolvePath(m_workingDirectory, filePath));
|
||||
return FilePath::fromString(m_workingDirectory).resolvePath(filePath);
|
||||
}
|
||||
|
||||
bool CustomParser::hasMatch(const QString &line, CustomParserExpression::CustomParserChannel channel,
|
||||
|
||||
@@ -66,9 +66,9 @@ static FilePath defaultBuildDirectory(const FilePath &projectFilePath, const Kit
|
||||
{
|
||||
const QString projectName = projectFilePath.toFileInfo().completeBaseName();
|
||||
ProjectMacroExpander expander(projectFilePath, projectName, k, bcName, buildType);
|
||||
QString projectDir = Project::projectDirectory(projectFilePath).toString();
|
||||
FilePath projectDir = Project::projectDirectory(projectFilePath);
|
||||
QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate());
|
||||
return FilePath::fromString(FileUtils::resolvePath(projectDir, buildPath));
|
||||
return projectDir.resolvePath(buildPath);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -86,14 +86,14 @@ QbsProjectImporter::QbsProjectImporter(const FilePath &path) : QtProjectImporter
|
||||
{
|
||||
}
|
||||
|
||||
static QString buildDir(const FilePath &projectFilePath, const Kit *k)
|
||||
static FilePath buildDir(const FilePath &projectFilePath, const Kit *k)
|
||||
{
|
||||
const QString projectName = projectFilePath.toFileInfo().completeBaseName();
|
||||
ProjectMacroExpander expander(projectFilePath, projectName, k, QString(),
|
||||
BuildConfiguration::Unknown);
|
||||
const QString projectDir = Project::projectDirectory(projectFilePath).toString();
|
||||
const FilePath projectDir = Project::projectDirectory(projectFilePath);
|
||||
const QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate());
|
||||
return FileUtils::resolvePath(projectDir, buildPath);
|
||||
return projectDir.resolvePath(buildPath);
|
||||
}
|
||||
|
||||
static bool hasBuildGraph(const QString &dir)
|
||||
@@ -123,7 +123,7 @@ QStringList QbsProjectImporter::importCandidates()
|
||||
seenCandidates.insert(projectDir);
|
||||
const auto &kits = KitManager::kits();
|
||||
for (Kit * const k : kits) {
|
||||
QFileInfo fi(buildDir(projectFilePath(), k));
|
||||
QFileInfo fi = buildDir(projectFilePath(), k).toFileInfo();
|
||||
const QString candidate = fi.absolutePath();
|
||||
if (!seenCandidates.contains(candidate)) {
|
||||
seenCandidates.insert(candidate);
|
||||
|
||||
@@ -86,9 +86,9 @@ FilePath QmakeBuildConfiguration::shadowBuildDirectory(const FilePath &proFilePa
|
||||
|
||||
const QString projectName = proFilePath.toFileInfo().completeBaseName();
|
||||
ProjectMacroExpander expander(proFilePath, projectName, k, suffix, buildType);
|
||||
QString projectDir = Project::projectDirectory(proFilePath).toString();
|
||||
FilePath projectDir = Project::projectDirectory(proFilePath);
|
||||
QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate());
|
||||
return FilePath::fromString(FileUtils::resolvePath(projectDir, buildPath));
|
||||
return projectDir.resolvePath(buildPath);
|
||||
}
|
||||
|
||||
const char BUILD_CONFIGURATION_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration";
|
||||
|
||||
@@ -91,8 +91,7 @@ bool WinRtPackageDeploymentStep::init()
|
||||
if (!qt)
|
||||
return false;
|
||||
|
||||
const QString windeployqtPath = FileUtils::resolvePath(qt->hostBinPath().toString(),
|
||||
"windeployqt.exe");
|
||||
const FilePath windeployqtPath = qt->hostBinPath().resolvePath("windeployqt.exe");
|
||||
|
||||
CommandLine windeployqt{windeployqtPath};
|
||||
windeployqt.addArg(QDir::toNativeSeparators(m_targetFilePath));
|
||||
@@ -104,7 +103,7 @@ bool WinRtPackageDeploymentStep::init()
|
||||
}
|
||||
|
||||
ProcessParameters *params = processParameters();
|
||||
if (!QFile::exists(windeployqtPath)) {
|
||||
if (!windeployqtPath.exists()) {
|
||||
raiseError(tr("Cannot find windeployqt.exe in \"%1\".")
|
||||
.arg(QDir::toNativeSeparators(qt->hostBinPath().toString())));
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user