
Johan Ström wrote:
Hello list!
Im working on an app wich is to run on windows, linux and OSX. I just switched from using filesystem::path to wpath, to be able to use i18n'ed paths on Windows. However this gave me a bunch of problems on Linux.
I was missing the obvious; you forgot to imbue a locale. Your test program works fine once that is done. See below. Because I didn't know your preferred encoding, I used the UTF-8 codecvt facet Boost.Filesystem uses for testing. Maybe it would be better if Boost.Filesystem defaulted to some likely encoding, such as UTF-8. --Beman
A simple test case:
test.cpp #include <iostream> #include <boost/filesystem/path.hpp> #include <boost/filesystem/convenience.hpp>
#include "libs/filesystem/src/utf8_codecvt_facet.hpp"
namespace fs = boost::filesystem; int main() {
std::locale global_loc = std::locale(); fs::detail::utf8_codecvt_facet utf8_facet; std::locale loc( global_loc, &utf8_facet ); fs::wpath_traits::imbue( loc );
fs::wpath mypath(L"/tmp/some/Directories"); for(int i = 0; i < 10; i++) { try { std::wcout << "Creating " << mypath << " nr " << i; fs::create_directories(mypath); }catch(std::exception&e) { std::cout << e.what() <<std::endl; } } }