brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 458f1e6 Raw
81 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___FILESYSTEM_PERMS_H11#define _LIBCPP___FILESYSTEM_PERMS_H12 13#include <__config>14 15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#  pragma GCC system_header17#endif18 19#if _LIBCPP_STD_VER >= 1720 21_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM22 23// On Windows, these permission bits map to one single readonly flag per24// file, and the executable bit is always returned as set. When setting25// permissions, as long as the write bit is set for either owner, group or26// others, the readonly flag is cleared.27enum class perms : unsigned {28  none = 0,29 30  owner_read  = 0400,31  owner_write = 0200,32  owner_exec  = 0100,33  owner_all   = 0700,34 35  group_read  = 040,36  group_write = 020,37  group_exec  = 010,38  group_all   = 070,39 40  others_read  = 04,41  others_write = 02,42  others_exec  = 01,43  others_all   = 07,44 45  all = 0777,46 47  set_uid    = 04000,48  set_gid    = 02000,49  sticky_bit = 01000,50  mask       = 07777,51  unknown    = 0xFFFF,52};53 54_LIBCPP_HIDE_FROM_ABI inline constexpr perms operator&(perms __lhs, perms __rhs) {55  return static_cast<perms>(static_cast<unsigned>(__lhs) & static_cast<unsigned>(__rhs));56}57 58_LIBCPP_HIDE_FROM_ABI inline constexpr perms operator|(perms __lhs, perms __rhs) {59  return static_cast<perms>(static_cast<unsigned>(__lhs) | static_cast<unsigned>(__rhs));60}61 62_LIBCPP_HIDE_FROM_ABI inline constexpr perms operator^(perms __lhs, perms __rhs) {63  return static_cast<perms>(static_cast<unsigned>(__lhs) ^ static_cast<unsigned>(__rhs));64}65 66_LIBCPP_HIDE_FROM_ABI inline constexpr perms operator~(perms __lhs) {67  return static_cast<perms>(~static_cast<unsigned>(__lhs));68}69 70_LIBCPP_HIDE_FROM_ABI inline perms& operator&=(perms& __lhs, perms __rhs) { return __lhs = __lhs & __rhs; }71 72_LIBCPP_HIDE_FROM_ABI inline perms& operator|=(perms& __lhs, perms __rhs) { return __lhs = __lhs | __rhs; }73 74_LIBCPP_HIDE_FROM_ABI inline perms& operator^=(perms& __lhs, perms __rhs) { return __lhs = __lhs ^ __rhs; }75 76_LIBCPP_END_NAMESPACE_FILESYSTEM77 78#endif // _LIBCPP_STD_VER >= 1779 80#endif // _LIBCPP___FILESYSTEM_PERMS_H81