From cbad159ac2de9387e9ef6130568eb2fa97732ad4 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Fri, 13 Mar 2015 00:31:08 +0100 Subject: [PATCH] Make sure a temporary file is always created in the global temporary dir. --- src/support/TempFile.cpp | 7 +++++-- src/support/TempFile.h | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/support/TempFile.cpp b/src/support/TempFile.cpp index 21559e144f..6e5a91d6e6 100644 --- a/src/support/TempFile.cpp +++ b/src/support/TempFile.cpp @@ -14,6 +14,7 @@ #include "support/debug.h" #include "support/FileName.h" +#include "support/filetools.h" #include "support/Package.h" #include "support/qstring_helpers.h" @@ -47,14 +48,16 @@ struct TempFile::Private TempFile::TempFile(FileName const & temp_dir, string const & mask) { - QFileInfo tmp_fi(QDir(toqstr(temp_dir.absoluteFilePath())), toqstr(mask)); + QFileInfo tmp_fi(QDir(toqstr(temp_dir.absoluteFilePath())), + toqstr(onlyFileName(mask))); d = new Private(tmp_fi.absoluteFilePath()); } TempFile::TempFile(string const & mask) { - QFileInfo tmp_fi(QDir(toqstr(package().temp_dir().absoluteFilePath())), toqstr(mask)); + QFileInfo tmp_fi(QDir(toqstr(package().temp_dir().absoluteFilePath())), + toqstr(onlyFileName(mask))); d = new Private(tmp_fi.absoluteFilePath()); } diff --git a/src/support/TempFile.h b/src/support/TempFile.h index b99ee756a1..53e91f0ae5 100644 --- a/src/support/TempFile.h +++ b/src/support/TempFile.h @@ -33,9 +33,9 @@ class TempFile { public: /** *Create a temporary file with the given mask. - * \p mask must be in filesystem encoding, if it contains a - * relative path, the template file will be created in the global - * temporary directory as given by 'package().temp_dir()'. + * \p mask must be in filesystem encoding, the template file + * will be created in the global temporary directory as given + * by 'package().temp_dir()'. * If the mask contains "XXXXXX" this portion will be replaced by * a uniquely generated string. If it does not contain this portion, * it will be automatically appended using a dot. Therefore, please