aboutsummaryrefslogtreecommitdiffstats
path: root/core/uploadDiveLogsDE.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/uploadDiveLogsDE.cpp')
-rw-r--r--core/uploadDiveLogsDE.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/core/uploadDiveLogsDE.cpp b/core/uploadDiveLogsDE.cpp
index fc8ead6c3..a9c39bf11 100644
--- a/core/uploadDiveLogsDE.cpp
+++ b/core/uploadDiveLogsDE.cpp
@@ -2,6 +2,7 @@
#include "uploadDiveLogsDE.h"
#include <QDir>
#include <QDebug>
+#include <QTemporaryFile>
#include <zip.h>
#include <errno.h>
#include "core/display.h"
@@ -34,21 +35,22 @@ uploadDiveLogsDE::uploadDiveLogsDE():
}
-void uploadDiveLogsDE::doUpload(bool selected, const QString &userid, const QString &password)
+static QString makeTempFileName()
{
- QString err;
-
+ QTemporaryFile tmpfile;
+ tmpfile.setFileTemplate(QDir::tempPath() + "/divelogsde-upload.XXXXXXXX.dld");
+ tmpfile.open();
+ QString filename(tmpfile.fileName());
+ tmpfile.close();
+ return filename;
+}
- /* generate a temporary filename and create/open that file with zip_open */
- QString filename(QDir::tempPath() + "/divelogsde-upload.dld");
- // delete file if it exist
+void uploadDiveLogsDE::doUpload(bool selected, const QString &userid, const QString &password)
+{
+ QString err;
- QFile f(filename);
- if (f.open(QIODevice::ReadOnly)) {
- f.close();
- f.remove();
- }
+ QString filename = makeTempFileName();
// Make zip file, with all dives, in divelogs.de format
if (!prepareDives(filename, selected)) {