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 946711feb..8cc1e0315 100644 --- a/src/libs/installer/replaceoperation.cpp +++ b/src/libs/installer/replaceoperation.cpp @@ -34,7 +34,8 @@ using namespace QInstaller; -ReplaceOperation::ReplaceOperation() +ReplaceOperation::ReplaceOperation(PackageManagerCore *core) + : UpdateOperation(core) { setName(QLatin1String("Replace")); } @@ -45,18 +46,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); @@ -64,7 +61,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; } @@ -74,7 +72,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; } @@ -95,8 +94,3 @@ bool ReplaceOperation::testOperation() { return true; } - -Operation *ReplaceOperation::clone() const -{ - return new ReplaceOperation(); -} |