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


PHP SplFileInfo::isLink方法代码示例

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


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

示例1: make_writable

 /**
  * This function will make directory writable.
  *
  * @param   string  path
  * @return  void
  * @throw   Kohana_Exception
  */
 public static function make_writable($path, $chmod = NULL)
 {
     try {
         $dir = new SplFileInfo($path);
         if ($dir->isFile()) {
             throw new Kohana_Exception('Could not make :path writable directory because it is regular file', array(':path' => Debug::path($path)));
         } elseif ($dir->isLink()) {
             throw new Kohana_Exception('Could not make :path writable directory because it is link', array(':path' => Debug::path($path)));
         } elseif (!$dir->isDir()) {
             // Try create directory
             Ku_Dir::make($path, $chmod);
             clearstatcache(TRUE, $path);
         }
         if (!$dir->isWritable()) {
             // Try make directory writable
             chmod($dir->getRealPath(), $chmod === NULL ? Ku_Dir::$default_dir_chmod : $chmod);
             clearstatcache(TRUE, $path);
             // Check result
             if (!$dir->isWritable()) {
                 throw new Exception('Make dir writable failed', 0);
             }
         }
     } catch (Kohana_Exception $e) {
         // Rethrow exception
         throw $e;
     } catch (Exception $e) {
         throw new Kohana_Exception('Could not make :path directory writable', array(':path' => Debug::path($path)));
     }
 }
开发者ID:greor,项目名称:satin-spb,代码行数:36,代码来源:dir.php

示例2: __construct

 public function __construct(SplFileInfo $fileInfo)
 {
     $this->perms = $fileInfo->getPerms();
     $this->size = $fileInfo->getSize();
     $this->is_dir = $fileInfo->isDir();
     $this->is_file = $fileInfo->isFile();
     $this->is_link = $fileInfo->isLink();
     if (($this->perms & 0xc000) === 0xc000) {
         $this->typename = 'File socket';
         $this->typeflag = 's';
     } elseif ($this->is_file) {
         if ($this->is_link) {
             $this->typename = 'File symlink';
             $this->typeflag = 'l';
         } else {
             $this->typename = 'File';
             $this->typeflag = '-';
         }
     } elseif (($this->perms & 0x6000) === 0x6000) {
         $this->typename = 'Block special file';
         $this->typeflag = 'b';
     } elseif ($this->is_dir) {
         if ($this->is_link) {
             $this->typename = 'Directory symlink';
             $this->typeflag = 'l';
         } else {
             $this->typename = 'Directory';
             $this->typeflag = 'd';
         }
     } elseif (($this->perms & 0x2000) === 0x2000) {
         $this->typename = 'Character special file';
         $this->typeflag = 'c';
     } elseif (($this->perms & 0x1000) === 0x1000) {
         $this->typename = 'FIFO pipe file';
         $this->typeflag = 'p';
     }
     parent::__construct('FsPath');
     $this->path = $fileInfo->getPathname();
     $this->realpath = realpath($this->path);
     if ($this->is_link && method_exists($fileInfo, 'getLinktarget')) {
         $this->linktarget = $fileInfo->getLinktarget();
     }
     $flags = array($this->typeflag);
     // User
     $flags[] = $this->perms & 0x100 ? 'r' : '-';
     $flags[] = $this->perms & 0x80 ? 'w' : '-';
     $flags[] = $this->perms & 0x40 ? $this->perms & 0x800 ? 's' : 'x' : ($this->perms & 0x800 ? 'S' : '-');
     // Group
     $flags[] = $this->perms & 0x20 ? 'r' : '-';
     $flags[] = $this->perms & 0x10 ? 'w' : '-';
     $flags[] = $this->perms & 0x8 ? $this->perms & 0x400 ? 's' : 'x' : ($this->perms & 0x400 ? 'S' : '-');
     // Other
     $flags[] = $this->perms & 0x4 ? 'r' : '-';
     $flags[] = $this->perms & 0x2 ? 'w' : '-';
     $flags[] = $this->perms & 0x1 ? $this->perms & 0x200 ? 't' : 'x' : ($this->perms & 0x200 ? 'T' : '-');
     $this->contents = implode($flags);
 }
开发者ID:jnvsor,项目名称:kint,代码行数:57,代码来源:FsPath.php

示例3: factory

 public static function factory($path)
 {
     $fileInfo = new SplFileInfo($path);
     if ($fileInfo->isDir()) {
         $element = new Stagehand_DirectorySnap_Element_Directory($path);
     } elseif ($fileInfo->isLink()) {
         $element = new Stagehand_DirectorySnap_Element_Link($path);
     } elseif ($fileInfo->isFile()) {
         $element = new Stagehand_DirectorySnap_Element_File($path);
     }
     return $element;
 }
开发者ID:piece,项目名称:stagehand-directorysnap,代码行数:12,代码来源:Factory.php

示例4: cleanFile

 private function cleanFile(\SplFileInfo $fileInfo)
 {
     if ($fileInfo->isLink()) {
         $result = @unlink($fileInfo->getPathname());
         if (!$result) {
             $this->error("Cannot delete symlink '{$fileInfo->getPathname()}'.");
         }
     } elseif ($fileInfo->isDir()) {
         $result = @rmdir($fileInfo->getPathname());
         if (!$result) {
             $this->error("Cannot delete file '{$fileInfo->getPathname()}'.");
         }
     } elseif ($fileInfo->isFile()) {
         $result = @unlink($fileInfo->getPathname());
         if (!$result) {
             $this->error("Cannot delete file '{$fileInfo->getPathname()}'.");
         }
     }
 }
开发者ID:genesis-php,项目名称:genesis,代码行数:19,代码来源:Directory.php

示例5: testSymlinkingSpecifiedPlugin

 /**
  * testSymlinkingSpecifiedPlugin
  *
  * @return void
  */
 public function testSymlinkingSpecifiedPlugin()
 {
     Plugin::load('TestPlugin');
     Plugin::load('Company/TestPluginThree');
     $this->Task->symlink('TestPlugin');
     $path = WWW_ROOT . 'test_plugin';
     $link = new \SplFileInfo($path);
     $this->assertTrue(file_exists($path . DS . 'root.js'));
     unlink($path);
     $path = WWW_ROOT . 'company' . DS . 'test_plugin_three';
     $link = new \SplFileInfo($path);
     $this->assertFalse($link->isDir());
     $this->assertFalse($link->isLink());
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:19,代码来源:AssetsTaskTest.php

示例6: PharData

<?php

$pd = new PharData(__DIR__ . '/tgz/with_symlink.tar.gz');
$tempdir = tempnam(sys_get_temp_dir(), '');
unlink($tempdir);
mkdir($tempdir);
$pd->extractTo($tempdir);
$fi = new SplFileInfo($tempdir . '/foo/herp');
var_dump($fi->isLink());
var_dump($fi->getLinkTarget());
$rdi = new RecursiveDirectoryIterator($tempdir, FileSystemIterator::SKIP_DOTS);
$rii = new RecursiveIteratorIterator($rdi, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($rii as $path => $info) {
    if ($info->isDir()) {
        rmdir($path);
    } else {
        unlink($path);
    }
}
rmdir($tempdir);
开发者ID:badlamer,项目名称:hhvm,代码行数:20,代码来源:tar_with_symlink.php

示例7: SplFileInfo

<?php

include __DIR__ . '/../../../test/sample_dir/fix_mtimes.inc';
$info = new SplFileInfo(__DIR__ . '/../../sample_dir');
if (!$info->isFile()) {
    echo $info->getRealPath();
}
$info = new SplFileInfo(__DIR__ . '/../../sample_dir/file');
var_dump($info->getbaseName());
var_dump($info->getbaseName('.cpp'));
$info->getCTime();
$info->getGroup();
$info->getInode();
$info->getMTime();
$info->getOwner();
$info->getPerms();
$info->getSize();
$info->getType();
$info->isDir();
$info->isFile();
$info->isLink();
$info->isReadable();
$info->isWritable();
开发者ID:badlamer,项目名称:hhvm,代码行数:23,代码来源:1795.php

示例8: createFileResult

 /**
  * @param SplFileInfo $file
  *
  * @return array
  */
 private function createFileResult(SplFileInfo $file)
 {
     $fileResult = array('path' => $this->replaceWindowsPath($this->getRelativePath($file->getRealPath(), ABSPATH)), 'pathEncoded' => false, 'isLink' => false, 'exists' => false, 'isDirectory' => false, 'owner' => 0, 'group' => 0, 'permissions' => 0);
     if (!seems_utf8($fileResult['path'])) {
         $fileResult['path'] = $this->pathEncode($fileResult['path']);
         $fileResult['pathEncoded'] = true;
     }
     try {
         $fileResult['link'] = $file->isLink();
         // need to be first
         $fileResult['size'] = $file->getSize();
         $fileResult['isDirectory'] = $file->isDir();
         $fileResult['owner'] = $file->getOwner();
         $fileResult['group'] = $file->getGroup();
         $fileResult['permissions'] = $file->getPerms();
         $fileResult['exists'] = true;
         if ($file->isLink()) {
             $fileResult['linkTarget'] = $file->getLinkTarget();
         }
     } catch (RuntimeException $e) {
     }
     return $fileResult;
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:28,代码来源:ListFiles.php

示例9: SplFileInfo

<?php

$info = new SplFileInfo('SplFileInfo.php');
printf("Extension: %s\n", $info->getExtension());
printf("Filename: %s\n", $info->getFilename());
printf("Path: %s\n", $info->getPathname());
printf("RealPath: %s\n", $info->getRealPath());
printf("Type: %s\n", $info->getType());
printf("Size: %s\n", $info->getSize());
printf("Dir: %b, Exec: %b, File: %b, Link: %b, R: %b, W: %b\n", $info->isDir(), $info->isExecutable(), $info->isFile(), $info->isLink(), $info->isReadable(), $info->isWritable());
$file = $info->openFile('r');
foreach ($file as $line) {
    printf("%s", $line);
}
开发者ID:Eldahar,项目名称:PHP_Library,代码行数:14,代码来源:SplFileInfo.php

示例10: SplFileInfo

<?php

$link = __DIR__ . '/test_link';
symlink(__FILE__, $link);
$fileInfo = new SplFileInfo($link);
if ($fileInfo->isLink()) {
    echo $fileInfo->getLinkTarget() == __FILE__ ? 'same' : 'different', PHP_EOL;
}
var_dump(unlink($link));
开发者ID:badlamer,项目名称:hhvm,代码行数:9,代码来源:spl_fileinfo_getlinktarget_basic.php

示例11: testIsLink

 /**
  * @depends     testExist
  * @return      void
  */
 public function testIsLink()
 {
     $path = __DIR__;
     $filePath = $path . '/example.txt';
     $fileObject = new File($filePath);
     $this->assertFalse($fileObject->isLink());
     $fileObject = new File($path);
     $this->assertFalse($fileObject->isLink());
     $fileObject = new \SplFileInfo($filePath);
     $this->assertFalse($fileObject->isLink());
     $fileObject = new \SplFileInfo($path);
     $this->assertFalse($fileObject->isLink());
 }
开发者ID:naucon,项目名称:file,代码行数:17,代码来源:FileTest.php

示例12: getFileDetailsRawStatistic

 protected function getFileDetailsRawStatistic(\SplFileInfo $info, $fileGiven)
 {
     return ['File is Dir' => $info->isDir(), 'File is Executable' => $info->isExecutable(), 'File is File' => $info->isFile(), 'File is Link' => $info->isLink(), 'File is Readable' => $info->isReadable(), 'File is Writable' => $info->isWritable(), 'File Permissions' => $this->explainPerms($info->getPerms()), 'Size' => $info->getSize(), 'Sha1' => sha1_file($fileGiven), 'Timestamp Accessed' => $this->getFileTimes($info->getATime()), 'Timestamp Changed' => $this->getFileTimes($info->getCTime()), 'Timestamp Modified' => $this->getFileTimes($info->getMTime())];
 }
开发者ID:danielgp,项目名称:common-lib,代码行数:4,代码来源:CommonBasic.php

示例13: isIgnored

 /**
  * Tell whether to ignore the element.
  *
  * @param SplFileInfo $element The element to check.
  *
  * @return bool True if the element should be ignored, false otherwise.
  */
 public function isIgnored(SplFileInfo $element)
 {
     return $element->isLink();
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:11,代码来源:Symlink.php

示例14: getLogMessageFileName

 public function getLogMessageFileName($session = true)
 {
     if ($session && !$this->_logMessageFileName) {
         try {
             $this->_logMessageFileName = $this->getSession()->getLogMessageFileName();
         } catch (Exception $e) {
             Mage::logException($e);
             $this->_logMessageFileName = null;
         }
     }
     if (!$this->_logMessageFileName) {
         $this->initBackupData();
         if ($this->_profile && $this->_profileId) {
             $logDir = $this->_profile->getData('profile_log_path');
             $this->_logMessageFileName = $logDir . DS . $this->getBackupLogFile();
             try {
                 $splFileInfo = new SplFileInfo($this->_logMessageFileName);
                 if (!$splFileInfo->isFile() && !$splFileInfo->isLink()) {
                     $splFileInfo->openFile('a');
                     if (!$splFileInfo->isReadable()) {
                         Mage::logException(new Exception('Log file is not readable'));
                     }
                     if (!$splFileInfo->isWritable()) {
                         Mage::logException(new Exception('Log file is not writable'));
                     }
                 }
             } catch (Exception $e) {
                 Mage::logException($e);
             }
             $this->getSession()->setLogMessageFileName($this->_logMessageFileName);
         }
     }
     return $this->_logMessageFileName;
 }
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:34,代码来源:Backup.php

示例15: testDecoratedMethods

 public function testDecoratedMethods()
 {
     $decorated = $this->getMockBuilder('hanneskod\\classtools\\Tests\\MockSplFileInfo')->setConstructorArgs([''])->getMock();
     $decorated->expects($this->once())->method('getRelativePath');
     $decorated->expects($this->once())->method('getRelativePathname');
     $decorated->expects($this->once())->method('getContents');
     $decorated->expects($this->once())->method('getATime');
     $decorated->expects($this->once())->method('getBasename');
     $decorated->expects($this->once())->method('getCTime');
     $decorated->expects($this->once())->method('getExtension');
     $decorated->expects($this->once())->method('getFileInfo');
     $decorated->expects($this->once())->method('getFilename');
     $decorated->expects($this->once())->method('getGroup');
     $decorated->expects($this->once())->method('getInode');
     $decorated->expects($this->once())->method('getLinkTarget');
     $decorated->expects($this->once())->method('getMTime');
     $decorated->expects($this->once())->method('getOwner');
     $decorated->expects($this->once())->method('getPath');
     $decorated->expects($this->once())->method('getPathInfo');
     $decorated->expects($this->once())->method('getPathname');
     $decorated->expects($this->once())->method('getPerms');
     $decorated->expects($this->once())->method('getRealPath');
     $decorated->expects($this->once())->method('getSize');
     $decorated->expects($this->once())->method('getType');
     $decorated->expects($this->once())->method('isDir');
     $decorated->expects($this->once())->method('isExecutable');
     $decorated->expects($this->once())->method('isFile');
     $decorated->expects($this->once())->method('isLink');
     $decorated->expects($this->once())->method('isReadable');
     $decorated->expects($this->once())->method('isWritable');
     $decorated->expects($this->once())->method('openFile');
     $decorated->expects($this->once())->method('setFileClass');
     $decorated->expects($this->once())->method('setInfoClass');
     $decorated->expects($this->once())->method('__toString')->will($this->returnValue(''));
     $fileInfo = new SplFileInfo($decorated);
     $fileInfo->getRelativePath();
     $fileInfo->getRelativePathname();
     $fileInfo->getContents();
     $fileInfo->getATime();
     $fileInfo->getBasename();
     $fileInfo->getCTime();
     $fileInfo->getExtension();
     $fileInfo->getFileInfo();
     $fileInfo->getFilename();
     $fileInfo->getGroup();
     $fileInfo->getInode();
     $fileInfo->getLinkTarget();
     $fileInfo->getMTime();
     $fileInfo->getOwner();
     $fileInfo->getPath();
     $fileInfo->getPathInfo();
     $fileInfo->getPathname();
     $fileInfo->getPerms();
     $fileInfo->getRealPath();
     $fileInfo->getSize();
     $fileInfo->getType();
     $fileInfo->isDir();
     $fileInfo->isExecutable();
     $fileInfo->isFile();
     $fileInfo->isLink();
     $fileInfo->isReadable();
     $fileInfo->isWritable();
     $fileInfo->openFile();
     $fileInfo->setFileClass();
     $fileInfo->setInfoClass();
     (string) $fileInfo;
 }
开发者ID:hanneskod,项目名称:classtools,代码行数:67,代码来源:SplFileInfoTest.php


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