forked from suyu/suyu
log/backend: Use in-class initializer for FileBackend
We can also avoid redundant constructions of the same string repeatedly.
This commit is contained in:
parent
aaaca1cd6d
commit
6125590a7b
2 changed files with 8 additions and 6 deletions
|
@ -148,12 +148,14 @@ void ColorConsoleBackend::Write(const Entry& entry) {
|
||||||
PrintColoredMessage(entry);
|
PrintColoredMessage(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileBackend::FileBackend(const std::string& filename) : bytes_written(0) {
|
FileBackend::FileBackend(const std::string& filename) {
|
||||||
if (FS::Exists(filename + ".old.txt")) {
|
const auto old_filename = filename + ".old.txt";
|
||||||
FS::Delete(filename + ".old.txt");
|
|
||||||
|
if (FS::Exists(old_filename)) {
|
||||||
|
FS::Delete(old_filename);
|
||||||
}
|
}
|
||||||
if (FS::Exists(filename)) {
|
if (FS::Exists(filename)) {
|
||||||
FS::Rename(filename, filename + ".old.txt");
|
FS::Rename(filename, old_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _SH_DENYWR allows read only access to the file for other programs.
|
// _SH_DENYWR allows read only access to the file for other programs.
|
||||||
|
|
|
@ -94,8 +94,8 @@ public:
|
||||||
void Write(const Entry& entry) override;
|
void Write(const Entry& entry) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::FS::IOFile file;
|
FS::IOFile file;
|
||||||
std::size_t bytes_written;
|
std::size_t bytes_written = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue