当前位置: 首页>>代码示例>>PHP>>正文


PHP RecursiveIteratorIterator::rewind方法代码示例

本文整理汇总了PHP中RecursiveIteratorIterator::rewind方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::rewind方法的具体用法?PHP RecursiveIteratorIterator::rewind怎么用?PHP RecursiveIteratorIterator::rewind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RecursiveIteratorIterator的用法示例。


在下文中一共展示了RecursiveIteratorIterator::rewind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Parse

 /**
  * Parse a tarball of .gcov files.
  **/
 public function Parse($handle)
 {
     global $CDASH_BACKUP_DIRECTORY;
     // This function receives an open file handle, but we really just need
     // the path to this file so that we can extract it.
     $meta_data = stream_get_meta_data($handle);
     $filename = $meta_data["uri"];
     fclose($handle);
     // Create a new directory where we can extract our tarball.
     $pathParts = pathinfo($filename);
     $dirName = $CDASH_BACKUP_DIRECTORY . "/" . $pathParts['filename'];
     mkdir($dirName);
     // Extract the tarball.
     $phar = new PharData($filename);
     $phar->extractTo($dirName);
     // Find the data.json file and extract the source directory from it.
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == "data.json") {
             $jsonContents = file_get_contents($fileinfo->getRealPath());
             $jsonDecoded = json_decode($jsonContents, true);
             if (is_null($jsonDecoded) || !array_key_exists("Source", $jsonDecoded) || !array_key_exists("Binary", $jsonDecoded)) {
                 $this->DeleteDirectory($dirName);
                 return false;
             }
             $this->SourceDirectory = $jsonDecoded['Source'];
             $this->BinaryDirectory = $jsonDecoded['Binary'];
             break;
         }
     }
     if (empty($this->SourceDirectory) || empty($this->BinaryDirectory)) {
         $this->DeleteDirectory($dirName);
         return false;
     }
     // Check if any Labels.json files were included
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == "Labels.json") {
             $this->ParseLabelsFile($fileinfo);
         }
     }
     // Recursively search for .gcov files and parse them.
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         if (pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION) == "gcov") {
             $this->ParseGcovFile($fileinfo);
         }
     }
     // Insert coverage summary (removing any old results first)
     //$this->CoverageSummary->RemoveAll();
     $this->CoverageSummary->Insert();
     $this->CoverageSummary->ComputeDifference();
     // Delete the directory when we're done.
     $this->DeleteDirectory($dirName);
     return true;
 }
开发者ID:josephsnyder,项目名称:CDash,代码行数:59,代码来源:GcovTar_handler.php

示例2: 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 = time() - $CFG->tempdatafoldercleanup * 3600;
     $dir = new \RecursiveDirectoryIterator($tmpdir);
     // Show all child nodes prior to their parent.
     $iter = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::CHILD_FIRST);
     // An array of the full path (key) and date last modified.
     $modifieddateobject = array();
     // Get the time modified for each directory node. Nodes will be updated
     // once a file is deleted, so we need a list of the original values.
     for ($iter->rewind(); $iter->valid(); $iter->next()) {
         $node = $iter->getRealPath();
         if (!is_readable($node)) {
             continue;
         }
         $modifieddateobject[$node] = $iter->getMTime();
     }
     // Now loop through again and remove old files and directories.
     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 ($modifieddateobject[$node] < $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}'.");
                 }
             }
         } else {
             // Return the time modified to the original date only for real files.
             if ($iter->isDir() && !$iter->isDot()) {
                 touch($node, $modifieddateobject[$node]);
             }
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:53,代码来源:file_temp_cleanup_task.php

示例3: array_flatten

function array_flatten(array $array, $key_separator = '/')
{
    $result = array();
    // a stack of strings
    $keys = array();
    $prev_depth = -1;
    $iter = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::SELF_FIRST);
    // rewind() is necessary
    for ($iter->rewind(); $iter->valid(); $iter->next()) {
        $curr_depth = $iter->getDepth();
        $diff_depth = $prev_depth - $curr_depth + 1;
        //##### TODO: It would be nice to do this with a single function.
        while ($diff_depth > 0) {
            array_pop($keys);
            --$diff_depth;
        }
        /*
        Note:
        http://bugs.php.net/bug.php?id=52425
        array_shift/array_pop: add parameter that tells how many to elements to pop
        */
        array_push($keys, $iter->key());
        if (is_scalar($iter->current())) {
            $result[implode($key_separator, $keys)] = $iter->current();
        }
        $prev_depth = $curr_depth;
    }
    return $result;
}
开发者ID:grevutiu-gabriel,项目名称:iqatest,代码行数:29,代码来源:array_flatten.php

示例4: 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;
     }
 }
开发者ID:one-more,项目名称:peach_framework,代码行数:33,代码来源:autoloader.php

示例5: runTest

 /**
  * Executes a specific Selenium System Tests in your machine
  *
  * @param string $seleniumPath   Optional path to selenium-standalone-server-x.jar
  * @param string $pathToTestFile Optional name of the test to be run
  * @param string $suite          Optional name of the suite containing the tests, Acceptance by default.
  *
  * @return mixed
  */
 public function runTest($pathToTestFile = null, $suite = 'acceptance')
 {
     $this->runSelenium();
     // Make sure to Run the Build Command to Generate AcceptanceTester
     $this->_exec("php vendor/bin/codecept build");
     if (!$pathToTestFile) {
         $this->say('Available tests in the system:');
         $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('tests/' . $suite, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
         $tests = array();
         $iterator->rewind();
         $i = 1;
         while ($iterator->valid()) {
             if (strripos($iterator->getSubPathName(), 'cept.php') || strripos($iterator->getSubPathName(), 'cest.php')) {
                 $this->say('[' . $i . '] ' . $iterator->getSubPathName());
                 $tests[$i] = $iterator->getSubPathName();
                 $i++;
             }
             $iterator->next();
         }
         $this->say('');
         $testNumber = $this->ask('Type the number of the test  in the list that you want to run...');
         $test = $tests[$testNumber];
     }
     $pathToTestFile = 'tests/' . $suite . '/' . $test;
     $this->taskCodecept()->test($pathToTestFile)->arg('--steps')->arg('--debug')->run()->stopOnFail();
     // Kill selenium server
     // $this->_exec('curl http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer');
 }
开发者ID:remotehelp,项目名称:weblinks,代码行数:37,代码来源:RoboFile.php

示例6: getIterator

 /**
  * @return \RecursiveIteratorIterator
  */
 public function getIterator()
 {
     //$iterator = new FileSearchIterator($this->baseDir, $this->pattern, $this->buildFlag());
     if (!is_null($this->iterator)) {
         $this->iterator->rewind();
         return $this->iterator;
     }
     $iterator = new \RecursiveDirectoryIterator($this->baseDir, $this->buildFlag());
     if ($this->ignoreVcsFiles) {
         $this->ignore = array_merge($this->ignore, static::$vcsFiles);
     }
     if (!empty($this->ignore)) {
         $iterator = new DirectoryExcludeFilter($iterator, $this->ignore);
     }
     if ($this->searchFor === static::SEARCH_FILES) {
         $iterator = new FilenameRegexFilter($iterator, $this->pattern);
     } else {
         $iterator = new DirectoryRegexFilter($iterator, $this->pattern);
     }
     if (!empty($this->filters)) {
         $iterator = $this->addFilters($iterator);
     }
     $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
     return $this->iterator = $iterator;
 }
开发者ID:core-framework,项目名称:core,代码行数:28,代码来源:Explorer.php

示例7: locate

 /**
  * @param $target
  * @return array
  */
 public function locate($target)
 {
     $paths = [];
     $target = sprintf("%s/%s", self::RESOURCE_SUFFIX, $target);
     foreach ($this->locations as $location) {
         if (!is_dir($location)) {
             continue;
         }
         $location = realpath($location);
         $dir = new \RecursiveDirectoryIterator($location, \FilesystemIterator::FOLLOW_SYMLINKS);
         $filter = new \RecursiveCallbackFilterIterator($dir, function (\SplFileInfo $current) use(&$paths, $target) {
             $fileName = strtolower($current->getFilename());
             if ($this->isExcluded($fileName) || $current->isFile()) {
                 return false;
             }
             if (!is_dir($current->getPathname() . '/Resources')) {
                 return true;
             } else {
                 $file = $current->getPathname() . sprintf("/Resources/%s", $target);
                 if (is_file($file)) {
                     $paths[] = $file;
                 }
                 return false;
             }
         });
         $iterator = new \RecursiveIteratorIterator($filter);
         $iterator->rewind();
     }
     return $paths;
 }
开发者ID:EvoCommerceTeam,项目名称:DistribuitionBundle,代码行数:34,代码来源:PlatformResourceLocator.php

示例8: unlinkDirectory

 private static function unlinkDirectory($path)
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
     $iterator->rewind();
     $files = array();
     $directories = array();
     foreach ($iterator as $path => $directory) {
         if (is_file($path)) {
             $files[] = $path;
         } elseif (is_dir($path)) {
             $directories[] = $path;
         }
     }
     // Remove the files, then the directories
     foreach ($files as $filePath) {
         self::unlinkFile($filePath);
     }
     foreach ($directories as $dirPath) {
         rmdir($dirPath);
     }
     // Finally, remove the path itself
     if (is_dir($path)) {
         rmdir($path);
     }
 }
开发者ID:enygma,项目名称:composerclean,代码行数:25,代码来源:Clean.php

示例9: testRecursiveIterator

 public function testRecursiveIterator()
 {
     $document = $this->createDocument();
     $iterator = new RecursiveDomIterator($document);
     $iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
     $iterator->rewind();
     $this->assertEquals('html', $iterator->current()->tagName);
     $iterator->next();
     $this->assertEquals('head', $iterator->current()->tagName);
     $iterator->next();
     $this->assertEquals('title', $iterator->current()->tagName);
     $iterator->next();
     $this->assertEquals('Hello World', $iterator->current()->textContent);
     $iterator->next();
     $this->assertEquals('body', $iterator->current()->tagName);
     $iterator->next();
     $this->assertEquals('div', $iterator->current()->tagName);
     $iterator->next();
     $this->assertEquals('p', $iterator->current()->tagName);
     $iterator->next();
     $this->assertEquals('foo', $iterator->current()->textContent);
     $iterator->next();
     $this->assertEquals('div', $iterator->current()->tagName);
     $iterator->next();
     $this->assertEquals('p', $iterator->current()->tagName);
     $iterator->next();
     $this->assertEquals('bar', $iterator->current()->textContent);
 }
开发者ID:blar,项目名称:dom,代码行数:28,代码来源:RecursiveDomIteratorTest.php

示例10: rmdir

	public function rmdir($path) {
		if (!$this->isDeletable($path)) {
			return false;
		}
		try {
			$it = new \RecursiveIteratorIterator(
				new \RecursiveDirectoryIterator($this->getSourcePath($path)),
				\RecursiveIteratorIterator::CHILD_FIRST
			);
			/**
			 * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach
			 * This bug is fixed in PHP 5.5.9 or before
			 * See #8376
			 */
			$it->rewind();
			while ($it->valid()) {
				/**
				 * @var \SplFileInfo $file
				 */
				$file = $it->current();
				if (in_array($file->getBasename(), array('.', '..'))) {
					$it->next();
					continue;
				} elseif ($file->isDir()) {
					rmdir($file->getPathname());
				} elseif ($file->isFile() || $file->isLink()) {
					unlink($file->getPathname());
				}
				$it->next();
			}
			return rmdir($this->getSourcePath($path));
		} catch (\UnexpectedValueException $e) {
			return false;
		}
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:35,代码来源:local.php

示例11: 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}'.");
                 }
             }
         }
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:36,代码来源:file_temp_cleanup_task.php

示例12: endChildren

 function endChildren()
 {
     global $count;
     echo $this->getDepth();
     if (--$count > 0) {
         // Trigger use-after-free
         parent::rewind();
     }
 }
开发者ID:gleamingthecube,项目名称:php,代码行数:9,代码来源:ext_spl_tests_bug69970.php

示例13: countThemePages

 protected function countThemePages($path)
 {
     $result = 0;
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
     $it->setMaxDepth(1);
     $it->rewind();
     while ($it->valid()) {
         if (!$it->isDot() && !$it->isDir() && $it->getExtension() == 'htm') {
             $result++;
         }
         $it->next();
     }
     return $result;
 }
开发者ID:360weboy,项目名称:october,代码行数:14,代码来源:ThemeTest.php

示例14: delete

 public function delete()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $moduleobject = $this->_uses[$this->modeltype];
     $db = DB::Instance();
     $db->StartTrans();
     if ($moduleobject->isLoaded()) {
         $modulename = $moduleobject->name;
         $modulelocation = FILE_ROOT . $moduleobject->location;
         if ($moduleobject->enabled && !$moduleobject->disable()) {
             $errors[] = 'Failed to disable module';
         }
         if ($moduleobject->registered && !$moduleobject->unregister()) {
             $errors[] = 'Failed to unregister module';
         }
         if (!$moduleobject->delete()) {
             $errors[] = 'Failed to delete module';
         } else {
             $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($modulelocation), RecursiveIteratorIterator::CHILD_FIRST);
             for ($dir->rewind(); $dir->valid(); $dir->next()) {
                 if ($dir->isDir()) {
                     rmdir($dir->getPathname());
                 } else {
                     unlink($dir->getPathname());
                 }
             }
             rmdir($modulelocation);
         }
     } else {
         $errors[] = 'Cannot find module';
     }
     $flash = Flash::Instance();
     if (count($errors) > 0) {
         $db->FailTrans();
         $flash->addErrors($errors);
         if (isset($this->_data['id'])) {
             $db->CompleteTrans();
             sendTo($this->name, 'view', $this->_modules, array('id' => $this->_data['id']));
         }
     } else {
         $flash->addMessage('Module ' . $modulename . ' deleted OK');
     }
     $db->CompleteTrans();
     sendTo($this->name, 'index', $this->_modules);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:48,代码来源:ModuleobjectsController.php

示例15: suite

 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite('Test Suite');
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/Test'));
     for ($it->rewind(); $it->valid(); $it->next()) {
         // Something like: Test\Application\Modules\Main\Controllers\Index.php
         $path = "Test\\" . $it->getInnerIterator()->getSubPathname();
         // Replace all of the \ with _
         $className = str_replace('\\', "_", $path);
         // Take off the extension
         $className = substr($className, 0, -4);
         require_once $path;
         $suite->addTestSuite($className);
     }
     return $suite;
 }
开发者ID:TheSavior,项目名称:WhiteBoard,代码行数:16,代码来源:AllTests.php


注:本文中的RecursiveIteratorIterator::rewind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。