From a771fcb3970e37338d3647e7d33a4c9fa2321bf5 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 29 Aug 2017 17:09:06 +0300 Subject: [PATCH] Fill log with \n --- Utilities/File.cpp | 4 ++-- Utilities/Log.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Utilities/File.cpp b/Utilities/File.cpp index b4d5a5afd2..210faafd41 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -765,10 +765,10 @@ fs::file::file(const std::string& path, bs_t mode) disp = test(mode & fs::trunc) ? TRUNCATE_EXISTING : OPEN_EXISTING; } - DWORD share = 0; + DWORD share = FILE_SHARE_READ; if (!test(mode & fs::unshare)) { - share |= FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; + share |= FILE_SHARE_WRITE | FILE_SHARE_DELETE; } const HANDLE handle = CreateFileW(to_wchar(path).get(), access, share, NULL, disp, FILE_ATTRIBUTE_NORMAL, NULL); diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 2c7a29f6ac..a863c851fb 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -56,6 +56,7 @@ namespace logs class file_writer { fs::file m_file; + std::string m_name; #ifdef _WIN32 ::HANDLE m_fmap; @@ -286,12 +287,13 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u [[noreturn]] extern void catch_all_exceptions(); logs::file_writer::file_writer(const std::string& name) + : m_name(fs::get_config_dir() + name) { try { - if (!m_file.open(fs::get_config_dir() + name, fs::read + fs::write + fs::create + fs::trunc + fs::unshare)) + if (!m_file.open(m_name, fs::read + fs::write + fs::create + fs::trunc + fs::unshare)) { - fmt::throw_exception("Can't create log file %s (error %s)", name, fs::g_tls_error); + fmt::throw_exception("Can't create file %s (error %s)", name, fs::g_tls_error); } #ifdef _WIN32 @@ -301,6 +303,8 @@ logs::file_writer::file_writer(const std::string& name) m_file.trunc(s_log_size); m_fptr = (uchar*)::mmap(0, s_log_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_file.get_handle(), 0); #endif + + std::memset(m_fptr, '\n', s_log_size); } catch (...) {