From 37212a4d0cb59929af6366b48d0a8cc110f06912 Mon Sep 17 00:00:00 2001 From: Legonzaur <34353603+Legonzaur@users.noreply.github.com> Date: Wed, 16 Feb 2022 13:16:32 +0100 Subject: Fix corrupted zipped logs (#76) Co-authored-by: Nathan TIEN YOU --- NorthstarDedicatedTest/logCompression.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/NorthstarDedicatedTest/logCompression.cpp b/NorthstarDedicatedTest/logCompression.cpp index d9e89fdf..5c170de3 100644 --- a/NorthstarDedicatedTest/logCompression.cpp +++ b/NorthstarDedicatedTest/logCompression.cpp @@ -17,7 +17,6 @@ using namespace std; bool compressFile(const fs::path path) { // read log file - ofstream output; string filename(path.string()); cout << "Compressing : '" + filename + "'" << endl; ifstream input(filename, ios_base::binary); @@ -31,13 +30,13 @@ bool compressFile(const fs::path path) // compress log file string compressed_data = gzip::compress(log_data.data(), log_data.size()); // write log file gzip - output.open(filename + ".gz"); - if (!output.is_open()) + ofstream output(filename + ".gz", ios::out | ios::binary); + if (!output) { cerr << "Could not write : '" + filename + "'" << endl; return false; } - output << compressed_data; + output.write(compressed_data.c_str(), compressed_data.size()); output.close(); // delete log file remove(path); -- cgit v1.2.3