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


PHP PhingFile::equals方法代码示例

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


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

示例1: areFilesetsUpToDate

 /**
  * @return array
  * @throws BuildException
  */
 public function areFilesetsUpToDate()
 {
     foreach ($this->filesets as $fs) {
         $files = $fs->getFiles($this->project, $this->includeEmpty);
         if (!$this->archiveIsUpToDate($files, $fs->getDir($this->project))) {
             return false;
         }
         for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
             if ($this->zipFile->equals(new PhingFile($fs->getDir($this->project), $files[$i]))) {
                 throw new BuildException("A zip file cannot include itself", $this->getLocation());
             }
         }
     }
     return true;
 }
开发者ID:alangalipaud,项目名称:ProjetQCM,代码行数:19,代码来源:ZipTask.php

示例2: main

 /**
  * do the work
  * @throws BuildException
  */
 public function main()
 {
     if ($this->zipFile === null) {
         throw new BuildException("zipfile attribute must be set!", $this->getLocation());
     }
     if ($this->zipFile->exists() && $this->zipFile->isDirectory()) {
         throw new BuildException("zipfile is a directory!", $this->getLocation());
     }
     if ($this->zipFile->exists() && !$this->zipFile->canWrite()) {
         throw new BuildException("Can not write to the specified zipfile!", $this->getLocation());
     }
     // shouldn't need to clone, since the entries in filesets
     // themselves won't be modified -- only elements will be added
     $savedFileSets = $this->filesets;
     try {
         if ($this->baseDir !== null) {
             if (!$this->baseDir->exists()) {
                 throw new BuildException("basedir does not exist!", $this->getLocation());
             }
             if (empty($this->filesets)) {
                 // add the main fileset to the list of filesets to process.
                 $mainFileSet = new ZipFileSet($this->fileset);
                 $mainFileSet->setDir($this->baseDir);
                 $this->filesets[] = $mainFileSet;
             }
         }
         if (empty($this->filesets)) {
             throw new BuildException("You must supply either a basedir " . "attribute or some nested filesets.", $this->getLocation());
         }
         // check if zip is out of date with respect to each
         // fileset
         $upToDate = true;
         foreach ($this->filesets as $fs) {
             $files = $fs->getFiles($this->project, $this->includeEmpty);
             if (!$this->archiveIsUpToDate($files, $fs->getDir($this->project))) {
                 $upToDate = false;
             }
             for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
                 if ($this->zipFile->equals(new PhingFile($fs->getDir($this->project), $files[$i]))) {
                     throw new BuildException("A zip file cannot include itself", $this->getLocation());
                 }
             }
         }
         if ($upToDate) {
             $this->log("Nothing to do: " . $this->zipFile->__toString() . " is up to date.", Project::MSG_INFO);
             return;
         }
         $this->log("Building zip: " . $this->zipFile->__toString(), Project::MSG_INFO);
         $zip = new Archive_Zip($this->zipFile->getAbsolutePath());
         foreach ($this->filesets as $fs) {
             $files = $fs->getFiles($this->project, $this->includeEmpty);
             $fsBasedir = null != $this->baseDir ? $this->baseDir : $fs->getDir($this->project);
             $filesToZip = array();
             for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
                 $f = new PhingFile($fsBasedir, $files[$i]);
                 $filesToZip[] = $f->getAbsolutePath();
                 $this->log("Adding " . $f->getPath() . " to archive.", Project::MSG_VERBOSE);
             }
             $zip->add($filesToZip, array('remove_path' => $fsBasedir->getCanonicalPath()));
         }
     } catch (IOException $ioe) {
         $msg = "Problem creating ZIP: " . $ioe->getMessage();
         $this->filesets = $savedFileSets;
         throw new BuildException($msg, $ioe, $this->getLocation());
     }
     $this->filesets = $savedFileSets;
 }
开发者ID:hunde,项目名称:bsc,代码行数:71,代码来源:ZipTask.php

示例3: main

 /**
  * do the work
  * @throws BuildException
  */
 public function main()
 {
     if (!extension_loaded('zip')) {
         throw new BuildException("Zip extension is required");
     }
     if ($this->zipFile === null) {
         throw new BuildException("zipfile attribute must be set!", $this->getLocation());
     }
     if ($this->zipFile->exists() && $this->zipFile->isDirectory()) {
         throw new BuildException("zipfile is a directory!", $this->getLocation());
     }
     if ($this->zipFile->exists() && !$this->zipFile->canWrite()) {
         throw new BuildException("Can not write to the specified zipfile!", $this->getLocation());
     }
     // shouldn't need to clone, since the entries in filesets
     // themselves won't be modified -- only elements will be added
     $savedFileSets = $this->filesets;
     try {
         if ($this->baseDir !== null) {
             if (!$this->baseDir->exists()) {
                 throw new BuildException("basedir '" . (string) $this->baseDir . "' does not exist!", $this->getLocation());
             }
             if (empty($this->filesets)) {
                 // add the main fileset to the list of filesets to process.
                 $mainFileSet = new ZipFileSet($this->fileset);
                 $mainFileSet->setDir($this->baseDir);
                 $this->filesets[] = $mainFileSet;
             }
         }
         if (empty($this->filesets)) {
             throw new BuildException("You must supply either a basedir " . "attribute or some nested filesets.", $this->getLocation());
         }
         // check if zip is out of date with respect to each
         // fileset
         $upToDate = true;
         foreach ($this->filesets as $fs) {
             $files = $fs->getFiles($this->project, $this->includeEmpty);
             if (!$this->archiveIsUpToDate($files, $fs->getDir($this->project))) {
                 $upToDate = false;
             }
             for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
                 if ($this->zipFile->equals(new PhingFile($fs->getDir($this->project), $files[$i]))) {
                     throw new BuildException("A zip file cannot include itself", $this->getLocation());
                 }
             }
         }
         if ($upToDate) {
             $this->log("Nothing to do: " . $this->zipFile->__toString() . " is up to date.", Project::MSG_INFO);
             return;
         }
         $this->log("Building zip: " . $this->zipFile->__toString(), Project::MSG_INFO);
         $zip = new ZipArchive();
         $res = $zip->open($this->zipFile->getAbsolutePath(), ZIPARCHIVE::CREATE);
         if ($res !== true) {
             throw new Exception("ZipArchive::open() failed with code " . $res);
         }
         foreach ($this->filesets as $fs) {
             $fsBasedir = null != $this->baseDir ? $this->baseDir : $fs->getDir($this->project);
             $files = $fs->getFiles($this->project, $this->includeEmpty);
             $filesToZip = array();
             for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
                 $f = new PhingFile($fsBasedir, $files[$i]);
                 $pathInZip = $this->prefix . $f->getPathWithoutBase($fsBasedir);
                 $pathInZip = str_replace('\\', '/', $pathInZip);
                 if ($f->isDirectory()) {
                     if ($pathInZip != '.') {
                         $zip->addEmptyDir($pathInZip);
                     }
                 } else {
                     $zip->addFile($f->getPath(), $pathInZip);
                 }
                 $this->log("Adding " . $f->getPath() . " as " . $pathInZip . " to archive.", Project::MSG_VERBOSE);
             }
         }
         $zip->close();
     } catch (IOException $ioe) {
         $msg = "Problem creating ZIP: " . $ioe->getMessage();
         $this->filesets = $savedFileSets;
         throw new BuildException($msg, $ioe, $this->getLocation());
     }
     $this->filesets = $savedFileSets;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:86,代码来源:ZipTask.php

示例4: checkFilename

 private function checkFilename($filename, $dir = null)
 {
     if ($dir !== null) {
         $f = new PhingFile($dir, $filename);
     } else {
         $f = new PhingFile($filename);
     }
     if (!$f->exists()) {
         $this->log("File " . (string) $f . " does not exist.", Project::MSG_ERR);
         return false;
     }
     if ($this->to !== null && $f->equals($this->to)) {
         throw new BuildException("Input file \"" . $f . "\" " . "is the same as the output file.");
     }
     if ($this->to !== null && !$this->overwrite && $this->to->exists() && $f->lastModified() > $this->to->lastModified()) {
         $this->log((string) $this->to . " is up-to-date.", Project::MSG_VERBOSE);
         return false;
     }
     return true;
 }
开发者ID:kenguest,项目名称:phing,代码行数:20,代码来源:AppendTask.php


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