| 1 | package Enum::Declare::Common::Permission; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.014; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use Enum::Declare; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | enum Bit :Flags :Type :Export { | ||
| 10 | Execute, | ||
| 11 | Write, | ||
| 12 | Read | ||
| 13 | 1 | }; | |
| 14 | |||
| 15 | enum Mask :Type :Export { | ||
| 16 | OwnerRead = 256, | ||
| 17 | OwnerWrite = 128, | ||
| 18 | OwnerExecute = 64, | ||
| 19 | GroupRead = 32, | ||
| 20 | GroupWrite = 16, | ||
| 21 | GroupExecute = 8, | ||
| 22 | OtherRead = 4, | ||
| 23 | OtherWrite = 2, | ||
| 24 | OtherExecute = 1 | ||
| 25 | 1 | }; | |
| 26 | |||
| 27 | 1 | 1; | |
| 28 | |||
| 29 | =head1 NAME | ||
| 30 | |||
| 31 | Enum::Declare::Common::Permission - Unix permission bits and masks | ||
| 32 | |||
| 33 | =head1 SYNOPSIS | ||
| 34 | |||
| 35 | use Enum::Declare::Common::Permission; | ||
| 36 | |||
| 37 | # Flags | ||
| 38 | my $rwx = Read | Write | Execute; # 7 | ||
| 39 | my $rw = Read | Write; # 6 | ||
| 40 | |||
| 41 | # Mask constants for chmod-style values | ||
| 42 | my $mode = OwnerRead | OwnerWrite | OwnerExecute | ||
| 43 | | GroupRead | GroupExecute | ||
| 44 | | OtherRead | OtherExecute; # 0755 | ||
| 45 | |||
| 46 | =head1 ENUMS | ||
| 47 | |||
| 48 | =head2 Bit :Flags :Export | ||
| 49 | |||
| 50 | Execute=1, Write=2, Read=4. Combinable with bitwise OR. | ||
| 51 | |||
| 52 | =head2 Mask :Export | ||
| 53 | |||
| 54 | OwnerRead=256, OwnerWrite=128, OwnerExecute=64, GroupRead=32, | ||
| 55 | GroupWrite=16, GroupExecute=8, OtherRead=4, OtherWrite=2, | ||
| 56 | OtherExecute=1. | ||
| 57 | |||
| 58 | =head1 AUTHOR | ||
| 59 | |||
| 60 | LNATION C<< <email@lnation.org> >> | ||
| 61 | |||
| 62 | =head1 LICENSE AND COPYRIGHT | ||
| 63 | |||
| 64 | Copyright 2026 LNATION. Artistic License 2.0. | ||
| 65 | |||
| 66 | =cut | ||