diff --git a/README.md b/README.md index 5865f98..5ada1c2 100644 --- a/README.md +++ b/README.md @@ -526,7 +526,7 @@ C++11/14. Starting with v1.1.0 these are supported when compiling `ghc::filesystem` under C++17 of C++20. Starting with v1.5.2 `ghc::filesystem` will try to allow the use of -`std::experimental::basic_string_view` where it detects is availability. +`std::experimental::basic_string_view` where it detects its availability. Additionally if you have a `basic_string_view` compatible c++11 implementation it can be used instead of `std::basic_string_view` by defining `GHC_HAS_CUSTOM_STRING_VIEW` and importing the @@ -633,7 +633,7 @@ the standard. As symbolic links on Windows, while being supported more or less since Windows Vista (with some strict security constraints) and fully since some earlier build of Windows 10, when "Developer Mode" is activated, are at time of writing -(2018) rarely used, still they are supported wiit th this implementation. +(2018) rarely used, still they are supported with this implementation. #### Permissions @@ -671,6 +671,8 @@ to the expected behavior. metadata now preserves subsecond modification times. * Fix for [#209](https://github.com/gulrak/filesystem/issues/209), malformed UTF-16 no longer drops subsequent valid code units. +* Fix for [#210](https://github.com/gulrak/filesystem/issues/210), + `equivalent()` now compares only filesystem identity. * Fix for [#178](https://github.com/gulrak/filesystem/issues/178), recursive iteration no longer resolves symlinks unless requested. * Fix for [#185](https://github.com/gulrak/filesystem/issues/185), diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 3015304..7eea0ce 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -4392,8 +4392,7 @@ GHC_INLINE bool equivalent(const path& p1, const path& p2, std::error_code& ec) ec = detail::make_system_error(); return false; } - return inf1.ftLastWriteTime.dwLowDateTime == inf2.ftLastWriteTime.dwLowDateTime && inf1.ftLastWriteTime.dwHighDateTime == inf2.ftLastWriteTime.dwHighDateTime && inf1.nFileIndexHigh == inf2.nFileIndexHigh && inf1.nFileIndexLow == inf2.nFileIndexLow && - inf1.nFileSizeHigh == inf2.nFileSizeHigh && inf1.nFileSizeLow == inf2.nFileSizeLow && inf1.dwVolumeSerialNumber == inf2.dwVolumeSerialNumber; + return inf1.nFileIndexHigh == inf2.nFileIndexHigh && inf1.nFileIndexLow == inf2.nFileIndexLow && inf1.dwVolumeSerialNumber == inf2.dwVolumeSerialNumber; #else struct ::stat s1, s2; auto rc1 = ::stat(p1.c_str(), &s1); @@ -4409,7 +4408,7 @@ GHC_INLINE bool equivalent(const path& p1, const path& p2, std::error_code& ec) #endif return false; } - return s1.st_dev == s2.st_dev && s1.st_ino == s2.st_ino && s1.st_size == s2.st_size && s1.st_mtime == s2.st_mtime; + return s1.st_dev == s2.st_dev && s1.st_ino == s2.st_ino; #endif } diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index 127f52e..649f1d7 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -2102,6 +2102,17 @@ TEST_CASE("fs.op.equivalent - equivalent", "[filesystem][operations][fs.op.equiv CHECK(fs::equivalent("foo", "foo2", ec)); CHECK(!ec); } + fs::create_hard_link("foo", "foo-hard-link"); + CHECK(fs::equivalent("foo", "foo-hard-link")); + generateFile("foo-hard-link", 4321); + CHECK(fs::file_size("foo") == 4321); + CHECK(fs::equivalent("foo", "foo-hard-link")); + std::error_code mutationEc(42, std::system_category()); + CHECK(fs::equivalent("foo", "foo-hard-link", mutationEc)); + CHECK(!mutationEc); + if (is_symlink_creation_supported()) { + CHECK(fs::equivalent("foo", "foo2")); + } #ifdef TEST_LWG_2937_BEHAVIOUR INFO("This test expects LWG #2937 result conformance."); std::error_code ec;