From 4e71abc1c94647e600e6db322636707bdb9f5817 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 29 Jan 2010 23:54:05 +0100 Subject: changed to boost::filesystem::wifstream to support wpath wifstream from boost could be created with a boost::filesystem::wpath to support Unicode paths --- src/utils/file.cpp | 7 +++++++ src/utils/file.hpp | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/utils/file.cpp b/src/utils/file.cpp index a7fc87e8..f97fc2e4 100644 --- a/src/utils/file.cpp +++ b/src/utils/file.cpp @@ -39,6 +39,13 @@ namespace usdx file.imbue(loc); } + File::File(const boost::filesystem::wpath& path) : file(path, std::wifstream::in) + { + std::locale global_loc = std::locale(); + std::locale loc(global_loc, new boost::program_options::detail::utf8_codecvt_facet()); + file.imbue(loc); + } + File::~File(void) { file.close(); diff --git a/src/utils/file.hpp b/src/utils/file.hpp index d08d7eb5..87aba35c 100644 --- a/src/utils/file.hpp +++ b/src/utils/file.hpp @@ -27,17 +27,18 @@ #ifndef FILE_HPP #define FILE_HPP -#include -#include +#include +#include namespace usdx { class File { private: - std::wifstream file; + boost::filesystem::wifstream file; public: File(const std::string& filename); + File(const boost::filesystem::wpath& path); virtual ~File(void); std::wistream &stream(void); -- cgit v1.2.3