"using lstat in find and check type 'd' directly against mode from lstat for better performance"

This commit is contained in:
Ralf Becker 2009-05-02 14:15:31 +00:00
parent 287131565f
commit 9e88b1ba9d

View File

@ -510,14 +510,14 @@ class egw_vfs extends vfs_stream_wrapper
{ {
$type = $options['type']; // 'd' or 'f' $type = $options['type']; // 'd' or 'f'
if ($type && ($type == 'd') !== (is_dir($path) && !is_link($path))) if (!($stat = self::url_stat($path,STREAM_URL_STAT_LINK)))
{
return; // wrong type
}
if (!($stat = self::url_stat($path,0)))
{ {
return; // not found, should not happen return; // not found, should not happen
} }
if ($type && ($type == 'd') == !($stat['mode'] & sqlfs_stream_wrapper::MODE_DIR)) // != is_dir() which can be true for symlinks
{
return; // wrong type
}
$stat = array_slice($stat,13); // remove numerical indices 0-12 $stat = array_slice($stat,13); // remove numerical indices 0-12
$stat['path'] = parse_url($path,PHP_URL_PATH); $stat['path'] = parse_url($path,PHP_URL_PATH);
$stat['name'] = $options['remove'] > 0 ? implode('/',array_slice(explode('/',$stat['path']),$options['remove'])) : self::basename($path); $stat['name'] = $options['remove'] > 0 ? implode('/',array_slice(explode('/',$stat['path']),$options['remove'])) : self::basename($path);