This class encapsulates the standard library's permissions bitmask type, and provides some higher-level object oriented features for working with permissions.
More...
|
| Permissions (const Permissions &)=default |
|
| Permissions (Permissions &&)=default |
|
Permissions & | operator= (const Permissions &)=default |
|
Permissions & | operator= (FSPerms p) noexcept |
| Assigns a new permissions bitmask to this object. More...
|
|
Permissions & | operator= (Permissions &&)=default |
|
std::string | toString () const |
| Returns a string representation of these permissions of the form rwxrwxrwx , where the first three characters represent the owner scope, the next three the group scope, and the final three the others scope. More...
|
|
|
| Permissions ()=default |
| Creates a Permissions object holding the value FSPerms::none . More...
|
|
| Permissions (FSPerms p) noexcept |
| Creates a Permissions object holding the specified permissions value. More...
|
|
|
| operator FSPerms () const noexcept |
| Implicitly converts this Permissions object to the standard library permissions bitmask it holds. More...
|
|
FSPerms | getStdPerms () const noexcept |
| Returns the standard library permissions bitmask this object holds. More...
|
|
|
bool | operator== (const Permissions &other) const noexcept |
| Compares permissions for equality. More...
|
|
bool | operator== (FSPerms p) const noexcept |
| Compares permissions for equality. More...
|
|
|
bool | isUnknownOrEmpty () const noexcept |
| Returns true if this permissions object holds the values FSPerms::none or FSPerms::unknown . More...
|
|
bool | hasRead (Scope s=Scope::All) const noexcept |
| Returns true if these permissions include read access for the specified scope. More...
|
|
bool | hasWrite (Scope s=Scope::All) const noexcept |
| Returns true if these permissions include write access for the specified scope. More...
|
|
bool | hasExecute (Scope s=Scope::All) const noexcept |
| Returns true if these permissions include execution access for the specified scope. More...
|
|
bool | hasAll (Scope s=Scope::All) const noexcept |
| Returns true if these permissions include read, write, and execution access for the specified scope. More...
|
|
bool | hasStickyBit () const noexcept |
| Returns true if these permissions have the sticky bit set. More...
|
|
|
Permissions | withRead (Scope s=Scope::All) const noexcept |
| Returns a new permissions object that adds read access in the specified scope to this object's existing permissions. More...
|
|
Permissions | withWrite (Scope s=Scope::All) const noexcept |
| Returns a new permissions object that adds write access in the specified scope to this object's existing permissions. More...
|
|
Permissions | withExecute (Scope s=Scope::All) const noexcept |
| Returns a new permissions object that adds execution access in the specified scope to this object's existing permissions. More...
|
|
Permissions | withAll (Scope s=Scope::All) const noexcept |
| Returns a new permissions object that adds read, write, and execution access in the specified scope to this object's existing permissions. More...
|
|
Permissions | withStickyBit () const noexcept |
| Returns a new permissions object that adds the sticky bit to this object's existing permissions. More...
|
|
This class encapsulates the standard library's permissions bitmask type, and provides some higher-level object oriented features for working with permissions.
This class is incredibly light, as it holds only a single integral value, so don't be afraid to copy them around.
Definition at line 45 of file lfilesystem_Permissions.h.
static Permissions limes::files::Permissions::fromString |
( |
const std::string_view & |
string | ) |
|
|
staticnoexcept |
This function parses a string in the format returned by toString()
.
See that function for a detailed description of the input string.
If the input string is not 9 characters long, this will return a Permissions object holding the unknown
value. For each set of three characters, this function simply checks for the presence of r, w, and x characters in the expected positions; other incorrect or invalid inputs will not throw errors.
You can check if this function succeeded by calling isUnknownOrEmpty()
on the returned Permissions object.
- See also
- toString()
std::string limes::files::Permissions::toString |
( |
| ) |
const |
Returns a string representation of these permissions of the form rwxrwxrwx
, where the first three characters represent the owner
scope, the next three the group
scope, and the final three the others
scope.
Each set of three characters consists of rwx
, representing "read", "write", and "execute", and these characters will be replaced with a -
if that permission is not present scope.
For example, if the only permissions set are read and write permission for the file owner, this function will return rw----—
. If all other users can read the file, but not write to it, this function will return rw-r–r–
. A file with all permissions set globally will return rwxrwxrwx
.
- See also
- fromString()
- Todo:
- test coverage for unknown/empty case