|
BDE 4.39.x Production Release
|
Enumerate the file-system permission bits used across bdl.
Enumerate the file-system permission bits used across bdl.
std::filesystem::perms-style enumThis component provides a struct, bdls::FilePermissions, that scopes a bit-mask enum, Enum, modelled on std::filesystem::perms [https://en.cppreference.com/w/cpp/filesystem/perms]. The enumerators describe the standard Unix file-system permission bits (owner, group, and others read/write/execute triples, plus the "set uid", "set gid", and sticky bits) with numeric values that match the traditional Unix octal representation. This component also provides two static predicates for validating an int bit mask against the set of defined bits.
This component is intended to be used by other components that accept a permission bit mask as an int argument. Taking an int (rather than the enumeration type) lets callers pass either a familiar octal literal (for example 0666) or a bitwise-OR of bdls::FilePermissions enumerators. The consuming component is expected to validate its argument by calling one of the isValid* predicates.
The Enum values are:
This section illustrates intended use of this component.
A component (for instance, balb::PipeControlChannel) may accept an int permission bit mask. A caller can build such a mask by OR-ing together enumerators of bdls::FilePermissions. Suppose we want a file readable and writable by the owner and readable by the owning group:
The consuming component may validate the mask before using it. To reject a mask that contains any bit outside the traditional 9-bit rwx set (that is, to reject k_SET_UID, k_SET_GID, and k_STICKY_BIT), use isValidBaseBits:
To accept any combination of defined bits, use isValid: