本文整理汇总了PHP中RecursiveIteratorIterator::isDot方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::isDot方法的具体用法?PHP RecursiveIteratorIterator::isDot怎么用?PHP RecursiveIteratorIterator::isDot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveIteratorIterator
的用法示例。
在下文中一共展示了RecursiveIteratorIterator::isDot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFile
/**
* @param $path
* @return mixed|string
*/
private function getFile($path)
{
$returnView = $this->viewFolder . $path . '.php';
if (!file_exists($returnView)) {
$dir = $path;
$dir = explode('/', $dir);
unset($dir[count($dir) - 1]);
$dir = implode('/', $dir);
$it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->viewFolder . $dir));
while ($it->valid()) {
if (!$it->isDot()) {
$cache['SelectView'] = strrev($path);
$cache['SelectView'] = explode("/", $cache['SelectView'])[0];
$cache['SelectView'] = strrev($cache['SelectView']);
$cache['ReturnView'] = explode(".", $it->key());
unset($cache['ReturnView'][count($cache['ReturnView']) - 1]);
$cache['ReturnView'] = implode('.', $cache['ReturnView']);
$cache['ReturnView'] = explode("\\", $cache['ReturnView']);
$cache['ReturnView'] = $cache['ReturnView'][count($cache['ReturnView']) - 1];
if ($cache['ReturnView'] == $cache['SelectView']) {
$returnView = $it->key();
}
}
$it->next();
}
if (!isset($returnView)) {
die('Can not find a file matching these arguments: getView("' . $this->getPath($path, TRUE) . '")');
}
return $returnView;
}
}
示例2: scanDir
/**
* Function to start a scan in a directory.
* @return Array
* @throws DirectoryNotFoundException
*/
public static function scanDir($parentDirectory)
{
$occurences = array(array());
//if the directory/file does not exists, then throw and error.
if (!file_exists($parentDirectory)) {
throw new DirectoryORFileNotFoundException("ERROR: Directory not found!");
}
//get the list of all the files inside this directory.
$allFiles = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($parentDirectory));
$fileList = array();
//remove (.), (..) and directories from the list of all files so that only files are left.
while ($allFiles->valid()) {
if (!$allFiles->isDot()) {
if (!is_dir($allFiles->key())) {
array_push($fileList, $allFiles->key());
}
}
$allFiles->next();
}
$i = 0;
foreach ($fileList as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) != "php") {
continue;
}
$occurences[$i]['file'] = realpath($file);
$occurences[$i]['result'] = Scanner::scanFile($file);
$i++;
}
return $occurences;
}
示例3: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
global $CFG;
$tmpdir = $CFG->tempdir;
// Default to last weeks time.
$time = strtotime('-1 week');
$dir = new \RecursiveDirectoryIterator($tmpdir);
// Show all child nodes prior to their parent.
$iter = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::CHILD_FIRST);
for ($iter->rewind(); $iter->valid(); $iter->next()) {
$node = $iter->getRealPath();
if (!is_readable($node)) {
continue;
}
// Check if file or directory is older than the given time.
if ($iter->getMTime() < $time) {
if ($iter->isDir() && !$iter->isDot()) {
// Don't attempt to delete the directory if it isn't empty.
if (!glob($node . DIRECTORY_SEPARATOR . '*')) {
if (@rmdir($node) === false) {
mtrace("Failed removing directory '{$node}'.");
}
}
}
if ($iter->isFile()) {
if (@unlink($node) === false) {
mtrace("Failed removing file '{$node}'.");
}
}
}
}
}
示例4: buildArray
public function buildArray()
{
$directory = new \RecursiveDirectoryIterator('assets');
$iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::CHILD_FIRST);
$tree = [];
foreach ($iterator as $info) {
//if (in_array($info->getFilename(), ['.', '..'])) continue;
if ($iterator->getDepth() >= 2 || !$iterator->isDir() || $iterator->isDot()) {
continue;
}
if ($iterator->getDepth() == 1) {
$path = $info->isDir() ? [$iterator->getDepth() - 1 => $info->getFilename()] : [$info->getFilename()];
} else {
$path = $info->isDir() ? [$info->getFilename() => []] : [$info->getFilename()];
}
for ($depth = $iterator->getDepth() - 1; $depth >= 0; $depth--) {
$path = [$iterator->getSubIterator($depth)->current()->getFilename() => $path];
}
$tree = array_merge_recursive($tree, $path);
}
$data = array();
foreach ($tree as $category => $children) {
foreach ($children as $index => $value) {
$data[$category][] = $value;
}
}
foreach ($data as $category => $children) {
$parentId = $this->addEntry($category, '0');
foreach ($children as $index => $value) {
$this->addEntry($value, $parentId);
}
}
return $data;
}
示例5: copyDir
/**
* @throws \Seitenbau\FileSystem\FileSystemException
*/
public static function copyDir($source, $destination)
{
if (!is_dir($source)) {
throw new FileSystemException('Sourcedir "' . $source . '" does not exists');
}
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
if (!self::createDirIfNotExists($destination)) {
return false;
}
// Verzeichnis rekursiv durchlaufen
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if ($iterator->current()->isDir()) {
// relativen Teil des Pfad auslesen
$relDir = str_replace($source, '', $iterator->key());
// Ziel-Verzeichnis erstellen
if (!self::createDirIfNotExists($destination . $relDir)) {
return false;
}
} elseif ($iterator->current()->isFile()) {
$destinationFile = $destination . str_replace($source, '', $iterator->key());
if (!copy($iterator->key(), $destinationFile)) {
return false;
}
}
}
$iterator->next();
}
return true;
}
示例6: recursive_rmdir
private function recursive_rmdir($dirname, $followLinks = false)
{
if (is_dir($dirname) && !is_link($dirname)) {
if (!is_writable($dirname)) {
throw new Exception('You do not have renaming permissions!');
}
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST);
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if (!$iterator->isWritable()) {
throw new Exception(sprintf('Permission Denied: %s.', $iterator->getPathName()));
}
if ($iterator->isLink() && false === (bool) $followLinks) {
$iterator->next();
}
if ($iterator->isFile()) {
unlink($iterator->getPathName());
} else {
if ($iterator->isDir()) {
rmdir($iterator->getPathName());
}
}
}
$iterator->next();
}
unset($iterator);
// Fix for Windows.
return rmdir($dirname);
} else {
throw new Exception(sprintf('Directory %s does not exist!', $dirname));
}
}
示例7: is_extension_changed
private static function is_extension_changed($name)
{
$name = strtolower($name);
$extension_build_dir = ROOT_PATH . DS . 'build' . DS . $name;
$extension_path = ROOT_PATH . DS . 'extensions' . DS . $name . '.tar.gz';
if (file_exists($extension_build_dir) && file_exists($extension_path)) {
$dir_iterator = new \RecursiveDirectoryIterator($extension_build_dir);
/**
* @var $iterator \RecursiveDirectoryIterator
*/
$iterator = new \RecursiveIteratorIterator($dir_iterator);
$iterator->rewind();
while ($iterator->valid()) {
if (!$iterator->isDot()) {
$file = $extension_build_dir . DS . $iterator->getSubPathName();
$phar_file = "phar://{$extension_path}/" . $iterator->getSubPathName();
if (!file_exists($phar_file)) {
return true;
} else {
$build_file_hash = md5(file_get_contents($file));
$phar_file_hash = md5(file_get_contents($phar_file));
if ($build_file_hash != $phar_file_hash) {
return true;
}
}
}
$iterator->next();
}
return false;
} else {
return false;
}
}
示例8: getTestFiles
/**
* Get Test Files
*
* @param null $directory
* @param null $excludes
* @return array
*/
public static function getTestFiles($directory = null, $excludes = null)
{
if (is_array($directory)) {
$files = array();
foreach ($directory as $d) {
$files = array_merge($files, self::getTestFiles($d, $excludes));
}
return array_unique($files);
}
if ($excludes !== null) {
$excludes = self::getTestFiles((array) $excludes);
}
if ($directory === null || $directory !== realpath($directory)) {
$basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS;
$directory = str_replace(DS . DS, DS, $basePath . $directory);
}
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
$files = array();
while ($it->valid()) {
if (!$it->isDot()) {
$file = $it->key();
if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__ && !preg_match('|^All.+?\\.php$|', basename($file)) && ($excludes === null || !in_array($file, $excludes))) {
$files[] = $file;
}
}
$it->next();
}
return $files;
}
示例9: assertDirContentsEquals
protected function assertDirContentsEquals($expDir, $actDir)
{
if (!file_exists($expDir)) {
throw new RuntimeException("Expected dir not found: " . $expDir);
}
if (!file_exists($actDir)) {
throw new RuntimeException("Actual dir not found: " . $actDir);
}
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($expDir));
$expFiles = array();
while ($dir->valid()) {
if (!$dir->isDot()) {
array_push($expFiles, $dir->getSubPathName());
}
$dir->next();
}
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($actDir));
$actFiles = array();
while ($dir->valid()) {
if (!$dir->isDot()) {
array_push($actFiles, $dir->getSubPathName());
}
$dir->next();
}
$this->assertEquals($expFiles, $actFiles);
foreach ($expFiles as $key => $value) {
$expFile = file_get_contents($expDir . DIRECTORY_SEPARATOR . $value);
$actFile = file_get_contents($expDir . DIRECTORY_SEPARATOR . $actFiles[$key]);
$this->assertEquals($expFile, $actFile);
}
}
示例10: rmdir
/**
* Remove recursively the directory named by dirname.
*
* @param string $dirname Path to the directory
* @param boolean $followLinks Removes symbolic links if set to true
* @return boolean True if success otherwise false
* @throws Exception When the directory does not exist or permission denied
*/
public static function rmdir($dirname, $followLinks = false)
{
if (!is_dir($dirname) && !is_link($dirname)) {
throw new Exception(sprintf('Directory %s does not exist', $dirname));
}
if (!is_writable($dirname)) {
throw new Exception('You do not have renaming permissions');
}
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST);
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if (!$iterator->isWritable()) {
throw new Exception(sprintf('Permission denied for %s', $iterator->getPathName()));
}
if ($iterator->isLink() && false === (bool) $followLinks) {
$iterator->next();
continue;
}
if ($iterator->isFile()) {
unlink($iterator->getPathName());
} else {
if ($iterator->isDir()) {
rmdir($iterator->getPathName());
}
}
}
$iterator->next();
}
unset($iterator);
return rmdir($dirname);
}
示例11: GetDirectoryContent
public static function GetDirectoryContent($Directory)
{
$Iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Directory));
$FilesArray = array();
while ($Iterator->valid()) {
if (!$Iterator->isDot()) {
$FilesArray[] = array('FileLink' => $Iterator->key(), 'FileName' => $Iterator->getSubPathName());
}
$Iterator->next();
}
return $FilesArray;
}
示例12: get_all_files
private function get_all_files()
{
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->input_dir));
$result = array();
while ($iterator->valid()) {
if (!$iterator->isDot()) {
$result[$iterator->getSubPath()][] = $iterator->key();
}
$iterator->next();
}
return $result;
}
示例13: addTestDirectoryRecursive
public static function addTestDirectoryRecursive(PHPUnit_Framework_TestSuite $suite, $directory)
{
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
while ($it->valid()) {
if (!$it->isDot()) {
$file = $it->key();
if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__) {
$suite->addTestFile($file);
}
}
$it->next();
}
}
示例14: _getPluggableFiles
private function _getPluggableFiles()
{
$FilePaths = array();
$directory = new \RecursiveDirectoryIterator($this->directory);
foreach ($F = new \RecursiveIteratorIterator($directory) as $filepath) {
if (!$F->isDot() && $F->getDepth() === 1) {
if ($F->getBasename() === $this->filename) {
$FilePaths[] = $filepath;
}
}
}
return $FilePaths;
}
示例15: countThemePages
protected function countThemePages($path)
{
$result = 0;
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
$it->setMaxDepth(1);
while ($it->valid()) {
if (!$it->isDot() && !$it->isDir() && $it->getExtension() == 'htm') {
$result++;
}
$it->next();
}
return $result;
}