From 6261a2544259645381ac634077f6e4ececf4b71d Mon Sep 17 00:00:00 2001 From: vogel76 Date: Thu, 9 Jan 2014 13:29:08 +0100 Subject: [PATCH] [BW]: [NIP] Support for unicode paths to avoid problems while accessing paths containing native characters. --- include/fc/filesystem.hpp | 19 ++++++++++++------- src/filesystem.cpp | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/fc/filesystem.hpp b/include/fc/filesystem.hpp index 1bc565f..13a0e19 100644 --- a/include/fc/filesystem.hpp +++ b/include/fc/filesystem.hpp @@ -30,6 +30,8 @@ namespace fc { ~path(); path( const boost::filesystem::path& ); path( const fc::string& p ); + /// Constructor to build path using unicode native characters. + path(const std::wstring& p); path( const char* ); path( const path& p ); path( path&& p ); @@ -45,13 +47,16 @@ namespace fc { operator boost::filesystem::path& (); operator const boost::filesystem::path& ()const; - void replace_extension( const fc::path& e ); - fc::path stem()const; - fc::path extension()const; - fc::path filename()const; - fc::path parent_path()const; - fc::string string()const; - fc::string generic_string()const; + void replace_extension( const fc::path& e ); + fc::path stem()const; + fc::path extension()const; + fc::path filename()const; + fc::path parent_path()const; + fc::string string()const; + fc::string generic_string()const; + + std::wstring wstring() const; + std::wstring generic_wstring() const; /** * @brief replaces '/' with '\' in the result of generic_string() diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 66f70c1..c971f88 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -29,6 +29,9 @@ namespace fc { path::path( const fc::string& p ) :_p(p.c_str()){} + path::path(const std::wstring& p) + :_p(p) {} + path::path( const path& p ) :_p(p){} @@ -67,6 +70,17 @@ namespace fc { fc::string path::generic_string()const { return _p->generic_string(); } + + std::wstring path::wstring() const + { + return _p->wstring(); + } + + std::wstring path::generic_wstring() const + { + return _p->generic_wstring(); + } + /** * @todo use iterators instead of indexes for * faster performance