Restore custom tmp directory

Fixes #1174
This commit is contained in:
Juergen Spitzmueller 2020-02-17 09:00:08 +01:00
parent 562917dc1c
commit 4debbdd6b6
2 changed files with 18 additions and 2 deletions

View File

@ -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 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 // Since the QTemporaryFile object is destroyed at function return
// (which is what is intended here), the next call to this function // (which is what is intended here), the next call to this function
// may return the same file name again. // 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)); QFileInfo tmp_fi(QDir(toqstr(tempdir.absFileName())), toqstr(mask));
FileName const tmpfl = 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)) { if (tmpfl.empty() || !tmpfl.createDirectory(0700)) {
LYXERR0("LyX could not create temporary directory in " << tempdir LYXERR0("LyX could not create temporary directory in " << tempdir

View File

@ -40,6 +40,10 @@ static std::set<std::string> tmp_names_;
* all used temp file names. * all used temp file names.
* If you don't have to remove the temp file manually, use TempFile instead! * 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); FileName const tempFileName(std::string const &, bool const dir = false);
/// Remove and unregister a temporary file. /// Remove and unregister a temporary file.