| From bdc7e03f69f4a48f0d34340c60d5ccfa20917e62 Mon Sep 17 00:00:00 2001 |
| From: Ray Donnelly <mingw.android@gmail.com> |
| Date: Wed, 7 May 2014 17:09:33 +0100 |
| Subject: [PATCH 3/9] add recursive option to rmdir operation |
| |
| --- |
| src/libs/kdtools/updateoperations.cpp | 8 ++++++-- |
| 1 file changed, 6 insertions(+), 2 deletions(-) |
| |
| diff --git a/src/libs/kdtools/updateoperations.cpp b/src/libs/kdtools/updateoperations.cpp |
| index aeeaffe..4df8c49 100644 |
| --- a/src/libs/kdtools/updateoperations.cpp |
| +++ b/src/libs/kdtools/updateoperations.cpp |
| @@ -524,7 +524,8 @@ void RmdirOperation::backup() |
| bool RmdirOperation::performOperation() |
| { |
| // Requires only one parameter. That is the name of the file to remove. |
| - if (!checkArgumentCount(1)) |
| + // A second optional parameter of true indicates recursive deletion. |
| + if (!checkArgumentCount(1) && !checkArgumentCount(2)) |
| return false; |
| |
| const QString firstArg = arguments().at(0); |
| @@ -536,8 +537,11 @@ bool RmdirOperation::performOperation() |
| return false; |
| } |
| |
| + bool isRecursive = (arguments().count() == 2 && arguments().last() == QLatin1String("true")) ? true : false; |
| + |
| errno = 0; |
| - const bool removed = dir.rmdir(firstArg); |
| + const bool removed = isRecursive ? dir.removeRecursively() |
| + : dir.rmdir(firstArg); |
| setValue(QLatin1String("removed"), removed); |
| if (!removed) { |
| setError(UserDefinedError); |
| -- |
| 2.7.0 |
| |