4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Finder\Iterator;
14 @trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
16 use Symfony\Component\Finder\SplFileInfo;
19 * Iterate over shell command result.
21 * @author Jean-François Simon <contact@jfsimon.fr>
23 * @deprecated since 2.8, to be removed in 3.0.
25 class FilePathsIterator extends \ArrayIterator
35 private $baseDirLength;
53 * @param array $paths List of paths returned by shell command
54 * @param string $baseDir Base dir for relative path building
56 public function __construct(array $paths, $baseDir)
58 $this->baseDir = $baseDir;
59 $this->baseDirLength = strlen($baseDir);
61 parent::__construct($paths);
66 * @param array $arguments
70 public function __call($name, array $arguments)
72 return call_user_func_array(array($this->current(), $name), $arguments);
76 * Return an instance of SplFileInfo with support for relative paths.
78 * @return SplFileInfo File information
80 public function current()
82 return $this->current;
90 return $this->current->getPathname();
93 public function next()
96 $this->buildProperties();
99 public function rewind()
102 $this->buildProperties();
108 public function getSubPath()
110 return $this->subPath;
116 public function getSubPathname()
118 return $this->subPathname;
121 private function buildProperties()
123 $absolutePath = parent::current();
125 if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
126 $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
127 $dir = dirname($this->subPathname);
128 $this->subPath = '.' === $dir ? '' : $dir;
130 $this->subPath = $this->subPathname = '';
133 $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);