summaryrefslogtreecommitdiff
path: root/src/tools/sdktool/operation.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-03-03 11:25:09 +0100
committerhjk <hjk@qt.io>2023-03-06 13:37:52 +0000
commitbb4d9c92e77f44b55f06a8b8080b5f35d363a1f5 (patch)
treeabd2ea248b349b404f89bea3d8711d80b7cc2f00 /src/tools/sdktool/operation.cpp
parent755d9769d81a5dc4e0b837650f9fab27a3f094ab (diff)
downloadqt-creator-bb4d9c92e77f44b55f06a8b8080b5f35d363a1f5.tar.gz
SdkTool: Fork utils/persistentsettings
And a few helper classes. This allows SdkTool being build without Creator's Utils, and does not impose restrictions on the development there. Change-Id: Id15db9293f343ad2aeee5c09cc819d112ec144e4 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/tools/sdktool/operation.cpp')
-rw-r--r--src/tools/sdktool/operation.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/tools/sdktool/operation.cpp b/src/tools/sdktool/operation.cpp
index ed673b9b78..7a81c3c7ad 100644
--- a/src/tools/sdktool/operation.cpp
+++ b/src/tools/sdktool/operation.cpp
@@ -4,8 +4,7 @@
#include "operation.h"
#include "settings.h"
-
-#include <utils/persistentsettings.h>
+#include "sdkpersistentsettings.h"
#include <QDir>
#include <QFile>
@@ -65,9 +64,9 @@ QVariantMap Operation::load(const QString &file)
QVariantMap map;
// Read values from original file:
- Utils::FilePath path = Settings::instance()->getPath(file);
- if (path.exists()) {
- Utils::PersistentSettingsReader reader;
+ QString path = Settings::instance()->getPath(file);
+ if (QFileInfo::exists(path)) {
+ SdkPersistentSettingsReader reader;
if (!reader.load(path))
return QVariantMap();
map = reader.restoreValues();
@@ -78,32 +77,32 @@ QVariantMap Operation::load(const QString &file)
bool Operation::save(const QVariantMap &map, const QString &file) const
{
- Utils::FilePath path = Settings::instance()->getPath(file);
+ QString path = Settings::instance()->getPath(file);
if (path.isEmpty()) {
std::cerr << "Error: No path found for " << qPrintable(file) << "." << std::endl;
return false;
}
- Utils::FilePath dirName = path.parentDir();
- QDir dir(dirName.toString());
+ QString dirName = QDir::cleanPath(path + "/..");
+ QDir dir(dirName);
if (!dir.exists() && !dir.mkpath(QLatin1String("."))) {
- std::cerr << "Error: Could not create directory " << qPrintable(dirName.toString())
+ std::cerr << "Error: Could not create directory " << qPrintable(dirName)
<< "." << std::endl;
return false;
}
- Utils::PersistentSettingsWriter writer(path, QLatin1String("QtCreator")
+ SdkPersistentSettingsWriter writer(path, QLatin1String("QtCreator")
+ file[0].toUpper() + file.mid(1));
QString errorMessage;
if (!writer.save(map, &errorMessage)) {
- std::cerr << "Error: Could not save settings " << qPrintable(path.toString())
+ std::cerr << "Error: Could not save settings " << qPrintable(path)
<< "." << std::endl;
return false;
}
- if (!path.setPermissions(QFile::ReadOwner | QFile::WriteOwner
+ if (!QFile(path).setPermissions(QFile::ReadOwner | QFile::WriteOwner
| QFile::ReadGroup | QFile::ReadOther)) {
- std::cerr << "Error: Could not set permissions for " << qPrintable(path.toString())
+ std::cerr << "Error: Could not set permissions for " << qPrintable(path)
<< "." << std::endl;
return false;
}