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 10 #ifndef _LIBCPP___FILESYSTEM_PERMS_H 11 #define _LIBCPP___FILESYSTEM_PERMS_H 12 13 #include <__availability> 14 #include <__config> 15 16 #ifndef _LIBCPP_CXX03_LANG 17 18 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM 19 20 _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH 21 22 // On Windows, these permission bits map to one single readonly flag per 23 // file, and the executable bit is always returned as set. When setting 24 // permissions, as long as the write bit is set for either owner, group or 25 // others, the readonly flag is cleared. 26 enum class _LIBCPP_ENUM_VIS perms : unsigned { 27 none = 0, 28 29 owner_read = 0400, 30 owner_write = 0200, 31 owner_exec = 0100, 32 owner_all = 0700, 33 34 group_read = 040, 35 group_write = 020, 36 group_exec = 010, 37 group_all = 070, 38 39 others_read = 04, 40 others_write = 02, 41 others_exec = 01, 42 others_all = 07, 43 44 all = 0777, 45 46 set_uid = 04000, 47 set_gid = 02000, 48 sticky_bit = 01000, 49 mask = 07777, 50 unknown = 0xFFFF, 51 }; 52 53 _LIBCPP_INLINE_VISIBILITY 54 inline constexpr perms operator&(perms _LHS, perms _RHS) { 55 return static_cast<perms>(static_cast<unsigned>(_LHS) & 56 static_cast<unsigned>(_RHS)); 57 } 58 59 _LIBCPP_INLINE_VISIBILITY 60 inline constexpr perms operator|(perms _LHS, perms _RHS) { 61 return static_cast<perms>(static_cast<unsigned>(_LHS) | 62 static_cast<unsigned>(_RHS)); 63 } 64 65 _LIBCPP_INLINE_VISIBILITY 66 inline constexpr perms operator^(perms _LHS, perms _RHS) { 67 return static_cast<perms>(static_cast<unsigned>(_LHS) ^ 68 static_cast<unsigned>(_RHS)); 69 } 70 71 _LIBCPP_INLINE_VISIBILITY 72 inline constexpr perms operator~(perms _LHS) { 73 return static_cast<perms>(~static_cast<unsigned>(_LHS)); 74 } 75 76 _LIBCPP_INLINE_VISIBILITY 77 inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; } 78 79 _LIBCPP_INLINE_VISIBILITY 80 inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; } 81 82 _LIBCPP_INLINE_VISIBILITY 83 inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; } 84 85 _LIBCPP_AVAILABILITY_FILESYSTEM_POP 86 87 _LIBCPP_END_NAMESPACE_FILESYSTEM 88 89 #endif // _LIBCPP_CXX03_LANG 90 91 #endif // _LIBCPP___FILESYSTEM_PERMS_H 92