7 #include "support/lyxlib.h"
8 #include "support/filetools.h"
13 extern string system_tempdir;
15 string const lyx::tempName(string const & dir, string const & mask)
17 string const tmpdir(dir.empty() ? system_tempdir : dir);
18 string tmpfl(AddName(tmpdir, mask));
19 tmpfl += tostr(getpid());
22 // The supposedly safe mkstemp version
23 char * tmpl = new char[tmpfl.length() + 1]; // + 1 for '\0'
24 tmpfl.copy(tmpl, string::npos);
25 tmpl[tmpfl.length()] = '\0'; // terminator
27 int const tmpf = ::mkstemp(tmpl);
32 lyxerr[Debug::FILES] << "Temporary file `" << t
33 << "' created." << endl;
37 << "LyX Error: Unable to create temporary file."