Skip to content

Commit bc69aa3

Browse files
authored
Merge pull request #103 from phprus/unix-wchar_t
Enabled wchar_t path Source on UNIX
2 parents 0e5f2f5 + f98478c commit bc69aa3

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

include/ghc/filesystem.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,19 +402,12 @@ class GHC_FS_API_CLASS path
402402

403403
template <typename T1, typename T2 = void>
404404
using path_type = typename std::enable_if<!std::is_same<path, T1>::value, path>::type;
405-
#ifdef GHC_USE_WCHAR_T
406405
template <typename T>
407406
using path_from_string = typename std::enable_if<_is_basic_string<T>::value || std::is_same<char const*, typename std::decay<T>::type>::value || std::is_same<char*, typename std::decay<T>::type>::value ||
408407
std::is_same<wchar_t const*, typename std::decay<T>::type>::value || std::is_same<wchar_t*, typename std::decay<T>::type>::value,
409408
path>::type;
410409
template <typename T>
411-
using path_type_EcharT = typename std::enable_if<std::is_same<T, char>::value || std::is_same<T, char16_t>::value || std::is_same<T, char32_t>::value, path>::type;
412-
#else
413-
template <typename T>
414-
using path_from_string = typename std::enable_if<_is_basic_string<T>::value || std::is_same<char const*, typename std::decay<T>::type>::value || std::is_same<char*, typename std::decay<T>::type>::value, path>::type;
415-
template <typename T>
416410
using path_type_EcharT = typename std::enable_if<std::is_same<T, char>::value || std::is_same<T, char16_t>::value || std::is_same<T, char32_t>::value || std::is_same<T, wchar_t>::value, path>::type;
417-
#endif
418411
// 30.10.8.4.1 constructors and destructor
419412
path() noexcept;
420413
path(const path& p);

test/filesystem_test.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ TEST_CASE("30.10.8.4.2 path assignments", "[filesystem][path][fs.path.assign]")
441441
REQUIRE(p1 == p3);
442442
p3 = fs::path{"/usr/local"};
443443
REQUIRE(p2 == p3);
444+
p3 = fs::path{L"/usr/local"};
445+
REQUIRE(p2 == p3);
446+
p3.assign(L"/usr/local");
447+
REQUIRE(p2 == p3);
444448
#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
445449
p3 = fs::path::string_type{L"/foo/bar"};
446450
REQUIRE(p1 == p3);
@@ -499,9 +503,13 @@ TEST_CASE("30.10.8.4.4 path concatenation", "[filesystem][path][fs.path.concat]"
499503

500504
CHECK((fs::path("foo") += "bar") == "foobar");
501505
CHECK((fs::path("foo") += "/bar") == "foo/bar");
506+
CHECK((fs::path("foo") += L"bar") == "foobar");
507+
CHECK((fs::path("foo") += L"/bar") == "foo/bar");
502508

503509
CHECK((fs::path("foo") += 'b') == "foob");
504510
CHECK((fs::path("foo") += '/') == "foo/");
511+
CHECK((fs::path("foo") += L'b') == "foob");
512+
CHECK((fs::path("foo") += L'/') == "foo/");
505513

506514
CHECK((fs::path("foo") += std::string("bar")) == "foobar");
507515
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]"
514522

515523
CHECK(fs::path("foo").concat("bar") == "foobar");
516524
CHECK(fs::path("foo").concat("/bar") == "foo/bar");
525+
CHECK(fs::path("foo").concat(L"bar") == "foobar");
526+
CHECK(fs::path("foo").concat(L"/bar") == "foo/bar");
517527
std::string bar = "bar";
518528
CHECK(fs::path("foo").concat(bar.begin(), bar.end()) == "foobar");
519529
#ifndef USE_STD_FS
@@ -2745,14 +2755,10 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]")
27452755
#if defined(GHC_HAS_STD_STRING_VIEW)
27462756
using namespace std::literals;
27472757
using string_view = std::string_view;
2748-
#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
27492758
using wstring_view = std::wstring_view;
2750-
#endif
27512759
#elif defined(GHC_HAS_STD_EXPERIMENTAL_STRING_VIEW)
27522760
using string_view = std::experimental::string_view;
2753-
#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
27542761
using wstring_view = std::experimental::wstring_view;
2755-
#endif
27562762
#endif
27572763

27582764
{
@@ -2769,7 +2775,6 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]")
27692775
p /= string_view("Appendix");
27702776
CHECK(p == "XYZ/Appendix");
27712777
}
2772-
#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
27732778
{
27742779
std::wstring p(L"foo/bar");
27752780
wstring_view sv(p);
@@ -2779,7 +2784,6 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]")
27792784
CHECK(p2 == "foo");
27802785
CHECK(p2.compare(wstring_view(L"foo")) == 0);
27812786
}
2782-
#endif
27832787

27842788
#else
27852789
WARN("std::string_view specific tests are empty without std::string_view.");

0 commit comments

Comments
 (0)