mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-27 01:22:37 -06:00
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
399f3d4e32
commit
5c86147ef4
2 changed files with 7 additions and 5 deletions
|
@ -145,12 +145,14 @@ void LogcatBackend::Write(const Entry& entry) {
|
||||||
PrintMessageToLogcat(entry);
|
PrintMessageToLogcat(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileBackend::FileBackend(const std::string& filename) : bytes_written(0) {
|
FileBackend::FileBackend(const std::string& filename) {
|
||||||
if (FileUtil::Exists(filename + ".old.txt")) {
|
const auto old_filename = filename + ".old.txt";
|
||||||
FileUtil::Delete(filename + ".old.txt");
|
|
||||||
|
if (FileUtil::Exists(old_filename)) {
|
||||||
|
FileUtil::Delete(old_filename);
|
||||||
}
|
}
|
||||||
if (FileUtil::Exists(filename)) {
|
if (FileUtil::Exists(filename)) {
|
||||||
FileUtil::Rename(filename, filename + ".old.txt");
|
FileUtil::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.
|
||||||
|
|
|
@ -109,7 +109,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileUtil::IOFile file;
|
FileUtil::IOFile file;
|
||||||
std::size_t bytes_written;
|
std::size_t bytes_written = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue