diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-05-26 01:32:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-26 01:32:56 +0200 |
commit | 065867e2c24e9856c360fc2d6b9a86c92aedc43e (patch) | |
tree | 7964e85ef4f01a3c2b8f44e850f37b384405b930 /src/common/logging/backend.cpp | |
parent | Merge pull request #6349 from german77/suppress_config_warning (diff) | |
download | yuzu-065867e2c24e9856c360fc2d6b9a86c92aedc43e.tar yuzu-065867e2c24e9856c360fc2d6b9a86c92aedc43e.tar.gz yuzu-065867e2c24e9856c360fc2d6b9a86c92aedc43e.tar.bz2 yuzu-065867e2c24e9856c360fc2d6b9a86c92aedc43e.tar.lz yuzu-065867e2c24e9856c360fc2d6b9a86c92aedc43e.tar.xz yuzu-065867e2c24e9856c360fc2d6b9a86c92aedc43e.tar.zst yuzu-065867e2c24e9856c360fc2d6b9a86c92aedc43e.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/logging/backend.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 96efa977d..6aa8ac960 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -11,13 +11,13 @@ #include <mutex> #include <thread> #include <vector> + #ifdef _WIN32 -#include <share.h> // For _SH_DENYWR #include <windows.h> // For OutputDebugStringW -#else -#define _SH_DENYWR 0 #endif + #include "common/assert.h" +#include "common/fs/fs.h" #include "common/logging/backend.h" #include "common/logging/log.h" #include "common/logging/text_formatter.h" @@ -148,19 +148,16 @@ void ColorConsoleBackend::Write(const Entry& entry) { PrintColoredMessage(entry); } -FileBackend::FileBackend(const std::string& filename) { - const auto old_filename = filename + ".old.txt"; +FileBackend::FileBackend(const std::filesystem::path& filename) { + auto old_filename = filename; + old_filename += ".old.txt"; - if (FS::Exists(old_filename)) { - FS::Delete(old_filename); - } - if (FS::Exists(filename)) { - FS::Rename(filename, old_filename); - } + // Existence checks are done within the functions themselves. + // We don't particularly care if these succeed or not. + void(FS::RemoveFile(old_filename)); + void(FS::RenameFile(filename, old_filename)); - // _SH_DENYWR allows read only access to the file for other programs. - // It is #defined to 0 on other platforms - file = FS::IOFile(filename, "w", _SH_DENYWR); + file = FS::IOFile(filename, FS::FileAccessMode::Write, FS::FileType::TextFile); } void FileBackend::Write(const Entry& entry) { @@ -181,7 +178,7 @@ void FileBackend::Write(const Entry& entry) { bytes_written += file.WriteString(FormatLogMessage(entry).append(1, '\n')); if (entry.log_level >= Level::Error) { - file.Flush(); + void(file.Flush()); } } |