Merge bitcoin/bitcoin#33550: Fix windows libc++ fs::path fstream compile errors

c864a4c194 Simplify fs::path by dropping filename() and make_preferred() overloads (Ryan Ofsky)
b0113afd44 Fix windows libc++ fs::path fstream compile errors (Ryan Ofsky)

Pull request description:

  Drop support for passing `fs::path` directly to `std::ifstream` and `std::ofstream` constructors and `open()` functions, because as reported by hebasto in https://github.com/bitcoin/bitcoin/issues/33545, after https://wg21.link/lwg3430 there is no way this can continue to work in windows builds, and there are already compile errors compiling for windows with newer versions of libc++.

  Instead, add an `fs::path::std_path()` method that returns `std::filesystem::path` references and use it where needed.

ACKs for top commit:
  hebasto:
    ACK c864a4c194.
  l0rinc:
    Code review ACK c864a4c194
  maflcko:
    re-ACK c864a4c194 🌥

Tree-SHA512: d22372692ab86244e2b2caf4c5e9c9acbd9ba38df5411606b75e428474eabead152fc7ca1afe0bb0df6b818351211a70487e94b40a17b68db5aa757604a0ddf6
This commit is contained in:
Hennadii Stepanov committed 2025-10-22 10:10:27 +02:00
commit 3fee0754a2
17 files changed
+45 -40

No files matched your search

+2 -2
View File
@@ -102,7 +102,7 @@ bool IsBDBFile(const fs::path& path)
if (ec) LogWarning("Error reading file_size: %s [%s]", ec.message(), fs::PathToString(path));
if (size < 4096) return false;
std::ifstream file{path, std::ios::binary};
std::ifstream file{path.std_path(), std::ios::binary};
if (!file.is_open()) return false;
file.seekg(12, std::ios::beg); // Magic bytes start at offset 12
@@ -126,7 +126,7 @@ bool IsSQLiteFile(const fs::path& path)
if (ec) LogWarning("Error reading file_size: %s [%s]", ec.message(), fs::PathToString(path));
if (size < 512) return false;
std::ifstream file{path, std::ios::binary};
std::ifstream file{path.std_path(), std::ios::binary};
if (!file.is_open()) return false;
// Magic is at beginning and is 16 bytes long
+2 -2
View File
@@ -37,7 +37,7 @@ bool DumpWallet(const ArgsManager& args, WalletDatabase& db, bilingual_str& erro
return false;
}
std::ofstream dump_file;
dump_file.open(path);
dump_file.open(path.std_path());
if (dump_file.fail()) {
error = strprintf(_("Unable to open %s for writing"), fs::PathToString(path));
return false;
@@ -134,7 +134,7 @@ bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::
error = strprintf(_("Dump file %s does not exist."), fs::PathToString(dump_path));
return false;
}
std::ifstream dump_file{dump_path};
std::ifstream dump_file{dump_path.std_path()};
// Compute the checksum
HashWriter hasher{};
+1 -1
View File
@@ -36,7 +36,7 @@ InitWalletDirTestingSetup::InitWalletDirTestingSetup(const ChainType chainType)
fs::create_directories(m_walletdir_path_cases["default"]);
fs::create_directories(m_walletdir_path_cases["custom"]);
fs::create_directories(m_walletdir_path_cases["relative"]);
std::ofstream f{m_walletdir_path_cases["file"]};
std::ofstream f{m_walletdir_path_cases["file"].std_path()};
f.close();
}