note 16924 added to function.is-dir

From: Date: Mon, 19 Nov 2001 14:06:47 +0000
Subject: note 16924 added to function.is-dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-21003@lists.php.net to get a copy of this message
This is an extract from my "AlberT-EasySite", I hope it's usefull ;-) <p> function &_AES_getPluginsDirName($directory) { // directories like "\foo\08032001" (on win systems) bring to an error // such a name, containing the special '\0' char, will terminate // prematurely the string. $directory = ereg_replace ('\0', "\\\\0", $directory); $dh = @opendir ($directory); // Under Windows NT opendir() seems to return a resource even for // a non-existent directory; we use is_dir to avoid it. if (!$dh) { if (defined('AES_DEBUG')) { if (!is_dir($directory)) { echo "Cannot open directory '$directory'. It is NOT a directory!"; } elseif (!is_readable($directory)) { echo "Cannot open directory '$directory'. It MUST be readable (+r)!"; } // check that dir il executable, if it isn't id_dir() used below doesn't // works properly! elseif (!is_executable($directory)) { echo "Directory '$directory' MUST be executable (+x)!"; } } return 0; } //this handle stange entries like a dir named '0' while (false !== ($entry = @readdir ($dh))) { if ($entry != '.' && $entry != '..') { $dir = "$directory/$entry"; // files will be ignored! Each plugin MUST have its own dir if (is_dir($dir)) { $plugins[] = $entry; } } } @closedir ($dh); return $plugins ; } </p> -- http://www.php.net/manual/en/function.is-dir.php http://master.php.net/manage/user-notes.php?action=edit+16924 http://master.php.net/manage/user-notes.php?action=delete+16924 http://master.php.net/manage/user-notes.php?action=reject+16924

« previous php.notes (#21003) next »