mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 18:22:57 +02:00
Fix windows libc++ fs::path fstream compile errors
As reported by hebasto in https://github.com/bitcoin/bitcoin/issues/33545, newer libc++ versions implementing https://wg21.link/lwg3430 will no longer implicitly convert `fs::path` objects to `std::filesystem::path` objects when constructing `std::ifstream` and `std::ofstream` types. This is not a problem in Unix systems since `fs::path` objects use `std::string` as their native string type, but it causes compile errors on Windows which use `std::wstring` as their string type, since `fstream`s can't be constructed from `wstring`s. Fix the windows libc++ compile errors by adding a new `fs::path::std_path()` method and using it construct `fstream`s more portably. Additionally, delete `fs::path`'s implicit `native_string` conversion so these errors will not go undetected in the future, even though there is not currently a CI job testing Windows libc++ builds.
This commit is contained in:
@@ -135,7 +135,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||
error = strprintf("Config file \"%s\" is a directory.", fs::PathToString(conf_path));
|
||||
return false;
|
||||
}
|
||||
stream = std::ifstream{conf_path};
|
||||
stream = std::ifstream{conf_path.std_path()};
|
||||
// If the file is explicitly specified, it must be readable
|
||||
if (IsArgSet("-conf") && !stream.good()) {
|
||||
error = strprintf("specified config file \"%s\" could not be opened.", fs::PathToString(conf_path));
|
||||
@@ -187,7 +187,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
||||
error = strprintf("Included config file \"%s\" is a directory.", fs::PathToString(include_conf_path));
|
||||
return false;
|
||||
}
|
||||
std::ifstream conf_file_stream{include_conf_path};
|
||||
std::ifstream conf_file_stream{include_conf_path.std_path()};
|
||||
if (conf_file_stream.good()) {
|
||||
if (!ReadConfigStream(conf_file_stream, conf_file_name, error, ignore_invalid_keys)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user