aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <[email protected]>2025-06-30 11:49:48 +0200
committerChristian Kandeler <[email protected]>2025-06-30 12:20:27 +0000
commit5a9b50377af19be2a5ea78bf40c7368d507f74a6 (patch)
tree1620ed887b6a796c50087beae23ddd51e71a394a
parent7212994f7080dd897957dca7dfdf9d1bd1989554 (diff)
ProjectExplorer: Inline two functions in UserFileAccessorHEADmaster
The double indirection was annoying when trying to understand the code. Change-Id: I6441fb1f4e258d4c504918a3b2225004ed1880b0 Reviewed-by: Eike Ziller <[email protected]>
-rw-r--r--src/plugins/projectexplorer/userfileaccessor.cpp59
1 files changed, 26 insertions, 33 deletions
diff --git a/src/plugins/projectexplorer/userfileaccessor.cpp b/src/plugins/projectexplorer/userfileaccessor.cpp
index 50a61853ffb..21260e36301 100644
--- a/src/plugins/projectexplorer/userfileaccessor.cpp
+++ b/src/plugins/projectexplorer/userfileaccessor.cpp
@@ -101,25 +101,6 @@ static QString generateSuffix(const QString &suffix)
return result;
}
-// Return path to shared directory for .user files, create if necessary.
-static inline std::optional<FilePath> defineExternalUserFileDir()
-{
- const char userFilePathVariable[] = "QTC_USER_FILE_PATH";
- if (Q_LIKELY(!qtcEnvironmentVariableIsSet(userFilePathVariable)))
- return std::nullopt;
- const FilePath path = FilePath::fromUserInput(qtcEnvironmentVariable(userFilePathVariable));
- if (path.isRelativePath()) {
- qWarning().nospace() << "Ignoring " << userFilePathVariable
- << ", which must be an absolute path, but is " << path;
- return std::nullopt;
- }
- if (const auto res = path.ensureWritableDir(); !res) {
- qWarning() << res.error();
- return std::nullopt;
- }
- return path;
-}
-
// Return a suitable relative path to be created under the shared .user directory.
static QString makeRelative(QString path)
{
@@ -147,19 +128,6 @@ static QString makeRelative(QString path)
return path;
}
-// Return complete file path of the .user file.
-static FilePath externalUserFilePath(const Utils::FilePath &projectFilePath, const QString &suffix)
-{
- static const std::optional<FilePath> externalUserFileDir = defineExternalUserFileDir();
-
- if (externalUserFileDir) {
- // Recreate the relative project file hierarchy under the shared directory.
- return externalUserFileDir->pathAppended(
- makeRelative(projectFilePath.toUrlishString()) + suffix);
- }
- return {};
-}
-
} // namespace
// --------------------------------------------------------------------
@@ -266,9 +234,34 @@ FilePath UserFileAccessor::projectUserFile() const
return m_project->projectFilePath().stringAppended(generateSuffix(userFileExtension()));
}
+// Return complete file path of the .user file.
FilePath UserFileAccessor::externalUserFile() const
{
- return externalUserFilePath(m_project->projectFilePath(), generateSuffix(userFileExtension()));
+ // Return path to shared directory for .user files, create if necessary.
+ static const auto defineExternalUserFileDir = [] {
+ const char userFilePathVariable[] = "QTC_USER_FILE_PATH";
+ if (Q_LIKELY(!qtcEnvironmentVariableIsSet(userFilePathVariable)))
+ return FilePath();
+ const FilePath path = FilePath::fromUserInput(qtcEnvironmentVariable(userFilePathVariable));
+ if (path.isRelativePath()) {
+ qWarning().nospace() << "Ignoring " << userFilePathVariable
+ << ", which must be an absolute path, but is " << path;
+ return FilePath();
+ }
+ if (const auto res = path.ensureWritableDir(); !res) {
+ qWarning() << res.error();
+ return FilePath();
+ }
+ return path;
+ };
+ static const FilePath externalUserFileDir = defineExternalUserFileDir();
+ if (externalUserFileDir.isEmpty())
+ return {};
+
+ // Recreate the relative project file hierarchy under the shared directory.
+ return externalUserFileDir.pathAppended(
+ makeRelative(m_project->projectFilePath().toUrlishString())
+ + generateSuffix(userFileExtension()));
}
FilePath UserFileAccessor::sharedFile() const