From:             arnaud dot lb at gmail dot com
Operating system: 
PHP version:      5.2.4
PHP Bug Type:     Feature/Change Request
Bug description:  Defining sys/stat.h's constants in PHP

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 bug report at http://bugs.php.net/?id=42705&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42705&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42705&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42705&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42705&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42705&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42705&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42705&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42705&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42705&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42705&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42705&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42705&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42705&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42705&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42705&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42705&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42705&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42705&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42705&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42705&r=mysqlcfg

Reply via email to