本文整理汇总了PHP中SplFileInfo::getLinkTarget方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getLinkTarget方法的具体用法?PHP SplFileInfo::getLinkTarget怎么用?PHP SplFileInfo::getLinkTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplFileInfo
的用法示例。
在下文中一共展示了SplFileInfo::getLinkTarget方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFileDetailsRaw
/**
* Returns the details about Communicator (current) file
* w/o any kind of verification of file existance
*
* @param string $fileGiven
* @return array
*/
protected function getFileDetailsRaw($fileGiven)
{
$info = new \SplFileInfo($fileGiven);
$aFileBasicDetails = ['File Extension' => $info->getExtension(), 'File Group' => $info->getGroup(), 'File Inode' => $info->getInode(), 'File Link Target' => $info->isLink() ? $info->getLinkTarget() : '-', 'File Name' => $info->getBasename('.' . $info->getExtension()), 'File Name w. Extension' => $info->getFilename(), 'File Owner' => $info->getOwner(), 'File Path' => $info->getPath(), 'Name' => $info->getRealPath(), 'Type' => $info->getType()];
$aDetails = array_merge($aFileBasicDetails, $this->getFileDetailsRawStatistic($info, $fileGiven));
ksort($aDetails);
return $aDetails;
}
示例2: 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;
}
示例3: 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);
示例4: 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;
}
示例5: getLinkTarget
public function getLinkTarget()
{
return $this->toUnix(parent::getLinkTarget());
}
示例6: SplFileInfo
<?php
chdir(__DIR__ . '/../../..');
$info = new SplFileInfo('test/sample_dir');
var_dump($info->getRealPath());
var_dump($info->getPath());
var_dump($info->getPathName());
$info = new SplFileInfo('test/sample_dir/');
var_dump($info->getRealPath());
var_dump($info->getPath());
var_dump($info->getPathName());
$info = new SplFileInfo('test/sample_dir//../sample_dir');
var_dump($info->getRealPath());
var_dump($info->getPath());
var_dump($info->getPathName());
$p = realpath('test');
$info = new SplFileInfo($p . '/sample_dir/symlink');
var_dump($info->getLinkTarget());
var_dump($info->getRealPath());
var_dump($info->getPath());
var_dump($info->getPathName());
示例7: SplFileInfo
<?php
$info = new SplFileInfo('does-not-exist-will-fail-on-getLinkTarget');
//readlink('does-not-throw-but-warns');
try {
$info->getLinkTarget();
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
return;
}
echo "failed to throw\n";
示例8: 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));