Assume we have code like this:
boost::iostreams::mapped_file_source dev(paFileName.u8string().c_str());
where paFileName
is a std::filesystem::path
object.
On Windows, the internal character in std::filesystem::path
is wchar_t
, but boost::iostreams::mapped_file_source
seems to only accept variant width character string. Therefore, we convert the fixed width wchar_t
string to a variant width char
string with method u8string
.
The problem is that the conversion apparently causes the ctor of boost::iostreams::mapped_file_source
unable to find the file in the filesystem, and the ctor will throw a boost::wrapexcept<std::ios_base::failure[abi:cxx11]>
that says "failed opening file: The system cannot find the file specified."
How to fix this problem? Any suggestions? Thanks.