Req #42705 [Opn]: Defining sys/stat.h's constants in PHP

From: Date: Wed, 08 Apr 2020 10:37:16 +0000
Subject: Req #42705 [Opn]: Defining sys/stat.h's constants in PHP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226475@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=42705&edit=1 ID: 42705 Updated by: cmb@php.net Reported by: arnaud dot lb at gmail dot com Summary: Defining sys/stat.h's constants in PHP Status: Open Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues PHP Version: 5.2.4 Block user comment: N Private report: N New Comment: The S_IF* constants are already available in the posix extension as of PHP 5.1.0[1]. [1] <https://www.php.net/manual/en/posix.constants.mknod.php> Previous Comments: ------------------------------------------------------------------------ [2007-09-19 05:46:45] arnaud dot lb at gmail dot com Description: ------------ It would be very useful to have the sys/stat.h constants (S_*, e.g. S_ISUID for the setuid bit) defined in PHP, to be able to more easily use the values returned by functions such as fileperms() or stat(). I actually use this to define them (from stat(2) man page), but I guess it's not portable: <?php define('S_IFMT', 0170000); //bit mask for the file type bit fields define('S_IFSOCK', 0140000); //socket define('S_IFLNK', 0120000); //symbolic link define('S_IFREG', 0100000); //regular file define('S_IFBLK', 0060000); //block device define('S_IFDIR', 0040000); //directory define('S_IFCHR', 0020000); //character device define('S_IFIFO', 0010000); //FIFO define('S_ISUID', 0004000); //set UID bit define('S_ISGID', 0002000); //set-group-ID bit (see below) define('S_ISVTX', 0001000); //sticky bit (see below) define('S_IRWXU', 00700); //mask for file owner permissions define('S_IRUSR', 00400); //owner has read permission define('S_IWUSR', 00200); //owner has write permission define('S_IXUSR', 00100); //owner has execute permission define('S_IRWXG', 00070); //mask for group permissions define('S_IRGRP', 00040); //group has read permission define('S_IWGRP', 00020); //group has write permission define('S_IXGRP', 00010); //group has execute permission define('S_IRWXO', 00007); //mask for permissions for others (not in group) define('S_IROTH', 00004); //others have read permission define('S_IWOTH', 00002); //others have write permission define('S_IXOTH', 00001); //others have execute permission ?> This make me able to do things like ($fileperms & S_IROTH) instead of ($fileperms & 00004) to know if a file is world readable. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=42705&edit=1

« previous php.bugs (#226475) next »