early-access version 1664

This commit is contained in:
pineappleEA
2021-05-08 09:49:31 +02:00
parent c6b346cfbb
commit 394300898e
72 changed files with 3883 additions and 791 deletions

View File

@@ -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());
}
}

View File

@@ -4,10 +4,11 @@
#pragma once
#include <chrono>
#include <filesystem>
#include <memory>
#include <string>
#include <string_view>
#include "common/file_util.h"
#include "common/fs/file.h"
#include "common/logging/filter.h"
#include "common/logging/log.h"
@@ -81,7 +82,7 @@ public:
*/
class FileBackend : public Backend {
public:
explicit FileBackend(const std::string& filename);
explicit FileBackend(const std::filesystem::path& filename);
static const char* Name() {
return "file";