本文整理匯總了PHP中dir::ignore方法的典型用法代碼示例。如果您正苦於以下問題:PHP dir::ignore方法的具體用法?PHP dir::ignore怎麽用?PHP dir::ignore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dir
的用法示例。
在下文中一共展示了dir::ignore方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: read
public function read($url = '', $recursive = false, $format = 'flat')
{
if (substr($url, -1) !== Application::DS) {
$url .= Application::DS;
}
if ($this->ignore('find', $url)) {
return array();
}
$list = array();
$cwd = getcwd();
chdir($url);
if ($handle = opendir($url)) {
while (false !== ($entry = readdir($handle))) {
$recursiveList = array();
if ($entry == '.' || $entry == '..') {
continue;
}
$file = new stdClass();
$file->url = $url . $entry;
if (is_dir($file->url)) {
$file->url .= Application::DS;
$file->type = 'dir';
}
if ($this->ignore('find', $file->url)) {
continue;
}
$file->name = $entry;
if (isset($file->type)) {
if (!empty($recursive)) {
$directory = new dir();
$directory->ignore('list', $this->ignore());
$recursiveList = $directory->read($file->url, $recursive, $format);
if ($format !== 'flat') {
$file->list = $recursiveList;
unset($recursiveList);
}
}
} else {
$file->type = 'file';
}
if (is_link($entry)) {
$file->link = true;
}
/* absolute url is_link wont work probably the targeting type
if(is_link($file->url)){
$file->link = true;
}
*/
$list[] = $file;
if (!empty($recursiveList)) {
foreach ($recursiveList as $recursive_nr => $recursive_file) {
$list[] = $recursive_file;
}
}
}
}
closedir($handle);
return $list;
}