More FileName::appendPath() -> .pathAppended()

Change-Id: I403d34e4f52f758339c158efc7a11fd329e3e043
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2019-05-17 12:32:05 +02:00
parent 0565457b5c
commit f4c9e5e5c4
23 changed files with 39 additions and 58 deletions

View File

@@ -248,7 +248,7 @@ private:
// Create needed extra dir nodes // Create needed extra dir nodes
FileName currentDirPath = parentDir; FileName currentDirPath = parentDir;
for (const QString &dirName : dirsToCreate) { for (const QString &dirName : dirsToCreate) {
currentDirPath.appendPath(dirName); currentDirPath = currentDirPath.pathAppended(dirName);
Tree *newDirNode = createDirNode(dirName, currentDirPath); Tree *newDirNode = createDirNode(dirName, currentDirPath);
linkDirNode(parentNode, newDirNode); linkDirNode(parentNode, newDirNode);

View File

@@ -276,7 +276,8 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
{ {
CMakeConfigItem settingFileItem; CMakeConfigItem settingFileItem;
settingFileItem.key = "ANDROID_DEPLOYMENT_SETTINGS_FILE"; settingFileItem.key = "ANDROID_DEPLOYMENT_SETTINGS_FILE";
settingFileItem.value = bc->buildDirectory().appendPath("android_deployment_settings.json").toString().toUtf8(); settingFileItem.value = bc->buildDirectory()
.pathAppended("android_deployment_settings.json").toString().toUtf8();
patchedConfig.append(settingFileItem); patchedConfig.append(settingFileItem);
} }

View File

@@ -207,9 +207,7 @@ static Utils::FileName qmakeFromCMakeCache(const CMakeConfig &config)
// Eat the leading "}/" and trailing " // Eat the leading "}/" and trailing "
const QByteArray locationPart = origLine.mid(sp + 2, ep - 2 - sp); const QByteArray locationPart = origLine.mid(sp + 2, ep - 2 - sp);
Utils::FileName result = baseQtDir; return baseQtDir.pathAppended(QString::fromUtf8(locationPart));
result.appendPath(QString::fromUtf8(locationPart));
return result;
} }
} }
} }

View File

@@ -144,8 +144,7 @@ bool CMakeListsNode::supportsAction(ProjectExplorer::ProjectAction action, const
Utils::optional<Utils::FileName> CMakeListsNode::visibleAfterAddFileAction() const Utils::optional<Utils::FileName> CMakeListsNode::visibleAfterAddFileAction() const
{ {
Utils::FileName projFile{filePath()}; return filePath().pathAppended("CMakeLists.txt");
return projFile.appendPath("CMakeLists.txt");
} }
CMakeProjectNode::CMakeProjectNode(const Utils::FileName &directory) : CMakeProjectNode::CMakeProjectNode(const Utils::FileName &directory) :
@@ -251,8 +250,7 @@ bool CMakeTargetNode::addFiles(const QStringList &filePaths, QStringList *)
Utils::optional<Utils::FileName> CMakeTargetNode::visibleAfterAddFileAction() const Utils::optional<Utils::FileName> CMakeTargetNode::visibleAfterAddFileAction() const
{ {
Utils::FileName projFile{filePath()}; return filePath().pathAppended("CMakeLists.txt");
return projFile.appendPath("CMakeLists.txt");
} }
void CMakeTargetNode::setTargetInformation(const QList<Utils::FileName> &artifacts, void CMakeTargetNode::setTargetInformation(const QList<Utils::FileName> &artifacts,

View File

@@ -190,8 +190,7 @@ QVariantMap CMakeTool::toMap() const
Utils::FileName CMakeTool::cmakeExecutable() const Utils::FileName CMakeTool::cmakeExecutable() const
{ {
if (Utils::HostOsInfo::isMacHost() && m_executable.endsWith(".app")) { if (Utils::HostOsInfo::isMacHost() && m_executable.endsWith(".app")) {
Utils::FileName toTest = m_executable; const Utils::FileName toTest = m_executable.pathAppended("Contents/bin/cmake");
toTest = toTest.appendPath("Contents/bin/cmake");
if (toTest.exists()) if (toTest.exists())
return toTest; return toTest;
} }

View File

@@ -813,8 +813,7 @@ static void createProjectNode(const QHash<Utils::FileName, ProjectNode *> &cmake
ProjectNode *cmln = cmakeListsNodes.value(dir); ProjectNode *cmln = cmakeListsNodes.value(dir);
QTC_ASSERT(cmln, qDebug() << dir.toUserOutput(); return); QTC_ASSERT(cmln, qDebug() << dir.toUserOutput(); return);
Utils::FileName projectName = dir; const Utils::FileName projectName = dir.pathAppended(".project::" + displayName);
projectName.appendPath(".project::" + displayName);
ProjectNode *pn = cmln->projectNode(projectName); ProjectNode *pn = cmln->projectNode(projectName);
if (!pn) { if (!pn) {
@@ -865,8 +864,7 @@ void ServerModeReader::addTargets(const QHash<Utils::FileName, ProjectExplorer::
tNode->setTargetInformation(t->artifacts, t->type); tNode->setTargetInformation(t->artifacts, t->type);
QList<FolderNode::LocationInfo> info; QList<FolderNode::LocationInfo> info;
// Set up a default target path: // Set up a default target path:
FileName targetPath = t->sourceDirectory; FileName targetPath = t->sourceDirectory.pathAppended("CMakeLists.txt");
targetPath.appendPath("CMakeLists.txt");
for (CrossReference *cr : qAsConst(t->crossReferences)) { for (CrossReference *cr : qAsConst(t->crossReferences)) {
BacktraceItem *bt = cr->backtrace.isEmpty() ? nullptr : cr->backtrace.at(0); BacktraceItem *bt = cr->backtrace.isEmpty() ? nullptr : cr->backtrace.at(0);
if (bt) { if (bt) {

View File

@@ -235,8 +235,7 @@ QList<CMakeBuildTarget> TeaLeafReader::takeBuildTargets()
CMakeConfig TeaLeafReader::takeParsedConfiguration() CMakeConfig TeaLeafReader::takeParsedConfiguration()
{ {
FileName cacheFile = m_parameters.workDirectory; const FileName cacheFile = m_parameters.workDirectory.pathAppended("CMakeCache.txt");
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
if (!cacheFile.exists()) if (!cacheFile.exists())
return { }; return { };
@@ -432,8 +431,7 @@ void TeaLeafReader::extractData()
m_cmakeFiles.insert(cbpFile); m_cmakeFiles.insert(cbpFile);
// Add CMakeCache.txt file: // Add CMakeCache.txt file:
FileName cacheFile = m_parameters.workDirectory; const FileName cacheFile = m_parameters.workDirectory.pathAppended("CMakeCache.txt");
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
if (cacheFile.toFileInfo().exists()) if (cacheFile.toFileInfo().exists())
m_cmakeFiles.insert(cacheFile); m_cmakeFiles.insert(cacheFile);

View File

@@ -475,14 +475,11 @@ void CompilationDatabaseProject::buildTreeAndProjectParts(const Utils::FileName
} }
if (!extras.empty()) { if (!extras.empty()) {
const QString baseDir = projectFile.parentDir().toString(); const Utils::FileName baseDir = projectFile.parentDir();
QStringList extraFiles; QStringList extraFiles;
for (const QString &extra : extras) { for (const QString &extra : extras)
auto extraFile = Utils::FileName::fromString(baseDir); extraFiles.append(baseDir.pathAppended(extra).toString());
extraFile.appendPath(extra);
extraFiles.append(extraFile.toString());
}
CppTools::RawProjectPart rppExtra; CppTools::RawProjectPart rppExtra;
rppExtra.setFiles(extraFiles); rppExtra.setFiles(extraFiles);

View File

@@ -148,9 +148,8 @@ void HeaderPathFilter::tweakHeaderPaths()
void HeaderPathFilter::addPreIncludesPath() void HeaderPathFilter::addPreIncludesPath()
{ {
if (projectDirectory.size()) { if (projectDirectory.size()) {
Utils::FileName rootProjectDirectory = Utils::FileName::fromString(projectDirectory); const Utils::FileName rootProjectDirectory = Utils::FileName::fromString(projectDirectory)
.pathAppended(".pre_includes");
rootProjectDirectory.appendPath(".pre_includes");
systemHeaderPaths.push_back( systemHeaderPaths.push_back(
{rootProjectDirectory.toString(), ProjectExplorer::HeaderPathType::System}); {rootProjectDirectory.toString(), ProjectExplorer::HeaderPathType::System});

View File

@@ -60,8 +60,7 @@ static inline QString detectApp(const char *defaultExe)
const FileName gitBinDir = GerritPlugin::gitBinDirectory(); const FileName gitBinDir = GerritPlugin::gitBinDirectory();
if (gitBinDir.isEmpty()) if (gitBinDir.isEmpty())
return QString(); return QString();
FileName path = gitBinDir; FileName path = gitBinDir.pathAppended(defaultApp);
path.appendPath(defaultApp);
if (path.exists()) if (path.exists())
return path.toString(); return path.toString();
@@ -74,7 +73,7 @@ static inline QString detectApp(const char *defaultExe)
const QStringList entries = dir.entryList({"mingw*"}); const QStringList entries = dir.entryList({"mingw*"});
if (entries.isEmpty()) if (entries.isEmpty())
return QString(); return QString();
path.appendPath(entries.first()).appendPath("bin").appendPath(defaultApp); path = path.pathAppended(entries.first()).pathAppended("bin").pathAppended(defaultApp);
if (path.exists()) if (path.exists())
return path.toString(); return path.toString();
return QString(); return QString();

View File

@@ -89,7 +89,7 @@ static FolderNode *recursiveFindOrCreateFolderNode(FolderNode *folder,
ProjectExplorer::FolderNode *parent = folder; ProjectExplorer::FolderNode *parent = folder;
foreach (const QString &part, parts) { foreach (const QString &part, parts) {
path.appendPath(part); path = path.pathAppended(part);
// Find folder in subFolders // Find folder in subFolders
FolderNode *next = folderNode(parent, path); FolderNode *next = folderNode(parent, path);
if (!next) { if (!next) {

View File

@@ -266,8 +266,8 @@ Utils::FileName QbsBuildStep::installRoot(VariableHandling variableHandling) con
const QbsBuildConfiguration * const bc const QbsBuildConfiguration * const bc
= static_cast<QbsBuildConfiguration *>(buildConfiguration()); = static_cast<QbsBuildConfiguration *>(buildConfiguration());
return bc->buildDirectory().appendPath(bc->configurationName()) return bc->buildDirectory().pathAppended(bc->configurationName())
.appendPath(qbs::InstallOptions::defaultInstallRoot()); .pathAppended(qbs::InstallOptions::defaultInstallRoot());
} }
int QbsBuildStep::maxJobs() const int QbsBuildStep::maxJobs() const

View File

@@ -203,8 +203,7 @@ Kit *QbsProjectImporter::createKit(void *directoryData) const
qCDebug(qbsPmLog) << "creating kit for imported build" << bgData->bgFilePath.toUserOutput(); qCDebug(qbsPmLog) << "creating kit for imported build" << bgData->bgFilePath.toUserOutput();
QtVersionData qtVersionData; QtVersionData qtVersionData;
if (!bgData->qtBinPath.isEmpty()) { if (!bgData->qtBinPath.isEmpty()) {
FileName qmakeFilePath = bgData->qtBinPath; const FileName qmakeFilePath = bgData->qtBinPath.pathAppended(HostOsInfo::withExecutableSuffix("qmake"));
qmakeFilePath.appendPath(HostOsInfo::withExecutableSuffix("qmake"));
qtVersionData = findOrCreateQtVersion(qmakeFilePath); qtVersionData = findOrCreateQtVersion(qmakeFilePath);
} }
return createTemporaryKit(qtVersionData,[this, bgData](Kit *k) -> void { return createTemporaryKit(qtVersionData,[this, bgData](Kit *k) -> void {

View File

@@ -1942,15 +1942,14 @@ FileNameList QmakeProFile::generatedFiles(const FileName &buildDir,
location = buildDir; location = buildDir;
if (location.isEmpty()) if (location.isEmpty())
return { }; return { };
location.appendPath(QLatin1String("ui_") location = location.pathAppended("ui_"
+ sourceFile.toFileInfo().completeBaseName() + sourceFile.toFileInfo().completeBaseName()
+ singleVariableValue(Variable::HeaderExtension)); + singleVariableValue(Variable::HeaderExtension));
return { Utils::FileName::fromString(QDir::cleanPath(location.toString())) }; return { Utils::FileName::fromString(QDir::cleanPath(location.toString())) };
} else if (sourceFileType == FileType::StateChart) { } else if (sourceFileType == FileType::StateChart) {
if (buildDir.isEmpty()) if (buildDir.isEmpty())
return { }; return { };
FileName location = buildDir; const FileName location = buildDir.pathAppended(sourceFile.toFileInfo().completeBaseName());
location.appendPath(sourceFile.toFileInfo().completeBaseName());
return { return {
location.stringAppended(singleVariableValue(Variable::HeaderExtension)), location.stringAppended(singleVariableValue(Variable::HeaderExtension)),
location.stringAppended(singleVariableValue(Variable::CppExtension)) location.stringAppended(singleVariableValue(Variable::CppExtension))

View File

@@ -1123,7 +1123,7 @@ void QmakeProject::collectLibraryData(const QmakeProFile *file, DeploymentData &
case Abi::DarwinOS: { case Abi::DarwinOS: {
FileName destDir = destDirFor(ti); FileName destDir = destDirFor(ti);
if (config.contains(QLatin1String("lib_bundle"))) { if (config.contains(QLatin1String("lib_bundle"))) {
destDir.appendPath(ti.target + ".framework"); destDir = destDir.pathAppended(ti.target + ".framework");
} else { } else {
if (!(isPlugin && config.contains(QLatin1String("no_plugin_name_prefix")))) if (!(isPlugin && config.contains(QLatin1String("no_plugin_name_prefix"))))
targetFileName.prepend(QLatin1String("lib")); targetFileName.prepend(QLatin1String("lib"));

View File

@@ -469,7 +469,7 @@ FileNameList BaseQtVersion::directoriesToIgnoreInProjectTree() const
FileName mkspecPathSrc = FileName::fromUserInput(qmakeProperty("QT_HOST_DATA", PropertyVariantSrc)); FileName mkspecPathSrc = FileName::fromUserInput(qmakeProperty("QT_HOST_DATA", PropertyVariantSrc));
if (!mkspecPathSrc.isEmpty()) { if (!mkspecPathSrc.isEmpty()) {
mkspecPathSrc.appendPath("mkspecs"); mkspecPathSrc = mkspecPathSrc.pathAppended("mkspecs");
if (mkspecPathSrc != mkspecPathGet) if (mkspecPathSrc != mkspecPathGet)
result.append(mkspecPathSrc); result.append(mkspecPathSrc);
} }

View File

@@ -159,8 +159,8 @@ QString ExamplesWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileI
it->replace(projectDir, targetDir); it->replace(projectDir, targetDir);
foreach (const QString &dependency, dependencies) { foreach (const QString &dependency, dependencies) {
FileName targetFile = FileName::fromString(targetDir); const FileName targetFile = FileName::fromString(targetDir)
targetFile.appendPath(QDir(dependency).dirName()); .pathAppended(QDir(dependency).dirName());
if (!FileUtils::copyRecursively(FileName::fromString(dependency), targetFile, if (!FileUtils::copyRecursively(FileName::fromString(dependency), targetFile,
&error)) { &error)) {
QMessageBox::warning(ICore::mainWindow(), tr("Cannot Copy Project"), error); QMessageBox::warning(ICore::mainWindow(), tr("Cannot Copy Project"), error);

View File

@@ -118,8 +118,7 @@ FileNameToContentsHash QScxmlcGenerator::handleProcessFinished(QProcess *process
const Utils::FileName wd = workingDirectory(); const Utils::FileName wd = workingDirectory();
FileNameToContentsHash result; FileNameToContentsHash result;
forEachTarget([&](const Utils::FileName &target) { forEachTarget([&](const Utils::FileName &target) {
Utils::FileName file = wd; const Utils::FileName file = wd.pathAppended(target.fileName());
file.appendPath(target.fileName());
QFile generated(file.toString()); QFile generated(file.toString());
if (!generated.open(QIODevice::ReadOnly)) if (!generated.open(QIODevice::ReadOnly))
return; return;

View File

@@ -119,7 +119,7 @@ void TarPackageCreationStep::addNeededDeploymentFiles(
} }
for (const QString &fileName : files) { for (const QString &fileName : files) {
const QString localFilePath = deployable.localFilePath().appendPath(fileName).toString(); const QString localFilePath = deployable.localFilePath().pathAppended(fileName).toString();
const QString remoteDir = deployable.remoteDirectory() + '/' + fileInfo.fileName(); const QString remoteDir = deployable.remoteDirectory() + '/' + fileInfo.fileName();

View File

@@ -462,7 +462,7 @@ bool ResourceTopLevelNode::showInSimpleTree() const
} }
ResourceFolderNode::ResourceFolderNode(const QString &prefix, const QString &lang, ResourceTopLevelNode *parent) ResourceFolderNode::ResourceFolderNode(const QString &prefix, const QString &lang, ResourceTopLevelNode *parent)
: FolderNode(FileName(parent->filePath()).appendPath(prefix)), : FolderNode(parent->filePath().pathAppended(prefix)),
// TOOD Why add existing directory doesn't work // TOOD Why add existing directory doesn't work
m_topLevelNode(parent), m_topLevelNode(parent),
m_prefix(prefix), m_prefix(prefix),

View File

@@ -149,7 +149,7 @@ static bool parseTaskFile(QString *errorString, const FileName &name)
file = QDir::fromNativeSeparators(file); file = QDir::fromNativeSeparators(file);
QFileInfo fi(file); QFileInfo fi(file);
if (fi.isRelative()) if (fi.isRelative())
file = FileName(parentDir).appendPath(file).toString(); file = parentDir.pathAppended(file).toString();
} }
description = unescape(description); description = unescape(description);

View File

@@ -119,9 +119,7 @@ QString CodeStylePool::settingsDir() const
Utils::FileName CodeStylePool::settingsPath(const QByteArray &id) const Utils::FileName CodeStylePool::settingsPath(const QByteArray &id) const
{ {
Utils::FileName path = Utils::FileName::fromString(settingsDir()); return Utils::FileName::fromString(settingsDir()).pathAppended(QString::fromUtf8(id + ".xml"));
path.appendPath(QString::fromUtf8(id + ".xml"));
return path;
} }
QList<ICodeStylePreferences *> CodeStylePool::codeStyles() const QList<ICodeStylePreferences *> CodeStylePool::codeStyles() const

View File

@@ -47,11 +47,10 @@ Settings::Settings() :
m_instance = this; m_instance = this;
// autodetect sdk dir: // autodetect sdk dir:
sdkPath = Utils::FileName::fromString(QCoreApplication::applicationDirPath()); sdkPath = Utils::FileName::fromString(QCoreApplication::applicationDirPath())
sdkPath.appendPath(QLatin1String(DATA_PATH)); .pathAppended(DATA_PATH);
sdkPath = Utils::FileName::fromString(QDir::cleanPath(sdkPath.toString())); sdkPath = Utils::FileName::fromString(QDir::cleanPath(sdkPath.toString()))
sdkPath.appendPath(QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR) .pathAppended(QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR) + '/' + Core::Constants::IDE_ID);
+ '/' + Core::Constants::IDE_ID);
} }
Utils::FileName Settings::getPath(const QString &file) Utils::FileName Settings::getPath(const QString &file)