int main() { using namespace fs; // Default ctor { static_assert(std::is_nothrow_default_constructible<file_status>::value, "The default constructor must be noexcept"); static_assert(test_convertible<file_status>(), "The default constructor must not be explicit"); const file_status f; assert(f.type() == file_type::none); assert(f.permissions() == perms::unknown); } // Unary ctor { static_assert(std::is_nothrow_constructible<file_status, file_type>::value, "This constructor must be noexcept"); static_assert(!test_convertible<file_status, file_type>(), "This constructor must be explicit"); const file_status f(file_type::not_found); assert(f.type() == file_type::not_found); assert(f.permissions() == perms::unknown); } // Binary ctor { static_assert(std::is_nothrow_constructible<file_status, file_type, perms>::value, "This constructor must be noexcept"); static_assert(!test_convertible<file_status, file_type, perms>(), "This constructor must b explicit"); const file_status f(file_type::regular, perms::owner_read); assert(f.type() == file_type::regular); assert(f.permissions() == perms::owner_read); } }
inline bool status_known( file_status f ) { return f.type() != status_unknown; }
inline bool is_regular_file(file_status s) noexcept { return s.type() == file_type::regular; }
inline bool exists(file_status s) noexcept { return status_known(s) && s.type() != file_type::not_found; }
inline bool status_known(file_status f) { return f.type() != status_error; }
inline bool is_symlink(file_status f) { return f.type() == symlink_file; }
inline bool exists(file_status f) { return f.type() != status_error && f.type() != file_not_found; }
inline bool permissions_present(file_status f) {return f.permissions() != perms_not_known;}
inline bool status_known(file_status s) noexcept { return s.type() != file_type::none; }
inline bool is_symlink(file_status s) noexcept { return s.type() == file_type::symlink; }
inline bool is_socket(file_status s) noexcept { return s.type() == file_type::socket; }
inline bool is_fifo(file_status s) noexcept { return s.type() == file_type::fifo; }
inline bool is_character_file(file_status s) noexcept { return s.type() == file_type::character; }
inline bool is_block_file(file_status s) noexcept { return s.type() == file_type::block; }
inline bool exists( file_status f ) { return f.type() != status_unknown && f.type() != file_not_found; }
inline bool type_present(file_status f) { return f.type() != status_error; }
bool operator==(const file_status& rhs) const { return type() == rhs.type() && permissions() == rhs.permissions(); }
inline size_t get_size(const file_status &p_status) { return p_status.get_len(); }
inline bool is_directory(const file_status &p_status) { return p_status.is_dir(); }
inline bool is_directory(file_status f) { return f.type() == directory_file; }
inline bool is_regular(const file_status &p_status) { return p_status.is_dir() == false; }
inline bool is_regular(file_status f) { return f.type() == regular_file; }
inline bool is_directory(file_status s) noexcept { return s.type() == file_type::directory ;}
Status::Status(const file_status &Status) : UID(Status.getUniqueID()), MTime(Status.getLastModificationTime()), User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()), Type(Status.type()), Perms(Status.permissions()) {}
bool exists(file_status status) noexcept { return status.type() != file_type::not_found; }