// anyway.
bool failed = false;
// anyway.
bool failed = false;
- FileName const tmp_ret = FileName::tempName(FileName(), "lyxauto");
+ FileName const tmp_ret = FileName::tempName("lyxauto");
if (!tmp_ret.empty()) {
buffer_.writeFile(tmp_ret);
// assume successful write of tmp_ret
if (!tmp_ret.empty()) {
buffer_.writeFile(tmp_ret);
// assume successful write of tmp_ret
if (!vcs)
return string();
if (!vcs)
return string();
- FileName const tmpf = FileName::tempName(FileName(), "lyxvclog");
+ FileName const tmpf = FileName::tempName("lyxvclog");
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return string();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return string();
FileName filename;
zipped_ = filename_.isZippedFile();
if (zipped_) {
FileName filename;
zipped_ = filename_.isZippedFile();
if (zipped_) {
- unzipped_filename_ = FileName::tempName(FileName(),
+ unzipped_filename_ = FileName::tempName(
filename_.toFilesystemEncoding());
if (unzipped_filename_.empty()) {
setStatus(ErrorConverting);
filename_.toFilesystemEncoding());
if (unzipped_filename_.empty()) {
setStatus(ErrorConverting);
// Add some stuff to create a uniquely named temporary file.
// This file is deleted in loadImage after it is loaded into memory.
// Add some stuff to create a uniquely named temporary file.
// This file is deleted in loadImage after it is loaded into memory.
- FileName const to_file_base = FileName::tempName(FileName(), "CacheItem");
+ FileName const to_file_base = FileName::tempName("CacheItem");
remove_loaded_file_ = true;
// Remove the temp file, we only want the name...
remove_loaded_file_ = true;
// Remove the temp file, we only want the name...
// Remember to remove the temp file because we only want the name...
static int counter = 0;
string const tmp = "gconvert" + convert<string>(counter++);
// Remember to remove the temp file because we only want the name...
static int counter = 0;
string const tmp = "gconvert" + convert<string>(counter++);
- FileName const to_base = FileName::tempName(FileName(), tmp);
+ FileName const to_base = FileName::tempName(tmp);
to_base.removeFile();
// Create a copy of the file in case the original name contains
to_base.removeFile();
// Create a copy of the file in case the original name contains
- FileName const tempname = FileName::tempName(FileName(), "lyxext");
+ FileName const tempname = FileName::tempName("lyxext");
// FIXME: This is unsafe
tempname.removeFile();
// must have an extension for the converter code to work correctly.
// FIXME: This is unsafe
tempname.removeFile();
// must have an extension for the converter code to work correctly.
{
// In order to avoid parsing problems with command interpreters
// we pass input data through a file
{
// In order to avoid parsing problems with command interpreters
// we pass input data through a file
- FileName const cas_tmpfile = FileName::tempName(FileName(), "casinput");
+ FileName const cas_tmpfile = FileName::tempName("casinput");
if (cas_tmpfile.empty()) {
lyxerr << "Warning: cannot create temporary file."
<< endl;
if (cas_tmpfile.empty()) {
lyxerr << "Warning: cannot create temporary file."
<< endl;
{
LYXERR(Debug::FILES, "isDirWriteable: " << *this);
{
LYXERR(Debug::FILES, "isDirWriteable: " << *this);
- FileName const tmpfl = FileName::tempName(*this, "lyxwritetest");
+ FileName const tmpfl = FileName::tempName(absFilename() + "/lyxwritetest");
if (tmpfl.empty())
return false;
if (tmpfl.empty())
return false;
-FileName FileName::tempName(FileName const & dir, string const & mask)
+FileName FileName::tempName(string const & mask)
- string const tmpdir = dir.empty() ?
- package().temp_dir().absFilename() : dir.absFilename();
- string tmpfl = to_filesystem8bit(from_utf8(addName(tmpdir, mask)));
+ FileName tmp_name(mask);
+ string tmpfl;
+ if (tmp_name.d->fi.isAbsolute())
+ tmpfl = mask;
+ else
+ tmpfl = package().temp_dir().absFilename() + "/" + mask;
+
#if defined (HAVE_GETPID)
tmpfl += convert<string>(getpid());
#elif defined (HAVE__GETPID)
#if defined (HAVE_GETPID)
tmpfl += convert<string>(getpid());
#elif defined (HAVE__GETPID)
bool isZippedFile() const;
static FileName fromFilesystemEncoding(std::string const & name);
bool isZippedFile() const;
static FileName fromFilesystemEncoding(std::string const & name);
- /// (securely) create a temporary file in the given dir with the given mask
- /// \p mask must be in filesystem encoding
- static FileName tempName(FileName const & dir = FileName(),
- std::string const & mask = empty_string());
+ /// (securely) create a temporary file with the given mask.
+ /// \p mask must be in filesystem encoding, if it contains a
+ /// relative path, the template file will be created in the global
+ /// temporary directory as given by 'package().temp_dir()'.
+ static FileName tempName(std::string const & mask = empty_string());
/// filename without path
std::string onlyFileName() const;
/// filename without path
std::string onlyFileName() const;
LYXERR(Debug::FILES, "createTmpDir: tempdir=`" << tempdir << "'\n"
<< "createTmpDir: mask=`" << mask << '\'');
LYXERR(Debug::FILES, "createTmpDir: tempdir=`" << tempdir << "'\n"
<< "createTmpDir: mask=`" << mask << '\'');
- FileName const tmpfl = FileName::tempName(tempdir, 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
// 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