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


PHP SplFileInfo::isLink方法代碼示例

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


在下文中一共展示了SplFileInfo::isLink方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: isLink

 public function isLink()
 {
     return $this->fileInfo->isLink();
 }
開發者ID:phramz,項目名稱:doctrine-annotation-scanner,代碼行數:4,代碼來源:ClassFileInfo.php

示例2: moveFile

 /**
  * Move a single file or folder.
  *
  * @param SplFileInfo $file      The file to move.
  *
  * @param string      $targetDir The destination directory.
  *
  * @param bool        $logging   Flag determining if actions shall get logged.
  *
  * @param IOInterface $ioHandler The io handler to log to.
  *
  * @return void
  *
  * @throws \RuntimeException When an unknown file type has been encountered.
  */
 private function moveFile(SplFileInfo $file, $targetDir, $logging, $ioHandler)
 {
     $pathName = $file->getPathname();
     $destinationFile = str_replace($this->tempDir, $targetDir, $pathName);
     // Symlink must(!) be handled first as the isDir() and isFile() checks return true for symlinks.
     if ($file->isLink()) {
         $target = $file->getLinkTarget();
         if ($logging) {
             $ioHandler->write(sprintf('link %s to %s', $target, $destinationFile));
         }
         symlink($target, $destinationFile);
         unlink($pathName);
         return;
     }
     if ($file->isDir()) {
         $permissions = substr(decoct(fileperms($pathName)), 1);
         $this->folders[] = $pathName;
         if (!is_dir($destinationFile)) {
             if ($logging) {
                 $ioHandler->write(sprintf('mkdir %s (permissions: %s)', $pathName, $permissions));
             }
             mkdir($destinationFile, octdec($permissions), true);
         }
         return;
     }
     if ($file->isFile()) {
         $permissions = substr(decoct(fileperms($pathName)), 1);
         if ($logging) {
             $ioHandler->write(sprintf('move %s to %s (permissions: %s)', $pathName, $destinationFile, $permissions));
         }
         copy($pathName, $destinationFile);
         chmod($destinationFile, octdec($permissions));
         unlink($pathName);
         return;
     }
     throw new \RuntimeException(sprintf('Unknown file of type %s encountered for %s', filetype($pathName), $pathName));
 }
開發者ID:tenside,項目名稱:core,代碼行數:52,代碼來源:InstallTask.php

示例3: copy

 /**
  * Copy a path to destination, check if file,directory or link
  * @param string $source      The Source File
  * @param string $destination The Destination File
  * @return boolean
  */
 public function copy(\Symfony\Component\Finder\SplFileInfo $source, $destination)
 {
     $new_path = $destination . DIRECTORY_SEPARATOR . $source->getRelativePathname();
     #Test if Source is a link
     if ($source->isLink()) {
         return symlink($source, $new_path);
     }
     # Test if source is a directory
     if ($source->isDir()) {
         return mkdir($new_path);
     }
     #Test if Source is a file
     if ($source->isFile()) {
         return copy($source, $new_path);
     }
     return FALSE;
 }
開發者ID:icomefromthenet,項目名稱:faker,代碼行數:23,代碼來源:Project.php


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