refs #89, added operator==() to fs::file_status

This commit is contained in:
Steffen Schuemann 2021-01-21 19:01:42 +01:00
parent de57485877
commit 973abff4b9
3 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -696,7 +696,7 @@ public:
// 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;

View File

@ -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]")