diff options
-rw-r--r-- | src/libs/utils/fileutils.cpp | 17 | ||||
-rw-r--r-- | src/libs/utils/fileutils.h | 1 | ||||
-rw-r--r-- | src/plugins/android/androidavdmanager.cpp | 3 | ||||
-rw-r--r-- | src/plugins/android/androidbuildapkstep.cpp | 2 | ||||
-rw-r--r-- | src/plugins/android/androidconfigurations.cpp | 43 |
5 files changed, 31 insertions, 35 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index e95051488a..aa9fb25605 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -166,10 +166,8 @@ bool FileUtils::copyRecursively(const FileName &srcFilePath, const FileName &tgt QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); foreach (const QString &fileName, fileNames) { - FileName newSrcFilePath = srcFilePath; - newSrcFilePath.appendPath(fileName); - FileName newTgtFilePath = tgtFilePath; - newTgtFilePath.appendPath(fileName); + const FileName newSrcFilePath = srcFilePath.pathAppended(fileName); + const FileName newTgtFilePath = tgtFilePath.pathAppended(fileName); if (!copyRecursively(newSrcFilePath, newTgtFilePath, error, copyHelper)) return false; } @@ -855,6 +853,17 @@ FileName &FileName::appendPath(const QString &s) return *this; } +FileName FileName::pathAppended(const QString &str) const +{ + FileName fn = *this; + if (str.isEmpty()) + return fn; + if (!isEmpty() && !m_data.endsWith(QLatin1Char('/'))) + fn.m_data.append('/'); + fn.m_data.append(str); + return fn; +} + FileName FileName::stringAppended(const QString &str) const { FileName fn = *this; diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index 7bcb9e9a29..3180ef25ba 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -94,6 +94,7 @@ public: FileName relativeChildPath(const FileName &parent) const; FileName &appendPath(const QString &s); + FileName pathAppended(const QString &str) const; FileName stringAppended(const QString &str) const; void clear() { m_data.clear(); } diff --git a/src/plugins/android/androidavdmanager.cpp b/src/plugins/android/androidavdmanager.cpp index f14a5bc78c..aef6caf2fd 100644 --- a/src/plugins/android/androidavdmanager.cpp +++ b/src/plugins/android/androidavdmanager.cpp @@ -433,8 +433,7 @@ bool AvdManagerOutputParser::parseAvd(const QStringList &deviceInfo, AndroidDevi if (avdPath.exists()) { // Get ABI. - Utils::FileName configFile = avdPath; - configFile.appendPath("config.ini"); + const Utils::FileName configFile = avdPath.pathAppended("config.ini"); QSettings config(configFile.toString(), QSettings::IniFormat); value = config.value(avdInfoAbiKey).toString(); if (!value.isEmpty()) diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index 908ac3de3e..e09d90bf12 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -416,7 +416,7 @@ void AndroidBuildApkStep::doRun() qmlRootPath = target()->project()->rootProjectDirectory().toString(); deploySettings["qml-root-path"] = qmlImportPath; - QFile f{bc->buildDirectory().appendPath("android_deployment_settings.json").toString()}; + QFile f{bc->buildDirectory().pathAppended("android_deployment_settings.json").toString()}; if (!f.open(QIODevice::WriteOnly)) return false; f.write(QJsonDocument{deploySettings}.toJson()); diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 6542b5f15f..70706c1174 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -271,8 +271,7 @@ void AndroidConfig::updateNdkInformation() const if (m_NdkInformationUpToDate) return; m_availableNdkPlatforms.clear(); - FileName path = ndkLocation(); - QDirIterator it(path.appendPath("platforms").toString(), QStringList("android-*"), QDir::Dirs); + QDirIterator it(m_ndkLocation.pathAppended("platforms").toString(), QStringList("android-*"), QDir::Dirs); while (it.hasNext()) { const QString &fileName = it.next(); m_availableNdkPlatforms.push_back(fileName.midRef(fileName.lastIndexOf(QLatin1Char('-')) + 1).toInt()); @@ -294,8 +293,7 @@ void AndroidConfig::updateNdkInformation() const default: /* unknown host */ return; } - path = ndkLocation(); - QDirIterator jt(path.appendPath(QLatin1String("prebuilt")).toString(), hostPatterns, QDir::Dirs); + QDirIterator jt(m_ndkLocation.pathAppended("prebuilt").toString(), hostPatterns, QDir::Dirs); if (jt.hasNext()) { jt.next(); m_toolchainHost = jt.fileName(); @@ -317,8 +315,7 @@ QString AndroidConfig::apiLevelNameFor(const SdkPlatform *platform) FileName AndroidConfig::adbToolPath() const { - FileName path = m_sdkLocation; - return path.appendPath(QLatin1String("platform-tools/adb" QTC_HOST_EXE_SUFFIX)); + return m_sdkLocation.pathAppended("platform-tools/adb" QTC_HOST_EXE_SUFFIX); } FileName AndroidConfig::androidToolPath() const @@ -326,35 +323,28 @@ FileName AndroidConfig::androidToolPath() const if (HostOsInfo::isWindowsHost()) { // I want to switch from using android.bat to using an executable. All it really does is call // Java and I've made some progress on it. So if android.exe exists, return that instead. - FileName path = m_sdkLocation; - path.appendPath(QLatin1String("tools/android" QTC_HOST_EXE_SUFFIX)); + const FileName path = m_sdkLocation.pathAppended("tools/android" QTC_HOST_EXE_SUFFIX); if (path.exists()) return path; - path = m_sdkLocation; - return path.appendPath(QLatin1String("tools/android" ANDROID_BAT_SUFFIX)); - } else { - FileName path = m_sdkLocation; - return path.appendPath(QLatin1String("tools/android")); + return m_sdkLocation.pathAppended("tools/android" ANDROID_BAT_SUFFIX); } + return m_sdkLocation.pathAppended("tools/android"); } FileName AndroidConfig::emulatorToolPath() const { - FileName path = m_sdkLocation; QString relativePath = "emulator/emulator"; if (sdkToolsVersion() < QVersionNumber(25, 3, 0)) relativePath = "tools/emulator"; - return path.appendPath(relativePath + QTC_HOST_EXE_SUFFIX); + return m_sdkLocation.pathAppended(relativePath + QTC_HOST_EXE_SUFFIX); } FileName AndroidConfig::sdkManagerToolPath() const { - FileName sdkPath = m_sdkLocation; QString toolPath = "tools/bin/sdkmanager"; if (HostOsInfo::isWindowsHost()) toolPath += ANDROID_BAT_SUFFIX; - sdkPath = sdkPath.appendPath(toolPath); - return sdkPath; + return m_sdkLocation.pathAppended(toolPath); } FileName AndroidConfig::avdManagerToolPath() const @@ -380,10 +370,8 @@ FileName AndroidConfig::aaptToolPath() const FileName AndroidConfig::clangPath() const { - FileName clangPath = m_ndkLocation; - clangPath.appendPath("toolchains/llvm/prebuilt/"); - FileName oldNdkClangPath = m_ndkLocation; - oldNdkClangPath.appendPath("toolchains/llvm-3.6/prebuilt/"); + const FileName clangPath = m_ndkLocation.pathAppended("toolchains/llvm/prebuilt/"); + const FileName oldNdkClangPath = m_ndkLocation.pathAppended("toolchains/llvm-3.6/prebuilt/"); const QVector<FileName> clangSearchPaths{clangPath, oldNdkClangPath}; // detect toolchain host @@ -430,22 +418,21 @@ FileName AndroidConfig::gdbPath(const ProjectExplorer::Abi &abi) const FileName AndroidConfig::makePath() const { - FileName path = m_ndkLocation; - path.appendPath(QString("prebuilt/%1/bin/make%2").arg(toolchainHost(), QTC_HOST_EXE_SUFFIX)); - return path; + return m_ndkLocation.pathAppended( + QString("prebuilt/%1/bin/make%2").arg(toolchainHost(), QTC_HOST_EXE_SUFFIX)); } FileName AndroidConfig::openJDKBinPath() const { - FileName path = m_openJDKLocation; + const FileName path = m_openJDKLocation; if (!path.isEmpty()) - return path.appendPath(QLatin1String("bin")); + return path.pathAppended("bin"); return path; } FileName AndroidConfig::keytoolPath() const { - return openJDKBinPath().appendPath(keytoolName); + return openJDKBinPath().pathAppended(keytoolName); } QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const |