diff --git a/src/fs.h b/src/fs.h --- a/src/fs.h +++ b/src/fs.h @@ -17,7 +17,6 @@ /** Bridge operations to C stdio */ namespace fsbridge { FILE *fopen(const fs::path &p, const char *mode); -FILE *freopen(const fs::path &p, const char *mode, FILE *stream); }; // namespace fsbridge #endif // BITCOIN_FS_H diff --git a/src/fs.cpp b/src/fs.cpp --- a/src/fs.cpp +++ b/src/fs.cpp @@ -11,8 +11,5 @@ return ::fopen(p.string().c_str(), mode); } -FILE *freopen(const fs::path &p, const char *mode, FILE *stream) { - return ::freopen(p.string().c_str(), mode, stream); -} } // namespace fsbridge diff --git a/src/logging.cpp b/src/logging.cpp --- a/src/logging.cpp +++ b/src/logging.cpp @@ -182,14 +182,14 @@ if (m_reopen_file) { m_reopen_file = false; fs::path pathDebug = GetDebugLogPath(); - m_fileout = fsbridge::freopen(pathDebug, "a", m_fileout); - if (!m_fileout) { - return; + FILE *new_fileout = fsbridge::fopen(pathDebug, "a"); + if (new_fileout) { + // unbuffered. + setbuf(m_fileout, nullptr); + fclose(m_fileout); + m_fileout = new_fileout; } - // unbuffered. - setbuf(m_fileout, nullptr); } - FileWriteStr(strTimestamped, m_fileout); } }