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


PHP PhingFile::lastModified方法代码示例

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


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

示例1: copyFile

 /**
  * Copies a file using filter chains.
  * 
  * @param PhingFile $sourceFile
  * @param PhingFile $destFile
  * @param boolean $overwrite
  * @param boolean $preserveLastModified
  * @param array $filterChains 
  * @param Project $project
  * @return void
  */
 function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false, $preserveLastModified = true, &$filterChains = null, Project $project)
 {
     if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
         if ($destFile->exists() && $destFile->isFile()) {
             $destFile->delete();
         }
         // ensure that parent dir of dest file exists!
         $parent = $destFile->getParentFile();
         if ($parent !== null && !$parent->exists()) {
             $parent->mkdirs();
         }
         if (is_array($filterChains) && !empty($filterChains)) {
             $in = self::getChainedReader(new BufferedReader(new FileReader($sourceFile)), $filterChains, $project);
             $out = new BufferedWriter(new FileWriter($destFile));
             // New read() methods returns a big buffer.
             while (-1 !== ($buffer = $in->read())) {
                 // -1 indicates EOF
                 $out->write($buffer);
             }
             if ($in !== null) {
                 $in->close();
             }
             if ($out !== null) {
                 $out->close();
             }
         } else {
             // simple copy (no filtering)
             $sourceFile->copyTo($destFile);
         }
         if ($preserveLastModified) {
             $destFile->setLastModified($sourceFile->lastModified());
         }
     }
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:45,代码来源:FileUtils.php

示例2: copyFile

 /**
  * Copies a file using filter chains.
  *
  * @param  PhingFile $sourceFile
  * @param  PhingFile $destFile
  * @param  boolean   $overwrite
  * @param  boolean   $preserveLastModified
  * @param  array     $filterChains
  * @param  Project   $project
  * @param  integer   $mode
  * @param bool       $preservePermissions
  *
  * @throws Exception
  * @throws IOException
  * @return void
  */
 public function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false, $preserveLastModified = true, &$filterChains = null, Project $project, $mode = 0755, $preservePermissions = true)
 {
     if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
         if ($destFile->exists() && $destFile->isFile()) {
             $destFile->delete();
         }
         // ensure that parent dir of dest file exists!
         $parent = $destFile->getParentFile();
         if ($parent !== null && !$parent->exists()) {
             // Setting source directory permissions to target
             // (On permissions preservation, the target directory permissions
             // will be inherited from the source directory, otherwise the 'mode'
             // will be used)
             $dirMode = $preservePermissions ? $sourceFile->getParentFile()->getMode() : $mode;
             $parent->mkdirs($dirMode);
         }
         if (is_array($filterChains) && !empty($filterChains)) {
             $in = self::getChainedReader(new BufferedReader(new FileReader($sourceFile)), $filterChains, $project);
             $out = new BufferedWriter(new FileWriter($destFile));
             // New read() methods returns a big buffer.
             while (-1 !== ($buffer = $in->read())) {
                 // -1 indicates EOF
                 $out->write($buffer);
             }
             if ($in !== null) {
                 $in->close();
             }
             if ($out !== null) {
                 $out->close();
             }
             // Set/Copy the permissions on the target
             if ($preservePermissions === true) {
                 $destFile->setMode($sourceFile->getMode());
             }
         } else {
             // simple copy (no filtering)
             $sourceFile->copyTo($destFile);
             // By default, PHP::Copy also copies the file permissions. Therefore,
             // re-setting the mode with the "user file-creation mask" information.
             if ($preservePermissions === false) {
                 $destFile->setMode(FileUtils::getDefaultFileCreationMask(false, true));
             }
         }
         if ($preserveLastModified && !$destFile->isLink()) {
             $destFile->setLastModified($sourceFile->lastModified());
         }
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:64,代码来源:FileUtils.php

示例3: doWork

 /**
  * Actually copies the files
  *
  * @access  private
  * @return  void
  * @throws  BuildException
  */
 protected function doWork()
 {
     // These "slots" allow filters to retrieve information about the currently-being-process files
     $fromSlot = $this->getRegisterSlot("currentFromFile");
     $fromBasenameSlot = $this->getRegisterSlot("currentFromFile.basename");
     $toSlot = $this->getRegisterSlot("currentToFile");
     $toBasenameSlot = $this->getRegisterSlot("currentToFile.basename");
     $mapSize = count($this->fileCopyMap);
     $total = $mapSize;
     // handle empty dirs if appropriate
     if ($this->includeEmpty) {
         $count = 0;
         foreach ($this->dirCopyMap as $srcdir => $destdir) {
             $s = new PhingFile((string) $srcdir);
             $d = new PhingFile((string) $destdir);
             if (!$d->exists()) {
                 if (!$d->mkdirs()) {
                     $this->logError("Unable to create directory " . $d->__toString());
                 } else {
                     if ($this->preserveLMT) {
                         $d->setLastModified($s->lastModified());
                     }
                     $count++;
                 }
             }
         }
         if ($count > 0) {
             $this->log("Created " . $count . " empty director" . ($count == 1 ? "y" : "ies") . " in " . $this->destDir->getAbsolutePath());
         }
     }
     if ($mapSize > 0) {
         $this->log("Copying " . $mapSize . " file" . ($mapSize === 1 ? '' : 's') . " to " . $this->destDir->getAbsolutePath());
         // walks the map and actually copies the files
         $count = 0;
         foreach ($this->fileCopyMap as $from => $to) {
             if ($from === $to) {
                 $this->log("Skipping self-copy of " . $from, $this->verbosity);
                 $total--;
                 continue;
             }
             $this->log("From " . $from . " to " . $to, $this->verbosity);
             try {
                 // try to copy file
                 $fromFile = new PhingFile($from);
                 $toFile = new PhingFile($to);
                 $fromSlot->setValue($fromFile->getPath());
                 $fromBasenameSlot->setValue($fromFile->getName());
                 $toSlot->setValue($toFile->getPath());
                 $toBasenameSlot->setValue($toFile->getName());
                 $this->fileUtils->copyFile($fromFile, $toFile, $this->overwrite, $this->preserveLMT, $this->filterChains, $this->getProject(), $this->mode);
                 $count++;
             } catch (IOException $ioe) {
                 $this->logError("Failed to copy " . $from . " to " . $to . ": " . $ioe->getMessage());
             }
         }
     }
 }
开发者ID:sergeytsivin,项目名称:haru,代码行数:64,代码来源:CopyTask.php

示例4: isOutOfDate

 /**
  * Returns dependency information on these two files. If src has been
  * modified later than target, it returns true. If target doesn't exist,
  * it likewise returns true. Otherwise, target is newer than src and
  * is not out of date, thus the method returns false. It also returns
  * false if the src file doesn't even exist, since how could the
  * target then be out of date.
  *
  * @param PhingFile $src the original file
  * @param PhingFile $target the file being compared against
  * @param int $granularity the amount in seconds of slack we will give in
  *        determining out of dateness
  * @return whether the target is out of date
  */
 public static function isOutOfDate(PhingFile $src, PhingFile $target, $granularity)
 {
     if (!$src->exists()) {
         return false;
     }
     if (!$target->exists()) {
         return true;
     }
     if ($src->lastModified() - $granularity > $target->lastModified()) {
         return true;
     }
     return false;
 }
开发者ID:nhemsley,项目名称:phing,代码行数:27,代码来源:SelectorUtils.php

示例5: doWork

 /**
  * Actually copies the files
  *
  * @return void
  * @throws BuildException
  */
 protected function doWork()
 {
     // These "slots" allow filters to retrieve information about the currently-being-process files
     $fromSlot = $this->getRegisterSlot("currentFromFile");
     $fromBasenameSlot = $this->getRegisterSlot("currentFromFile.basename");
     $toSlot = $this->getRegisterSlot("currentToFile");
     $toBasenameSlot = $this->getRegisterSlot("currentToFile.basename");
     $mapSize = count($this->fileCopyMap);
     $total = $mapSize;
     // handle empty dirs if appropriate
     if ($this->includeEmpty) {
         $count = 0;
         foreach ($this->dirCopyMap as $srcdir => $destdir) {
             $s = new PhingFile((string) $srcdir);
             $d = new PhingFile((string) $destdir);
             if (!$d->exists()) {
                 // Setting source directory permissions to target
                 // (On permissions preservation, the target directory permissions
                 // will be inherited from the source directory, otherwise the 'mode'
                 // will be used)
                 $dirMode = $this->preservePermissions ? $s->getMode() : $this->mode;
                 // Directory creation with specific permission mode
                 if (!$d->mkdirs($dirMode)) {
                     $this->logError("Unable to create directory " . $d->__toString());
                 } else {
                     if ($this->preserveLMT) {
                         $d->setLastModified($s->lastModified());
                     }
                     $count++;
                 }
             }
         }
         if ($count > 0) {
             $this->log("Created " . $count . " empty director" . ($count == 1 ? "y" : "ies") . " in " . $this->destDir->getAbsolutePath());
         }
     }
     if ($mapSize == 0) {
         return;
     }
     $this->log("Copying " . $mapSize . " file" . ($mapSize === 1 ? '' : 's') . " to " . $this->destDir->getAbsolutePath());
     // walks the map and actually copies the files
     $count = 0;
     foreach ($this->fileCopyMap as $from => $toFiles) {
         if (is_array($toFiles)) {
             foreach ($toFiles as $to) {
                 $this->copyToSingleDestination($from, $to, $fromSlot, $fromBasenameSlot, $toSlot, $toBasenameSlot, $count, $total);
             }
         } else {
             $this->copyToSingleDestination($from, $toFiles, $fromSlot, $fromBasenameSlot, $toSlot, $toBasenameSlot, $count, $total);
         }
     }
 }
开发者ID:vlajos,项目名称:phing,代码行数:58,代码来源:CopyTask.php

示例6: isSelected

 /**
  * The heart of the matter. This is where the selector gets to decide
  * on the inclusion of a file in a particular fileset.
  *
  * @param PhingFile $basedir the base directory the scan is being done from
  * @param string $filename is the name of the file to check
  * @param PhingFile $file is a PhingFile object the selector can use
  * @return boolean Whether the file should be selected or not
  */
 public function isSelected(PhingFile $basedir, $filename, PhingFile $file)
 {
     $this->validate();
     if ($file->isDirectory() && $this->includeDirs === false) {
         return true;
     }
     if ($this->cmp === 0) {
         return $file->lastModified() - $this->granularity < $this->seconds;
     } elseif ($this->cmp === 1) {
         return $file->lastModified() - $this->granularity > $this->seconds;
     } else {
         return abs($file->lastModified() - $this->seconds) <= $this->granularity;
     }
 }
开发者ID:andrew-ejov,项目名称:start-template,代码行数:23,代码来源:DateSelector.php

示例7: selectionTest

 /**
  * This test is our selection test that compared the file with the destfile.
  *
  * @param PhingFile $srcfile the source file
  * @param PhingFile $destfile the destination file
  * @return bool true if the files are different
  *
  * @throws BuildException
  */
 protected function selectionTest(PhingFile $srcfile, PhingFile $destfile)
 {
     try {
         // if either of them is missing, they are different
         if ($srcfile->exists() !== $destfile->exists()) {
             return true;
         }
         if ($srcfile->length() !== $destfile->length()) {
             // different size => different files
             return true;
         }
         if (!$this->ignoreFileTimes) {
             // different dates => different files
             if ($destfile->lastModified() !== $srcfile->lastModified()) {
                 return true;
             }
         }
         if (!$this->ignoreContents) {
             //here do a bulk comparison
             $fu = new FileUtils();
             return !$fu->contentEquals($srcfile, $destfile);
         }
     } catch (IOException $e) {
         throw new BuildException("while comparing {$srcfile} and {$destfile}", $e);
     }
     return false;
 }
开发者ID:Geeklog-Japan,项目名称:geeklog-japan,代码行数:36,代码来源:DifferentSelector.php

示例8: _writeFile

 /**
  * Writing a file.
  * 
  * @param  PhingFile $file    The file to write
  * @param  mixed     $content The file's content
  * @return void
  * @throws BuildException
  * @access protected
  **/
 protected function _writeFile(PhingFile $file, $content)
 {
     if ($this->_preserveLastModified) {
         $lastModified = $file->lastModified();
     }
     $output = new FileWriter($file);
     $output->write($content);
     $output->close();
     if ($this->_preserveLastModified) {
         $file->setLastModified($lastModified);
     }
 }
开发者ID:piouPiouM,项目名称:phing-header,代码行数:21,代码来源:HeaderTask.php

示例9: 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

示例10: generateURL

 public function generateURL(PhingFile $file)
 {
     //Build modified param to help with caching
     $modtime = $file->lastModified();
     $mod_param = $modtime !== 0 ? "?{$modtime}" : '';
     //Build path to actual file
     $folder = !empty($this->assetFolder) ? $this->assetFolder : '';
     $url_path = $folder . $this->file;
     return sprintf("%s%s%s", $this->url, $url_path, $mod_param);
 }
开发者ID:rcrowe,项目名称:phing-asset,代码行数:10,代码来源:Asset.php


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