diff options
-rw-r--r-- | src/utils/file.cpp | 7 | ||||
-rw-r--r-- | src/utils/file.hpp | 7 |
2 files changed, 11 insertions, 3 deletions
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 <iostream> -#include <fstream> +#include <boost/filesystem.hpp> +#include <boost/filesystem/fstream.hpp> 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); |