For all path_traits convert() and dispatch() functions provide two overloads, one with a "const codecvt_type&" argument, and one without. The overload without a codecvt argument calls path::codecvt() iff a conversion actually needs to be performed. Change all uses of path_traits convert() and dispatch() functions call the appropriate overload, rather than calling with path::codecvt() as a default. This limits the impact of locale("") initialization failures on Linux and other non-BSD POSIX systems to programs that actually depend on locale(""). It further ensures that exceptions thrown as a result of such failures occur after main() has started, and so can be caught.

This commit is contained in:
Beman
2014-10-27 19:20:17 -04:00
parent 6cafaf5e34
commit 490c2c3298
5 changed files with 309 additions and 77 deletions

View File

@@ -185,8 +185,15 @@ namespace filesystem
# ifdef BOOST_WINDOWS_API
const std::string path::generic_string() const
{
path tmp(*this);
std::replace(tmp.m_pathname.begin(), tmp.m_pathname.end(), L'\\', L'/');
return tmp.string();
}
const std::string path::generic_string(const codecvt_type& cvt) const
{
{
path tmp(*this);
std::replace(tmp.m_pathname.begin(), tmp.m_pathname.end(), L'\\', L'/');
return tmp.string(cvt);