-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathperm.hh
68 lines (50 loc) · 1.41 KB
/
perm.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2022 Mikael Simonsson <https://mikaelsimonsson.com>.
// SPDX-License-Identifier: BSL-1.0
// # Permission bits (enum)
#pragma once
#include "snn-core/core.hh"
namespace snn::file
{
// ## Enums
// ### perm
enum class perm : u16
{
none = 0,
all_read = 0444,
all_write = 0222,
all_exec = 0111,
all_all = 0777,
owner_read = 0400,
owner_write = 0200,
owner_exec = 0100,
owner_all = 0700,
group_read = 0040,
group_write = 0020,
group_exec = 0010,
group_all = 0070,
other_read = 0004,
other_write = 0002,
other_exec = 0001,
other_all = 0007,
setuid = 04000,
setgid = 02000,
sticky = 01000,
directory_default = 0777,
regular_default = 0666,
mask = 07777,
};
// ## Functions
// ### Bitwise operators
[[nodiscard]] constexpr perm operator&(const perm left, const perm right) noexcept
{
return static_cast<perm>(to_underlying(left) & to_underlying(right));
}
[[nodiscard]] constexpr perm operator|(const perm left, const perm right) noexcept
{
return static_cast<perm>(to_underlying(left) | to_underlying(right));
}
[[nodiscard]] constexpr perm operator~(const perm p) noexcept
{
return static_cast<perm>(~to_underlying(p));
}
}