Log backup rotation (incomplete)

This commit is contained in:
Nekotekina 2017-08-30 17:15:35 +03:00
parent 010b75251f
commit 7b96190e6c

View File

@ -300,13 +300,17 @@ logs::file_writer::file_writer(const std::string& name)
#ifdef _WIN32
m_fmap = CreateFileMappingW(m_file.get_handle(), 0, PAGE_READWRITE, s_log_size >> 32, s_log_size & 0xffffffff, 0);
m_fptr = (uchar*)MapViewOfFile(m_fmap, FILE_MAP_WRITE, 0, 0, 0);
m_fptr = m_fmap ? (uchar*)MapViewOfFile(m_fmap, FILE_MAP_WRITE, 0, 0, 0) : nullptr;
#else
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
verify(m_name.c_str()), m_fptr;
std::memset(m_fptr, '\n', s_log_size);
// Rotate backups (TODO)
fs::rename(m_name + ".gz", m_name + "1.gz", true);
}
catch (...)
{