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


PHP RecursiveIteratorIterator::getBaseName方法代码示例

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


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

示例1: process

 /**
  * @param array $preprocvars     list of key/value representing variables for the preprocessor
  * @param bool  $preprocmanifest if true, the manifest file is preprocessed then the manifest
  *                               reader will used the generated manifest file instead of the given manifest file.
  */
 public function process($preprocvars, $preprocmanifest = false)
 {
     $this->preprocvars = $preprocvars;
     if ($preprocmanifest) {
         $this->preproc->setVars($preprocvars);
         try {
             $content = $this->preproc->parseFile($this->ficlist);
         } catch (\Exception $e) {
             throw new \Exception('cannot preprocess the manifest file ' . $this->ficlist . ' (' . $e . ")\n");
         }
         $script = explode("\n", $content);
     } else {
         $script = file($this->ficlist);
     }
     $currentdestdir = '';
     $currentsrcdir = '';
     foreach ($script as $nbline => $line) {
         ++$nbline;
         if (preg_match(';^(cd|sd|dd|\\*|!|\\*!|c|\\*c|cch)?\\s+([a-zA-Z0-9\\/.\\-_]+)\\s*(?:\\(([a-zA-Z0-9\\%\\/.\\-_]*)\\))?\\s*$;m', $line, $m)) {
             if ($m[1] == 'dd') {
                 // set destination dir
                 $currentdestdir = DirUtils::normalizeDir($m[2]);
                 $this->fs->createDir($currentdestdir);
             } elseif ($m[1] == 'sd') {
                 // set source dir
                 $currentsrcdir = DirUtils::normalizeDir($m[2]);
             } elseif ($m[1] == 'cd') {
                 // set source dir and destination dir (same sub path)
                 $currentsrcdir = DirUtils::normalizeDir($m[2]);
                 $currentdestdir = DirUtils::normalizeDir($m[2]);
                 $this->fs->createDir($currentdestdir);
             } else {
                 // copy a file
                 // should we do processing on the file?
                 $doPreprocessing = strpos($m[1], '*') !== false;
                 // should we compress files or generate encoded files?
                 $doCompression = strpos($m[1], 'c') !== false && $m[1] != 'cch' || $this->stripComment && strpos($m[1], '!') === false;
                 if ($m[2] == '') {
                     throw new \Exception($this->ficlist . ": file required on line {$nbline} \n");
                 }
                 if (!isset($m[3]) || $m[3] == '') {
                     $m[3] = $m[2];
                 }
                 if ($m[2] == '__ALL__') {
                     $dir = new \DirectoryIterator($this->sourcedir . $currentsrcdir);
                     foreach ($dir as $dirContent) {
                         if (!$dirContent->isFile()) {
                             continue;
                         }
                         $m[2] = $m[3] = $dirContent->getFileName();
                         $destfile = $currentdestdir . $m[3];
                         $sourcefile = $this->sourcedir . $currentsrcdir . $m[2];
                         $this->processFile($sourcefile, $destfile, $nbline, $m, $doPreprocessing, $doCompression);
                     }
                 } elseif ($m[2] == '__ALL_RECURSIVELY__') {
                     $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sourcedir . $currentsrcdir));
                     $it->rewind();
                     while ($it->valid()) {
                         if (!$it->isDot()) {
                             $this->fs->createDir($currentdestdir . $it->getSubPath());
                             $sourcefile = $this->sourcedir . $currentsrcdir . $it->getSubPath() . '/' . $it->getBaseName();
                             $destfile = $currentdestdir . $it->getSubPath() . '/' . $it->getBaseName();
                             $this->processFile($sourcefile, $destfile, $nbline, $m, $doPreprocessing, $doCompression);
                         }
                         $it->next();
                     }
                 } else {
                     $destfile = $currentdestdir . $m[3];
                     $sourcefile = $this->sourcedir . $currentsrcdir . $m[2];
                     $this->processFile($sourcefile, $destfile, $nbline, $m, $doPreprocessing, $doCompression);
                 }
             }
         } elseif (preg_match("!^\\s*(\\#.*)?\$!", $line)) {
             // we ignore comments
         } else {
             throw new \Exception($this->ficlist . ": syntax error on line {$nbline} \n");
         }
     }
 }
开发者ID:julieni,项目名称:BuildTools,代码行数:84,代码来源:Reader.php


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