From 41d7166c8a598b604aad6c6b1d88ad46e23be247 Mon Sep 17 00:00:00 2001 From: Kiminuo Date: Thu, 11 Jun 2020 08:58:46 +0200 Subject: refactor: replace boost::filesystem with std::filesystem Warning: Replacing fs::system_complete calls with fs::absolute calls in this commit may cause minor changes in behaviour because fs::absolute no longer strips trailing slashes; however these changes are believed to be safe. Co-authored-by: Russell Yanofsky Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> --- src/addrdb.cpp | 1 + src/bench/bench.cpp | 3 +- src/fs.cpp | 116 +---------------------------- src/fs.h | 134 ++++++++++------------------------ src/init.cpp | 9 ++- src/logging.cpp | 1 + src/logging.h | 1 + src/net.cpp | 1 + src/qt/guiutil.cpp | 11 ++- src/qt/psbtoperationsdialog.cpp | 5 +- src/qt/sendcoinsdialog.cpp | 5 +- src/qt/walletframe.cpp | 5 +- src/rpc/request.cpp | 9 ++- src/test/fs_tests.cpp | 18 +++-- src/test/fuzz/fuzz.cpp | 6 +- src/test/fuzz/utxo_snapshot.cpp | 1 + src/test/script_tests.cpp | 5 +- src/test/settings_tests.cpp | 8 +- src/test/streams_tests.cpp | 1 + src/test/util_tests.cpp | 4 + src/util/asmap.cpp | 1 + src/util/settings.cpp | 10 ++- src/util/syscall_sandbox.cpp | 1 + src/util/system.cpp | 35 ++++----- src/wallet/bdb.cpp | 5 +- src/wallet/db.cpp | 22 +++--- src/wallet/dump.cpp | 12 ++- src/wallet/dump.h | 3 + src/wallet/load.cpp | 6 +- src/wallet/rpc/backup.cpp | 9 ++- src/wallet/test/db_tests.cpp | 7 +- src/wallet/test/init_test_fixture.cpp | 9 ++- src/wallet/test/init_tests.cpp | 3 + src/wallet/wallet.cpp | 8 +- src/wallet/walletdb.cpp | 2 +- 35 files changed, 193 insertions(+), 284 deletions(-) (limited to 'src') diff --git a/src/addrdb.cpp b/src/addrdb.cpp index 94518b88d8..4f22e688db 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index 9bd176f0a0..5c24b712a7 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,7 @@ void GenerateTemplateResults(const std::vector& bench // nothing to write, bail out return; } - fsbridge::ofstream fout{fs::PathFromString(filename)}; + std::ofstream fout{fs::PathFromString(filename)}; if (fout.is_open()) { ankerl::nanobench::render(tpl, benchmarkResults, fout); } else { diff --git a/src/fs.cpp b/src/fs.cpp index 8fcadcb3ef..219fdee959 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -37,7 +37,7 @@ FILE *fopen(const fs::path& p, const char *mode) fs::path AbsPathJoin(const fs::path& base, const fs::path& path) { assert(base.is_absolute()); - return fs::absolute(path, base); + return path.empty() ? base : fs::path(base / path); } #ifndef WIN32 @@ -153,118 +153,4 @@ std::string get_filesystem_error_message(const fs::filesystem_error& e) #endif } -#ifdef WIN32 -#ifdef __GLIBCXX__ - -// reference: https://github.com/gcc-mirror/gcc/blob/gcc-7_3_0-release/libstdc%2B%2B-v3/include/std/fstream#L270 -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wswitch" -#endif -static std::string openmodeToStr(std::ios_base::openmode mode) -{ - switch (mode & ~std::ios_base::ate) { - case std::ios_base::out: - case std::ios_base::out | std::ios_base::trunc: - return "w"; - case std::ios_base::out | std::ios_base::app: - case std::ios_base::app: - return "a"; - case std::ios_base::in: - return "r"; - case std::ios_base::in | std::ios_base::out: - return "r+"; - case std::ios_base::in | std::ios_base::out | std::ios_base::trunc: - return "w+"; - case std::ios_base::in | std::ios_base::out | std::ios_base::app: - case std::ios_base::in | std::ios_base::app: - return "a+"; - case std::ios_base::out | std::ios_base::binary: - case std::ios_base::out | std::ios_base::trunc | std::ios_base::binary: - return "wb"; - case std::ios_base::out | std::ios_base::app | std::ios_base::binary: - case std::ios_base::app | std::ios_base::binary: - return "ab"; - case std::ios_base::in | std::ios_base::binary: - return "rb"; - case std::ios_base::in | std::ios_base::out | std::ios_base::binary: - return "r+b"; - case std::ios_base::in | std::ios_base::out | std::ios_base::trunc | std::ios_base::binary: - return "w+b"; - case std::ios_base::in | std::ios_base::out | std::ios_base::app | std::ios_base::binary: - case std::ios_base::in | std::ios_base::app | std::ios_base::binary: - return "a+b"; - default: - return std::string(); - } -} -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC diagnostic pop -#endif - -void ifstream::open(const fs::path& p, std::ios_base::openmode mode) -{ - close(); - mode |= std::ios_base::in; - m_file = fsbridge::fopen(p, openmodeToStr(mode).c_str()); - if (m_file == nullptr) { - return; - } - m_filebuf = __gnu_cxx::stdio_filebuf(m_file, mode); - rdbuf(&m_filebuf); - if (mode & std::ios_base::ate) { - seekg(0, std::ios_base::end); - } -} - -void ifstream::close() -{ - if (m_file != nullptr) { - m_filebuf.close(); - fclose(m_file); - } - m_file = nullptr; -} - -void ofstream::open(const fs::path& p, std::ios_base::openmode mode) -{ - close(); - mode |= std::ios_base::out; - m_file = fsbridge::fopen(p, openmodeToStr(mode).c_str()); - if (m_file == nullptr) { - return; - } - m_filebuf = __gnu_cxx::stdio_filebuf(m_file, mode); - rdbuf(&m_filebuf); - if (mode & std::ios_base::ate) { - seekp(0, std::ios_base::end); - } -} - -void ofstream::close() -{ - if (m_file != nullptr) { - m_filebuf.close(); - fclose(m_file); - } - m_file = nullptr; -} -#else // __GLIBCXX__ - -#if BOOST_VERSION >= 107700 -static_assert(sizeof(*BOOST_FILESYSTEM_C_STR(boost::filesystem::path())) == sizeof(wchar_t), -#else -static_assert(sizeof(*boost::filesystem::path().BOOST_FILESYSTEM_C_STR) == sizeof(wchar_t), -#endif // BOOST_VERSION >= 107700 - "Warning: This build is using boost::filesystem ofstream and ifstream " - "implementations which will fail to open paths containing multibyte " - "characters. You should delete this static_assert to ignore this warning, " - "or switch to a different C++ standard library like the Microsoft C++ " - "Standard Library (where boost uses non-standard extensions to construct " - "stream objects with wide filenames), or the GNU libstdc++ library (where " - "a more complicated workaround has been implemented above)."); - -#endif // __GLIBCXX__ -#endif // WIN32 - } // fsbridge diff --git a/src/fs.h b/src/fs.h index bc36636084..d2299db168 100644 --- a/src/fs.h +++ b/src/fs.h @@ -5,46 +5,42 @@ #ifndef BITCOIN_FS_H #define BITCOIN_FS_H -#include -#include -#if defined WIN32 && defined __GLIBCXX__ -#include -#endif - -#include -#include #include +#include +#include +#include +#include +#include +#include +#include + /** Filesystem operations and types */ namespace fs { -using namespace boost::filesystem; +using namespace std::filesystem; /** - * Path class wrapper to prepare application code for transition from - * boost::filesystem library to std::filesystem implementation. The main - * purpose of the class is to define fs::path::u8string() and fs::u8path() - * functions not present in boost. It also blocks calls to the - * fs::path(std::string) implicit constructor and the fs::path::string() - * method, which worked well in the boost::filesystem implementation, but have - * unsafe and unpredictable behavior on Windows in the std::filesystem - * implementation (see implementation note in \ref PathToString for details). + * Path class wrapper to block calls to the fs::path(std::string) implicit + * constructor and the fs::path::string() method, which have unsafe and + * unpredictable behavior on Windows (see implementation note in + * \ref PathToString for details) */ -class path : public boost::filesystem::path +class path : public std::filesystem::path { public: - using boost::filesystem::path::path; + using std::filesystem::path::path; // Allow path objects arguments for compatibility. - path(boost::filesystem::path path) : boost::filesystem::path::path(std::move(path)) {} - path& operator=(boost::filesystem::path path) { boost::filesystem::path::operator=(std::move(path)); return *this; } - path& operator/=(boost::filesystem::path path) { boost::filesystem::path::operator/=(std::move(path)); return *this; } + path(std::filesystem::path path) : std::filesystem::path::path(std::move(path)) {} + path& operator=(std::filesystem::path path) { std::filesystem::path::operator=(std::move(path)); return *this; } + path& operator/=(std::filesystem::path path) { std::filesystem::path::operator/=(std::move(path)); return *this; } // Allow literal string arguments, which are safe as long as the literals are ASCII. - path(const char* c) : boost::filesystem::path(c) {} - path& operator=(const char* c) { boost::filesystem::path::operator=(c); return *this; } - path& operator/=(const char* c) { boost::filesystem::path::operator/=(c); return *this; } - path& append(const char* c) { boost::filesystem::path::append(c); return *this; } + path(const char* c) : std::filesystem::path(c) {} + path& operator=(const char* c) { std::filesystem::path::operator=(c); return *this; } + path& operator/=(const char* c) { std::filesystem::path::operator/=(c); return *this; } + path& append(const char* c) { std::filesystem::path::append(c); return *this; } // Disallow std::string arguments to avoid locale-dependent decoding on windows. path(std::string) = delete; @@ -55,52 +51,48 @@ public: // Disallow std::string conversion method to avoid locale-dependent encoding on windows. std::string string() const = delete; - // Define UTF-8 string conversion method not present in boost::filesystem but present in std::filesystem. - std::string u8string() const { return boost::filesystem::path::string(); } + // Required for path overloads in . + // See https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=96e0367ead5d8dcac3bec2865582e76e2fbab190 + path& make_preferred() { std::filesystem::path::make_preferred(); return *this; } + path filename() const { return std::filesystem::path::filename(); } }; -// Define UTF-8 string conversion function not present in boost::filesystem but present in std::filesystem. -static inline path u8path(const std::string& string) -{ - return boost::filesystem::path(string); -} - -// Disallow implicit std::string conversion for system_complete to avoid +// Disallow implicit std::string conversion for absolute to avoid // locale-dependent encoding on windows. -static inline path system_complete(const path& p) +static inline path absolute(const path& p) { - return boost::filesystem::system_complete(p); + return std::filesystem::absolute(p); } // Disallow implicit std::string conversion for exists to avoid // locale-dependent encoding on windows. static inline bool exists(const path& p) { - return boost::filesystem::exists(p); + return std::filesystem::exists(p); } // Allow explicit quoted stream I/O. static inline auto quoted(const std::string& s) { - return boost::io::quoted(s, '&'); + return std::quoted(s, '"', '&'); } // Allow safe path append operations. static inline path operator+(path p1, path p2) { - p1 += static_cast(p2); + p1 += std::move(p2); return p1; } // Disallow implicit std::string conversion for copy_file // to avoid locale-dependent encoding on Windows. -static inline void copy_file(const path& from, const path& to, copy_option options) +static inline bool copy_file(const path& from, const path& to, copy_options options) { - boost::filesystem::copy_file(from, to, options); + return std::filesystem::copy_file(from, to, options); } /** - * Convert path object to byte string. On POSIX, paths natively are byte + * Convert path object to a byte string. On POSIX, paths natively are byte * strings, so this is trivial. On Windows, paths natively are Unicode, so an * encoding step is necessary. The inverse of \ref PathToString is \ref * PathFromString. The strings returned and parsed by these functions can be @@ -112,7 +104,7 @@ static inline void copy_file(const path& from, const path& to, copy_option optio * appropriate to use in applications requiring UTF-8, where * fs::path::u8string() and fs::u8path() methods should be used instead. Other * applications could require still different encodings. For example, JSON, XML, - * or URI applications might prefer to use higher level escapes (\uXXXX or + * or URI applications might prefer to use higher-level escapes (\uXXXX or * &XXXX; or %XX) instead of multibyte encoding. Rust, Python, Java applications * may require encoding paths with their respective UTF-8 derivatives WTF-8, * PEP-383, and CESU-8 (see https://en.wikipedia.org/wiki/UTF-8#Derivatives). @@ -133,7 +125,7 @@ static inline std::string PathToString(const path& path) return path.u8string(); #else static_assert(std::is_same::value, "PathToString not implemented on this platform"); - return path.boost::filesystem::path::string(); + return path.std::filesystem::path::string(); #endif } @@ -145,7 +137,7 @@ static inline path PathFromString(const std::string& string) #ifdef WIN32 return u8path(string); #else - return boost::filesystem::path(string); + return std::filesystem::path(string); #endif } } // namespace fs @@ -186,60 +178,12 @@ namespace fsbridge { }; std::string get_filesystem_error_message(const fs::filesystem_error& e); - - // GNU libstdc++ specific workaround for opening UTF-8 paths on Windows. - // - // On Windows, it is only possible to reliably access multibyte file paths through - // `wchar_t` APIs, not `char` APIs. But because the C++ standard doesn't - // require ifstream/ofstream `wchar_t` constructors, and the GNU library doesn't - // provide them (in contrast to the Microsoft C++ library, see - // https://stackoverflow.com/questions/821873/how-to-open-an-stdfstream-ofstream-or-ifstream-with-a-unicode-filename/822032#822032), - // Boost is forced to fall back to `char` constructors which may not work properly. - // - // Work around this issue by creating stream objects with `_wfopen` in - // combination with `__gnu_cxx::stdio_filebuf`. This workaround can be removed - // with an upgrade to C++17, where streams can be constructed directly from - // `std::filesystem::path` objects. - -#if defined WIN32 && defined __GLIBCXX__ - class ifstream : public std::istream - { - public: - ifstream() = default; - explicit ifstream(const fs::path& p, std::ios_base::openmode mode = std::ios_base::in) { open(p, mode); } - ~ifstream() { close(); } - void open(const fs::path& p, std::ios_base::openmode mode = std::ios_base::in); - bool is_open() { return m_filebuf.is_open(); } - void close(); - - private: - __gnu_cxx::stdio_filebuf m_filebuf; - FILE* m_file = nullptr; - }; - class ofstream : public std::ostream - { - public: - ofstream() = default; - explicit ofstream(const fs::path& p, std::ios_base::openmode mode = std::ios_base::out) { open(p, mode); } - ~ofstream() { close(); } - void open(const fs::path& p, std::ios_base::openmode mode = std::ios_base::out); - bool is_open() { return m_filebuf.is_open(); } - void close(); - - private: - __gnu_cxx::stdio_filebuf m_filebuf; - FILE* m_file = nullptr; - }; -#else // !(WIN32 && __GLIBCXX__) - typedef fs::ifstream ifstream; - typedef fs::ofstream ofstream; -#endif // WIN32 && __GLIBCXX__ }; // Disallow path operator<< formatting in tinyformat to avoid locale-dependent // encoding on windows. namespace tinyformat { -template<> inline void formatValue(std::ostream&, const char*, const char*, int, const boost::filesystem::path&) = delete; +template<> inline void formatValue(std::ostream&, const char*, const char*, int, const std::filesystem::path&) = delete; template<> inline void formatValue(std::ostream&, const char*, const char*, int, const fs::path&) = delete; } // namespace tinyformat diff --git a/src/init.cpp b/src/init.cpp index 015e17596c..84564cf2aa 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -72,10 +72,13 @@ #include #include +#include +#include +#include +#include #include #include -#include -#include +#include #include #include @@ -137,7 +140,7 @@ static fs::path GetPidFile(const ArgsManager& args) [[nodiscard]] static bool CreatePidFile(const ArgsManager& args) { - fsbridge::ofstream file{GetPidFile(args)}; + std::ofstream file{GetPidFile(args)}; if (file) { #ifdef WIN32 tfm::format(file, "%d\n", GetCurrentProcessId()); diff --git a/src/logging.cpp b/src/logging.cpp index 6edcebf87e..764941c8ea 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -3,6 +3,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include #include #include #include diff --git a/src/logging.h b/src/logging.h index 31f0bdc690..710e6c4c32 100644 --- a/src/logging.h +++ b/src/logging.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include diff --git a/src/net.cpp b/src/net.cpp index be56d1e2d2..68569560ce 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index c6c8f7b7a6..dc73bcd911 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -66,6 +67,10 @@ #include #include +#include +#include +#include +#include #if defined(Q_OS_MAC) @@ -426,7 +431,7 @@ bool openBitcoinConf() fs::path pathConfig = GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)); /* Create the file */ - fsbridge::ofstream configFile(pathConfig, std::ios_base::app); + std::ofstream configFile{pathConfig, std::ios_base::app}; if (!configFile.good()) return false; @@ -586,7 +591,7 @@ fs::path static GetAutostartFilePath() bool GetStartOnSystemStartup() { - fsbridge::ifstream optionFile(GetAutostartFilePath()); + std::ifstream optionFile{GetAutostartFilePath()}; if (!optionFile.good()) return false; // Scan through file for "Hidden=true": @@ -617,7 +622,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) fs::create_directories(GetAutostartDir()); - fsbridge::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc); + std::ofstream optionFile{GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc}; if (!optionFile.good()) return false; std::string chain = gArgs.GetChainName(); diff --git a/src/qt/psbtoperationsdialog.cpp b/src/qt/psbtoperationsdialog.cpp index d328290cbc..6880c157c0 100644 --- a/src/qt/psbtoperationsdialog.cpp +++ b/src/qt/psbtoperationsdialog.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -15,7 +16,9 @@ #include #include +#include #include +#include using node::AnalyzePSBT; using node::DEFAULT_MAX_RAW_TX_FEE_RATE; @@ -158,7 +161,7 @@ void PSBTOperationsDialog::saveTransaction() { if (filename.isEmpty()) { return; } - fsbridge::ofstream out{filename.toLocal8Bit().data(), fsbridge::ofstream::out | fsbridge::ofstream::binary}; + std::ofstream out{filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary}; out << ssTx.str(); out.close(); showStatus(tr("PSBT saved to disk."), StatusLevel::INFO); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 1206f610cd..e37168830e 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -29,7 +29,10 @@ #include #include +#include #include +#include +#include #include #include @@ -509,7 +512,7 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked) if (filename.isEmpty()) { return; } - fsbridge::ofstream out{filename.toLocal8Bit().data(), fsbridge::ofstream::out | fsbridge::ofstream::binary}; + std::ofstream out{filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary}; out << ssTx.str(); out.close(); Q_EMIT message(tr("PSBT saved"), "PSBT saved to disk", CClientUIInterface::MSG_INFORMATION); diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index fba83dd510..08190f0b9f 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -14,6 +15,8 @@ #include #include +#include +#include #include #include @@ -210,7 +213,7 @@ void WalletFrame::gotoLoadPSBT(bool from_clipboard) Q_EMIT message(tr("Error"), tr("PSBT file must be smaller than 100 MiB"), CClientUIInterface::MSG_ERROR); return; } - fsbridge::ifstream in{filename.toLocal8Bit().data(), std::ios::binary}; + std::ifstream in{filename.toLocal8Bit().data(), std::ios::binary}; data = std::string(std::istreambuf_iterator{in}, {}); } diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp index fbb4e5ddd0..95a7c25b93 100644 --- a/src/rpc/request.cpp +++ b/src/rpc/request.cpp @@ -12,6 +12,11 @@ #include #include +#include +#include +#include +#include + /** * JSON-RPC protocol. Bitcoin speaks version 1.0 for maximum compatibility, * but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were @@ -83,7 +88,7 @@ bool GenerateAuthCookie(std::string *cookie_out) /** the umask determines what permissions are used to create this file - * these are set to 077 in init.cpp unless overridden with -sysperms. */ - fsbridge::ofstream file; + std::ofstream file; fs::path filepath_tmp = GetAuthCookieFile(true); file.open(filepath_tmp); if (!file.is_open()) { @@ -107,7 +112,7 @@ bool GenerateAuthCookie(std::string *cookie_out) bool GetAuthCookie(std::string *cookie_out) { - fsbridge::ifstream file; + std::ifstream file; std::string cookie; fs::path filepath = GetAuthCookieFile(); file.open(filepath); diff --git a/src/test/fs_tests.cpp b/src/test/fs_tests.cpp index d3389c30eb..1256395849 100644 --- a/src/test/fs_tests.cpp +++ b/src/test/fs_tests.cpp @@ -9,6 +9,10 @@ #include +#include +#include +#include + BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(fsbridge_pathtostring) @@ -45,37 +49,37 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream) fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃"; fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃"; { - fsbridge::ofstream file(tmpfile1); + std::ofstream file{tmpfile1}; file << "bitcoin"; } { - fsbridge::ifstream file(tmpfile2); + std::ifstream file{tmpfile2}; std::string input_buffer; file >> input_buffer; BOOST_CHECK_EQUAL(input_buffer, "bitcoin"); } { - fsbridge::ifstream file(tmpfile1, std::ios_base::in | std::ios_base::ate); + std::ifstream file{tmpfile1, std::ios_base::in | std::ios_base::ate}; std::string input_buffer; file >> input_buffer; BOOST_CHECK_EQUAL(input_buffer, ""); } { - fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::app); + std::ofstream file{tmpfile2, std::ios_base::out | std::ios_base::app}; file << "tests"; } { - fsbridge::ifstream file(tmpfile1); + std::ifstream file{tmpfile1}; std::string input_buffer; file >> input_buffer; BOOST_CHECK_EQUAL(input_buffer, "bitcointests"); } { - fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::trunc); + std::ofstream file{tmpfile2, std::ios_base::out | std::ios_base::trunc}; file << "bitcoin"; } { - fsbridge::ifstream file(tmpfile1); + std::ifstream file{tmpfile1}; std::string input_buffer; file >> input_buffer; BOOST_CHECK_EQUAL(input_buffer, "bitcoin"); diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp index 60c48e7c22..a490bbfa1d 100644 --- a/src/test/fuzz/fuzz.cpp +++ b/src/test/fuzz/fuzz.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -12,9 +13,12 @@ #include #include +#include #include +#include #include #include +#include #include #include @@ -80,7 +84,7 @@ void initialize() } if (const char* out_path = std::getenv("WRITE_ALL_FUZZ_TARGETS_AND_ABORT")) { std::cout << "Writing all fuzz target names to '" << out_path << "'." << std::endl; - fsbridge::ofstream out_stream{out_path, std::ios::binary}; + std::ofstream out_stream{out_path, std::ios::binary}; for (const auto& t : FuzzTargets()) { if (std::get<2>(t.second)) continue; out_stream << t.first << std::endl; diff --git a/src/test/fuzz/utxo_snapshot.cpp b/src/test/fuzz/utxo_snapshot.cpp index 19ca1f0c99..e513f1883c 100644 --- a/src/test/fuzz/utxo_snapshot.cpp +++ b/src/test/fuzz/utxo_snapshot.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 4906bd2386..c453f22594 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -24,7 +24,8 @@ #include