本文整理汇总了PHP中RecursiveIteratorIterator::getPerms方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::getPerms方法的具体用法?PHP RecursiveIteratorIterator::getPerms怎么用?PHP RecursiveIteratorIterator::getPerms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveIteratorIterator
的用法示例。
在下文中一共展示了RecursiveIteratorIterator::getPerms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public static function build($directory)
{
$list = array();
$unique = array();
// Build
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::KEY_AS_PATHNAME), RecursiveIteratorIterator::SELF_FIRST);
while ($it->valid()) {
$key = $it->key();
// Make sure it's unique, Skip .svn files
if (isset($unique[$key]) || stripos($key, '.svn') !== false) {
$it->next();
continue;
}
$unique[$key] = true;
// Add
$subpath = $it->getSubPathName();
// Skip dot files, package files and .svn or CVS folders
if (!$it->isDot() && substr(basename($subpath), 0, strrpos(basename($subpath), '.')) != 'package' && basename($subpath) != '.svn' && basename($subpath) != 'CVS') {
$key = $it->key();
//$list[$it->getSubPathName()] = array(
$list[] = array('path' => self::fix_path($it->getSubPathName()), 'dir' => $it->isDir(), 'file' => $it->isFile(), 'perms' => substr(sprintf('%o', $it->getPerms()), -4), 'size' => $it->getSize(), 'sha1' => $it->isFile() ? sha1_file($key) : null);
}
$it->next();
}
ksort($list);
return $list;
}
示例2: copyDir
/**
* Copy directory
*
* @param string $source
* @param string $dest
*/
private function copyDir(string $source, string $dest)
{
$dir_iterator = new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $item) {
if ($item->isDir()) {
mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), octdec(str_pad($iterator->getPerms(), 4, 0, STR_PAD_LEFT)));
} else {
$this->copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
}
}
return true;
}