diff options
Diffstat (limited to 'src/libs/installer/replaceoperation.cpp')
-rw-r--r-- | src/libs/installer/replaceoperation.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/libs/installer/replaceoperation.cpp b/src/libs/installer/replaceoperation.cpp index a3f470d5d..55d501278 100644 --- a/src/libs/installer/replaceoperation.cpp +++ b/src/libs/installer/replaceoperation.cpp @@ -39,7 +39,8 @@ using namespace QInstaller; -ReplaceOperation::ReplaceOperation() +ReplaceOperation::ReplaceOperation(PackageManagerCore *core) + : UpdateOperation(core) { setName(QLatin1String("Replace")); } @@ -50,18 +51,14 @@ void ReplaceOperation::backup() bool ReplaceOperation::performOperation() { - const QStringList args = arguments(); - // Arguments: // 1. filename // 2. Source-String // 3. Replace-String - if (args.count() != 3) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 3"), QLatin1String(""))); + if (!checkArgumentCount(3)) return false; - } + + const QStringList args = arguments(); const QString fileName = args.at(0); const QString before = args.at(1); const QString after = args.at(2); @@ -69,7 +66,8 @@ bool ReplaceOperation::performOperation() QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { setError(UserDefinedError); - setErrorString(tr("Failed to open %1 for reading").arg(fileName)); + setErrorString(tr("Cannot open file \"%1\" for reading: %2").arg( + QDir::toNativeSeparators(fileName), file.errorString())); return false; } @@ -79,7 +77,8 @@ bool ReplaceOperation::performOperation() if (!file.open(QIODevice::WriteOnly)) { setError(UserDefinedError); - setErrorString(tr("Failed to open %1 for writing").arg(fileName)); + setErrorString(tr("Cannot open file \"%1\" for writing: %2").arg( + QDir::toNativeSeparators(fileName), file.errorString())); return false; } @@ -100,8 +99,3 @@ bool ReplaceOperation::testOperation() { return true; } - -Operation *ReplaceOperation::clone() const -{ - return new ReplaceOperation(); -} |