aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt/src/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'lang/qt/src/util.h')
-rw-r--r--lang/qt/src/util.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/lang/qt/src/util.h b/lang/qt/src/util.h
index 9128e4bf..c2d63405 100644
--- a/lang/qt/src/util.h
+++ b/lang/qt/src/util.h
@@ -57,4 +57,26 @@ QStringList toFingerprints(const std::vector<GpgME::Key> &keys);
void removeFile(const QString &fileName);
+/**
+ * Helper for using a temporary "part" file for writing a result to, similar
+ * to what browsers do when downloading files.
+ * On success, you commit() which renames the temporary file to the
+ * final file name. Otherwise, you do nothing and let the helper remove the
+ * temporary file on destruction.
+ */
+class PartialFileGuard
+{
+public:
+ explicit PartialFileGuard(const QString &fileName);
+ ~PartialFileGuard();
+
+ QString tempFileName() const;
+
+ bool commit();
+
+private:
+ QString mFileName;
+ QString mTempFileName;
+};
+
#endif // __QGPGME_UTIL_H__