mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
util: Remove fsbridge::get_filesystem_error_message()
The `fsbridge::get_filesystem_error_message()` function exhibits several drawbacks: 1. It was introduced in https://github.com/bitcoin/bitcoin/pull/14192 to account for platform-specific variations in `boost::filesystem::filesystem_error::what()`. Since migrating to `std::filesystem`, those discrepancies no longer exist. 2. It fails to display UTF-8 paths correctly on Windows. 3. It relies on `std::wstring_convert`, which was deprecated in C++17 and removed in C++26. This change removes the `fsbridge::get_filesystem_error_message()` function, thereby resolving all of the above issues. Additionally, filesystem error messages now use the "Warning" log level.
This commit is contained in:
@@ -115,20 +115,4 @@ bool FileLock::TryLock()
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string get_filesystem_error_message(const fs::filesystem_error& e)
|
||||
{
|
||||
#ifndef WIN32
|
||||
return e.what();
|
||||
#else
|
||||
// Convert from Multi Byte to utf-16
|
||||
std::string mb_string(e.what());
|
||||
int size = MultiByteToWideChar(CP_ACP, 0, mb_string.data(), mb_string.size(), nullptr, 0);
|
||||
|
||||
std::wstring utf16_string(size, L'\0');
|
||||
MultiByteToWideChar(CP_ACP, 0, mb_string.data(), mb_string.size(), &*utf16_string.begin(), size);
|
||||
// Convert from utf-16 to utf-8
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t>().to_bytes(utf16_string);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace fsbridge
|
||||
|
||||
Reference in New Issue
Block a user