protected function ensureDirsRecursively($volume, $target, $dirs, $path = '')
{
$res = array('stats' => array(), 'hashes' => array());
foreach ($dirs as $name => $sub) {
$name = (string) $name;
if (($parent = $volume->realpath($target)) && ($dir = $volume->dir($volume->getHash($parent, $name))) || ($dir = $volume->mkdir($target, $name))) {
$_path = $path . '/' . $name;
$res['stats'][] = $dir;
$res['hashes'][$_path] = $dir['hash'];
if (count($sub)) {
if ($subRes = $this->ensureDirsRecursively($volume, $dir['hash'], $sub, $_path)) {
$res = array_merge_recursive($res, $subRes);
} else {
return false;
}
}
} else {
return false;
}
}
return $res;
}