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:
1 parent
a33bd767a3
commit
b0113afd44
13 files changed
+37
-27
No files matched your search
+3
-3
@@ -447,7 +447,7 @@ bool openBitcoinConf()
|
||||
fs::path pathConfig = gArgs.GetConfigFilePath();
|
||||
|
||||
/* Create the file */
|
||||
std::ofstream configFile{pathConfig, std::ios_base::app};
|
||||
std::ofstream configFile{pathConfig.std_path(), std::ios_base::app};
|
||||
|
||||
if (!configFile.good())
|
||||
return false;
|
||||
@@ -607,7 +607,7 @@ fs::path static GetAutostartFilePath()
|
||||
|
||||
bool GetStartOnSystemStartup()
|
||||
{
|
||||
std::ifstream optionFile{GetAutostartFilePath()};
|
||||
std::ifstream optionFile{GetAutostartFilePath().std_path()};
|
||||
if (!optionFile.good())
|
||||
return false;
|
||||
// Scan through file for "Hidden=true":
|
||||
@@ -639,7 +639,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||
|
||||
fs::create_directories(GetAutostartDir());
|
||||
|
||||
std::ofstream optionFile{GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc};
|
||||
std::ofstream optionFile{GetAutostartFilePath().std_path(), std::ios_base::out | std::ios_base::trunc};
|
||||
if (!optionFile.good())
|
||||
return false;
|
||||
ChainType chain = gArgs.GetChainType();
|
||||
|
||||
@@ -70,7 +70,7 @@ void OptionTests::migrateSettings()
|
||||
QVERIFY(!settings.contains("fUseSeparateProxyTor"));
|
||||
QVERIFY(!settings.contains("addrSeparateProxyTor"));
|
||||
|
||||
std::ifstream file(gArgs.GetDataDirNet() / "settings.json");
|
||||
std::ifstream file((gArgs.GetDataDirNet() / "settings.json").std_path());
|
||||
std::string default_warning = strprintf("This file is automatically generated and updated by %s. Please do not edit this file while the node "
|
||||
"is running, as any changes might be ignored or overwritten.",
|
||||
CLIENT_NAME);
|
||||
|
||||
Reference in new issue
Block a user