#include <QDir>
-#include "support/assert.h"
+#include "support/lassert.h"
#include <boost/regex.hpp>
#include <fcntl.h>
LYXERR(Debug::FILES, "createTmpDir: tempdir=`" << tempdir << "'\n"
<< "createTmpDir: mask=`" << mask << '\'');
- FileName const tmpfl = FileName::tempName(tempdir.absFilename()
- + "/" + mask);
- // FileName::tempName actually creates a file to make sure that it
- // stays unique. So we have to delete it before we can create
- // a dir with the same name. Note also that we are not thread
- // safe because of the gap between unlink and mkdir. (Lgb)
- tmpfl.removeFile();
+ FileName const tmpfl = FileName::tempName(tempdir, mask);
if (tmpfl.empty() || !tmpfl.createDirectory(0700)) {
- lyxerr << "LyX could not create the temporary directory '"
- << tmpfl << "'" << endl;
+ LYXERR0("LyX could not create temporary directory in " << tempdir
+ << "'");
return FileName();
}
FileName const createLyXTmpDir(FileName const & deflt)
{
- if (deflt.empty() || deflt.absFilename() == "/tmp")
- return createTmpDir(FileName("/tmp"), "lyx_tmpdir");
+ if (deflt.empty() || deflt == package().system_temp_dir())
+ return createTmpDir(package().system_temp_dir(), "lyx_tmpdir");
if (deflt.createDirectory(0777))
return deflt;
return createTmpDir(deflt, "lyx_tmpdir");
} else {
// some other error occured.
- return createTmpDir(FileName("/tmp"), "lyx_tmpdir");
+ return createTmpDir(package().system_temp_dir(), "lyx_tmpdir");
}
}
if (absfile.exists())
return absfile;
- // No we try to find it using kpsewhich.
+ // Now we try to find it using kpsewhich.
// It seems from the kpsewhich manual page that it is safe to use
// kpsewhich without --format: "When the --format option is not
// given, the search path used when looking for a file is inferred