/usr/share/php/Symfony/Component/Finder/Iterator/FilePathsIterator.php is in php-symfony-finder 2.3.21+dfsg-4+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | <?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Finder\Iterator;
use Symfony\Component\Finder\SplFileInfo;
/**
* Iterate over shell command result.
*
* @author Jean-François Simon <contact@jfsimon.fr>
*/
class FilePathsIterator extends \ArrayIterator
{
/**
* @var string
*/
private $baseDir;
/**
* @var int
*/
private $baseDirLength;
/**
* @var string
*/
private $subPath;
/**
* @var string
*/
private $subPathname;
/**
* @var SplFileInfo
*/
private $current;
/**
* @param array $paths List of paths returned by shell command
* @param string $baseDir Base dir for relative path building
*/
public function __construct(array $paths, $baseDir)
{
$this->baseDir = $baseDir;
$this->baseDirLength = strlen($baseDir);
parent::__construct($paths);
}
/**
* @param string $name
* @param array $arguments
*
* @return mixed
*/
public function __call($name, array $arguments)
{
return call_user_func_array(array($this->current(), $name), $arguments);
}
/**
* Return an instance of SplFileInfo with support for relative paths.
*
* @return SplFileInfo File information
*/
public function current()
{
return $this->current;
}
/**
* @return string
*/
public function key()
{
return $this->current->getPathname();
}
public function next()
{
parent::next();
$this->buildProperties();
}
public function rewind()
{
parent::rewind();
$this->buildProperties();
}
/**
* @return string
*/
public function getSubPath()
{
return $this->subPath;
}
/**
* @return string
*/
public function getSubPathname()
{
return $this->subPathname;
}
private function buildProperties()
{
$absolutePath = parent::current();
if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
$this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
$dir = dirname($this->subPathname);
$this->subPath = '.' === $dir ? '' : $dir;
} else {
$this->subPath = $this->subPathname = '';
}
$this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
}
}
|