refs #70, fix for non LWG2936 mode and updated readme

This commit is contained in:
Steffen Schümann 2020-10-06 21:17:15 +02:00
parent 56b5e7a174
commit 3cd5bc6873
3 changed files with 27 additions and 21 deletions

View File

@ -489,9 +489,18 @@ to the expected behavior.
### v1.3.5 (WIP)
* Refactoring for [#73](https://github.com/gulrak/filesystem/issues/68), enhanced performance
* Refactoring for [#73](https://github.com/gulrak/filesystem/issues/73), enhanced performance
in path handling. the changes lead to much fewer path/string creations or copies, speeding
up large directory iteration or operations on many path instances.
* Bugfix for [#72](https://github.com/gulrak/filesystem/issues/72), the `TestAllocator` in
`filesystem_test.cpp` was completed to fulfill the requirements to build on CentOS 7 with
`devtoolset-9`. CentOS 7 and CentOS 8 are now part of the CI builds.
* Bugfix for [#70](https://github.com/gulrak/filesystem/issues/70), root names are now case
insensitive on Windows. This fix also adds the new behaviour switch `LWG_2936_BEHAVIOUR`
that allows to enable post C++17 `fs::path::compare` behaviour, where the comparison is as
if it was an element wise path comparison as described in
[LWG 2936](https://cplusplus.github.io/LWG/issue2936) and C++20 `[fs.path.compare]`.
It is default off in v1.3.6 and will be default starting from v1.4.0 as it changes ordering.
### [v1.3.4](https://github.com/gulrak/filesystem/releases/tag/v1.3.4)

View File

@ -2719,6 +2719,9 @@ GHC_INLINE int path::compare(const path& p) const noexcept
auto rnl1 = root_name_length();
auto rnl2 = p.root_name_length();
auto rnc = detail::compare_simple_insensitive(_path.c_str(), rnl1, p._path.c_str(), rnl2);
if (rnc) {
return rnc;
}
auto p1 = _path;
std::replace(p1.begin()+rnl1, p1.end(), '/', '\\');
auto p2 = p._path;
@ -3191,11 +3194,7 @@ GHC_INLINE size_t hash_value(const path& p) noexcept
GHC_INLINE bool operator==(const path& lhs, const path& rhs) noexcept
{
#ifdef LWG_2936_BEHAVIOUR
return lhs.compare(rhs) == 0;
#else
return lhs.generic_string() == rhs.generic_string();
#endif
}
GHC_INLINE bool operator!=(const path& lhs, const path& rhs) noexcept
@ -3205,38 +3204,22 @@ GHC_INLINE bool operator!=(const path& lhs, const path& rhs) noexcept
GHC_INLINE bool operator<(const path& lhs, const path& rhs) noexcept
{
#ifdef LWG_2936_BEHAVIOUR
return lhs.compare(rhs) < 0;
#else
return lhs.generic_string() < rhs.generic_string();
#endif
}
GHC_INLINE bool operator<=(const path& lhs, const path& rhs) noexcept
{
#ifdef LWG_2936_BEHAVIOUR
return lhs.compare(rhs) <= 0;
#else
return lhs.generic_string() <= rhs.generic_string();
#endif
}
GHC_INLINE bool operator>(const path& lhs, const path& rhs) noexcept
{
#ifdef LWG_2936_BEHAVIOUR
return lhs.compare(rhs) > 0;
#else
return lhs.generic_string() > rhs.generic_string();
#endif
}
GHC_INLINE bool operator>=(const path& lhs, const path& rhs) noexcept
{
#ifdef LWG_2936_BEHAVIOUR
return lhs.compare(rhs) >= 0;
#else
return lhs.generic_string() >= rhs.generic_string();
#endif
}
GHC_INLINE path operator/(const path& lhs, const path& rhs)

View File

@ -907,6 +907,8 @@ TEST_CASE("30.10.8.4.11 path generation", "[filesystem][path][fs.path.gen]")
CHECK(fs::path("c:/foo").lexically_relative("/bar") == "");
CHECK(fs::path("c:foo").lexically_relative("c:/bar") == "");
CHECK(fs::path("foo").lexically_relative("/bar") == "");
CHECK(fs::path("c:/foo/bar.txt").lexically_relative("c:/foo/") == "bar.txt");
CHECK(fs::path("c:/foo/bar.txt").lexically_relative("C:/foo/") == "bar.txt");
#else
CHECK(fs::path("/foo").lexically_relative("bar") == "");
CHECK(fs::path("foo").lexically_relative("/bar") == "");
@ -972,7 +974,13 @@ TEST_CASE("30.10.8.5 path iterators", "[filesystem][path][fs.path.itr]")
CHECK("/,foo," == iterateResult(fs::path("/foo/")));
CHECK("foo,bar" == iterateResult(fs::path("foo/bar")));
CHECK("/,foo,bar" == iterateResult(fs::path("/foo/bar")));
#ifndef USE_STD_FS
// ghc::filesystem enforces redundant slashes to be reduced to one
CHECK("/,foo,bar" == iterateResult(fs::path("///foo/bar")));
#else
// typically std::filesystem keeps them
CHECK("///,foo,bar" == iterateResult(fs::path("///foo/bar")));
#endif
CHECK("/,foo,bar," == iterateResult(fs::path("/foo/bar///")));
CHECK("foo,.,bar,..," == iterateResult(fs::path("foo/.///bar/../")));
#ifdef GHC_OS_WINDOWS
@ -989,7 +997,13 @@ TEST_CASE("30.10.8.5 path iterators", "[filesystem][path][fs.path.itr]")
CHECK(",foo,/" == reverseIterateResult(fs::path("/foo/")));
CHECK("bar,foo" == reverseIterateResult(fs::path("foo/bar")));
CHECK("bar,foo,/" == reverseIterateResult(fs::path("/foo/bar")));
#ifndef USE_STD_FS
// ghc::filesystem enforces redundant slashes to be reduced to one
CHECK("bar,foo,/" == reverseIterateResult(fs::path("///foo/bar")));
#else
// typically std::filesystem keeps them
CHECK("bar,foo,///" == reverseIterateResult(fs::path("///foo/bar")));
#endif
CHECK(",bar,foo,/" == reverseIterateResult(fs::path("/foo/bar///")));
CHECK(",..,bar,.,foo" == reverseIterateResult(fs::path("foo/.///bar/../")));
#ifdef GHC_OS_WINDOWS