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


PHP PhingFile::getMode方法代码示例

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


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

示例1: testCorrectModeSet

 public function testCorrectModeSet()
 {
     $this->executeTarget("test");
     $dir = new PhingFile(PHING_TEST_BASE . "/etc/regression/745/testdir");
     $mode = $dir->getMode() & 511;
     $this->assertEquals($mode, 511);
     $dir->delete(true);
 }
开发者ID:laiello,项目名称:lion-framework,代码行数:8,代码来源:MkdirTaskModeTest.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: copy

 /**
  * Copy a file.
  *
  * @param PhingFile $src Source path and name file to copy.
  * @param PhingFile $dest Destination path and name of new file.
  *
  * @return void     
  * @throws Exception if file cannot be copied.
  */
 function copy(PhingFile $src, PhingFile $dest)
 {
     global $php_errormsg;
     $srcPath = $src->getAbsolutePath();
     $destPath = $dest->getAbsolutePath();
     if (false === @copy($srcPath, $destPath)) {
         // Copy FAILED. Log and return err.
         // Add error from php to end of log message. $php_errormsg.
         $msg = "FileSystem::copy() FAILED. Cannot copy {$srcPath} to {$destPath}. {$php_errormsg}";
         throw new Exception($msg);
     }
     try {
         $dest->setMode($src->getMode());
     } catch (Exception $exc) {
         // [MA] does chmod returns an error on systems that do not support it ?
         // eat it up for now.
     }
 }
开发者ID:nhemsley,项目名称:phing,代码行数:27,代码来源:FileSystem.php

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

示例5: 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
  * @return void
  */
 function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false, $preserveLastModified = true, &$filterChains = null, Project $project, $mode = 0755)
 {
     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($mode);
         }
         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();
             }
             $destFile->setMode($sourceFile->getMode());
         } else {
             // simple copy (no filtering)
             $sourceFile->copyTo($destFile);
         }
         if ($preserveLastModified) {
             $destFile->setLastModified($sourceFile->lastModified());
         }
     }
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:47,代码来源:FileUtils.php

示例6: 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()) {
                 // 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) {
         $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, $this->preservePermissions);
                 $count++;
             } catch (IOException $ioe) {
                 $this->logError("Failed to copy " . $from . " to " . $to . ": " . $ioe->getMessage());
             }
         }
     }
 }
开发者ID:rozwell,项目名称:phing,代码行数:70,代码来源:CopyTask.php

示例7: copy

 /**
  * Copy a file.
  *
  * @param PhingFile $src  Source path and name file to copy.
  * @param PhingFile $dest Destination path and name of new file.
  *
  * @return void
  *
  * @throws IOException if file cannot be copied.
  */
 public function copy(PhingFile $src, PhingFile $dest)
 {
     global $php_errormsg;
     // Recursively copy a directory
     if ($src->isDirectory()) {
         return $this->copyr($src->getAbsolutePath(), $dest->getAbsolutePath());
     }
     $srcPath = $src->getAbsolutePath();
     $destPath = $dest->getAbsolutePath();
     if (false === @copy($srcPath, $destPath)) {
         // Copy FAILED. Log and return err.
         // Add error from php to end of log message. $php_errormsg.
         $msg = "FileSystem::copy() FAILED. Cannot copy {$srcPath} to {$destPath}. {$php_errormsg}";
         throw new IOException($msg);
     }
     $dest->setMode($src->getMode());
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:27,代码来源:FileSystem.php


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