Merge branch 'feature-89-file_status-equal-op'

This commit is contained in:
Steffen Schuemann 2021-02-07 11:53:19 +01:00
commit 8353715199
3 changed files with 23 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

@ -127,6 +127,14 @@ struct StringMaker<fs::perms>
static std::string convert(fs::perms const& value) { return std::to_string(static_cast<unsigned int>(value)); }
};
template <>
struct StringMaker<fs::file_status>
{
static std::string convert(fs::file_status const& value) {
return std::string("[") + std::to_string(static_cast<unsigned int>(value.type())) + "," + std::to_string(static_cast<unsigned int>(value.permissions())) + "]";
}
};
#ifdef __cpp_lib_char8_t
template <>
struct StringMaker<char8_t>
@ -1219,6 +1227,17 @@ 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);
}
#if !defined(USE_STD_FS) || defined(GHC_FILESYSTEM_RUNNING_CPP20)
{
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);
}
#endif
}
TEST_CASE("30.10.12 class directory_entry", "[filesystem][directory_entry][fs.dir.entry]")