aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt/src/util.cpp
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2023-10-27 09:27:29 +0000
committerIngo Klöcker <[email protected]>2023-10-27 14:07:34 +0000
commit8d8985bda1747a18b3b1378ea7c627302a61464a (patch)
treef519130dd111c2b0c4e82224eb2a05e9c6d34500 /lang/qt/src/util.cpp
parentPost release updates (diff)
downloadgpgme-8d8985bda1747a18b3b1378ea7c627302a61464a.tar.gz
gpgme-8d8985bda1747a18b3b1378ea7c627302a61464a.zip
qt: Refactor removal of output file on cancel or error
* lang/qt/src/util.h, lang/qt/src/util.cpp (removeFile): New. * lang/qt/src/qgpgmeencryptarchivejob.cpp (encrypt): Move removal of output file from here (encrypt_to_filename): ... to here and use new function. * lang/qt/src/qgpgmesignarchivejob.cpp (sign): Move removal of output file from here (sign_to_filename): ... to here and use new function. * lang/qt/src/qgpgmesignencryptarchivejob.cpp (sign_encrypt): Move removal of output file from here (sign_encrypt_to_filename): ... to here and use new function. -- GnuPG-bug-id: 6721
Diffstat (limited to 'lang/qt/src/util.cpp')
-rw-r--r--lang/qt/src/util.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lang/qt/src/util.cpp b/lang/qt/src/util.cpp
index d4190eb8..a9a70290 100644
--- a/lang/qt/src/util.cpp
+++ b/lang/qt/src/util.cpp
@@ -37,6 +37,10 @@
#include "util.h"
+#include "qgpgme_debug.h"
+
+#include <QFile>
+
#include <key.h>
#include <algorithm>
@@ -61,3 +65,14 @@ QStringList toFingerprints(const std::vector<GpgME::Key> &keys)
});
return fprs;
}
+
+void removeFile(const QString &fileName)
+{
+ if (QFile::exists(fileName)) {
+ if (QFile::remove(fileName)) {
+ qCDebug(QGPGME_LOG) << __func__ << "- Removed file" << fileName;
+ } else {
+ qCDebug(QGPGME_LOG) << __func__ << "- Removing file" << fileName << "failed";
+ }
+ }
+}