2018-04-20 07:02:12 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2023-04-25 13:51:26 +02:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2018-04-20 07:02:12 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include <logging.h>
|
2021-06-27 08:33:13 +02:00
|
|
|
#include <util/system.h>
|
|
|
|
#include <util/threadnames.h>
|
|
|
|
#include <util/time.h>
|
2018-04-20 07:02:12 +02:00
|
|
|
|
|
|
|
const char * const DEFAULT_DEBUGLOGFILE = "debug.log";
|
|
|
|
|
2019-02-04 20:26:02 +01:00
|
|
|
BCLog::Logger& LogInstance()
|
|
|
|
{
|
2018-04-20 07:02:12 +02:00
|
|
|
/**
|
2018-05-01 04:13:30 +02:00
|
|
|
* NOTE: the logger instances is leaked on exit. This is ugly, but will be
|
|
|
|
* cleaned up by the OS/libc. Defining a logger as a global object doesn't work
|
|
|
|
* since the order of destruction of static/global objects is undefined.
|
|
|
|
* Consider if the logger gets destroyed, and then some later destructor calls
|
|
|
|
* LogPrintf, maybe indirectly, and you get a core dump at shutdown trying to
|
|
|
|
* access the logger. When the shutdown sequence is fully audited and tested,
|
|
|
|
* explicit destruction of these objects can be implemented by changing this
|
|
|
|
* from a raw pointer to a std::unique_ptr.
|
2020-05-05 07:07:47 +02:00
|
|
|
* Since the ~Logger() destructor is never called, the Logger class and all
|
|
|
|
* its subclasses must have implicitly-defined destructors.
|
2018-04-20 07:02:12 +02:00
|
|
|
*
|
2018-05-01 04:13:30 +02:00
|
|
|
* This method of initialization was originally introduced in
|
|
|
|
* ee3374234c60aba2cc4c5cd5cac1c0aefc2d817c.
|
2018-04-20 07:02:12 +02:00
|
|
|
*/
|
2019-02-04 20:26:02 +01:00
|
|
|
static BCLog::Logger* g_logger{new BCLog::Logger()};
|
|
|
|
return *g_logger;
|
|
|
|
}
|
2018-05-01 04:13:30 +02:00
|
|
|
|
|
|
|
bool fLogIPs = DEFAULT_LOGIPS;
|
2018-04-20 07:02:12 +02:00
|
|
|
|
|
|
|
static int FileWriteStr(const std::string &str, FILE *fp)
|
|
|
|
{
|
|
|
|
return fwrite(str.data(), 1, str.size(), fp);
|
|
|
|
}
|
|
|
|
|
2021-06-08 04:19:35 +02:00
|
|
|
bool BCLog::Logger::StartLogging()
|
2018-04-20 07:02:12 +02:00
|
|
|
{
|
2021-06-09 14:02:42 +02:00
|
|
|
StdLockGuard scoped_lock(m_cs);
|
2018-05-01 04:13:30 +02:00
|
|
|
|
2021-06-08 04:19:35 +02:00
|
|
|
assert(m_buffering);
|
2018-05-01 04:13:30 +02:00
|
|
|
assert(m_fileout == nullptr);
|
|
|
|
|
2021-06-08 04:19:35 +02:00
|
|
|
if (m_print_to_file) {
|
|
|
|
assert(!m_file_path.empty());
|
|
|
|
m_fileout = fsbridge::fopen(m_file_path, "a");
|
|
|
|
if (!m_fileout) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
setbuf(m_fileout, nullptr); // unbuffered
|
|
|
|
|
|
|
|
// Add newlines to the logfile to distinguish this execution from the
|
|
|
|
// last one.
|
|
|
|
FileWriteStr("\n\n\n\n\n", m_fileout);
|
2018-05-01 04:13:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// dump buffered messages from before we opened the log
|
2021-06-08 04:19:35 +02:00
|
|
|
m_buffering = false;
|
2018-05-01 04:13:30 +02:00
|
|
|
while (!m_msgs_before_open.empty()) {
|
2021-06-08 04:19:35 +02:00
|
|
|
const std::string& s = m_msgs_before_open.front();
|
|
|
|
|
|
|
|
if (m_print_to_file) FileWriteStr(s, m_fileout);
|
|
|
|
if (m_print_to_console) fwrite(s.data(), 1, s.size(), stdout);
|
2022-02-26 06:07:36 +01:00
|
|
|
for (const auto& cb : m_print_callbacks) {
|
|
|
|
cb(s);
|
|
|
|
}
|
2021-06-08 04:19:35 +02:00
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
m_msgs_before_open.pop_front();
|
|
|
|
}
|
2021-06-08 04:19:35 +02:00
|
|
|
if (m_print_to_console) fflush(stdout);
|
2018-05-01 04:13:30 +02:00
|
|
|
|
|
|
|
return true;
|
2018-04-20 07:02:12 +02:00
|
|
|
}
|
|
|
|
|
2019-06-25 12:13:08 +02:00
|
|
|
void BCLog::Logger::DisconnectTestLogger()
|
|
|
|
{
|
|
|
|
StdLockGuard scoped_lock(m_cs);
|
|
|
|
m_buffering = true;
|
|
|
|
if (m_fileout != nullptr) fclose(m_fileout);
|
|
|
|
m_fileout = nullptr;
|
2022-02-26 06:07:36 +01:00
|
|
|
m_print_callbacks.clear();
|
2019-06-25 12:13:08 +02:00
|
|
|
}
|
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
|
2018-04-20 07:02:12 +02:00
|
|
|
{
|
2018-05-01 04:13:30 +02:00
|
|
|
m_categories |= flag;
|
2018-04-20 07:02:12 +02:00
|
|
|
}
|
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
bool BCLog::Logger::EnableCategory(const std::string& str)
|
2018-04-20 07:02:12 +02:00
|
|
|
{
|
2018-05-01 04:13:30 +02:00
|
|
|
BCLog::LogFlags flag;
|
2019-11-10 10:50:36 +01:00
|
|
|
if (!GetLogCategory(flag, str)) {
|
|
|
|
if (str == "db") {
|
|
|
|
// DEPRECATION: Added in 0.20, should start returning an error in 0.21
|
|
|
|
LogPrintf("Warning: logging category 'db' is deprecated, use 'walletdb' instead\n");
|
|
|
|
EnableCategory(BCLog::WALLETDB);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2018-05-01 04:13:30 +02:00
|
|
|
EnableCategory(flag);
|
|
|
|
return true;
|
|
|
|
}
|
2018-04-20 07:02:12 +02:00
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
void BCLog::Logger::DisableCategory(BCLog::LogFlags flag)
|
|
|
|
{
|
|
|
|
m_categories &= ~flag;
|
|
|
|
}
|
2018-04-20 07:02:12 +02:00
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
bool BCLog::Logger::DisableCategory(const std::string& str)
|
|
|
|
{
|
|
|
|
BCLog::LogFlags flag;
|
|
|
|
if (!GetLogCategory(flag, str)) return false;
|
|
|
|
DisableCategory(flag);
|
|
|
|
return true;
|
|
|
|
}
|
2018-04-20 07:02:12 +02:00
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
bool BCLog::Logger::WillLogCategory(BCLog::LogFlags category) const
|
|
|
|
{
|
|
|
|
return (m_categories.load(std::memory_order_relaxed) & category) != 0;
|
|
|
|
}
|
2018-04-20 07:02:12 +02:00
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
bool BCLog::Logger::DefaultShrinkDebugFile() const
|
|
|
|
{
|
|
|
|
return m_categories == BCLog::NONE;
|
2018-04-20 07:02:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct CLogCategoryDesc
|
|
|
|
{
|
2018-05-01 04:13:30 +02:00
|
|
|
BCLog::LogFlags flag;
|
2018-04-20 07:02:12 +02:00
|
|
|
std::string category;
|
|
|
|
};
|
|
|
|
|
|
|
|
const CLogCategoryDesc LogCategories[] =
|
|
|
|
{
|
|
|
|
{BCLog::NONE, "0"},
|
|
|
|
{BCLog::NONE, "none"},
|
|
|
|
{BCLog::NET, "net"},
|
|
|
|
{BCLog::TOR, "tor"},
|
|
|
|
{BCLog::MEMPOOL, "mempool"},
|
|
|
|
{BCLog::HTTP, "http"},
|
2020-07-18 21:22:44 +02:00
|
|
|
{BCLog::BENCHMARK, "bench"},
|
2018-04-20 07:02:12 +02:00
|
|
|
{BCLog::ZMQ, "zmq"},
|
2019-11-10 10:50:36 +01:00
|
|
|
{BCLog::WALLETDB, "walletdb"},
|
2018-04-20 07:02:12 +02:00
|
|
|
{BCLog::RPC, "rpc"},
|
|
|
|
{BCLog::ESTIMATEFEE, "estimatefee"},
|
|
|
|
{BCLog::ADDRMAN, "addrman"},
|
|
|
|
{BCLog::SELECTCOINS, "selectcoins"},
|
|
|
|
{BCLog::REINDEX, "reindex"},
|
|
|
|
{BCLog::CMPCTBLOCK, "cmpctblock"},
|
2020-07-18 21:22:44 +02:00
|
|
|
{BCLog::RANDOM, "rand"},
|
2018-04-20 07:02:12 +02:00
|
|
|
{BCLog::PRUNE, "prune"},
|
|
|
|
{BCLog::PROXY, "proxy"},
|
|
|
|
{BCLog::MEMPOOLREJ, "mempoolrej"},
|
|
|
|
{BCLog::LIBEVENT, "libevent"},
|
|
|
|
{BCLog::COINDB, "coindb"},
|
|
|
|
{BCLog::QT, "qt"},
|
|
|
|
{BCLog::LEVELDB, "leveldb"},
|
2020-01-09 20:37:09 +01:00
|
|
|
{BCLog::VALIDATION, "validation"},
|
2018-04-20 07:02:12 +02:00
|
|
|
{BCLog::ALL, "1"},
|
|
|
|
{BCLog::ALL, "all"},
|
|
|
|
|
|
|
|
//Start Dash
|
|
|
|
{BCLog::CHAINLOCKS, "chainlocks"},
|
|
|
|
{BCLog::GOBJECT, "gobject"},
|
|
|
|
{BCLog::INSTANTSEND, "instantsend"},
|
|
|
|
{BCLog::LLMQ, "llmq"},
|
|
|
|
{BCLog::LLMQ_DKG, "llmq-dkg"},
|
|
|
|
{BCLog::LLMQ_SIGS, "llmq-sigs"},
|
|
|
|
{BCLog::MNPAYMENTS, "mnpayments"},
|
|
|
|
{BCLog::MNSYNC, "mnsync"},
|
2021-03-17 23:36:11 +01:00
|
|
|
{BCLog::COINJOIN, "coinjoin"},
|
2018-04-20 07:02:12 +02:00
|
|
|
{BCLog::SPORK, "spork"},
|
|
|
|
{BCLog::NETCONN, "netconn"},
|
2018-05-01 04:13:30 +02:00
|
|
|
{BCLog::DASH, "dash"},
|
2018-04-20 07:02:12 +02:00
|
|
|
//End Dash
|
|
|
|
};
|
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str)
|
2018-04-20 07:02:12 +02:00
|
|
|
{
|
2018-05-01 04:13:30 +02:00
|
|
|
if (str == "") {
|
|
|
|
flag = BCLog::ALL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
for (const CLogCategoryDesc& category_desc : LogCategories) {
|
|
|
|
if (category_desc.category == str) {
|
|
|
|
flag = category_desc.flag;
|
2018-04-20 07:02:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ListLogCategories()
|
|
|
|
{
|
|
|
|
std::string ret;
|
|
|
|
int outcount = 0;
|
2018-05-01 04:13:30 +02:00
|
|
|
for (const CLogCategoryDesc& category_desc : LogCategories) {
|
2018-04-20 07:02:12 +02:00
|
|
|
// Omit the special cases.
|
2018-05-01 04:13:30 +02:00
|
|
|
if (category_desc.flag != BCLog::NONE && category_desc.flag != BCLog::ALL && category_desc.flag != BCLog::DASH) {
|
2018-04-20 07:02:12 +02:00
|
|
|
if (outcount != 0) ret += ", ";
|
2018-05-01 04:13:30 +02:00
|
|
|
ret += category_desc.category;
|
2018-04-20 07:02:12 +02:00
|
|
|
outcount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<CLogCategoryActive> ListActiveLogCategories()
|
|
|
|
{
|
|
|
|
std::vector<CLogCategoryActive> ret;
|
2018-05-01 04:13:30 +02:00
|
|
|
for (const CLogCategoryDesc& category_desc : LogCategories) {
|
2018-04-20 07:02:12 +02:00
|
|
|
// Omit the special cases.
|
2018-05-01 04:13:30 +02:00
|
|
|
if (category_desc.flag != BCLog::NONE && category_desc.flag != BCLog::ALL && category_desc.flag != BCLog::DASH) {
|
2018-04-20 07:02:12 +02:00
|
|
|
CLogCategoryActive catActive;
|
2018-05-01 04:13:30 +02:00
|
|
|
catActive.category = category_desc.category;
|
|
|
|
catActive.active = LogAcceptCategory(category_desc.flag);
|
2018-04-20 07:02:12 +02:00
|
|
|
ret.push_back(catActive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ListActiveLogCategoriesString()
|
|
|
|
{
|
2019-02-04 20:26:02 +01:00
|
|
|
if (LogInstance().GetCategoryMask() == BCLog::NONE)
|
2018-04-20 07:02:12 +02:00
|
|
|
return "0";
|
2019-02-04 20:26:02 +01:00
|
|
|
if (LogInstance().GetCategoryMask() == BCLog::ALL)
|
2018-04-20 07:02:12 +02:00
|
|
|
return "1";
|
|
|
|
|
|
|
|
std::string ret;
|
|
|
|
int outcount = 0;
|
2018-05-01 04:13:30 +02:00
|
|
|
for (const CLogCategoryDesc& category_desc : LogCategories) {
|
2018-04-20 07:02:12 +02:00
|
|
|
// Omit the special cases.
|
2018-05-01 04:13:30 +02:00
|
|
|
if (category_desc.flag != BCLog::NONE && category_desc.flag != BCLog::ALL && category_desc.flag != BCLog::DASH && LogAcceptCategory(category_desc.flag)) {
|
2018-04-20 07:02:12 +02:00
|
|
|
if (outcount != 0) ret += ", ";
|
2018-05-01 04:13:30 +02:00
|
|
|
ret += category_desc.category;
|
2018-04-20 07:02:12 +02:00
|
|
|
outcount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-06-24 19:54:20 +02:00
|
|
|
std::string BCLog::Logger::LogTimestampStr(const std::string& str)
|
2018-04-20 07:02:12 +02:00
|
|
|
{
|
|
|
|
std::string strStamped;
|
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
if (!m_log_timestamps)
|
2018-04-20 07:02:12 +02:00
|
|
|
return str;
|
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
if (m_started_new_line) {
|
2018-04-20 07:02:12 +02:00
|
|
|
int64_t nTimeMicros = GetTimeMicros();
|
2020-12-16 09:55:24 +01:00
|
|
|
strStamped = FormatISO8601DateTime(nTimeMicros/1000000);
|
2018-05-01 04:13:30 +02:00
|
|
|
if (m_log_time_micros) {
|
2020-12-16 09:55:24 +01:00
|
|
|
strStamped.pop_back();
|
|
|
|
strStamped += strprintf(".%06dZ", nTimeMicros%1000000);
|
|
|
|
}
|
2018-04-20 07:02:12 +02:00
|
|
|
int64_t mocktime = GetMockTime();
|
|
|
|
if (mocktime) {
|
2020-12-16 09:55:24 +01:00
|
|
|
strStamped += " (mocktime: " + FormatISO8601DateTime(mocktime) + ")";
|
2018-04-20 07:02:12 +02:00
|
|
|
}
|
|
|
|
strStamped += ' ' + str;
|
|
|
|
} else
|
|
|
|
strStamped = str;
|
|
|
|
|
|
|
|
return strStamped;
|
|
|
|
}
|
|
|
|
|
2019-10-10 13:25:08 +02:00
|
|
|
namespace BCLog {
|
|
|
|
/** Belts and suspenders: make sure outgoing log messages don't contain
|
|
|
|
* potentially suspicious characters, such as terminal control codes.
|
|
|
|
*
|
|
|
|
* This escapes control characters except newline ('\n') in C syntax.
|
|
|
|
* It escapes instead of removes them to still allow for troubleshooting
|
|
|
|
* issues where they accidentally end up in strings.
|
|
|
|
*/
|
|
|
|
std::string LogEscapeMessage(const std::string& str) {
|
|
|
|
std::string ret;
|
|
|
|
for (char ch_in : str) {
|
|
|
|
uint8_t ch = (uint8_t)ch_in;
|
|
|
|
if ((ch >= 32 || ch == '\n') && ch != '\x7f') {
|
|
|
|
ret += ch_in;
|
|
|
|
} else {
|
|
|
|
ret += strprintf("\\x%02x", ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-08 04:19:35 +02:00
|
|
|
void BCLog::Logger::LogPrintStr(const std::string& str)
|
2018-04-20 07:02:12 +02:00
|
|
|
{
|
2021-06-09 14:02:42 +02:00
|
|
|
StdLockGuard scoped_lock(m_cs);
|
2019-10-10 13:25:08 +02:00
|
|
|
std::string str_prefixed = LogEscapeMessage(str);
|
2021-06-24 19:54:20 +02:00
|
|
|
|
|
|
|
if (m_log_threadnames && m_started_new_line) {
|
|
|
|
// 16 chars total, "dash-" is 5 of them and another 1 is a NUL terminator
|
|
|
|
str_prefixed.insert(0, "[" + strprintf("%10s", util::ThreadGetInternalName()) + "] ");
|
|
|
|
}
|
|
|
|
|
|
|
|
str_prefixed = LogTimestampStr(str_prefixed);
|
2018-04-20 07:02:12 +02:00
|
|
|
|
2021-06-24 19:54:20 +02:00
|
|
|
m_started_new_line = !str.empty() && str[str.size()-1] == '\n';
|
2018-04-20 07:02:12 +02:00
|
|
|
|
2021-06-08 04:19:35 +02:00
|
|
|
if (m_buffering) {
|
|
|
|
// buffer if we haven't started logging yet
|
2021-06-24 19:54:20 +02:00
|
|
|
m_msgs_before_open.push_back(str_prefixed);
|
2021-06-08 04:19:35 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
if (m_print_to_console) {
|
2018-04-20 07:02:12 +02:00
|
|
|
// print to console
|
2021-06-24 19:54:20 +02:00
|
|
|
fwrite(str_prefixed.data(), 1, str_prefixed.size(), stdout);
|
2018-04-20 07:02:12 +02:00
|
|
|
fflush(stdout);
|
|
|
|
}
|
2022-02-26 06:07:36 +01:00
|
|
|
for (const auto& cb : m_print_callbacks) {
|
|
|
|
cb(str_prefixed);
|
|
|
|
}
|
2018-05-01 04:13:30 +02:00
|
|
|
if (m_print_to_file) {
|
2021-06-08 04:19:35 +02:00
|
|
|
assert(m_fileout != nullptr);
|
|
|
|
|
|
|
|
// reopen the log file, if requested
|
|
|
|
if (m_reopen_file) {
|
|
|
|
m_reopen_file = false;
|
|
|
|
FILE* new_fileout = fsbridge::fopen(m_file_path, "a");
|
|
|
|
if (new_fileout) {
|
|
|
|
setbuf(new_fileout, nullptr); // unbuffered
|
|
|
|
fclose(m_fileout);
|
|
|
|
m_fileout = new_fileout;
|
2018-04-20 07:02:12 +02:00
|
|
|
}
|
|
|
|
}
|
2021-06-24 19:54:20 +02:00
|
|
|
FileWriteStr(str_prefixed, m_fileout);
|
2018-04-20 07:02:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
void BCLog::Logger::ShrinkDebugFile()
|
2018-04-20 07:02:12 +02:00
|
|
|
{
|
|
|
|
// Amount of debug.log to save at end when shrinking (must fit in memory)
|
|
|
|
constexpr size_t RECENT_DEBUG_HISTORY_SIZE = 10 * 1000000;
|
2018-05-01 04:13:30 +02:00
|
|
|
|
|
|
|
assert(!m_file_path.empty());
|
|
|
|
|
2018-04-20 07:02:12 +02:00
|
|
|
// Scroll debug.log if it's getting too big
|
2018-05-01 04:13:30 +02:00
|
|
|
FILE* file = fsbridge::fopen(m_file_path, "r");
|
2018-04-17 17:07:19 +02:00
|
|
|
|
|
|
|
// Special files (e.g. device nodes) may not have a size.
|
|
|
|
size_t log_size = 0;
|
|
|
|
try {
|
2018-05-01 04:13:30 +02:00
|
|
|
log_size = fs::file_size(m_file_path);
|
2018-08-15 17:07:34 +02:00
|
|
|
} catch (const fs::filesystem_error&) {}
|
2018-04-17 17:07:19 +02:00
|
|
|
|
2018-04-20 07:02:12 +02:00
|
|
|
// If debug.log file is more than 10% bigger the RECENT_DEBUG_HISTORY_SIZE
|
|
|
|
// trim it down by saving only the last RECENT_DEBUG_HISTORY_SIZE bytes
|
2018-04-17 17:07:19 +02:00
|
|
|
if (file && log_size > 11 * (RECENT_DEBUG_HISTORY_SIZE / 10))
|
2018-04-20 07:02:12 +02:00
|
|
|
{
|
|
|
|
// Restart the file with some of the end
|
|
|
|
std::vector<char> vch(RECENT_DEBUG_HISTORY_SIZE, 0);
|
2018-05-07 13:39:13 +02:00
|
|
|
if (fseek(file, -((long)vch.size()), SEEK_END)) {
|
|
|
|
LogPrintf("Failed to shrink debug log file: fseek(...) failed\n");
|
|
|
|
fclose(file);
|
|
|
|
return;
|
|
|
|
}
|
2018-04-20 07:02:12 +02:00
|
|
|
int nBytes = fread(vch.data(), 1, vch.size(), file);
|
|
|
|
fclose(file);
|
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
file = fsbridge::fopen(m_file_path, "w");
|
2018-04-20 07:02:12 +02:00
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
fwrite(vch.data(), 1, nBytes, file);
|
|
|
|
fclose(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (file != nullptr)
|
|
|
|
fclose(file);
|
2020-07-18 21:22:44 +02:00
|
|
|
}
|