BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdls::FilePermissions Struct Reference

#include <bdls_filepermissions.h>

Detailed Description

This struct provides a namespace for a std::filesystem::perms-style enumeration of file-system permission bits, and a pair of predicates for validating an int bit mask against that enumeration.

See bdls_filepermissions

Public Types

enum  Enum {
  k_NONE = 0 , k_OWNER_READ = 0400 , k_OWNER_WRITE = 0200 , k_OWNER_EXEC = 0100 ,
  k_OWNER_ALL = k_OWNER_READ | k_OWNER_WRITE | k_OWNER_EXEC , k_GROUP_READ = 0040 , k_GROUP_WRITE = 0020 , k_GROUP_EXEC = 0010 ,
  k_GROUP_ALL = k_GROUP_READ | k_GROUP_WRITE | k_GROUP_EXEC , k_OTHERS_READ = 0004 , k_OTHERS_WRITE = 0002 , k_OTHERS_EXEC = 0001 ,
  k_OTHERS_ALL = k_OTHERS_READ | k_OTHERS_WRITE | k_OTHERS_EXEC , k_ALL = k_OWNER_ALL | k_GROUP_ALL | k_OTHERS_ALL , k_SET_UID = 04000 , k_SET_GID = 02000 ,
  k_STICKY_BIT = 01000 , k_MASK = k_ALL | k_SET_UID | k_SET_GID | k_STICKY_BIT
}
 

Static Public Member Functions

static bool isValidBaseBits (int permissions)
 
static bool isValid (int permissions)
 
static bsl::ostream & print (bsl::ostream &stream, FilePermissions::Enum value, int level=0, int spacesPerLevel=4)
 

Member Enumeration Documentation

◆ Enum

File-system permission bits, in the conventional Unix octal layout. Values may be combined with the bitwise-OR operator. See the component-level documentation for the meaning of each enumerator.

Enumerator
k_NONE 
k_OWNER_READ 
k_OWNER_WRITE 
k_OWNER_EXEC 
k_OWNER_ALL 
k_GROUP_READ 
k_GROUP_WRITE 
k_GROUP_EXEC 
k_GROUP_ALL 
k_OTHERS_READ 
k_OTHERS_WRITE 
k_OTHERS_EXEC 
k_OTHERS_ALL 
k_ALL 
k_SET_UID 
k_SET_GID 
k_STICKY_BIT 
k_MASK 

Member Function Documentation

◆ isValid()

bool bdls::FilePermissions::isValid ( int  permissions)
inlinestatic

Return true if the specified permissions bit mask consists only of bits defined in Enum (i.e., bits in k_MASK), and false otherwise. A negative value always returns false.

◆ isValidBaseBits()

bool bdls::FilePermissions::isValidBaseBits ( int  permissions)
inlinestatic

Return true if the specified permissions bit mask consists only of the "base" nine rwx bits (owner/group/others read/write/execute, i.e., bits in k_ALL), and false otherwise.

Note
Note that this predicate is stricter than isValid: k_SET_UID, k_SET_GID, and k_STICKY_BIT are rejected.

◆ print()

static bsl::ostream & bdls::FilePermissions::print ( bsl::ostream &  stream,
FilePermissions::Enum  value,
int  level = 0,
int  spacesPerLevel = 4 
)
static

Write the octal numeric representation of the specified permission bit mask value to the specified output stream, and return a reference to stream. Optionally specify an initial indentation level, whose absolute value is incremented recursively for nested objects. If level is specified, optionally specify spacesPerLevel, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). The value is written in octal notation without the customary leading 0 prefix (for example, the mask 0640 is written as 640).


The documentation for this struct was generated from the following file: