note 16924 deleted from function.is-dir by jimw
| From: | jimw@php.net | Date: | Sat, 08 Dec 2001 23:47:06 +0000 |
| Subject: | note 16924 deleted from function.is-dir by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-22375@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>