// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-int const LYX_FORMAT = 354; // jspitzm: support for \print[sub]index*
+int const LYX_FORMAT = 357; // sanda: change latex output for various underline commands
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
void Buffer::setFileName(string const & newfile)
{
- // bring the autosave file with us, just in case.
- FileName const oldauto = getAutosaveFilename();
d->filename = makeAbsPath(newfile);
setReadonly(d->filename.isReadOnly());
updateTitles();
- FileName const newauto = getAutosaveFilename();
- if (oldauto == newauto)
- return;
- if (oldauto.moveTo(newauto))
- return;
- LYXERR0("Unable to remove autosave file `" << oldauto << "'!");
}
FileName Buffer::getAutosaveFilename() const
{
- string const fpath = isUnnamed() ? lyxrc.document_path : filePath();
+ // if the document is unnamed try to save in the backup dir, else
+ // in the default document path, and as a last try in the filePath,
+ // which will most often be the temporary directory
+ string fpath;
+ if (isUnnamed())
+ fpath = lyxrc.backupdir_path.empty() ? lyxrc.document_path
+ : lyxrc.backupdir_path;
+ if (!isUnnamed() || fpath.empty() || !FileName(fpath).exists())
+ fpath = filePath();
+
string const fname = "#" + d->filename.onlyFileName() + "#";
return makeAbsPath(fname, fpath);
}
}
+void Buffer::moveAutosaveFile(support::FileName const & oldauto) const
+{
+ FileName const newauto = getAutosaveFilename();
+ if (!(oldauto == newauto || oldauto.moveTo(newauto)))
+ LYXERR0("Unable to remove autosave file `" << oldauto << "'!");
+}
+
+
// Perfect target for a thread...
void Buffer::autoSave() const
{