note 20492 deleted from function.stat by alindeman

From: Date: Fri, 09 May 2003 21:39:51 +0000
Subject: note 20492 deleted from function.stat by alindeman
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47773@lists.php.net to get a copy of this message
I think "3. inode protection mode" is incorrect. Value 2 in the array actually seems to actually correspond to st_mode from a C stat() call, ie what the UNIX man pages call file "mode", or what I would call "file type". At the moment, I'm trying to reliably detect files that are not regular files or directories. I don't seem to be able to do this with is_file and is_dir (this seems to mess up on special files, eg named pipes). What I have constructed below seems to do what I want, but careful if you want to reuse it: it isn't well tested yet and the constant values are from a system file on Solaris 8. // from /usr/include/sys/stat.h -- careful: probably only valid on Solaris define("S_IFMT", 0xF000); define("S_IFREG", 0x8000); define("S_IFDIR", 0x4000); if ((s = lstat($fileName)) == false) die("ERROR: failed to stat file $fileName"); $type = s[2] & S_IFMT; if (($type != S_IFREG) && ($type != S_IFDIR)) die("ERROR: expecting file or directory and found something else at $fileName");

« previous php.notes (#47773) next »