本文整理汇总了PHP中Symfony\Component\Finder\SplFileInfo::getLinkTarget方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getLinkTarget方法的具体用法?PHP SplFileInfo::getLinkTarget怎么用?PHP SplFileInfo::getLinkTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Finder\SplFileInfo
的用法示例。
在下文中一共展示了SplFileInfo::getLinkTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: getLinkTarget
public function getLinkTarget()
{
return $this->fileInfo->getLinkTarget();
}