mode


The os_mode class is an encapsulation of POSIX permission characteristics. This class permits you to set these characteristics without remembering either the names of the POSIX flags (such as S_IRWXU and S_IRWXG , defined in /usr/include/sys/stat.h ), or their numeric representations. The mode class is also useful for converting these permission characteristics into a text string as displayed by the UNIX ls command.

Conversions permit interchangeable use of os_mode and os_mode_t .

Any constructor that takes an os_mode_t parameter permits you to specify the permissions flags for a newly-created I/O object. A parameter of this type accepts either an os_mode object or an octal representation of the permissions. The default os_mode_t value for all I/O objects (except directories) is 0660 , which means that the I/O object can be read and written to by processes with the same user or group. The default os_mode_t value for directories is 0770 , which means that these objects can also be searched by processes with the same user or group.

Library

Platform<ToolKit> for UNIX

Declaration

#include <ospace/unix/mode.h>

class os_mode

Interface

Constructor
os_mode( os_mode_t mode )
Constructs an object with POSIX.1 encoded mode mode (default 0 ).
Constructor
os_mode( const os_mode& mode )
Constructs an object that is a copy of mode .
<
bool operator<( const os_mode& mode ) const
Returns true if the value is less than mode .
=
os_mode& operator=( os_mode_t mode )
Assigns an object from mode .
=
os_mode& operator=( const os_mode& mode )
Assigns an object from mode .
==
bool operator==( const os_mode& mode ) const
Returns true if the value is the same as mode .
(os_mode_t)
operator os_mode_t() const
Returns POSIX.1 encoded mode bits.
block_special
bool block_special() const
Returns true if the object is a block special mode.
char_special
bool char_special() const
Returns true if the object is a character special mode.
directory
bool directory() const
Returns true if the object is a directory mode.
fifo
bool fifo() const
Returns true if the object is a FIFO mode.
group_execute
bool group_execute() const
Returns the group execute/directory search permission.
group_execute
void group_execute( bool flag )
Sets the group execute/directory search permission to flag .
group_read
bool group_read() const
Returns the group read permission.
group_read
void group_read( bool flag )
Sets the group read permission to flag .
group_write
bool group_write() const
Returns the group write permission.
group_write
void group_write( bool flag )
Sets the group write permission to flag .
mandatory_locking
void mandatory_locking( bool flag )
Sets the mandatory record locking to flag .
mandatory_locking
bool mandatory_locking() const
Returns true if the object is set for mandatory record locking.
others_execute
bool others_execute() const
Returns the world execute/directory search permission.
others_execute
void others_execute( bool flag )
Sets the world execute/directory search permissions to flag .
others_read
void others_read( bool flag )
Sets the world read permission to flag .
others_read
bool others_read() const
Returns the world read permission.
others_write
void others_write( bool flag )
Sets the world write permission to flag .
others_write
bool others_write() const
Returns the world write permission.
print
void print( ostream& stream ) const
Prints to stream using the standard POSIX notation.
regular
bool regular() const
Returns true if the object is a regular file mode.
set_group_id
void set_group_id( bool flag )
Sets the "set group ID" bit to flag .
set_group_id
bool set_group_id() const
Returns the "set group ID" setting.
set_user_id
void set_user_id( bool flag )
Sets the "set user ID" bit to flag .
set_user_id
bool set_user_id() const
Returns the "set user ID" setting.
socket
bool socket() const
Returns true if the object is a socket mode.
sticky
bool sticky() const
Returns the "sticky" bit setting (not POSIX.1).
sticky
void sticky( bool flag )
Sets the "sticky" bit to flag .
symbolic_link
bool symbolic_link() const
Returns true if the object is a symbolic link mode.
user_execute
bool user_execute() const
Returns the execute/directory search permission of the object's owner.
user_execute
void user_execute( bool flag )
Sets the execute/directory search permissions of the object's owner to flag .
user_read
void user_read( bool flag )
Sets the read permission of the object's owner to flag .
user_read
bool user_read() const
Returns the read permission of the object's owner.
user_write
void user_write( bool flag )
Sets the write permission of the object's owner to flag .
user_write
bool user_write() const
Returns the write permission of the object's owner.
value
void value( os_mode_t mode )
Sets the POSIX.1 encoded mode bits to mode .
value
os_mode_t value() const
Returns the POSIX.1 encoded mode bits.

Non-Member Functions

<<
ostream& operator<<( ostream& stream , const os_mode& mode )
Prints mode using ls -al style output to stream .

Universal Streaming Service

#include <ospace/uss/unix.h>
<<
os_bstream& operator<<( os_bstream& stream , const os_mode& mode )
Writes mode to stream .
>>
os_bstream& operator>>( os_bstream& stream , os_mode& mode )
Reads mode from stream .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only. - For use by licensed users only.