mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 06:21:26 +12:00
Compress log to RPCS3.log.gz
This commit is contained in:
parent
a771fcb397
commit
26e13b4f5f
1 changed files with 22 additions and 0 deletions
|
@ -16,6 +16,8 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
static std::string empty_string()
|
static std::string empty_string()
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
|
@ -319,6 +321,26 @@ logs::file_writer::~file_writer()
|
||||||
m_size = std::min<std::size_t>(+m_pos, s_log_size);
|
m_size = std::min<std::size_t>(+m_pos, s_log_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compress
|
||||||
|
z_stream zs{};
|
||||||
|
if (deflateInit2(&zs, 9, Z_DEFLATED, 16 + 15, 9, Z_DEFAULT_STRATEGY) == Z_OK)
|
||||||
|
{
|
||||||
|
auto buf = std::make_unique<uchar[]>(s_log_size);
|
||||||
|
zs.avail_in = ::narrow<u32>(m_size);
|
||||||
|
zs.avail_out = s_log_size;
|
||||||
|
zs.next_in = m_fptr;
|
||||||
|
zs.next_out = buf.get();
|
||||||
|
|
||||||
|
if (deflate(&zs, Z_FINISH) != Z_STREAM_ERROR)
|
||||||
|
{
|
||||||
|
fs::file(m_name + ".gz", fs::rewrite).write(buf.get(), zs.total_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deflateEnd(&zs) != Z_OK)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
UnmapViewOfFile(m_fptr);
|
UnmapViewOfFile(m_fptr);
|
||||||
CloseHandle(m_fmap);
|
CloseHandle(m_fmap);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue