From f98478c33b75eedd9a349be3b3e1cfb3631478eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A9=D0=B0=D0=BF=D0=BE=D0=B2?= Date: Sun, 21 Feb 2021 21:57:27 +0500 Subject: [PATCH] Enabled wchar_t path Source on UNIX --- include/ghc/filesystem.hpp | 7 ------- test/filesystem_test.cpp | 16 ++++++++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 472c608..783e467 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -402,19 +402,12 @@ class GHC_FS_API_CLASS path template using path_type = typename std::enable_if::value, path>::type; -#ifdef GHC_USE_WCHAR_T template using path_from_string = typename std::enable_if<_is_basic_string::value || std::is_same::type>::value || std::is_same::type>::value || std::is_same::type>::value || std::is_same::type>::value, path>::type; template - using path_type_EcharT = typename std::enable_if::value || std::is_same::value || std::is_same::value, path>::type; -#else - template - using path_from_string = typename std::enable_if<_is_basic_string::value || std::is_same::type>::value || std::is_same::type>::value, path>::type; - template using path_type_EcharT = typename std::enable_if::value || std::is_same::value || std::is_same::value || std::is_same::value, path>::type; -#endif // 30.10.8.4.1 constructors and destructor path() noexcept; path(const path& p); diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index 2ad464a..cf889d9 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -441,6 +441,10 @@ TEST_CASE("30.10.8.4.2 path assignments", "[filesystem][path][fs.path.assign]") REQUIRE(p1 == p3); p3 = fs::path{"/usr/local"}; REQUIRE(p2 == p3); + p3 = fs::path{L"/usr/local"}; + REQUIRE(p2 == p3); + p3.assign(L"/usr/local"); + REQUIRE(p2 == p3); #if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T) p3 = fs::path::string_type{L"/foo/bar"}; REQUIRE(p1 == p3); @@ -499,9 +503,13 @@ TEST_CASE("30.10.8.4.4 path concatenation", "[filesystem][path][fs.path.concat]" CHECK((fs::path("foo") += "bar") == "foobar"); CHECK((fs::path("foo") += "/bar") == "foo/bar"); + CHECK((fs::path("foo") += L"bar") == "foobar"); + CHECK((fs::path("foo") += L"/bar") == "foo/bar"); CHECK((fs::path("foo") += 'b') == "foob"); CHECK((fs::path("foo") += '/') == "foo/"); + CHECK((fs::path("foo") += L'b') == "foob"); + CHECK((fs::path("foo") += L'/') == "foo/"); CHECK((fs::path("foo") += std::string("bar")) == "foobar"); CHECK((fs::path("foo") += std::string("/bar")) == "foo/bar"); @@ -514,6 +522,8 @@ TEST_CASE("30.10.8.4.4 path concatenation", "[filesystem][path][fs.path.concat]" CHECK(fs::path("foo").concat("bar") == "foobar"); CHECK(fs::path("foo").concat("/bar") == "foo/bar"); + CHECK(fs::path("foo").concat(L"bar") == "foobar"); + CHECK(fs::path("foo").concat(L"/bar") == "foo/bar"); std::string bar = "bar"; CHECK(fs::path("foo").concat(bar.begin(), bar.end()) == "foobar"); #ifndef USE_STD_FS @@ -2745,14 +2755,10 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]") #if defined(GHC_HAS_STD_STRING_VIEW) using namespace std::literals; using string_view = std::string_view; -#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T) using wstring_view = std::wstring_view; -#endif #elif defined(GHC_HAS_STD_EXPERIMENTAL_STRING_VIEW) using string_view = std::experimental::string_view; -#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T) using wstring_view = std::experimental::wstring_view; -#endif #endif { @@ -2769,7 +2775,6 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]") p /= string_view("Appendix"); CHECK(p == "XYZ/Appendix"); } -#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T) { std::wstring p(L"foo/bar"); wstring_view sv(p); @@ -2779,7 +2784,6 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]") CHECK(p2 == "foo"); CHECK(p2.compare(wstring_view(L"foo")) == 0); } -#endif #else WARN("std::string_view specific tests are empty without std::string_view.");