#include <QDir>
-#include <boost/assert.hpp>
+#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");
}
}
string const ext = getExtension(zipped_file);
if (ext == "gz" || ext == "z" || ext == "Z")
return changeExtension(zipped_file, string());
- return "unzipped_" + zipped_file;
+ return onlyPath(zipped_file) + "unzipped_" + onlyFilename(zipped_file);
}
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