Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / include / __filesystem / perms.h
blobf2b5dfaae9d5816e94ddc6b19619941695239490
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 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___FILESYSTEM_PERMS_H
11 #define _LIBCPP___FILESYSTEM_PERMS_H
13 #include <__availability>
14 #include <__config>
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 # pragma GCC system_header
18 #endif
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 {
29 none = 0,
31 owner_read = 0400,
32 owner_write = 0200,
33 owner_exec = 0100,
34 owner_all = 0700,
36 group_read = 040,
37 group_write = 020,
38 group_exec = 010,
39 group_all = 070,
41 others_read = 04,
42 others_write = 02,
43 others_exec = 01,
44 others_all = 07,
46 all = 0777,
48 set_uid = 04000,
49 set_gid = 02000,
50 sticky_bit = 01000,
51 mask = 07777,
52 unknown = 0xFFFF,
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