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


PHP DirectoryIterator类代码示例

本文整理汇总了PHP中DirectoryIterator的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryIterator类的具体用法?PHP DirectoryIterator怎么用?PHP DirectoryIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: fromFileScan

 /**
  * @ignore
  */
 public static function fromFileScan($uPattern)
 {
     $tSep = quotemeta(DIRECTORY_SEPARATOR);
     $tPos = strrpos($uPattern, $tSep);
     if ($tSep !== '/' && $tPos === false) {
         $tSep = '/';
         $tPos = strrpos($uPattern, $tSep);
     }
     if ($tPos !== false) {
         $tPattern = substr($uPattern, $tPos + strlen($tSep));
         $tPath = substr($uPattern, 0, $tPos + strlen($tSep));
     } else {
         $tPath = $uPattern;
         $tPattern = "";
     }
     $tTemp = new static();
     $tHandle = new \DirectoryIterator($tPath);
     $tPatExists = strlen($uPattern) > 0;
     for (; $tHandle->valid(); $tHandle->next()) {
         if (!$tHandle->isFile()) {
             continue;
         }
         $tFile = $tHandle->current();
         if ($tPatExists && !fnmatch($tPattern, $tFile)) {
             continue;
         }
         $tTemp->add(simplexml_load_file($tPath . $tFile));
     }
     return $tTemp;
 }
开发者ID:eserozvataf,项目名称:scabbia1,代码行数:33,代码来源:XmlCollection.php

示例2: getImgArray

 /**
  * Obtem um array de ImgObject com todos os arquivos de imagens dos 
  * diretórios especificados
  * 
  * @param int|null $limit
  * @return array
  */
 public function getImgArray($limit = null)
 {
     $imgArray = array();
     foreach ($this->getDir() as $diretorio) {
         $imgArray = array();
         $d = new DirectoryIterator($diretorio);
         while ($d->valid()) {
             if (!$d->isDot()) {
                 $fileName = $d->getFilename();
                 if ($this->validateFormat($fileName)) {
                     $imgObj = new ImgObject($fileName, $diretorio);
                     $imgArray[] = $imgObj;
                     ++$this->imgCount;
                     if ($limit != null) {
                         if ($this->imgCount >= $limit) {
                             break;
                         }
                     }
                 }
             }
             $d->next();
         }
     }
     return $imgArray;
 }
开发者ID:laiello,项目名称:samusframework,代码行数:32,代码来源:ImgDir.php

示例3: index

 public function index($args)
 {
     $t = Registry::getInstance()->twig->loadTemplate('form/filepicker.tpl');
     $c = array();
     $localpath = Functions::nz($args['path'], '');
     $mediapath = SITE_PATH . '/media/';
     $dir = new \DirectoryIterator($mediapath . $localpath);
     $picformats = array('png', 'jpg', 'gif');
     $files = array();
     foreach ($dir as $file) {
         if (!$dir->isDot()) {
             $path = URL_PATH . '/media/' . $localpath . $file;
             $f = new \stdClass();
             if (strlen($file) > 4 && in_array(substr($file, -3), $picformats)) {
                 $picture = $path;
             } elseif ($dir->isDir()) {
                 $picture = TEMPLATE_PATH . 'form/pics/folder.png';
             } else {
                 $picture = TEMPLATE_PATH . 'form/pics/file.png';
             }
             $f->path = $localpath;
             $f->picture = $picture;
             $f->name = (string) $file;
             $f->type = $dir->isDir() ? 'dir' : 'file';
             $files[] = $f;
         }
     }
     $c['files'] = $files;
     $t->display($c);
 }
开发者ID:johsbk,项目名称:penguin,代码行数:30,代码来源:Filepicker.php

示例4: executeDir

 function executeDir($directory)
 {
     $iterator = new DirectoryIterator($directory);
     while ($iterator->valid()) {
         $entry = $iterator->getFilename();
         $path = $directory . '/' . $entry;
         $iterator->next();
         if ($entry[0] == '.') {
             continue;
         }
         if (is_file($path)) {
             if (substr($entry, -4) != '.php') {
                 continue;
             }
             if (ctype_upper($entry[0])) {
                 $test = new DocTest($path);
                 if ($test->failed()) {
                     echo $test->toString();
                     $this->fail('Doc test failed.');
                 } else {
                     if ($test->numOfPassed()) {
                         echo ',';
                     } else {
                         echo ' ';
                     }
                 }
             }
         } elseif (is_dir($path)) {
             $this->executeDir($path);
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:ubook-svn,代码行数:32,代码来源:DocumentationTest.php

示例5: ProcessFile

 protected function ProcessFile(DirectoryIterator $pParent, DirectoryIterator $pNode)
 {
     $oldname = $pNode->getPathname();
     $newname = $pParent->getPath() . '\\' . $this->GetLastFolderName($pParent->getPath()) . '.dds';
     rename($oldname, $newname);
     echo '<p>rename <b>' . $oldname . '</b> to <b>' . $newname . '<br/></p>';
 }
开发者ID:rizaramadan,项目名称:folder-walking,代码行数:7,代码来源:renamer.php

示例6: collectSchema

 /**
  * Collect schema from wordpress active theme
  * 
  * @return boolean true on success false if color schema folder is not exists
  *                 in the active theme folder
  */
 public function collectSchema()
 {
     $options = $this->getOptions();
     $path = get_template_directory() . $options['path'];
     // make sure that the color schema folder exsists
     if (!file_exists($path) || !is_dir($path)) {
         return;
         // just ignore
     }
     // register the new color schema
     $contents = new \DirectoryIterator($path);
     foreach ($contents as $content) {
         if ($contents->isDot()) {
             continue;
         }
         if ($contents->isDir()) {
             $name = $content->getFilename();
             $init = parse_ini_file($content->getPathname() . '/schema.ini');
             if (!is_array($init)) {
                 trigger_error('Unbale Admin Color Schema Config File', E_USER_ERROR);
             }
             $suffix = is_rtl() ? '-rtl' : '';
             $url = get_template_directory_uri() . $options['path'] . '/' . $name . "/colors{$suffix}.css";
             wp_admin_css_color($name, __(isset($init['name']) && !empty($init['name']) ? $init['name'] : $name, isset($init['domain']) && !empty($init['domain']) ? $init['domain'] : 'default'), $url, isset($init['colors']) && is_array($init['colors']) ? $init['colors'] : array(), isset($init['icons']) && is_array($init['icons']) ? $init['icons'] : array());
         }
     }
 }
开发者ID:hyyan,项目名称:admin-color-schema,代码行数:33,代码来源:HyyanAdminColorSchema.php

示例7: find_plugins

 /**
  * Find all plugins defined in your Kohana codebase
  */
 public function find_plugins()
 {
     $paths = Kohana::include_paths();
     foreach ($paths as $path) {
         $dir = $path . self::$plugins_dir;
         //if there's no plugin dir skip to the next path
         if (!file_exists($dir)) {
             continue;
         }
         // Instantiate a new directory iterator object
         $directory = new DirectoryIterator($dir);
         if ($directory->isDir()) {
             foreach ($directory as $plugin) {
                 // Is directory?
                 if ($plugin->isDir() && !$plugin->isDot()) {
                     // if there's no plugin.php in this folder, ignore it
                     if (!file_exists($plugin->getPath() . DIRECTORY_SEPARATOR . $directory->getBasename() . DIRECTORY_SEPARATOR . 'plugin.php')) {
                         continue;
                     }
                     // Store plugin in our pool
                     self::$plugins_pool[$plugin->getFilename()]['plugin'] = ucfirst($plugin->getFilename());
                     self::$plugins_pool[$plugin->getFilename()]['path'] = $plugin->getPath() . DIRECTORY_SEPARATOR . $directory->getBasename();
                 }
             }
         }
     }
     return $this;
 }
开发者ID:vheissu,项目名称:kohana-plugin-system,代码行数:31,代码来源:Plugins.php

示例8: exportpluginAction

 function exportpluginAction()
 {
     $aExtDir = array('ALYS.Report.Dictionary', 'ALYS.Report.Plugin');
     //		var_dump(LIB_PATH_ALYS);
     //		var_dump(EXT_PATH_ALYS);
     $LIB_PATH_ALYS = "D:\\htdocs\\work\\apps\\code\\l_project_web\\module\\ycheukf\\Report\\src\\Report\\Lib";
     $EXT_PATH_ALYS = "D:\\htdocs\\work\\apps\\code\\l_project_web\\module\\Application\\src\\Application\\YcheukfReportExt";
     foreach ($aExtDir as $sTmp) {
         $path = str_replace(".", '/', $sTmp);
         $sDirPath = $LIB_PATH_ALYS . '/' . $path;
         $sExtDirPath = $EXT_PATH_ALYS . '/' . str_replace("ALYS/", "", (string) $path);
         //扩展目录, 若需要改路径请改此处
         //	var_export($sDirPath);
         $it = new \DirectoryIterator($sDirPath);
         foreach ($it as $file) {
             if (!$it->isDot() && $file != '.svn' && $file != '.git') {
                 $this->recursiveMkdir($sExtDirPath, '0700');
                 copy($sDirPath . '/' . $file, $sExtDirPath . '/' . $file);
                 $sContent = file_get_contents($sExtDirPath . '/' . $file);
                 //					$sContent = preg_replace("/require_once\(\"".str_replace(".", '\/', $sTmp).".php\"\);/s", ' ', $sContent);
                 $sClassName = str_replace(".php", "", (string) $file);
                 preg_match_all('/namespace (.*);/', $sContent, $aMatch);
                 //					var_dump((string)$file);
                 //					var_dump($aMatch[1][0]);
                 $sContent = str_replace("namespace YcheukfReport\\Lib\\ALYS", 'namespace YcheukfReportExt', $sContent);
                 $sContent = preg_replace("/class ([^\\s]+?) extends ([^}]+?)\\{/s", 'class \\1 extends \\2\\' . $sClassName . '{', $sContent);
                 //			echo $sContent;
                 file_put_contents($sExtDirPath . '/' . $file, $sContent);
             }
         }
     }
     echo "\n\n export file to ext   ... DONE\n\n";
     exit;
 }
开发者ID:ycheukf,项目名称:report,代码行数:34,代码来源:DemoController.php

示例9: scanFolder

 protected function scanFolder($folder, &$position, $forFolders = true, $threshold_key = 'dir', $threshold_default = 50)
 {
     $registry = AEFactory::getConfiguration();
     // Initialize variables
     $arr = array();
     $false = false;
     if (!is_dir($folder) && !is_dir($folder . '/')) {
         return $false;
     }
     try {
         $di = new DirectoryIterator($folder);
     } catch (Exception $e) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!$di->valid()) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!empty($position)) {
         $di->seek($position);
         if ($di->key() != $position) {
             $position = null;
             return $arr;
         }
     }
     $counter = 0;
     $maxCounter = $registry->get("engine.scan.large.{$threshold_key}_threshold", $threshold_default);
     while ($di->valid()) {
         if ($di->isDot()) {
             $di->next();
             continue;
         }
         if ($di->isDir() != $forFolders) {
             $di->next();
             continue;
         }
         $ds = $folder == '' || $folder == '/' || @substr($folder, -1) == '/' || @substr($folder, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
         $dir = $folder . $ds . $di->getFilename();
         $data = _AKEEBA_IS_WINDOWS ? AEUtilFilesystem::TranslateWinPath($dir) : $dir;
         if ($data) {
             $counter++;
             $arr[] = $data;
         }
         if ($counter == $maxCounter) {
             break;
         } else {
             $di->next();
         }
     }
     // Determine the new value for the position
     $di->next();
     if ($di->valid()) {
         $position = $di->key() - 1;
     } else {
         $position = null;
     }
     return $arr;
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:59,代码来源:large.php

示例10: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->checkORMType($options['type']);
     parent::execute($arguments, $options);
     $this->_runInitTask();
     $options['application'] = $arguments['application'];
     // still no class_path given? take the default one!
     if (empty($options['class_path'])) {
         $options['class_path'] = $this->modelTypes[$options['type']]['default_model_path'];
     }
     if (!empty($options['skip_methods'])) {
         $methods = explode(',', $options['skip_methods']);
         foreach ($methods as $method) {
             array_push($this->skipMethods, $method);
         }
     }
     // a custom class given?
     if (!empty($options['class'])) {
         if (strpos($options['class_path'], ':') !== false) {
             throw new sfCommandException(': is not supported in class_path when specifying the class name.');
         }
         $options['libpath'] = $options['class_path'];
         $this->createTestClass($options, $options['target']);
         return;
     }
     $paths = explode(':', $options['class_path']);
     $namespaces = array();
     foreach ($paths as $path) {
         $finder = sfFinder::type('directory');
         $ignoredDirs = $this->modelTypes[$options['type']]['ignored_directory'];
         foreach ($ignoredDirs as $ignDir) {
             $finder = $finder->not_name($ignDir);
         }
         $dirs = $finder->in($path);
         foreach ($dirs as $dir) {
             if (is_dir($dir)) {
                 $namespaces[] = $dir;
             }
         }
     }
     $paths = array_merge($paths, $namespaces);
     foreach ($paths as $path) {
         $options['libpath'] = $path;
         $dir = new DirectoryIterator($path);
         $this->logSection('phpunit', sprintf('Searching %s', $path));
         while ($dir->valid()) {
             if (strpos($dir, '.php') !== false) {
                 $subfolder = basename(dirname($path . DIRECTORY_SEPARATOR . $dir));
                 $suffix = !empty($options['file_suffix']) ? $options['file_suffix'] : $this->modelTypes[$options['type']]['classFileSuffix'];
                 $options['class'] = str_replace($suffix, '', $dir);
                 $this->createTestClass($options, $subfolder);
             }
             $dir->next();
         }
     }
     $this->_runInitTask();
 }
开发者ID:harking,项目名称:sfPhpunitPlugin,代码行数:60,代码来源:sfPhpunitCreateModelsTestTask.class.php

示例11: pushItem

 /**
  * Overwrite in children to parse files according to our style.
  * @param array $listing
  * @param DirectoryIterator $item
  */
 public function pushItem(&$listing, DirectoryIterator $entry)
 {
     if (substr($filename = $entry->getFilename(), -4) == '.css') {
         // a reset stylesheet, always used
         if (strpos($stylename = $entry->getBasename('.css'), 'tripoli') !== FALSE) {
         } else {
             array_push($listing, $stylename);
         }
     }
 }
开发者ID:radekstepan,项目名称:Fireside,代码行数:15,代码来源:Layouts.php

示例12: cleanDir

 protected function cleanDir($dir)
 {
     $files = new \DirectoryIterator($dir);
     while ($files->valid()) {
         if (in_array(substr($files->current(), -2), ['.0', '.1'])) {
             unlink($dir . '/' . $files->current());
         }
         $files->next();
     }
 }
开发者ID:vtk13,项目名称:word-counter,代码行数:10,代码来源:Parser.php

示例13: compileFile

 private function compileFile(\DirectoryIterator $file)
 {
     $tag = file_get_contents($file->getPathname());
     $tagName = $file->getBasename('.html');
     $jsFunc = $this->extractJsFunction($tag, $tagName);
     $tagHtml = $this->removeJsFromTag($tag, $tagName);
     $tagHtml = str_replace('"', '\\"', $tagHtml);
     $tagHtml = preg_replace("/\r|\n/", "", $tagHtml);
     return 'riot.tag("' . $tagName . '", "' . $tagHtml . '", ' . $jsFunc . ');';
 }
开发者ID:josecelano,项目名称:php-ddd-cargo-sample,代码行数:10,代码来源:RiotCompiler.php

示例14: __construct

 function __construct($link)
 {
     $d = new DirectoryIterator($link);
     while ($d->valid()) {
         $file = $d->current();
         if (!$file->isDot()) {
             $this->files[] = $file->getFilename();
         }
         $d->next();
     }
     $this->path = $d->getPath();
 }
开发者ID:AzoteStark,项目名称:php-class-checkFolder,代码行数:12,代码来源:checkFolder.class.php

示例15: addFromFile

 /**
  * @param DirectoryIterator $file
  */
 private function addFromFile(DirectoryIterator $file)
 {
     $match = preg_match('/([^.]+)-custom.definition.json/', $file->getFilename(), $matches);
     if (!$match) {
         return;
     }
     $dictionaryName = $matches[1];
     $translations = $this->loadTranslations($file->getPathname());
     foreach ($translations as $translationName => $translations) {
         $this->includeTranslation($dictionaryName, $translationName, $translations);
     }
 }
开发者ID:baszoetekouw,项目名称:janus,代码行数:15,代码来源:CustomDictionaryLoader.php


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