- Модуль: fileman
- Путь к файлу: ~/bitrix/modules/fileman/classes/general/fileman_utils.php
- Класс: CFilemanUtilDir
- Вызов: CFilemanUtilDir::Recursion
public function Recursion($dir)
{
//error_reporting(0);
global $USER;
$io = CBXVirtualIo::GetInstance();
if ($this->bDirFirst && $this->processDir && (!$this->startPath || $this->bFound))
if (!$this->CallMethod($this->processDir, $dir))
{
$this->err[] = 'Error on dir: '.$dir;
return false;
}
$dTmp = $io->GetDirectory($dir);
$arChildren = $dTmp->GetChildren();
$arItems = array();
foreach ($arChildren as $child)
$arItems[] = $child->GetName();
sort($arItems);
$s_dir = CFilemanUtils::TrimPath($dir, $this->docRoot);
foreach($arItems as $item)
{
$f = $dir."/".$item;
if ($this->startPath && !$this->bFound)
{
if ($this->startPath == $f)
$this->bFound = true;
elseif (mb_substr($this->startPath, 0, mb_strlen($f) + 1) != $f.'/')
continue;
}
$arPath = array($this->site, $s_dir."/".$item);
$this->nextPath = $f;
if ($this->checkBreak && $this->CallMethod($this->checkBreak))
{
$this->bBreak = true;
return true;
}
if ($this->bSkipSymLinks && is_link($f))
continue;
if ($io->DirectoryExists($f))
{
if (!$USER->CanDoFileOperation('fm_view_listing', $arPath)) // access
continue;
$r = $this->CallMethod($this->callBack, $f);
if ($r == 'stop')
{
$this->bBreak = true;
$this->bStoped = true;
return true;
}
if ($this->checkSubdirs)
{
$r = $this->Recursion($f);
if ($this->bBreak)
return $r;
if ($r===false)
return false;
}
}
elseif ($this->callBack)
{
$r = $this->CallMethod($this->callBack, $f);
if ($r == 'stop')
{
$this->bBreak = true;
$this->bStoped = true;
return true;
}
if ($r===false)
{
$this->err[] = 'Error on file: '.$f.'';
return false;
}
$this->cntFile++;
}
}
if ($this->processDir && !$this->bDirFirst)
{
if (!$this->CallMethod($this->processDir, $dir))
{
$this->err[] = 'Error on folder: '.$dir;
return false;
}
}
return true;
}