當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhingFile::getParentFile方法代碼示例

本文整理匯總了PHP中PhingFile::getParentFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhingFile::getParentFile方法的具體用法?PHP PhingFile::getParentFile怎麽用?PHP PhingFile::getParentFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PhingFile的用法示例。


在下文中一共展示了PhingFile::getParentFile方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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

 function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false, $preserveLastModified = true, &$filterChains = null, Project $project)
 {
     // writes to tmp file first, then rename it to avoid file locking race
     // conditions
     $parent = $destFile->getParentFile();
     $tmpFile = new PhingFile($parent, substr(md5(time()), 0, 8));
     parent::copyFile($sourceFile, $tmpFile, $overwrite, $preserveLastModified, $filterChains, $project);
     $tmpFile->renameTo($destFile);
 }
開發者ID:hellogerard,項目名稱:phing-things,代碼行數:9,代碼來源:ConsistentCopy.php

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

示例4: renameFile

 /**
  * Attempts to rename a file from a source to a destination.
  * If overwrite is set to true, this method overwrites existing file
  * even if the destination file is newer.
  * Otherwise, the source f
  * ile is renamed only if the destination file #
  * is older than it.
  */
 private function renameFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite)
 {
     $renamed = true;
     // ensure that parent dir of dest file exists!
     $parent = $destFile->getParentFile();
     if ($parent !== null) {
         if (!$parent->exists()) {
             $parent->mkdirs();
         }
     }
     if ($destFile->exists()) {
         try {
             $destFile->delete();
         } catch (Exception $e) {
             throw new BuildException("Unable to remove existing file " . $destFile->__toString() . ": " . $e->getMessage());
         }
     }
     $renamed = $sourceFile->renameTo($destFile);
     return $renamed;
 }
開發者ID:sensorsix,項目名稱:app,代碼行數:28,代碼來源:MoveTask.php

示例5: setFile

 public function setFile(PhingFile $file)
 {
     $this->setDir($file->getParentFile());
     $this->createInclude()->setName($file->getName());
 }
開發者ID:Geeklog-Japan,項目名稱:geeklog-japan,代碼行數:5,代碼來源:AbstractFileSet.php


注:本文中的PhingFile::getParentFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。