3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "support/TempFile.h"
15 #include "support/debug.h"
16 #include "support/FileName.h"
17 #include "support/Package.h"
18 #include "support/qstring_helpers.h"
22 #include <QTemporaryFile>
29 struct TempFile::Private
32 Private(QString const & mask) : f(mask)
34 LYXERR(Debug::FILES, "Temporary file in " << fromqstr(mask));
36 LYXERR(Debug::FILES, "Temporary file `"
37 << fromqstr(f.fileName()) << "' created.");
39 LYXERR(Debug::FILES, "Unable to create temporary file with following template: "
48 TempFile::TempFile(FileName const & temp_dir, string const & mask)
50 QFileInfo tmp_fi(QDir(toqstr(temp_dir.absoluteFilePath())), toqstr(mask));
51 d = new Private(tmp_fi.absoluteFilePath());
55 TempFile::TempFile(string const & mask)
57 QFileInfo tmp_fi(QDir(toqstr(package().temp_dir().absoluteFilePath())), toqstr(mask));
58 d = new Private(tmp_fi.absoluteFilePath());
68 FileName TempFile::name() const
70 QString const n = d->f.fileName();
73 return FileName(fromqstr(n));
77 } // namespace support