2 //===----------------------------------------------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___FILESYSTEM_PERMS_H
11 #define _LIBCPP___FILESYSTEM_PERMS_H
13 #include <__availability>
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 # pragma GCC system_header
20 #ifndef _LIBCPP_CXX03_LANG
22 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
24 // On Windows, these permission bits map to one single readonly flag per
25 // file, and the executable bit is always returned as set. When setting
26 // permissions, as long as the write bit is set for either owner, group or
27 // others, the readonly flag is cleared.
28 enum class perms
: unsigned {
55 _LIBCPP_INLINE_VISIBILITY
56 inline constexpr perms
operator&(perms __lhs
, perms __rhs
) {
57 return static_cast<perms
>(static_cast<unsigned>(__lhs
) &
58 static_cast<unsigned>(__rhs
));
61 _LIBCPP_INLINE_VISIBILITY
62 inline constexpr perms
operator|(perms __lhs
, perms __rhs
) {
63 return static_cast<perms
>(static_cast<unsigned>(__lhs
) |
64 static_cast<unsigned>(__rhs
));
67 _LIBCPP_INLINE_VISIBILITY
68 inline constexpr perms
operator^(perms __lhs
, perms __rhs
) {
69 return static_cast<perms
>(static_cast<unsigned>(__lhs
) ^
70 static_cast<unsigned>(__rhs
));
73 _LIBCPP_INLINE_VISIBILITY
74 inline constexpr perms
operator~(perms __lhs
) {
75 return static_cast<perms
>(~static_cast<unsigned>(__lhs
));
78 _LIBCPP_INLINE_VISIBILITY
79 inline perms
& operator&=(perms
& __lhs
, perms __rhs
) { return __lhs
= __lhs
& __rhs
; }
81 _LIBCPP_INLINE_VISIBILITY
82 inline perms
& operator|=(perms
& __lhs
, perms __rhs
) { return __lhs
= __lhs
| __rhs
; }
84 _LIBCPP_INLINE_VISIBILITY
85 inline perms
& operator^=(perms
& __lhs
, perms __rhs
) { return __lhs
= __lhs
^ __rhs
; }
87 _LIBCPP_END_NAMESPACE_FILESYSTEM
89 #endif // _LIBCPP_CXX03_LANG
91 #endif // _LIBCPP___FILESYSTEM_PERMS_H