Skip to content

Commit

Permalink
refs #89, added operator==() to fs::file_status
Browse files Browse the repository at this point in the history
  • Loading branch information
gulrak committed Jan 21, 2021
1 parent de57485 commit 973abff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
Expand Down

0 comments on commit 973abff

Please sign in to comment.