4 static QList<QString> paths;
6 static QString userName;
9 Temporary::Temporary() { }
11 QString Temporary::filename() {
13 static const QString tempDir = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
15 QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" + QString::number(qrand());
18 if (userName.isNull()) {
19 userName = QString(getenv("USERNAME"));
20 if (userName.isEmpty())
21 userName = QString(getenv("USER"));
23 if (!userName.isEmpty())
24 tempFile += "-" + userName;
27 // tempFile += ".mp4";
29 if (QFile::exists(tempFile) && !QFile::remove(tempFile)) {
30 qDebug() << "Cannot remove temp file" << tempFile;
35 if (paths.size() > 1) {
36 QString removedFile = paths.takeFirst();
37 if (QFile::exists(removedFile) && !QFile::remove(removedFile)) {
38 qDebug() << "Cannot remove temp file" << removedFile;
46 void Temporary::deleteAll() {
47 foreach(QString path, paths) {
48 if (QFile::exists(path) && !QFile::remove(path)) {
49 qDebug() << "Cannot remove temp file" << path;