11 #include "filetools.h"
13 extern string system_tempdir;
15 string const lyx::tempName(string const & dir, string const & mask)
18 // the tmpnam version...
19 char const * const tmp = ::tmpnam(0);
20 return (tmp) ? tmp : string ();
24 tmpdir = system_tempdir;
27 string tmpfl(AddName(tmpdir, mask));
28 tmpfl += tostr(getpid());
30 // the supposedly safer mkstemp version
31 char * tmpl = new char[256];
33 ::strcpy(tmpl, tmpfl.c_str());
34 int tmpf = ::mkstemp(tmpl);
39 lyxerr << "Temporary file `" << t << "' created." << endl;
42 lyxerr << "LyX Error: Unable to create temporary file."