commit 9efa43d2be7dcff0c1152b6f6a45801cfdd6d70e Author: Richard Heck <rgh...@lyx.org> Date: Fri Nov 13 17:12:52 2015 -0500
Simplify use of Buffer::getBackupName(). Previous versions of this code used the string in a different way, but now it is sufficient just to return a FileName. diff --git a/src/Buffer.cpp b/src/Buffer.cpp index f907d6c..b1807ed 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1306,7 +1306,7 @@ Buffer::ReadStatus Buffer::convertLyXFormat(FileName const & fn, } -string Buffer::getBackupName() const { +FileName Buffer::getBackupName() const { FileName const & fn = fileName(); string const fname = fn.onlyFileNameWithoutExt(); string const fext = fn.extension(); @@ -1337,7 +1337,7 @@ string Buffer::getBackupName() const { backup.set(addName(fpath, addExtension(newbackname, fext))); v++; } - return v < 100 ? backup.absFileName() : ""; + return v < 100 ? backup : FileName(); } @@ -1402,11 +1402,8 @@ bool Buffer::save() const FileName backupName; if (lyxrc.make_backup || d->need_format_backup) { - if (d->need_format_backup) { - string backup_name = getBackupName(); - if (!backup_name.empty()) - backupName.set(backup_name); - } + if (d->need_format_backup) + backupName = getBackupName(); // If we for some reason failed to find a backup name in case of // a format change, this will still set one. It's the best we can diff --git a/src/Buffer.h b/src/Buffer.h index 7dd9365..7450790 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -268,7 +268,7 @@ private: ReadStatus convertLyXFormat(support::FileName const & fn, support::FileName & tmpfile, int from_format); /// get appropriate name for backing up files from older versions - std::string getBackupName() const; + support::FileName getBackupName() const; //@} public: