diff options
| author | 2021-04-20 12:57:45 -0400 | |
|---|---|---|
| committer | 2021-04-20 12:57:49 -0400 | |
| commit | 6125590a7b2bbad7d5efdfbab69ba86601e0769b (patch) | |
| tree | c420bcf8709cf5af735988fddf25bba63ddbd2eb | |
| parent | log/backend: Make use of erase_if (diff) | |
| download | yuzu-6125590a7b2bbad7d5efdfbab69ba86601e0769b.tar.gz yuzu-6125590a7b2bbad7d5efdfbab69ba86601e0769b.tar.xz yuzu-6125590a7b2bbad7d5efdfbab69ba86601e0769b.zip | |
log/backend: Use in-class initializer for FileBackend
We can also avoid redundant constructions of the same string repeatedly.
| -rw-r--r-- | src/common/logging/backend.cpp | 10 | ||||
| -rw-r--r-- | src/common/logging/backend.h | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index f0bb392c6..96efa977d 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -148,12 +148,14 @@ void ColorConsoleBackend::Write(const Entry& entry) { | |||
| 148 | PrintColoredMessage(entry); | 148 | PrintColoredMessage(entry); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | FileBackend::FileBackend(const std::string& filename) : bytes_written(0) { | 151 | FileBackend::FileBackend(const std::string& filename) { |
| 152 | if (FS::Exists(filename + ".old.txt")) { | 152 | const auto old_filename = filename + ".old.txt"; |
| 153 | FS::Delete(filename + ".old.txt"); | 153 | |
| 154 | if (FS::Exists(old_filename)) { | ||
| 155 | FS::Delete(old_filename); | ||
| 154 | } | 156 | } |
| 155 | if (FS::Exists(filename)) { | 157 | if (FS::Exists(filename)) { |
| 156 | FS::Rename(filename, filename + ".old.txt"); | 158 | FS::Rename(filename, old_filename); |
| 157 | } | 159 | } |
| 158 | 160 | ||
| 159 | // _SH_DENYWR allows read only access to the file for other programs. | 161 | // _SH_DENYWR allows read only access to the file for other programs. |
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index 84a544ea4..9dd2589c3 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h | |||
| @@ -94,8 +94,8 @@ public: | |||
| 94 | void Write(const Entry& entry) override; | 94 | void Write(const Entry& entry) override; |
| 95 | 95 | ||
| 96 | private: | 96 | private: |
| 97 | Common::FS::IOFile file; | 97 | FS::IOFile file; |
| 98 | std::size_t bytes_written; | 98 | std::size_t bytes_written = 0; |
| 99 | }; | 99 | }; |
| 100 | 100 | ||
| 101 | /** | 101 | /** |