diff --git a/README.md b/README.md index 59fade2..58a131e 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ It is from after the standardization of C++17 but it contains the latest filesys interface changes compared to the [Working Draft N4659](https://github.com/cplusplus/draft/raw/master/papers/n4659.pdf). Staring with v1.4.0, when compiled using C++20, it adapts to the changes according to path sorting order -and `std::u8string` handling from [Working Draft N4680](https://isocpp.org/files/papers/N4860.pdf). +and `std::u8string` handling from [Working Draft N4860](https://isocpp.org/files/papers/N4860.pdf). I want to thank the people working on improving C++, I really liked how the language evolved with C++11 and the following standards. Keep on the good work! @@ -554,6 +554,8 @@ to the expected behavior. ### v1.4.2 (WIP) +* Enhancement for [#89](https://github.com/gulrak/filesystem/issues/89), `fs::file_status` + now supports `operator==` introduced in `std::filesystem` with C++20. * Refactoring for [#88](https://github.com/gulrak/filesystem/issues/88), `fs::path::parent_path()` had a performance issue, as it was still using a loop based approach to recreate the parent from elements. This created lots of temporaries and was too slow diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 9bf36f4..ec707ed 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -696,7 +696,7 @@ class GHC_FS_API_CLASS file_status // 30.10.11.2 observers file_type type() const noexcept; perms permissions() const noexcept; - + friend bool operator==(const file_status& lhs, const file_status& rhs) noexcept { return lhs.type() == rhs.type() && lhs.permissions() == rhs.permissions(); } private: file_type _type; perms _perms; diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index eb9e879..23e6c01 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -1219,6 +1219,15 @@ TEST_CASE("30.10.11 class file_status", "[filesystem][file_status][fs.class.file CHECK(fs.type() == fs::file_type::regular); CHECK(fs.permissions() == fs::perms::unknown); } + { + fs::file_status fs1{fs::file_type::regular, fs::perms::owner_read | fs::perms::owner_write | fs::perms::owner_exec}; + fs::file_status fs2{fs::file_type::regular, fs::perms::owner_read | fs::perms::owner_write | fs::perms::owner_exec}; + fs::file_status fs3{fs::file_type::directory, fs::perms::owner_read | fs::perms::owner_write | fs::perms::owner_exec}; + fs::file_status fs4{fs::file_type::regular, fs::perms::owner_read | fs::perms::owner_write}; + CHECK(fs1 == fs2); + CHECK_FALSE(fs1 == fs3); + CHECK_FALSE(fs1 == fs4); + } } TEST_CASE("30.10.12 class directory_entry", "[filesystem][directory_entry][fs.dir.entry]")