#include "temporary.h"
#include "constants.h"
-static QList<QString> paths;
-#ifdef Q_OS_LINUX
+static QVector<QString> paths;
+#ifdef APP_LINUX
static QString userName;
#endif
Temporary::Temporary() { }
QString Temporary::filename() {
-#if QT_VERSION >= 0x050000
static const QString tempDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
-#else
- static const QString tempDir = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
-#endif
- QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" + QString::number(qrand());
+ QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" +
+ QString::number(QRandomGenerator::global()->generate());
-#ifdef Q_OS_LINUX
+#ifdef APP_LINUX
if (userName.isNull()) {
userName = QString(getenv("USERNAME"));
if (userName.isEmpty())
}
void Temporary::deleteAll() {
- foreach(QString path, paths) {
+ foreach(const QString &path, paths) {
if (QFile::exists(path) && !QFile::remove(path)) {
qDebug() << "Cannot remove temp file" << path;
}