Skip to content

Commit

Permalink
fixes #63, Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit fdcb3ce
Author: Steffen Schuemann <[email protected]>
Date:   Thu Apr 9 12:59:13 2020 +0200

    refs #63, fix typo

commit a5cadd2
Author: Steffen Schuemann <[email protected]>
Date:   Thu Apr 9 11:45:36 2020 +0200

    refs #63, work on issues with wchar and clang in windows.
  • Loading branch information
gulrak committed Apr 10, 2020
1 parent 9a047b9 commit 3f1c185
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
14 changes: 11 additions & 3 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,14 @@ inline path::path(const std::string_view& source, format fmt)
_path = detail::toUtf8(std::string(source));
postprocess_path_with_format(_path, fmt);
}
#ifdef GHC_USE_WCHAR_T
template <>
inline path::path(const std::wstring_view& source, format fmt)
{
_path = detail::toUtf8(std::wstring(source).c_str());
postprocess_path_with_format(_path, fmt);
}
#endif
#endif

template <class Source, typename>
Expand Down Expand Up @@ -4506,9 +4514,9 @@ GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept
{
ec.clear();
#ifdef GHC_OS_WINDOWS
ULARGE_INTEGER freeBytesAvailableToCaller = {0, 0};
ULARGE_INTEGER totalNumberOfBytes = {0, 0};
ULARGE_INTEGER totalNumberOfFreeBytes = {0, 0};
ULARGE_INTEGER freeBytesAvailableToCaller = {{0, 0}};
ULARGE_INTEGER totalNumberOfBytes = {{0, 0}};
ULARGE_INTEGER totalNumberOfFreeBytes = {{0, 0}};
if (!GetDiskFreeSpaceExW(detail::fromUtf8<std::wstring>(p.u8string()).c_str(), &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes)) {
ec = detail::make_system_error();
return {static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1)};
Expand Down
29 changes: 22 additions & 7 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2628,13 +2628,28 @@ TEST_CASE("30.10.15.39 weakly_canonical", "[filesystem][operations][fs.op.weakly
TEST_CASE("std::string_view support", "[filesystem][fs.string_view]")
{
#if __cpp_lib_string_view
std::string p("foo/bar");
std::string_view sv(p);
CHECK(fs::path(sv, fs::path::format::generic_format).generic_string() == "foo/bar");
fs::path p2("fo");
p2 += std::string_view("o");
CHECK(p2 == "foo");
CHECK(p2.compare(std::string_view("foo")) == 0);
{
std::string p("foo/bar");
std::string_view sv(p);
CHECK(fs::path(sv, fs::path::format::generic_format).generic_string() == "foo/bar");
fs::path p2("fo");
p2 += std::string_view("o");
CHECK(p2 == "foo");
CHECK(p2.compare(std::string_view("foo")) == 0);
}

#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
{
std::wstring p(L"foo/bar");
std::wstring_view sv(p);
CHECK(fs::path(sv, fs::path::format::generic_format).generic_string() == "foo/bar");
fs::path p2(L"fo");
p2 += std::wstring_view(L"o");
CHECK(p2 == "foo");
CHECK(p2.compare(std::wstring_view(L"foo")) == 0);
}
#endif

#else
WARN("std::string_view specific tests are empty without std::string_view.");
#endif
Expand Down

0 comments on commit 3f1c185

Please sign in to comment.