From 4debbdd6b6d87739e6d55adb6dfd00c8c8af4895 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 17 Feb 2020 09:00:08 +0100 Subject: [PATCH] Restore custom tmp directory Fixes #1174 --- src/support/filetools.cpp | 16 ++++++++++++++-- src/support/filetools.h | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index a36446dc4c..a34ee225f9 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -442,9 +442,20 @@ string const commandPrep(string const & command_in) } +FileName const tempFileName(FileName tempdir, string const & mask, bool const dir) +{ + return tempFileName(TempFile(tempdir, mask).name(), dir); +} + + FileName const tempFileName(string const & mask, bool const dir) { - FileName tempfile = TempFile(mask).name(); + return tempFileName(TempFile(mask).name(), dir); +} + + +FileName const tempFileName(FileName tempfile, bool const dir) +{ // Since the QTemporaryFile object is destroyed at function return // (which is what is intended here), the next call to this function // may return the same file name again. @@ -499,7 +510,8 @@ static FileName createTmpDir(FileName const & tempdir, string const & mask) QFileInfo tmp_fi(QDir(toqstr(tempdir.absFileName())), toqstr(mask)); FileName const tmpfl = - tempFileName(fromqstr(tmp_fi.absoluteFilePath()) + ".XXXXXXXXXXXX", true); + tempFileName(FileName(fromqstr(tmp_fi.absolutePath())), + fromqstr(tmp_fi.fileName()) + ".XXXXXXXXXXXX", true); if (tmpfl.empty() || !tmpfl.createDirectory(0700)) { LYXERR0("LyX could not create temporary directory in " << tempdir diff --git a/src/support/filetools.h b/src/support/filetools.h index 05b3d705ec..1ac0edf15b 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -40,6 +40,10 @@ static std::set tmp_names_; * all used temp file names. * If you don't have to remove the temp file manually, use TempFile instead! */ +FileName const tempFileName(FileName, bool const dir = false); +/// Get temporary file name with custom path +FileName const tempFileName(FileName, std::string const &, bool const dir = false); +/// Get temporary file name with default path FileName const tempFileName(std::string const &, bool const dir = false); /// Remove and unregister a temporary file. -- 2.39.2