file_status.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP___FILESYSTEM_FILE_STATUS_H
  10. #define _LIBCPP___FILESYSTEM_FILE_STATUS_H
  11. #include <__availability>
  12. #include <__config>
  13. #include <__filesystem/file_type.h>
  14. #include <__filesystem/perms.h>
  15. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  16. # pragma GCC system_header
  17. #endif
  18. #ifndef _LIBCPP_CXX03_LANG
  19. _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
  20. class _LIBCPP_EXPORTED_FROM_ABI file_status {
  21. public:
  22. // constructors
  23. _LIBCPP_INLINE_VISIBILITY
  24. file_status() noexcept : file_status(file_type::none) {}
  25. _LIBCPP_INLINE_VISIBILITY
  26. explicit file_status(file_type __ft, perms __prms = perms::unknown) noexcept
  27. : __ft_(__ft),
  28. __prms_(__prms) {}
  29. _LIBCPP_HIDE_FROM_ABI file_status(const file_status&) noexcept = default;
  30. _LIBCPP_HIDE_FROM_ABI file_status(file_status&&) noexcept = default;
  31. _LIBCPP_INLINE_VISIBILITY
  32. ~file_status() {}
  33. _LIBCPP_HIDE_FROM_ABI file_status& operator=(const file_status&) noexcept = default;
  34. _LIBCPP_HIDE_FROM_ABI file_status& operator=(file_status&&) noexcept = default;
  35. // observers
  36. _LIBCPP_INLINE_VISIBILITY
  37. file_type type() const noexcept { return __ft_; }
  38. _LIBCPP_INLINE_VISIBILITY
  39. perms permissions() const noexcept { return __prms_; }
  40. // modifiers
  41. _LIBCPP_INLINE_VISIBILITY
  42. void type(file_type __ft) noexcept { __ft_ = __ft; }
  43. _LIBCPP_INLINE_VISIBILITY
  44. void permissions(perms __p) noexcept { __prms_ = __p; }
  45. # if _LIBCPP_STD_VER >= 20
  46. _LIBCPP_HIDE_FROM_ABI friend bool operator==(const file_status& __lhs, const file_status& __rhs) noexcept {
  47. return __lhs.type() == __rhs.type() && __lhs.permissions() == __rhs.permissions();
  48. }
  49. # endif
  50. private:
  51. file_type __ft_;
  52. perms __prms_;
  53. };
  54. _LIBCPP_END_NAMESPACE_FILESYSTEM
  55. #endif // _LIBCPP_CXX03_LANG
  56. #endif // _LIBCPP___FILESYSTEM_FILE_STATUS_H