From 9efa43d2be7dcff0c1152b6f6a45801cfdd6d70e Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 13 Nov 2015 17:12:52 -0500 Subject: [PATCH] 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. --- src/Buffer.cpp | 11 ++++------- src/Buffer.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index f907d6cdff..b1807ed6f2 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 7dd936514d..74507909df 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: