* Jordi Boggiano * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Composer\Downloader; use Composer\Package\PackageInterface; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; /** * Download a package from a local path. * * @author Samuel Roze * @author Johann Reinke */ class PathDownloader extends FileDownloader { /** * {@inheritdoc} */ public function download(PackageInterface $package, $path) { $fileSystem = new Filesystem(); $this->filesystem->removeDirectory($path); $this->io->writeError(sprintf( ' - Installing %s (%s)', $package->getName(), $package->getFullPrettyVersion() )); $url = $package->getDistUrl(); $realUrl = realpath($url); if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) { throw new \RuntimeException(sprintf( 'Path "%s" is not found', $url )); } try { $fileSystem->symlink($realUrl, $path); $this->io->writeError(sprintf(' Symlinked from %s', $url)); } catch (IOException $e) { $fileSystem->mirror($realUrl, $path); $this->io->writeError(sprintf(' Mirrored from %s', $url)); } $this->io->writeError(''); } }