mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
refactor: Block unsafe fs::path std::string conversion calls
There is no change in behavior. This just helps prepare for the transition from boost::filesystem to std::filesystem by avoiding calls to methods which will be unsafe after the transaction to std::filesystem to due lack of a boost::filesystem::path::imbue equivalent and inability to set a predictable locale. Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Co-authored-by: Kiminuo <kiminuo@protonmail.com> Co-authored-by: MarcoFalke <falke.marco@gmail.com>
This commit is contained in:
@@ -24,7 +24,7 @@ namespace fsbridge {
|
||||
FILE *fopen(const fs::path& p, const char *mode)
|
||||
{
|
||||
#ifndef WIN32
|
||||
return ::fopen(p.string().c_str(), mode);
|
||||
return ::fopen(p.c_str(), mode);
|
||||
#else
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t> utf8_cvt;
|
||||
return ::_wfopen(p.wstring().c_str(), utf8_cvt.from_bytes(mode).c_str());
|
||||
@@ -46,7 +46,7 @@ static std::string GetErrorReason()
|
||||
|
||||
FileLock::FileLock(const fs::path& file)
|
||||
{
|
||||
fd = open(file.string().c_str(), O_RDWR);
|
||||
fd = open(file.c_str(), O_RDWR);
|
||||
if (fd == -1) {
|
||||
reason = GetErrorReason();
|
||||
}
|
||||
@@ -249,9 +249,9 @@ void ofstream::close()
|
||||
#else // __GLIBCXX__
|
||||
|
||||
#if BOOST_VERSION >= 107700
|
||||
static_assert(sizeof(*BOOST_FILESYSTEM_C_STR(fs::path())) == sizeof(wchar_t),
|
||||
static_assert(sizeof(*BOOST_FILESYSTEM_C_STR(boost::filesystem::path())) == sizeof(wchar_t),
|
||||
#else
|
||||
static_assert(sizeof(*fs::path().BOOST_FILESYSTEM_C_STR) == sizeof(wchar_t),
|
||||
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 "
|
||||
|
||||
Reference in New Issue
Block a user