Uni/Mode#

Intuitive interface for mode_t.

Info

To use declarations from this page, include the <essence/uni/mode.hpp> header.

They are found in the essence::uni namespace.

class permission#

A set of permissions for a single entity, group, owner or others.

bool read = false#

Whether the file/dir is readable by the entity.

bool write = false#

Whether the file/dir is writable by the entity.

bool execute = false#

Whether the file/dir is executable by the entity.

permission::permission(bool r, bool w, bool x)#

Constructor accepting a boolean for each of the three bits.

permission::permission(bool a)#

Constructor accepting a single boolean for all three bits.

permission::permission()#

Base constructor which retains false for all three bits.

class mode#

A wrapper around mode_t.

permission owner#

The permissions for the files’ owner.

permission group#

The permissions for the files’ group.

permission other#

The permissions for those who are not the owner or a member of the files’ group.

bool sticky = false#

Whether or not the sticky bit is set.

bool setuid = false#

Whether or not the file is setuid.

bool setgid = false#

Whether or not the file is setgid.

void update()#

Update the underlying mode_t to reflect the current configuration.

operator mode_t()#

Implicit conversion to a mode_t for use with C functions.

std::string octal() const#

Obtain an octal representation of the mode.

Example

uni::mode m;
m.owner.read = true;
m.owner.write = true;
m.owner.execute = true;

m.group.read = true;
m.group.write = true;
m.group.execute = true;

m.group.read = true;
m.group.write = true;
m.group.execute = true;

m.sticky = true;
m.setuid = true;
m.setgid = true;

uni::chmod("foo.txt", m);