diff --git a/src/libs/utils/settingsaccessor.cpp b/src/libs/utils/settingsaccessor.cpp index 5bcee4211c6..4d954d08674 100644 --- a/src/libs/utils/settingsaccessor.cpp +++ b/src/libs/utils/settingsaccessor.cpp @@ -329,10 +329,8 @@ void BackingUpSettingsAccessor::backupFile(const FilePath &path, const QVariantM return; // Do we need to do a backup? - const QString origName = path.toString(); - optional backupFileName = m_strategy->backupName(oldSettings.data, path, data); - if (backupFileName) - QFile::copy(origName, backupFileName.value().toString()); + if (optional backupFileName = m_strategy->backupName(oldSettings.data, path, data)) + path.copyFile(backupFileName.value()); } // -------------------------------------------------------------------- diff --git a/src/plugins/clangformat/clangformatutils.cpp b/src/plugins/clangformat/clangformatutils.cpp index 816dc09650b..938fa9522de 100644 --- a/src/plugins/clangformat/clangformatutils.cpp +++ b/src/plugins/clangformat/clangformatutils.cpp @@ -42,6 +42,7 @@ using namespace llvm; using namespace CppTools; using namespace ProjectExplorer; using namespace TextEditor; +using namespace Utils; namespace ClangFormat { @@ -279,25 +280,25 @@ static clang::format::FormatStyle constructStyle(const QByteArray &baseStyle = Q void createStyleFileIfNeeded(bool isGlobal) { - const Utils::FilePath path = isGlobal ? globalPath() : projectPath(); - const QString configFile = path.pathAppended(Constants::SETTINGS_FILE_NAME).toString(); + const FilePath path = isGlobal ? globalPath() : projectPath(); + const FilePath configFile = path / Constants::SETTINGS_FILE_NAME; - if (QFile::exists(configFile)) + if (configFile.exists()) return; QDir().mkpath(path.toString()); if (!isGlobal) { const Project *project = SessionManager::startupProject(); - Utils::FilePath possibleProjectConfig = project->rootProjectDirectory().pathAppended( - Constants::SETTINGS_FILE_NAME); + FilePath possibleProjectConfig = project->rootProjectDirectory() + / Constants::SETTINGS_FILE_NAME; if (possibleProjectConfig.exists()) { // Just copy th .clang-format if current project has one. - QFile::copy(possibleProjectConfig.toString(), configFile); + possibleProjectConfig.copyFile(configFile); return; } } - std::fstream newStyleFile(configFile.toStdString(), std::fstream::out); + std::fstream newStyleFile(configFile.toString().toStdString(), std::fstream::out); if (newStyleFile.is_open()) { newStyleFile << clang::format::configurationAsText(constructStyle()); newStyleFile.close();